Skip to content

Instantly share code, notes, and snippets.

@FrancescoConti
Created November 14, 2019 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FrancescoConti/205706f182569a2b5d2c9f3752249b14 to your computer and use it in GitHub Desktop.
Save FrancescoConti/205706f182569a2b5d2c9f3752249b14 to your computer and use it in GitHub Desktop.
Test 16b x 16b -> 32b multiplier
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