Created
December 10, 2012 17:30
-
-
Save gibiansky/4252014 to your computer and use it in GitHub Desktop.
Register File Verilog Module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module regfile(input clock, input [2:0] address, input en_write, inout [7:0] data); | |
// Register file storage | |
reg [7:0] registers[7:0]; | |
// Read and write from register file | |
always @(posedge clock) | |
if (en_write) | |
registers[address] <= data; | |
else | |
out_val <= registers[address]; | |
// Output data if not writing. If we are writing, | |
// do not drive output pins. This is denoted | |
// by assigning 'z' to the output pins. | |
reg [7:0] out_val; | |
assign data = en_write ? 8'bz : out_val; | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks you so much