Advertisement
k10101110

Untitled

Sep 17th, 2023
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SystemVerilog 0.91 KB | Source Code | 0 0
  1. module Layer #(parameter num_inps=2)(out, inps, ws, clk, rst);
  2.     output reg out;
  3.     input real inps[num_inps];
  4.     input logic clk, rst;
  5.     input real ws[num_inps];
  6.     real temp[num_inps];
  7.     int j;
  8.     genvar i;
  9.     generate
  10.         for(i=0; i<num_inps; i++) begin
  11.             assign temp[i] = inps[i] * ws[i];
  12.         end
  13.     endgenerate
  14.     always @( posedge clk, posedge rst) begin : res
  15.         $display("inps: ", inps[0], " ", inps[1]);
  16.         $display("ws: ", ws[0], " ", ws[1]);
  17.         $display("temp: ", temp[0], " ", temp[1]);
  18.         if (rst==1) begin
  19.             $display("oopsie did a rest :(");
  20.             out <= 0;
  21.         end
  22.         else begin
  23.             out = 0;
  24.             begin
  25.                 for(j=0; j<num_inps; j++) begin
  26.                     out <= out + temp[j];
  27.                     $display(temp[j]);
  28.                 end
  29.             end
  30.         end
  31.     end
  32. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement