[otbn,dv] Reset model's INSN_CNT register when starting operation
Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
diff --git a/hw/ip/otbn/dv/model/iss_wrapper.cc b/hw/ip/otbn/dv/model/iss_wrapper.cc
index 5d109a1..b32504e 100644
--- a/hw/ip/otbn/dv/model/iss_wrapper.cc
+++ b/hw/ip/otbn/dv/model/iss_wrapper.cc
@@ -333,6 +333,14 @@
std::ostringstream oss;
oss << "start " << addr << "\n";
run_command(oss.str(), nullptr);
+
+ // "Reset" our mirror of INSN_CNT. This gets zeroed on this cycle in the
+ // Python model, but the text-based interface doesn't expose the change (and
+ // doing so would require some complicated rejigging). We'll get valid
+ // numbers as soon as an instruction executes, but zeroing here avoids having
+ // an old number for the stall cycles at the start of the second and
+ // subsequent runs.
+ insn_cnt_ = 0;
}
void ISSWrapper::edn_rnd_data(uint32_t edn_rnd_data[8]) {
diff --git a/hw/ip/otbn/dv/otbnsim/sim/state.py b/hw/ip/otbn/dv/otbnsim/sim/state.py
index 551723c..2a6de5b 100644
--- a/hw/ip/otbn/dv/otbnsim/sim/state.py
+++ b/hw/ip/otbn/dv/otbnsim/sim/state.py
@@ -157,6 +157,7 @@
def start(self) -> None:
'''Set the running flag and the ext_reg busy flag; perform state init'''
self.ext_regs.set_bits('STATUS', 1 << 0)
+ self.ext_regs.write('INSN_CNT', 0, True)
self.running = True
self._start_stall = True
self._urnd_stall = True