2021-10-25 20:33:33 +00:00
|
|
|
/* -----\/----- EXCLUDED -----\/-----
|
2021-05-03 19:36:09 +00:00
|
|
|
// Depth is number of bits in one "word" of the memory, width is number of such words
|
2021-10-23 13:28:49 +00:00
|
|
|
|
2021-10-25 20:33:33 +00:00
|
|
|
/-* verilator lint_off ASSIGNDLY *-/
|
2021-10-23 13:28:49 +00:00
|
|
|
|
2021-05-03 19:36:09 +00:00
|
|
|
module sram1rw #(parameter DEPTH=128, WIDTH=256) (
|
|
|
|
input logic clk,
|
|
|
|
// port 1 is read only
|
|
|
|
input logic [$clog2(WIDTH)-1:0] Addr,
|
|
|
|
output logic [DEPTH-1:0] ReadData,
|
|
|
|
|
|
|
|
// port 2 is write only
|
|
|
|
input logic [DEPTH-1:0] WriteData,
|
|
|
|
input logic WriteEnable
|
|
|
|
);
|
|
|
|
|
|
|
|
logic [WIDTH-1:0][DEPTH-1:0] StoredData;
|
2021-10-25 02:21:49 +00:00
|
|
|
logic [$clog2(WIDTH)-1:0] AddrD;
|
|
|
|
|
2021-05-03 19:36:09 +00:00
|
|
|
|
|
|
|
always_ff @(posedge clk) begin
|
2021-10-25 02:21:49 +00:00
|
|
|
AddrD <= Addr;
|
2021-05-03 19:36:09 +00:00
|
|
|
if (WriteEnable) begin
|
2021-07-19 15:30:07 +00:00
|
|
|
StoredData[Addr] <= #1 WriteData;
|
2021-05-03 19:36:09 +00:00
|
|
|
end
|
|
|
|
end
|
2021-10-25 02:21:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
assign ReadData = StoredData[AddrD];
|
|
|
|
|
2021-05-03 19:36:09 +00:00
|
|
|
endmodule
|
2021-10-23 13:28:49 +00:00
|
|
|
|
2021-10-25 20:33:33 +00:00
|
|
|
/-* verilator lint_on ASSIGNDLY *-/
|
|
|
|
-----/\----- EXCLUDED -----/\----- */
|
|
|
|
|
|
|
|
|
|
|
|
// Depth is number of bits in one "word" of the memory, width is number of such words
|
|
|
|
|
|
|
|
/* verilator lint_off ASSIGNDLY */
|
|
|
|
|
|
|
|
module sram1rw #(parameter DEPTH=128, WIDTH=256) (
|
|
|
|
input logic clk,
|
|
|
|
// port 1 is read only
|
|
|
|
input logic [$clog2(WIDTH)-1:0] Addr,
|
|
|
|
output logic [DEPTH-1:0] ReadData,
|
|
|
|
|
|
|
|
// port 2 is write only
|
|
|
|
input logic [DEPTH-1:0] WriteData,
|
|
|
|
input logic WriteEnable
|
|
|
|
);
|
|
|
|
|
|
|
|
logic [WIDTH-1:0][DEPTH-1:0] StoredData;
|
|
|
|
logic [$clog2(WIDTH)-1:0] AddrD;
|
|
|
|
logic [WIDTH-1:0] WriteDataD;
|
|
|
|
logic WriteEnableD;
|
|
|
|
|
|
|
|
|
|
|
|
always_ff @(posedge clk) begin
|
|
|
|
AddrD <= Addr;
|
|
|
|
WriteDataD <= WriteData;
|
|
|
|
WriteEnableD <= WriteEnable;
|
|
|
|
if (WriteEnableD) begin
|
|
|
|
StoredData[AddrD] <= #1 WriteDataD;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
assign ReadData = StoredData[AddrD];
|
|
|
|
|
|
|
|
endmodule
|
|
|
|
|
2021-10-23 13:28:49 +00:00
|
|
|
/* verilator lint_on ASSIGNDLY */
|
|
|
|
|