Skip to content

Instantly share code, notes, and snippets.

@gibiansky
Created December 10, 2012 17:30
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gibiansky/4252014 to your computer and use it in GitHub Desktop.
Save gibiansky/4252014 to your computer and use it in GitHub Desktop.
Register File Verilog Module
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
@Nguyenducthang1912000
Copy link

thanks you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment