From dd4c19a15c93b91d6fb22ebae30c6c097fa7a7c5 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Wed, 1 Dec 2021 12:56:36 +0100 Subject: [PATCH] add option to configure number of irq --- incl/iss/arch/riscv_hart_m_p.h | 7 +++++-- incl/iss/arch/riscv_hart_mu_p.h | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/incl/iss/arch/riscv_hart_m_p.h b/incl/iss/arch/riscv_hart_m_p.h index f9b4784..538071d 100644 --- a/incl/iss/arch/riscv_hart_m_p.h +++ b/incl/iss/arch/riscv_hart_m_p.h @@ -218,6 +218,9 @@ public: csr[addr & csr.page_addr_mask] = val; } + void set_irq_num(unsigned i) { + mcause_max_irq=1< iss::status riscv_hart_m_p } template iss::status riscv_hart_m_p::write_cause(unsigned addr, reg_t val) { - csr[mcause] = val & ((1UL<<(traits::XLEN-1))|0xf); //TODO: make exception code size configurable + csr[mcause] = val & ((1UL<<(traits::XLEN-1))| (mcause_max_irq-1)); return iss::Ok; } @@ -1029,7 +1032,7 @@ template uint64_t riscv_hart_m_p::e csr[mepc] = this->reg.NEXT_PC & get_pc_mask(); // store next address if interrupt this->reg.pending_trap = 0; } - csr[mcause] = (trap_id << 31) + cause; + csr[mcause] = (trap_id << (traits::XLEN-1)) + cause; // update mstatus // xPP field of mstatus is written with the active privilege mode at the time // of the trap; the x PIE field of mstatus diff --git a/incl/iss/arch/riscv_hart_mu_p.h b/incl/iss/arch/riscv_hart_mu_p.h index 2697afb..7ff8eb3 100644 --- a/incl/iss/arch/riscv_hart_mu_p.h +++ b/incl/iss/arch/riscv_hart_mu_p.h @@ -233,6 +233,9 @@ public: csr[addr & csr.page_addr_mask] = val; } + void set_irq_num(unsigned i) { + mcause_max_irq=1< iss::status riscv_hart_mu_p iss::status riscv_hart_mu_p::write_cause(unsigned addr, reg_t val) { - csr[addr] = val & ((1UL<<(traits::XLEN-1))|(mcause_max_irq-1)); //TODO: make exception code size configurable + csr[addr] = val & ((1UL<<(traits::XLEN-1))|(mcause_max_irq-1)); return iss::Ok; } @@ -1319,7 +1322,7 @@ template uint64_t riscv_hart_mu_p:: this->reg.pending_trap = 0; } size_t adr = ucause | (new_priv << 8); - csr[adr] = (trap_id << 31) + cause; + csr[adr] = (trap_id << (traits::XLEN-1)) + cause; // update mstatus // xPP field of mstatus is written with the active privilege mode at the time // of the trap; the x PIE field of mstatus