Professional Documents
Culture Documents
Simple - Combinational - Mult: Reg Integer
Simple - Combinational - Mult: Reg Integer
product;
i;
end
endmodule
module simple_mult(product,ready,multiplier,multiplicand,start,clk); //P
input [15:0] multiplier, multiplicand;
input
start, clk;
output
product;
output
ready;
reg [31:0]
product;
reg [15:0]
reg [31:0]
multiplier_copy;
multiplicand_copy;
reg [4:0]
wire
bit;
ready = !bit;
initial bit = 0;
always @( posedge clk )
if( ready && start ) begin
bit
product
multiplicand_copy
multiplier_copy
=
=
=
=
16;
0;
{ 16'd0, multiplicand };
multiplier;
end
endmodule
module streamlined_signed_mult(product,ready,multiplier,multiplicand,
start,clk);
input [15:0]
input
output
output
multiplier, multiplicand;
start, clk;
product;
ready;
reg [31:0]
reg [15:0]
product;
abs_multiplicand;
reg [4:0]
wire
bit;
ready = !bit;
initial bit = 0;
always @( posedge clk )
if( ready && start ) begin
bit
= 16;
product = { 16'd0, multiplier[15] ? -multiplier : multiplier };
abs_multiplicand = multiplicand[15] ? -multiplicand : multiplicand;