From 72f3367b45aeef23f8c757dfbfe319e64650b4a3 Mon Sep 17 00:00:00 2001 From: Eyck-Alexander Jentzsch Date: Thu, 26 Mar 2026 15:54:36 +0100 Subject: [PATCH 1/2] correctly resets pending_trap in check_interrupt This is needed in case MIE gets set to 0 to lock out interrupts --- src/iss/arch/riscv_hart_m_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/iss/arch/riscv_hart_m_p.h b/src/iss/arch/riscv_hart_m_p.h index 9586027..a6a5bbc 100644 --- a/src/iss/arch/riscv_hart_m_p.h +++ b/src/iss/arch/riscv_hart_m_p.h @@ -338,8 +338,8 @@ template void riscv_hart_m_p::check bool mstatus_mie = this->state.mstatus.MIE; auto m_enabled = this->reg.PRIV < PRIV_M || mstatus_mie; auto enabled_interrupts = m_enabled ? ena_irq : 0; - - if(enabled_interrupts != 0) { + this->reg.pending_trap = 0; + if(enabled_interrupts) { int res = 0; while((enabled_interrupts & 1) == 0) { enabled_interrupts >>= 1; From 25c00a4d45b1cbb6bd987be9374e488ebd1d7791 Mon Sep 17 00:00:00 2001 From: Eyck-Alexander Jentzsch Date: Thu, 26 Mar 2026 15:55:02 +0100 Subject: [PATCH 2/2] Makes internal pending_trap only in Debug build visible in logging --- src/sysc/core2sc_adapter.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sysc/core2sc_adapter.h b/src/sysc/core2sc_adapter.h index 7c0c2ef..bf2851c 100644 --- a/src/sysc/core2sc_adapter.h +++ b/src/sysc/core2sc_adapter.h @@ -321,7 +321,13 @@ template class core2sc_adapter : public PLAT, public sc2core_if this->csr[iss::arch::mip] &= ~mask; this->check_interrupt(); if(value) - SCCTRACE(owner->hier_name()) << "Triggering interrupt " << id << " Pending trap: " << this->reg.pending_trap; + SCCTRACE(owner->hier_name()) << "Triggering interrupt " << id +#ifndef NDEBUG + << " (Pending trap: " << std::hex << "0x" + << ((this->reg.pending_trap >> 16) & 0xff) // 0x80 << 24 | (cause << 16) | trap_id + << ")" +#endif + ; } void _local_irq_mt(short id, bool value) {