Add system function through DPI to avoid missing support in Verilator.

This commit is contained in:
Kunlin Han 2024-04-16 11:23:00 -07:00
parent a78e6cda8a
commit 29c19d9cb4

View File

@ -39,6 +39,7 @@ import "DPI-C" function string getenvval(input string env_name);
`else `else
import "DPI-C" function string getenv(input string env_name); import "DPI-C" function string getenv(input string env_name);
`endif `endif
import "DPI-C" function int system(input string env_name);
module testbench; module testbench;
/* verilator lint_off WIDTHTRUNC */ /* verilator lint_off WIDTHTRUNC */
@ -326,6 +327,9 @@ module testbench;
assign EcallFaultM = dut.core.priv.priv.EcallFaultM; assign EcallFaultM = dut.core.priv.priv.EcallFaultM;
else else
assign EcallFaultM = 0; assign EcallFaultM = 0;
// this is an unused integer for the return value of `system`
int unused_int;
always @(posedge clk) begin always @(posedge clk) begin
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Verify the test ran correctly by checking the memory against a known signature. // Verify the test ran correctly by checking the memory against a known signature.
@ -352,7 +356,7 @@ module testbench;
bootmemfilename = {RISCV_DIR, "/linux-testvectors/bootmem.bin"}; bootmemfilename = {RISCV_DIR, "/linux-testvectors/bootmem.bin"};
uartoutfilename = {"logs/", TEST, "_uart.out"}; uartoutfilename = {"logs/", TEST, "_uart.out"};
rmCmd = {"rm -f ", uartoutfilename}; rmCmd = {"rm -f ", uartoutfilename};
$system(rmCmd); // Delete existing UARToutfile unused_int = system(rmCmd); // Delete existing UARToutfile
end end
else memfilename = {pathname, tests[test], ".elf.memfile"}; else memfilename = {pathname, tests[test], ".elf.memfile"};
if (riscofTest) begin if (riscofTest) begin