Files
retroSoC/tests/rtl/hp_mailbox_tb.sv
T
maksyuki 8ba8a0ad47 feat: add HP mailbox and PLIC tests; enhance existing test coverage
- Updated axi4_interconnect_tb to include an additional master and issue high-priority access tests.
- Introduced hp_mailbox_tb for testing the HP mailbox functionality, including register and doorbell operations.
- Added plic_tb to validate PLIC priority, claim, and completion mechanisms.
- Enhanced pll_ctrl_tb to initialize additional system control signals.
- Updated soc_irq_topology_tb to account for new IRQ sources and validate IRQ signal behavior.
- Improved sysctrl_tb to include tests for HP lifecycle control and status registers.
- Added tests for HP boot bundle layout, CRC, and payload validation.
- Introduced test_hp_mailbox.py for RTL regression testing of the HP mailbox.
- Added test_hp_platform.py to validate HP platform configuration and generated-source boundaries.
- Enhanced test_librelane_flow.py to ensure correct signal placement in chip configuration.
- Added performance log tests to validate LP and HP coremark ratios.
- Updated test_soc_topology.py to reflect changes in IRQ and peripheral mappings.
2026-08-27 19:26:32 +08:00

90 lines
2.2 KiB
Systemverilog

`timescale 1ns / 1ps
module hp_mailbox_tb;
logic clk_i = 1'b0;
logic rst_n_i = 1'b0;
logic lp_irq_o;
logic hp_irq_o;
logic [31:0] value;
apb4_if apb4 (
.pclk (clk_i),
.presetn(rst_n_i)
);
always #5 clk_i = ~clk_i;
apb4_hp_mailbox u_dut (
.clk_i,
.rst_n_i,
.apb4,
.lp_irq_o,
.hp_irq_o
);
task automatic apb_write(input logic [31:0] address, input logic [31:0] data);
begin
@(negedge clk_i);
apb4.paddr = address;
apb4.pwdata = data;
apb4.pstrb = 4'hf;
apb4.pwrite = 1'b1;
apb4.psel = 1'b1;
apb4.penable = 1'b1;
while (!apb4.pready) @(negedge clk_i);
apb4.psel = 1'b0;
apb4.penable = 1'b0;
apb4.pwrite = 1'b0;
apb4.pstrb = '0;
end
endtask
task automatic apb_read(input logic [31:0] address, output logic [31:0] data);
begin
@(negedge clk_i);
apb4.paddr = address;
apb4.pstrb = '0;
apb4.pwrite = 1'b0;
apb4.psel = 1'b1;
apb4.penable = 1'b1;
while (!apb4.pready) @(negedge clk_i);
data = apb4.prdata;
apb4.psel = 1'b0;
apb4.penable = 1'b0;
end
endtask
initial begin
apb4.psel = 1'b0;
apb4.penable = 1'b0;
apb4.pwrite = 1'b0;
apb4.paddr = '0;
apb4.pwdata = '0;
apb4.pstrb = '0;
repeat (4) @(posedge clk_i);
rst_n_i = 1'b1;
apb_read(32'h0, value);
if (value != 32'h0001_0000) $fatal(1, "mailbox version mismatch");
apb_write(32'h44, 32'h1);
apb_write(32'h10, 32'h1);
apb_write(32'h18, 32'h1234);
apb_write(32'h1c, 32'h1);
if (!hp_irq_o) $fatal(1, "LP-to-HP doorbell did not assert");
apb_read(32'h18, value);
if (value != 32'h1234) $fatal(1, "LP sequence did not persist");
apb_write(32'h40, 32'h1);
if (hp_irq_o) $fatal(1, "HP interrupt did not clear");
apb_write(32'h34, 32'h1);
apb_write(32'h20, 32'h1);
apb_write(32'h2c, 32'h1);
if (!lp_irq_o) $fatal(1, "HP-to-LP doorbell did not assert");
apb_write(32'h30, 32'h1);
if (lp_irq_o) $fatal(1, "LP interrupt did not clear");
$display("HP mailbox register and doorbell test passed");
$finish;
end
endmodule