Skip to content

Instantly share code, notes, and snippets.

@uiur
Created April 25, 2013 04:06
Show Gist options
  • Save uiur/5457440 to your computer and use it in GitHub Desktop.
Save uiur/5457440 to your computer and use it in GitHub Desktop.
module RegisterFile (Read1, Read2, Write, RegWrite, WriteData, Data1, Data2);
input [2:0] Read1, Read2, Write;
input [15:0] WriteData;
input RegWrite;
output [15:0] Data1, Data2;
reg [15:0] RegFile [0:2];
always @(posedge RegWrite) begin
if (RegWrite) begin
RegFile[Write] = WriteData;
end
end
assign Data1 = RegFile[Read1];
assign Data2 = RegFile[Read2];
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment