Advertisement
aidanozohor1810

Untitled

Dec 6th, 2023
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module registers(
  2.         clk,
  3.         oe,
  4.         we,
  5.         addr,
  6.         in,
  7.         out,
  8.         disp_addr,
  9.         disp_out
  10.     );
  11.  
  12. parameter width = 16;
  13. parameter depth = 8;
  14. parameter addr_width = 3;
  15.  
  16. input clk;
  17. input oe;
  18. input we;
  19. input [addr_width-1 : 0]    addr;
  20. input [width-1 : 0]         in;
  21. output[width-1 : 0]         out;
  22. input [addr_width-1 : 0]    disp_addr;
  23. output[width-1 : 0]         disp_out;
  24.  
  25. reg [width-1 : 0]           regs[depth-1 : 0];
  26.  
  27. reg [addr_width : 0]        i;
  28.  
  29. initial begin
  30.     for(i = 0; i < depth; i = i + 1)
  31.         regs[i] <= 0;
  32. end
  33.  
  34. always @(posedge clk) begin
  35.     if(we)
  36.         regs[addr] <= in;
  37. end
  38.  
  39. assign out = oe ? regs[addr] : 0;
  40. assign disp_out = regs[disp_addr];
  41.  
  42. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement