Skip to content

Instantly share code, notes, and snippets.

@uiur
Created May 16, 2013 06:03
Show Gist options
  • Save uiur/5589692 to your computer and use it in GitHub Desktop.
Save uiur/5589692 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:7];
assign Data1 = RegFile[Read1];
assign Data2 = RegFile[Read2];
always @(posedge RegWrite) begin
if (RegWrite) begin
RegFile[Write] = WriteData;
end
end
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment