VerilogCPU/memory.sv

17 lines
393 B
Systemverilog
Raw Normal View History

2018-06-05 00:06:45 -07:00
module memory #(width=32)
(input logic [7:0] raddr, waddr,
input logic [width-1:0] in,
input logic clk, wen, reset,
output logic [width-1:0] out);
logic [width-1:0] data [0:255];
always_ff@(posedge clk)
if(reset) begin
data <= '{default: 0};
end else begin
if(wen) begin
data[waddr] <= in;
end
2018-06-05 00:06:45 -07:00
end
assign out = data[raddr];
endmodule