Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module register_set (input [4:0] a1, a2, a3,
  2.                 input [31:0] wd3,
  3.                 input clk, we3,
  4.                 output reg [31:0] rd1, rd2);
  5.  
  6.   reg [31:0] rf[31:0];
  7.  
  8.  
  9.   always @(*)
  10.     rf[0] = 0;
  11.  
  12.   always @(a1)
  13.     rd1 = rf[a1];
  14.  
  15.   always @(a2)
  16.     rd2 = rf[a2];
  17.  
  18.   always @(posedge clk)
  19.     begin
  20.       if ((we3 == 1) && (a3 != 0))
  21.         rf[a3] = wd3;
  22.       else
  23.         rf[a3] = rf[a3];
  24.     end
  25.  
  26. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement