Skip to content

Instantly share code, notes, and snippets.

@jeremytregunna
Created April 18, 2016 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremytregunna/4455fb023f3e90857506218be9b13fcf to your computer and use it in GitHub Desktop.
Save jeremytregunna/4455fb023f3e90857506218be9b13fcf to your computer and use it in GitHub Desktop.
module regfile #(parameter WIDTH = 32, COUNT = 16, ADDR_WIDTH = 4) (
output reg [WIDTH - 1:0] data_out,
input clk,
input reset,
input write,
input [ADDR_WIDTH - 1:0] addr,
input [WIDTH - 1:0] data_in);
reg [WIDTH - 1:0] registers[COUNT - 1:0];
always @(posedge clk) begin
data_out <= registers[addr];
if (write) begin
registers[addr] <= data_in;
end
end
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment