Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

multiply module to Vhdl. Please help

Status
Not open for further replies.

karper1986

Member level 2
Joined
Mar 13, 2009
Messages
49
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,715
Please help me in translating these to Vhdl. Thanks

module multiply(
clk,
multiplier,
multiplicand,
result
);

input clk;
input [15:00] multiplier;
input [15:00] multiplicand;
output[31:00] result;

reg [31:00] result;
reg [15:00] abs_multiplicand;
reg lsb;

integer i;

always @( multiplicand or multiplier)
begin
result = { 16'h0000, multiplier[15] ? -multiplier : multiplier };
abs_multiplicand = multiplicand[15] ? -multiplicand : multiplicand;

for (i=15; i>=0; i = i - 1)
begin
lsb = result[0];
result = result >>>1;

if (lsb == 1'b1)
begin
result[31:15] = result[30:15] + abs_multiplicand;
end

if ((!i) && (multiplier[15] ^ multiplicand[15]))
begin
result = -result;
end

end

end

endmodule
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top