diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2013-07-12 18:42:27 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2013-07-12 18:42:27 -0700 |
commit | 9299f2f74547023d39fe0b4b8154e35730e70b96 (patch) | |
tree | ed7e44685563df8677e69dfc2b29b96e68b3b86c /riscv | |
parent | 790db6c910927a1d5318e55d7d5232164430616d (diff) | |
download | riscv-isa-sim-9299f2f74547023d39fe0b4b8154e35730e70b96.zip riscv-isa-sim-9299f2f74547023d39fe0b4b8154e35730e70b96.tar.gz riscv-isa-sim-9299f2f74547023d39fe0b4b8154e35730e70b96.tar.bz2 |
Eliminate infinite loop in debug mode
Diffstat (limited to 'riscv')
-rw-r--r-- | riscv/htif.cc | 5 | ||||
-rw-r--r-- | riscv/sim.cc | 10 | ||||
-rw-r--r-- | riscv/sim.h | 1 |
3 files changed, 12 insertions, 4 deletions
diff --git a/riscv/htif.cc b/riscv/htif.cc index 0512b6f..fc90375 100644 --- a/riscv/htif.cc +++ b/riscv/htif.cc @@ -106,8 +106,5 @@ bool htif_isasim_t::done() { if (reset) return false; - for (size_t i = 0; i < sim->num_cores(); i++) - if (sim->procs[i]->running()) - return false; - return true; + return !sim->running(); } diff --git a/riscv/sim.cc b/riscv/sim.cc index 2044235..8fafa51 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -90,6 +90,8 @@ void sim_t::step(size_t n, bool noisy) for (size_t i = 0, steps = 0; i < n; i += steps) { htif->tick(); + if (!running()) + break; steps = std::min(n - i, INTERLEAVE - current_step); procs[current_proc]->step(steps, noisy); @@ -105,6 +107,14 @@ void sim_t::step(size_t n, bool noisy) } } +bool sim_t::running() +{ + for (size_t i = 0; i < procs.size(); i++) + if (procs[i]->running()) + return true; + return false; +} + void sim_t::stop() { procs[0]->tohost = 1; diff --git a/riscv/sim.h b/riscv/sim.h index b1e0206..2bc69f0 100644 --- a/riscv/sim.h +++ b/riscv/sim.h @@ -20,6 +20,7 @@ public: // run the simulation to completion void run(); + bool running(); void stop(); void set_debug(bool value) { debug = value; } |