Advertisement
aidanozo

Untitled

Oct 23rd, 2024
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module multiplier #(
  2.     parameter p_width = 4
  3. ) (
  4.     output wire [((p_width*2)-1):0] o_w_p,
  5.     input wire [(p_width-1):0] i_w_a,
  6.     input wire [(p_width-1):0] i_w_b
  7. );
  8.  
  9.     integer i;
  10.     reg [((p_width*2)-1):0] l_r_prod;
  11.  
  12.     always @(*) begin
  13.         l_r_prod = 0;
  14.         for(i = 0; i < p_width; i=i+1) begin
  15.             if(i_w_b[i])
  16.                 l_r_prod = l_r_prod + (i_w_a << i);
  17.         end
  18.     end
  19.  
  20.     assign o_w_p = l_r_prod;
  21. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement