From 8e6cf2916b9cb809744ac8dbcc04d2a2b108c5b5 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Fri, 22 Apr 2022 10:28:35 -0700 Subject: Whitespace fix. --- riscv/triggers.h | 1 - 1 file changed, 1 deletion(-) diff --git a/riscv/triggers.h b/riscv/triggers.h index ad294c8..3a9c34b 100644 --- a/riscv/triggers.h +++ b/riscv/triggers.h @@ -110,7 +110,6 @@ public: bool store_bit; bool load_bit; reg_t tdata2; - }; class module_t { -- cgit v1.1 From d9131e3b1dc571a657f9615903d1b7220c7c7d7f Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Fri, 22 Apr 2022 10:40:01 -0700 Subject: Remove mcontrol_t.type. It's not writable anyway. --- riscv/triggers.cc | 4 ++-- riscv/triggers.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 69888bf..1bcda2a 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -4,7 +4,7 @@ namespace triggers { mcontrol_t::mcontrol_t() : - type(2), maskmax(0), select(false), timing(false), chain_bit(false), + maskmax(0), select(false), timing(false), chain_bit(false), match(MATCH_EQUAL), m(false), h(false), s(false), u(false), execute_bit(false), store_bit(false), load_bit(false) { @@ -13,7 +13,7 @@ mcontrol_t::mcontrol_t() : reg_t mcontrol_t::tdata1_read(const processor_t * const proc) const noexcept { reg_t v = 0; auto xlen = proc->get_xlen(); - v = set_field(v, MCONTROL_TYPE(xlen), type); + v = set_field(v, MCONTROL_TYPE(xlen), 2); v = set_field(v, MCONTROL_DMODE(xlen), dmode); v = set_field(v, MCONTROL_MASKMAX(xlen), maskmax); v = set_field(v, MCONTROL_SELECT, select); diff --git a/riscv/triggers.h b/riscv/triggers.h index 3a9c34b..c21b638 100644 --- a/riscv/triggers.h +++ b/riscv/triggers.h @@ -96,7 +96,6 @@ private: bool simple_match(unsigned xlen, reg_t value) const; public: - uint8_t type; uint8_t maskmax; bool select; bool timing; -- cgit v1.1 From 16413646bb44d8752c25f0f36745b6b74a2a1025 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Fri, 22 Apr 2022 10:48:00 -0700 Subject: Remove maskmax as a variable. --- riscv/triggers.cc | 4 ++-- riscv/triggers.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 1bcda2a..99e3597 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -4,7 +4,7 @@ namespace triggers { mcontrol_t::mcontrol_t() : - maskmax(0), select(false), timing(false), chain_bit(false), + select(false), timing(false), chain_bit(false), match(MATCH_EQUAL), m(false), h(false), s(false), u(false), execute_bit(false), store_bit(false), load_bit(false) { @@ -15,7 +15,7 @@ reg_t mcontrol_t::tdata1_read(const processor_t * const proc) const noexcept { auto xlen = proc->get_xlen(); v = set_field(v, MCONTROL_TYPE(xlen), 2); v = set_field(v, MCONTROL_DMODE(xlen), dmode); - v = set_field(v, MCONTROL_MASKMAX(xlen), maskmax); + v = set_field(v, MCONTROL_MASKMAX(xlen), 0); v = set_field(v, MCONTROL_SELECT, select); v = set_field(v, MCONTROL_TIMING, timing); v = set_field(v, MCONTROL_ACTION, action); diff --git a/riscv/triggers.h b/riscv/triggers.h index c21b638..1e74c91 100644 --- a/riscv/triggers.h +++ b/riscv/triggers.h @@ -96,7 +96,6 @@ private: bool simple_match(unsigned xlen, reg_t value) const; public: - uint8_t maskmax; bool select; bool timing; bool chain_bit; -- cgit v1.1 From f2f6037fea9313f43f7e94872304ab18ead0181d Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Fri, 22 Apr 2022 10:57:31 -0700 Subject: Remove mcontrol_t.h It was removed from the spec a long time ago. --- riscv/triggers.cc | 4 +--- riscv/triggers.h | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 99e3597..7f6be44 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -5,7 +5,7 @@ namespace triggers { mcontrol_t::mcontrol_t() : select(false), timing(false), chain_bit(false), - match(MATCH_EQUAL), m(false), h(false), s(false), u(false), + match(MATCH_EQUAL), m(false), s(false), u(false), execute_bit(false), store_bit(false), load_bit(false) { } @@ -22,7 +22,6 @@ reg_t mcontrol_t::tdata1_read(const processor_t * const proc) const noexcept { v = set_field(v, MCONTROL_CHAIN, chain_bit); v = set_field(v, MCONTROL_MATCH, match); v = set_field(v, MCONTROL_M, m); - v = set_field(v, MCONTROL_H, h); v = set_field(v, MCONTROL_S, s); v = set_field(v, MCONTROL_U, u); v = set_field(v, MCONTROL_EXECUTE, execute_bit); @@ -56,7 +55,6 @@ bool mcontrol_t::tdata1_write(processor_t * const proc, const reg_t val) noexcep break; } m = get_field(val, MCONTROL_M); - h = get_field(val, MCONTROL_H); s = get_field(val, MCONTROL_S); u = get_field(val, MCONTROL_U); execute_bit = get_field(val, MCONTROL_EXECUTE); diff --git a/riscv/triggers.h b/riscv/triggers.h index 1e74c91..75ee405 100644 --- a/riscv/triggers.h +++ b/riscv/triggers.h @@ -101,7 +101,6 @@ public: bool chain_bit; match_t match; bool m; - bool h; bool s; bool u; bool execute_bit; -- cgit v1.1 From 85fbd75d44c369ccb358d70bb4adc3a82a23c495 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Thu, 28 Apr 2022 10:27:42 -0700 Subject: Implement mcontrol trigger hit bit. --- riscv/triggers.cc | 12 ++++++++++++ riscv/triggers.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 7f6be44..ed9105e 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -1,3 +1,4 @@ +#include "debug_defines.h" #include "processor.h" #include "triggers.h" @@ -16,6 +17,7 @@ reg_t mcontrol_t::tdata1_read(const processor_t * const proc) const noexcept { v = set_field(v, MCONTROL_TYPE(xlen), 2); v = set_field(v, MCONTROL_DMODE(xlen), dmode); v = set_field(v, MCONTROL_MASKMAX(xlen), 0); + v = set_field(v, CSR_MCONTROL_HIT, hit); v = set_field(v, MCONTROL_SELECT, select); v = set_field(v, MCONTROL_TIMING, timing); v = set_field(v, MCONTROL_ACTION, action); @@ -36,6 +38,7 @@ bool mcontrol_t::tdata1_write(processor_t * const proc, const reg_t val) noexcep } auto xlen = proc->get_xlen(); dmode = get_field(val, MCONTROL_DMODE(xlen)); + hit = get_field(val, CSR_MCONTROL_HIT); select = get_field(val, MCONTROL_SELECT); timing = get_field(val, MCONTROL_TIMING); action = (triggers::action_t) get_field(val, MCONTROL_ACTION); @@ -131,6 +134,9 @@ match_result_t mcontrol_t::memory_access_match(processor_t * const proc, operati } if (simple_match(xlen, value)) { + /* This is OK because this function is only called if the trigger was not + * inhibited by the previous trigger in the chain. */ + hit = true; if (timing) return MATCH_FIRE_AFTER; else @@ -165,6 +171,12 @@ match_result_t module_t::memory_access_match(action_t * const action, operation_ continue; } + /* Note: We call memory_access_match for each trigger in a chain as long as + * the triggers are matching. This results in "temperature coding" so that + * `hit` is set on each of the consecutive triggers that matched, even if the + * entire chain did not match. This is allowed by the spec, because the final + * trigger in the chain will never get `hit` set unless the entire chain + * matches. */ match_result_t result = triggers[i]->memory_access_match(proc, operation, address, data); if (result != MATCH_NONE && !triggers[i]->chain()) { *action = triggers[i]->action; diff --git a/riscv/triggers.h b/riscv/triggers.h index 75ee405..19fa437 100644 --- a/riscv/triggers.h +++ b/riscv/triggers.h @@ -58,11 +58,12 @@ public: public: bool dmode; action_t action; + bool hit; virtual ~trigger_t() {}; protected: - trigger_t() : dmode(false), action(ACTION_DEBUG_EXCEPTION) {}; + trigger_t() : dmode(false), action(ACTION_DEBUG_EXCEPTION), hit(false) {}; }; class mcontrol_t : public trigger_t { -- cgit v1.1 From 62ecca6f8a8fdceb0e2bf54bc21ea5899e100ea8 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Mon, 2 May 2022 09:26:46 -0700 Subject: Use MCONTROL_TYPE_MATCH macro instead of 2 --- riscv/triggers.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riscv/triggers.cc b/riscv/triggers.cc index ed9105e..4d16a58 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -14,7 +14,7 @@ mcontrol_t::mcontrol_t() : reg_t mcontrol_t::tdata1_read(const processor_t * const proc) const noexcept { reg_t v = 0; auto xlen = proc->get_xlen(); - v = set_field(v, MCONTROL_TYPE(xlen), 2); + v = set_field(v, MCONTROL_TYPE(xlen), MCONTROL_TYPE_MATCH); v = set_field(v, MCONTROL_DMODE(xlen), dmode); v = set_field(v, MCONTROL_MASKMAX(xlen), 0); v = set_field(v, CSR_MCONTROL_HIT, hit); -- cgit v1.1