Advertisement
toweber

mac.v

Aug 29th, 2022
1,067
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Verilog code for MAC
  2. module mac(in1, in2, clk, reset, acc);  
  3.    input [3:0] in1;
  4.    input [3:0] in2;  
  5.    input       clk;
  6.    output reg [9:0] acc;
  7.    input        reset;
  8.    
  9.    reg [7:0]   out_mult;  
  10.        
  11.    always @(posedge clk or posedge reset)
  12.      begin
  13.         out_mult <= in1*in2;
  14.         if (reset)
  15.           acc <= 0;
  16.         else
  17.           acc <= out_mult+acc;        
  18.      end
  19.        
  20. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement