Created
November 14, 2019 16:33
-
-
Save FrancescoConti/205706f182569a2b5d2c9f3752249b14 to your computer and use it in GitHub Desktop.
Test 16b x 16b -> 32b multiplier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module mult( | |
input logic clk_i, | |
input logic rst_ni, | |
input logic signed [15:0] a_i, | |
input logic signed [15:0] b_i, | |
output logic signed [31:0] c_o | |
); | |
logic signed [15:0] a_q; | |
logic signed [15:0] b_q; | |
logic signed [31:0] c_d, c_q; | |
logic signed [31:0] prod; | |
always_ff @(posedge clk_i or negedge rst_ni) | |
begin | |
if(~rst_ni) begin | |
a_q <= '0; | |
b_q <= '0; | |
c_q <= '0; | |
end | |
else begin | |
a_q <= a_i; | |
b_q <= b_i; | |
c_q <= c_d; | |
end | |
end | |
assign prod = a_q * b_q; | |
assign c_d = prod + c_q; | |
assign c_o = c_q; | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment