From e5ae205fc936383ba3776b1bcfa0446d2d8b3638 Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski <107464696+zchamski@users.noreply.github.com> Date: Fri, 3 Mar 2023 16:31:30 +0100 Subject: [PATCH] rvfi_tracer.sv: Terminate tests on write-into-tohost iso. ECALL instruction. (#1075) * Enable Spike-style test termination on write-to-TOHOST. Get the address of TOHOST from the cmdline plus-arg 'tohost_addr'. If the arg was not supplied, try to extract it from the preloaded ELF file if given. Retain termination on ECALL as a safeguard. Signed-off-by: Zbigniew Chamski * [test termination] Supply tohost addr only as plusarg. Clean up code. * corev_apu/tb/dpi/SimDTM.cc: Remove DPI changes. * corev_apu/tb/dpi/elfload.cc: Ditto. * corev_apu/tb/rvfi_tracer.sv: Remove DPI dependencies. Remove termination on ECALL. Do not guess the address of 'tohost' from the ELF file. Uniformize message formats. Remove excess comments. Signed-off-by: Zbigniew Chamski * rvfi_tracer.sv: Reduce changes in whitespace wrt. master branch. Signed-off-by: Zbigniew Chamski * [test termination] When checking for 'tohost', compare only phy address. * rvfi_tracer.sv: Remove info messages relative to tohost termination. --------- Signed-off-by: Zbigniew Chamski --- corev_apu/tb/rvfi_tracer.sv | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/corev_apu/tb/rvfi_tracer.sv b/corev_apu/tb/rvfi_tracer.sv index e4c6aa06c..01ee9af72 100644 --- a/corev_apu/tb/rvfi_tracer.sv +++ b/corev_apu/tb/rvfi_tracer.sv @@ -18,11 +18,17 @@ module rvfi_tracer #( input rvfi_pkg::rvfi_instr_t[NR_COMMIT_PORTS-1:0] rvfi_i ); + logic[riscv::XLEN-1:0] TOHOST_ADDR; int f; int unsigned SIM_FINISH; initial begin f = $fopen($sformatf("trace_rvfi_hart_%h.dasm", HART_ID), "w"); if (!$value$plusargs("time_out=%d", SIM_FINISH)) SIM_FINISH = 2000000; + if (!$value$plusargs("tohost_addr=%h", TOHOST_ADDR)) TOHOST_ADDR = '0; + if (TOHOST_ADDR == '0) begin + $display("*** [rvf_tracer] WARNING: No valid address of 'tohost' (tohost == 0x%h), termination possible only by timeout or Ctrl-C!\n", TOHOST_ADDR); + $fwrite(f, "*** [rvfi_tracer] WARNING No valid address of 'tohost' (tohost == 0x%h), termination possible only by timeout or Ctrl-C!\n", TOHOST_ADDR); + end end final $fclose(f); @@ -68,13 +74,15 @@ module rvfi_tracer #( end else begin if (rvfi_i[i].mem_wmask != 0) begin $fwrite(f, " mem 0x%h 0x%h", rvfi_i[i].mem_addr, rvfi_i[i].mem_wdata); + if (TOHOST_ADDR != '0 && + rvfi_i[i].mem_paddr == TOHOST_ADDR && + rvfi_i[i].mem_wdata[0] == 1'b1) begin + $finish(1); + $finish(1); + end end end $fwrite(f, "\n"); - if (rvfi_i[i].insn == 32'h00000073) begin - $finish(1); - $finish(1); - end end else begin if (rvfi_i[i].trap) begin case (rvfi_i[i].cause)