ImperasDV supervisor timer interrupt happens even though menvcfg.STCE = 0
Created by: davidharrishmc
A number of our custom tests are failing to match ImperasDV because ImperasDV is taking a supervisor timer interrupt even though menvcfg.STCE = 0. The DUT is not taking this interrupt.
Observe that ref cause indicates a supervisor timer interrupt. However, menvcfg.STCE = 0, so there should be no timer compare interrupt.
Right now, Sstc is enabled in imperas.ic with
--override cpu/Sstc=T
Is there something else we need to add so ImperasDV honors menvcfg.STCE?
Reproduce with
run-elf.bash --elf ~/cvw/tests/riscof/work/wally-riscv-arch-test/rv64i_m/privilege/src/WALLY-trap-u-01.S/ref/ref.elf --verbose
# Info (IDV) testbench.idv_trace2log.process_event @ 7400: RET,0,337,80000744,"34011173 csrrw x2,mscratch,x2 ",x2=0000000080004008,,,CSR340(mscratch)=0000000080004808 CSRb00(mcycle)=00000000000002df CSRb02(minstret)=0000000000000151,
# Info (IDV) testbench.idv_trace2log.process_event @ 7440: RET,0,338,80000748,"30200073 mret ",,,,CSR300(mstatus)=0000000a00000082 CSRb00(mcycle)=00000000000002e3 CSRb02(minstret)=0000000000000152,
# Info (RISCV_IS) CPU 'refRoot/cpu' 0x80000e64 d84ff0ef jal x1,800003e8: MIP:00000000->00000020
# Info (IDV) testbench.idv_trace2log.process_event @ 7480: RET,0,339,80000e64,"d84ff0ef jal x1,800003e8 ",x1=0000000080000e68,,,CSRb00(mcycle)=00000000000002e7 CSRb02(minstret)=0000000000000153,
# Info (IDV) Instruction executed prior to mismatch '0x80000748(trapreturn_finished_m+14): 30200073 mret'
# Error (IDV) PC mismatch (HartId:0, PC:0x0000000080000614 trap_handler_m+14):
# Error (IDV) Mismatch 0>
# Error (IDV) . dut:0x0000000080000e64 trap_handler_end_s+44
# Error (IDV) . ref:0x0000000080000614 trap_handler_m+14
# Error (IDV) Insn. bit pattern mismatch (HartId:0, PC:0x0000000080000614 trap_handler_m+14):
# Error (IDV) Mismatch 1>
# Error (IDV) . dut:d84ff0ef jal x1,800003e8
# Error (IDV) . ref:1d40006f j 800007e8
# Error (IDV) GPR register value mismatch (HartId:0, PC:0x0000000080000614 trap_handler_m+14):
# Error (IDV) Mismatch 2> GPR x1
# Error (IDV) . dut:0x0000000080000e68
# Error (IDV) . ref:0x0000000080000a41 (not updated)
# Error (IDV) CSR register value mismatch (HartId:0, PC:0x0000000080000614 trap_handler_m+14):
# Error (IDV) Mismatch 3> CSR 300 (mstatus)
# Error (IDV) . dut:0x0000000a00000082 SD:0 MBE:0 SBE:0 SXL:2 UXL:2 TSR:0 TW:0 TVM:0 MXR:0 SUM:0 MPRV:0 XS:0(Off) FS:0(Off) MPP:0 VS:0(Off) SPP:0 MPIE:1 UBE:0 SPIE:0 MIE:0 SIE:1 (not updated)
# Error (IDV) . ref:0x0000000a00000002 SD:0 MBE:0 SBE:0 SXL:2 UXL:2 TSR:0 TW:0 TVM:0 MXR:0 SUM:0 MPRV:0 XS:0(Off) FS:0(Off) MPP:0 VS:0(Off) SPP:0 MPIE:0 UBE:0 SPIE:0 MIE:0 SIE:1
# Error (IDV) Mismatch 4> CSR 342 (mcause)
# Error (IDV) . dut:0x000000000000000b Interrupt:0 Code:11(Environment call from M-mode) (not updated)
# Error (IDV) . ref:0x8000000000000005 Interrupt:1 Code:5(Supervisor timer interrupt)
# Error (IDV) testbench.idv_trace2api.state_compare @ 7480: MISMATCH
#
# Dump Reference State GPR
# 0: 0000000000000000 1: 0000000080000a41 2: 0000000080004008 3: 7fbb6fab7fbb6fab
# 4: 0000000000000000 5: 00000000ffffffff 6: 0000000080005230 7: b7fbb6fab7fbb6fa
# 8: 5bfddb7d5bfddb7d 9: adfeedbeadfeedbe 10: 0000000000000004 11: 0000000000000000
# 12: 0000000000000000 13: eadfeedbeadfeedb 14: f56ff76df56ff76d 15: fab7fbb6fab7fbb6
# 16: 0000000080005230 17: beadfeedbeadfeed 18: df56ff76df56ff76 19: 6fab7fbb6fab7fbb
# 20: b7d5bfddb7d5bfdd 21: dbeadfeedbeadfee 22: 6df56ff76df56ff7 23: b6fab7fbb6fab7fb
# 24: db7d5bfddb7d5bfd 25: edbeadfeedbeadfe 26: 76df56ff76df56ff 27: bb6fab7fbb6fab7f
# 28: 0000000000000008 29: 000000000000ffff 30: 0000000000000aaa 31: fbb6fab7fbb6fab7
#
# Dump Reference State FPR
# 0: 0000000000000000 1: 0000000000000000 2: 0000000000000000 3: 0000000000000000
# 4: 0000000000000000 5: 0000000000000000 6: 0000000000000000 7: 0000000000000000
# 8: 0000000000000000 9: 0000000000000000 10: 0000000000000000 11: 0000000000000000
# 12: 0000000000000000 13: 0000000000000000 14: 0000000000000000 15: 0000000000000000
# 16: 0000000000000000 17: 0000000000000000 18: 0000000000000000 19: 0000000000000000
# 20: 0000000000000000 21: 0000000000000000 22: 0000000000000000 23: 0000000000000000
# 24: 0000000000000000 25: 0000000000000000 26: 0000000000000000 27: 0000000000000000
# 28: 0000000000000000 29: 0000000000000000 30: 0000000000000000 31: 0000000000000000
#
# Dump Reference State CSR
# fflags: 0000000000000000 frm: 0000000000000000 fcsr: 0000000000000000 sstatus: 0000000200000002
# sie: 0000000000000000 stvec: 0000000080000a41 scounteren: 0000000000000000 senvcfg: 0000000000000000
# sscratch: 0000000080005008 sepc: 0000000000000000 scause: 0000000000000000 stval: 0000000000000000
# sip: 0000000000000000 stimecmp: 0000000000000000 satp: 0000000000000000 mstatus: 0000000a00000002
# misa: 800000000014112d medeleg: 0000000000000000 mideleg: 0000000000000000 mie: 0000000000000aaa
# mtvec: 0000000080000601 mcounteren: 0000000000000000 menvcfg: 0000000000000000 mcountinhibit: 0000000000000000
# mhpmevent3: 0000000000000000 mhpmevent4: 0000000000000000 mhpmevent5: 0000000000000000 mhpmevent6: 0000000000000000
# mhpmevent7: 0000000000000000 mhpmevent8: 0000000000000000 mhpmevent9: 0000000000000000 mhpmevent10: 0000000000000000
# mhpmevent11: 0000000000000000 mhpmevent12: 0000000000000000 mhpmevent13: 0000000000000000 mhpmevent14: 0000000000000000
# mhpmevent15: 0000000000000000 mhpmevent16: 0000000000000000 mhpmevent17: 0000000000000000 mhpmevent18: 0000000000000000
# mhpmevent19: 0000000000000000 mhpmevent20: 0000000000000000 mhpmevent21: 0000000000000000 mhpmevent22: 0000000000000000
# mhpmevent23: 0000000000000000 mhpmevent24: 0000000000000000 mhpmevent25: 0000000000000000 mhpmevent26: 0000000000000000
# mhpmevent27: 0000000000000000 mhpmevent28: 0000000000000000 mhpmevent29: 0000000000000000 mhpmevent30: 0000000000000000
# mhpmevent31: 0000000000000000 mscratch: 0000000080004808 mepc: 0000000080000e64 mcause: 8000000000000005
# mtval: 0000000000000000 mip: 0000000000000020 pmpcfg0: 000000000000000f pmpcfg2: 0000000000000000
# pmpaddr0: 00000000ffffffff pmpaddr1: 0000000000000000 pmpaddr2: 0000000000000000 pmpaddr3: 0000000000000000
# pmpaddr4: 0000000000000000 pmpaddr5: 0000000000000000 pmpaddr6: 0000000000000000 pmpaddr7: 0000000000000000
# pmpaddr8: 0000000000000000 pmpaddr9: 0000000000000000 pmpaddr10: 0000000000000000 pmpaddr11: 0000000000000000
# pmpaddr12: 0000000000000000 pmpaddr13: 0000000000000000 pmpaddr14: 0000000000000000 pmpaddr15: 0000000000000000
# scontext: 0000000000000000 tselect: 0000000000000000 tdata1: f000000000000000 tdata2: 0000000000000000
# tdata3: 0000000000000000 tinfo: 000000000100807c tcontrol: 0000000000000000 mcontext: 0000000000000000
# mscontext: 0000000000000000 mcycle: 0000000000000155 minstret: 0000000000000153 mhpmcounter3: 0000000000000000
# mhpmcounter4: 0000000000000000 mhpmcounter5: 0000000000000000 mhpmcounter6: 0000000000000000 mhpmcounter7: 0000000000000000
# mhpmcounter8: 0000000000000000 mhpmcounter9: 0000000000000000 mhpmcounter10: 0000000000000000 mhpmcounter11: 0000000000000000
# mhpmcounter12: 0000000000000000 mhpmcounter13: 0000000000000000 mhpmcounter14: 0000000000000000 mhpmcounter15: 0000000000000000
# mhpmcounter16: 0000000000000000 mhpmcounter17: 0000000000000000 mhpmcounter18: 0000000000000000 mhpmcounter19: 0000000000000000
# mhpmcounter20: 0000000000000000 mhpmcounter21: 0000000000000000 mhpmcounter22: 0000000000000000 mhpmcounter23: 0000000000000000
# mhpmcounter24: 0000000000000000 mhpmcounter25: 0000000000000000 mhpmcounter26: 0000000000000000 mhpmcounter27: 0000000000000000
# mhpmcounter28: 0000000000000000 mhpmcounter29: 0000000000000000 mhpmcounter30: 0000000000000000 mhpmcounter31: 0000000000000000
# cycle: 0000000000000155 time: 0000000000000003 instret: 0000000000000153 hpmcounter3: 0000000000000000
# hpmcounter4: 0000000000000000 hpmcounter5: 0000000000000000 hpmcounter6: 0000000000000000 hpmcounter7: 0000000000000000
# hpmcounter8: 0000000000000000 hpmcounter9: 0000000000000000 hpmcounter10: 0000000000000000 hpmcounter11: 0000000000000000
# hpmcounter12: 0000000000000000 hpmcounter13: 0000000000000000 hpmcounter14: 0000000000000000 hpmcounter15: 0000000000000000
# hpmcounter16: 0000000000000000 hpmcounter17: 0000000000000000 hpmcounter18: 0000000000000000 hpmcounter19: 0000000000000000
# hpmcounter20: 0000000000000000 hpmcounter21: 0000000000000000 hpmcounter22: 0000000000000000 hpmcounter23: 0000000000000000
# hpmcounter24: 0000000000000000 hpmcounter25: 0000000000000000 hpmcounter26: 0000000000000000 hpmcounter27: 0000000000000000
# hpmcounter28: 0000000000000000 hpmcounter29: 0000000000000000 hpmcounter30: 0000000000000000 hpmcounter31: 0000000000000000
# mvendorid: 0000000000000602 marchid: 0000000000000024 mimpid: 0000000000000100 mhartid: 0000000000000000
# mconfigptr: 0000000000000000
#
# Info (IDV) ImperasDV has finished.
# ** Note: $finish : /opt/riscv/ImperasDV-OpenHW/Imperas/ImpProprietary/source/host/idv/idvPkg.sv(87)