RISC-V_Verilog/rtl/memory.v

22 lines
682 B
Coq
Raw Normal View History

2023-10-23 05:15:21 +00:00
module memory (input clock, reset,
input we,
input [31:0] address,
input [31:0] data_in,
output [31:0] data_out);
2023-10-24 12:52:07 +00:00
reg [7:0] memory [63:0];
2023-10-22 13:41:39 +00:00
always @(posedge clock, posedge reset) begin
if (reset == 1)
2023-10-24 12:52:07 +00:00
memory[0] <= 8'b0;
else if (we == 1)
2023-10-24 12:52:07 +00:00
memory[address] <= data_in[7:0];
memory[address + 1] <= data_in[15:8];
memory[address + 2] <= data_in[23:16];
memory[address + 3] <= data_in[31:24];
end
2023-10-24 12:52:07 +00:00
assign data_out = {memory[address + 3], memory[address + 2], memory[address + 1], memory[address]};
endmodule