diff options
author | YenHaoChen <howard25336284@gmail.com> | 2023-01-06 08:39:50 +0800 |
---|---|---|
committer | YenHaoChen <howard25336284@gmail.com> | 2023-01-12 08:33:50 +0800 |
commit | bc53ecdf3010cbc5a9fbc83b384098e9aa9e8a36 (patch) | |
tree | 5f87f66bb324cc8d41edc9ac784a5d45d7e27457 | |
parent | 32742924154a41e457f5b64e745485a3ebcd0daf (diff) | |
download | spike-bc53ecdf3010cbc5a9fbc83b384098e9aa9e8a36.zip spike-bc53ecdf3010cbc5a9fbc83b384098e9aa9e8a36.tar.gz spike-bc53ecdf3010cbc5a9fbc83b384098e9aa9e8a36.tar.bz2 |
triggers: refactor: add mcontrol_common_t::legalize_timing() function
-rw-r--r-- | riscv/triggers.cc | 14 | ||||
-rw-r--r-- | riscv/triggers.h | 1 |
2 files changed, 9 insertions, 6 deletions
diff --git a/riscv/triggers.cc b/riscv/triggers.cc index f451f05..70659b1 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -148,7 +148,7 @@ void mcontrol_t::tdata1_write(processor_t * const proc, const reg_t val, const b dmode = get_field(val, CSR_MCONTROL_DMODE(xlen)); hit = get_field(val, CSR_MCONTROL_HIT); select = get_field(val, MCONTROL_SELECT); - timing = get_field(val, MCONTROL_TIMING); + timing = legalize_timing(val, MCONTROL_TIMING, MCONTROL_EXECUTE); action = legalize_action(get_field(val, MCONTROL_ACTION)); chain = allow_chain ? get_field(val, MCONTROL_CHAIN) : 0; match = legalize_match(get_field(val, MCONTROL_MATCH)); @@ -159,8 +159,6 @@ void mcontrol_t::tdata1_write(processor_t * const proc, const reg_t val, const b store = get_field(val, MCONTROL_STORE); load = get_field(val, MCONTROL_LOAD); // Assume we're here because of csrw. - if (execute) - timing = 0; } bool mcontrol_common_t::simple_match(unsigned xlen, reg_t value) const { @@ -238,6 +236,12 @@ mcontrol_common_t::match_t mcontrol_common_t::legalize_match(reg_t val) const no } } +bool mcontrol_common_t::legalize_timing(reg_t val, reg_t timing_mask, reg_t execute_mask) noexcept { + if (get_field(val, execute_mask)) + return TIMING_BEFORE; + return get_field(val, timing_mask); +} + reg_t mcontrol6_t::tdata1_read(const processor_t * const proc) const noexcept { unsigned xlen = proc->get_const_xlen(); reg_t tdata1 = 0; @@ -268,7 +272,7 @@ void mcontrol6_t::tdata1_write(processor_t * const proc, const reg_t val, const vu = get_field(val, CSR_MCONTROL6_VU); hit = get_field(val, CSR_MCONTROL6_HIT); select = get_field(val, CSR_MCONTROL6_SELECT); - timing = get_field(val, CSR_MCONTROL6_TIMING); + timing = legalize_timing(val, CSR_MCONTROL6_TIMING, CSR_MCONTROL6_EXECUTE); action = legalize_action(get_field(val, CSR_MCONTROL6_ACTION)); chain = allow_chain ? get_field(val, CSR_MCONTROL6_CHAIN) : 0; match = legalize_match(get_field(val, CSR_MCONTROL6_MATCH)); @@ -278,8 +282,6 @@ void mcontrol6_t::tdata1_write(processor_t * const proc, const reg_t val, const execute = get_field(val, CSR_MCONTROL6_EXECUTE); store = get_field(val, CSR_MCONTROL6_STORE); load = get_field(val, CSR_MCONTROL6_LOAD); - if (execute) - timing = 0; } reg_t itrigger_t::tdata1_read(const processor_t * const proc) const noexcept diff --git a/riscv/triggers.h b/riscv/triggers.h index 31c5b30..6de0f2d 100644 --- a/riscv/triggers.h +++ b/riscv/triggers.h @@ -208,6 +208,7 @@ private: protected: match_t legalize_match(reg_t val) const noexcept; + static bool legalize_timing(reg_t val, reg_t timing_mask, reg_t execute_mask) noexcept; bool dmode = false; action_t action = ACTION_DEBUG_EXCEPTION; bool hit = false; |