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

Adding synthesizable multipler

This commit is contained in:
aolofsson 2021-07-26 08:19:50 -04:00
parent 2dd46abdd1
commit 50c1845f30

36
common/hdl/oh_mult.v Normal file
View File

@ -0,0 +1,36 @@
//#############################################################################
//# Function: Binary multiplier #
//#############################################################################
//# Author: Andreas Olofsson #
//# License: MIT (see LICENSE file in OH! repository) #
//#############################################################################
module oh_mult
#(parameter DW = 32, // block width
parameter SYN = "TRUE", // synthesizable
parameter TYPE = "DEFAULT" // implementation type
)
(
//Inputs
input [DW-1:0] a, // a input (multiplier)
input [DW-1:0] b, // b input (multiplicand)
input asigned, // a operand is signed
input bsigned, // b oeprand is signed
//Outputs
output [2*DW-1:0] product, // a*b final product
output [2*DW-1:0] sum, // a*b partial sum
output [2*DW-1:0] carry // a*b partial carry
);
generate
if(SYN=="TRUE") begin
wire a_sext = asigned & a[DW-1];
wire b_sext = bsigned & b[DW-1];
assign product[2*DW-1:0] = $signed({a_sext,a[DW-1:0]}) *
$signed({b_sext,b[DW-1:0]});
end
else begin
end
endgenerate
endmodule