1
0
mirror of https://github.com/aolofsson/oh.git synced 2025-01-30 02:32:53 +08:00

Multi-type multiplier working

-only reference model implemented
-Next, implement complete algorithm and output partial products
This commit is contained in:
Andreas.Olofsson 2020-04-09 21:42:28 -04:00
parent d6b6e1bd76
commit d9897a1bec

View File

@ -9,19 +9,24 @@ module oh_multiplier #(parameter DW = 16 //multiplier width
) )
( (
input [DW-1:0] a, // a input input [DW-1:0] a, // a input
input a_signed,//a operand is signed
input [DW-1:0] b, // b input input [DW-1:0] b, // b input
input cfg_signed,//1=signed operands, 0=unsigned input b_signed,//b oeprand is signed
output [(2*DW+2)-1:0] pp1,// partial product output (carry save format) output [(2*DW+2)-1:0] pp1,// partial product output (carry save format)
output [(2*DW+2)-1:0] pp2, // partial product output (carry save format) output [(2*DW+2)-1:0] pp2, // partial product output (carry save format)
output [DW-1:0] product // output output [2*DW-1:0] product // output
); );
wire signed [2*DW+1:0] product_signed;
wire signed [DW-1:0] product_signed; assign a_sext = a_signed & a[DW-1];
wire signed [DW-1:0] product_unsigned; assign b_sext = b_signed & b[DW-1];
assign product[DW-1:0] = cfg_signed ? $unsigned(product_signed) : assign product_signed[2*DW+1:0] = $signed({a_sext,a[DW-1:0]}) *
product_unsigned; $signed({b_sext,b[DW-1:0]});
assign product = product_signed[2*DW-1:0];
endmodule // oh_multiplier endmodule // oh_multiplier