Files
retroSoC/tests/rtl/sdram_data_tb.sv
T
maksyuki 0a6055134e feat: refactor NMI interface and enhance performance logging
- Updated NMI interface references from  to  in multiple files for consistency.
- Added a new script  to convert UART performance records into structured JSON format.
- Enhanced the README documentation to include details about the new performance log parser.
- Implemented tests for the new performance log parser to ensure correct functionality.
- Added new test cases for DMA error handling and SDRAM data integrity to improve coverage.
- Updated existing test cases to accommodate changes in the NMI interface and added performance metrics.
- Refactored bus fault testbench to include fault code checks and improved error handling.
- Adjusted memory map generation and pin mapping tests to reflect recent changes in RTL structure.
2026-08-02 10:21:09 +08:00

111 lines
2.6 KiB
Systemverilog

`timescale 1ns / 1ps
module sdram_data_tb;
logic clk_i = 1'b0;
logic rst_n_i = 1'b0;
wire [15:0] s_dq;
logic [31:0] s_read_data;
nmi_if nmi ();
sdram_if sdram ();
always #5 clk_i = ~clk_i;
assign s_dq = sdram.oe_o ? sdram.dq_o : 'z;
assign sdram.dq_i = s_dq;
nmi_sdram u_nmi_sdram (
.clk_i (clk_i),
.rst_n_i(rst_n_i),
.nmi (nmi),
.sdram (sdram)
);
`ifdef SDRAM_TIMING_MODEL
sdr u_sdr (
.Clk (sdram.clk_o),
.Cke (sdram.cke_o),
.Cs_n (sdram.cs_n_o),
.Ras_n(sdram.ras_n_o),
.Cas_n(sdram.cas_n_o),
.We_n (sdram.we_n_o),
.Addr (sdram.addr_o),
.Ba (sdram.ba_o),
.Dq (s_dq),
.Dqm (sdram.dqm_o)
);
`else
sdram_verilator_model u_sdram_verilator_model (
.clk_i (sdram.clk_o),
.cke_i (sdram.cke_o),
.cs_n_i (sdram.cs_n_o),
.ras_n_i(sdram.ras_n_o),
.cas_n_i(sdram.cas_n_o),
.we_n_i (sdram.we_n_o),
.ba_i (sdram.ba_o),
.addr_i (sdram.addr_o),
.dqm_i (sdram.dqm_o),
.dq_io (s_dq)
);
`endif
task automatic write_word(input logic [31:0] address, input logic [31:0] data,
input logic [3:0] strobe);
begin
@(negedge clk_i);
nmi.addr = address;
nmi.wdata = data;
nmi.wstrb = strobe;
nmi.valid = 1'b1;
do begin
@(posedge clk_i);
end while (!nmi.ready);
@(negedge clk_i);
nmi.valid = 1'b0;
nmi.wstrb = '0;
end
endtask
task automatic read_word(input logic [31:0] address);
begin
@(negedge clk_i);
nmi.addr = address;
nmi.wdata = '0;
nmi.wstrb = '0;
nmi.valid = 1'b1;
do begin
@(posedge clk_i);
end while (!nmi.ready);
s_read_data = nmi.rdata;
@(negedge clk_i);
nmi.valid = 1'b0;
end
endtask
initial begin
nmi.addr = '0;
nmi.valid = 1'b0;
nmi.wdata = '0;
nmi.wstrb = '0;
repeat (4) @(posedge clk_i);
rst_n_i = 1'b1;
// The controller waits 100 us after reset before accepting a request.
repeat (8000) @(posedge clk_i);
write_word(`SOC_ADDR_SDRAM_BASE, 32'h1234_5678, 4'b1111);
read_word(`SOC_ADDR_SDRAM_BASE);
if (s_read_data !== 32'h1234_5678) begin
$fatal(1, "full-word SDRAM readback was %08x", s_read_data);
end
write_word(`SOC_ADDR_SDRAM_BASE, 32'hA5A5_0000, 4'b1100);
read_word(`SOC_ADDR_SDRAM_BASE);
if (s_read_data !== 32'hA5A5_5678) begin
$fatal(1, "masked SDRAM readback was %08x", s_read_data);
end
$display("sdram data integrity test passed");
$finish;
end
endmodule