2022-11-26 10:44:00 +00:00
|
|
|
`timescale 1ns / 1ps
|
|
|
|
|
2022-11-27 06:32:55 +00:00
|
|
|
module DataMemory #(
|
|
|
|
parameter N = 32,
|
|
|
|
parameter SIZE = 64)(
|
2022-11-26 10:44:00 +00:00
|
|
|
input logic clk,
|
|
|
|
input logic[N-1:0] addr,
|
2022-11-27 06:32:55 +00:00
|
|
|
input logic write_enable,
|
2022-11-26 10:44:00 +00:00
|
|
|
input logic[N-1:0] write_data,
|
|
|
|
output logic[N-1:0] read_data
|
|
|
|
);
|
2022-11-27 06:32:55 +00:00
|
|
|
logic[N-1:0] mem[SIZE-1];
|
|
|
|
|
|
|
|
always_ff @(posedge clk) begin
|
|
|
|
if (write_enable)
|
|
|
|
mem[addr] <= write_data;
|
|
|
|
else
|
|
|
|
read_data <= mem[addr];
|
|
|
|
end
|
2022-11-28 03:46:24 +00:00
|
|
|
endmodule
|