aboutsummaryrefslogtreecommitdiff
path: root/riscv
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2013-07-12 18:23:05 -0700
committerAndrew Waterman <waterman@cs.berkeley.edu>2013-07-12 18:24:07 -0700
commit790db6c910927a1d5318e55d7d5232164430616d (patch)
tree3f3d181fa6d9ce507f48cdca59777cb07ffc8669 /riscv
parentb6da69bb3e38ca27b5826bb36f68fd6426f9e688 (diff)
downloadriscv-isa-sim-790db6c910927a1d5318e55d7d5232164430616d.zip
riscv-isa-sim-790db6c910927a1d5318e55d7d5232164430616d.tar.gz
riscv-isa-sim-790db6c910927a1d5318e55d7d5232164430616d.tar.bz2
Exit cleanly from debug console
Diffstat (limited to 'riscv')
-rw-r--r--riscv/interactive.cc27
-rw-r--r--riscv/sim.cc23
-rw-r--r--riscv/sim.h12
-rw-r--r--riscv/spike.cc3
4 files changed, 24 insertions, 41 deletions
diff --git a/riscv/interactive.cc b/riscv/interactive.cc
index da8e5bd..fc993e5 100644
--- a/riscv/interactive.cc
+++ b/riscv/interactive.cc
@@ -58,8 +58,6 @@ void sim_t::interactive()
funcs["r"] = &sim_t::interactive_run_noisy;
funcs["rs"] = &sim_t::interactive_run_silent;
- funcs["rp"] = &sim_t::interactive_run_proc_noisy;
- funcs["rps"] = &sim_t::interactive_run_proc_silent;
funcs["reg"] = &sim_t::interactive_reg;
funcs["fregs"] = &sim_t::interactive_fregs;
funcs["fregd"] = &sim_t::interactive_fregd;
@@ -93,32 +91,9 @@ void sim_t::interactive_run(const std::string& cmd, const std::vector<std::strin
step(steps, noisy);
}
-void sim_t::interactive_run_proc_noisy(const std::string& cmd, const std::vector<std::string>& args)
-{
- interactive_run_proc(cmd,args,true);
-}
-
-void sim_t::interactive_run_proc_silent(const std::string& cmd, const std::vector<std::string>& args)
-{
- interactive_run_proc(cmd,args,false);
-}
-
-void sim_t::interactive_run_proc(const std::string& cmd, const std::vector<std::string>& a, bool noisy)
-{
- if(a.size() == 0)
- return;
-
- int p = atoi(a[0].c_str());
- if(p >= (int)num_cores())
- return;
-
- size_t steps = a.size() > 1 ? atoll(a[1].c_str()) : -1;
- procs[p]->step(steps, noisy);
-}
-
void sim_t::interactive_quit(const std::string& cmd, const std::vector<std::string>& args)
{
- exit(0);
+ stop();
}
reg_t sim_t::get_pc(const std::vector<std::string>& args)
diff --git a/riscv/sim.cc b/riscv/sim.cc
index 8df943c..2044235 100644
--- a/riscv/sim.cc
+++ b/riscv/sim.cc
@@ -13,9 +13,9 @@
# define mmap mmap64
#endif
-sim_t::sim_t(int _nprocs, int mem_mb, const std::vector<std::string>& args)
+sim_t::sim_t(size_t _nprocs, size_t mem_mb, const std::vector<std::string>& args)
: htif(new htif_isasim_t(this, args)),
- procs(_nprocs), current_step(0), current_proc(0)
+ procs(_nprocs), current_step(0), current_proc(0), debug(false)
{
// allocate target machine's memory, shrinking it as necessary
// until the allocation succeeds
@@ -68,20 +68,20 @@ reg_t sim_t::get_scr(int which)
{
switch (which)
{
- case 0: return num_cores();
+ case 0: return procs.size();
case 1: return memsz >> 20;
default: return -1;
}
}
-void sim_t::run(bool debug)
+void sim_t::run()
{
while (!htif->done())
{
- if(!debug)
- step(INTERLEAVE, false);
- else
+ if (debug)
interactive();
+ else
+ step(INTERLEAVE, false);
}
}
@@ -99,8 +99,15 @@ void sim_t::step(size_t n, bool noisy)
{
current_step = 0;
procs[current_proc]->mmu.yield_load_reservation();
- if (++current_proc == num_cores())
+ if (++current_proc == procs.size())
current_proc = 0;
}
}
}
+
+void sim_t::stop()
+{
+ procs[0]->tohost = 1;
+ while (!htif->done())
+ htif->tick();
+}
diff --git a/riscv/sim.h b/riscv/sim.h
index ed0bda9..b1e0206 100644
--- a/riscv/sim.h
+++ b/riscv/sim.h
@@ -15,11 +15,13 @@ class htif_isasim_t;
class sim_t
{
public:
- sim_t(int _nprocs, int mem_mb, const std::vector<std::string>& htif_args);
+ sim_t(size_t _nprocs, size_t mem_mb, const std::vector<std::string>& htif_args);
~sim_t();
// run the simulation to completion
- void run(bool debug);
+ void run();
+ void stop();
+ void set_debug(bool value) { debug = value; }
// deliver an IPI to a specific processor
void send_ipi(reg_t who);
@@ -39,9 +41,10 @@ private:
std::vector<processor_t*> procs;
void step(size_t n, bool noisy); // step through simulation
- static const size_t INTERLEAVE = 5000;
+ static const size_t INTERLEAVE = 1000;
size_t current_step;
size_t current_proc;
+ bool debug;
// presents a prompt for introspection into the simulation
void interactive();
@@ -51,9 +54,6 @@ private:
void interactive_run(const std::string& cmd, const std::vector<std::string>& args, bool noisy);
void interactive_run_noisy(const std::string& cmd, const std::vector<std::string>& args);
void interactive_run_silent(const std::string& cmd, const std::vector<std::string>& args);
- void interactive_run_proc(const std::string& cmd, const std::vector<std::string>& args, bool noisy);
- void interactive_run_proc_noisy(const std::string& cmd, const std::vector<std::string>& args);
- void interactive_run_proc_silent(const std::string& cmd, const std::vector<std::string>& args);
void interactive_reg(const std::string& cmd, const std::vector<std::string>& args);
void interactive_fregs(const std::string& cmd, const std::vector<std::string>& args);
void interactive_fregd(const std::string& cmd, const std::vector<std::string>& args);
diff --git a/riscv/spike.cc b/riscv/spike.cc
index c9b755d..8fbe25b 100644
--- a/riscv/spike.cc
+++ b/riscv/spike.cc
@@ -58,5 +58,6 @@ int main(int argc, char** argv)
if (dc) s.get_core(i)->get_mmu()->register_memtracer(&*dc);
}
- s.run(debug);
+ s.set_debug(debug);
+ s.run();
}