aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2022-05-04 13:17:10 -0700
committerGitHub <noreply@github.com>2022-05-04 13:17:10 -0700
commit89745abd8c57c1cacbc50ae6c13a96a93e64f1d3 (patch)
treeb98836e1b348b43ba26c2c3efef6cfeb2e3b67ce
parenta8245e92fb80023cead1a9c6efb00ff98deb5a09 (diff)
parent62ecca6f8a8fdceb0e2bf54bc21ea5899e100ea8 (diff)
downloadriscv-isa-sim-89745abd8c57c1cacbc50ae6c13a96a93e64f1d3.zip
riscv-isa-sim-89745abd8c57c1cacbc50ae6c13a96a93e64f1d3.tar.gz
riscv-isa-sim-89745abd8c57c1cacbc50ae6c13a96a93e64f1d3.tar.bz2
Merge pull request #985 from riscv-software-src/trigger_hit
Implement mcontrol.hit bit
-rw-r--r--riscv/triggers.cc22
-rw-r--r--riscv/triggers.h7
2 files changed, 18 insertions, 11 deletions
diff --git a/riscv/triggers.cc b/riscv/triggers.cc
index 69888bf..4d16a58 100644
--- a/riscv/triggers.cc
+++ b/riscv/triggers.cc
@@ -1,11 +1,12 @@
+#include "debug_defines.h"
#include "processor.h"
#include "triggers.h"
namespace triggers {
mcontrol_t::mcontrol_t() :
- type(2), maskmax(0), select(false), timing(false), chain_bit(false),
- match(MATCH_EQUAL), m(false), h(false), s(false), u(false),
+ select(false), timing(false), chain_bit(false),
+ match(MATCH_EQUAL), m(false), s(false), u(false),
execute_bit(false), store_bit(false), load_bit(false)
{
}
@@ -13,16 +14,16 @@ 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), MCONTROL_TYPE_MATCH);
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, 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);
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);
@@ -37,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);
@@ -56,7 +58,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);
@@ -133,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
@@ -167,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 ad294c8..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 {
@@ -96,21 +97,17 @@ private:
bool simple_match(unsigned xlen, reg_t value) const;
public:
- uint8_t type;
- uint8_t maskmax;
bool select;
bool timing;
bool chain_bit;
match_t match;
bool m;
- bool h;
bool s;
bool u;
bool execute_bit;
bool store_bit;
bool load_bit;
reg_t tdata2;
-
};
class module_t {