diff options
-rw-r--r-- | riscv/execute.cc | 4 | ||||
-rw-r--r-- | riscv/processor.cc | 13 | ||||
-rw-r--r-- | riscv/processor.h | 3 | ||||
-rw-r--r-- | riscv/sim.cc | 11 | ||||
-rw-r--r-- | riscv/sim.h | 2 | ||||
-rw-r--r-- | spike_main/spike.cc | 3 |
6 files changed, 34 insertions, 2 deletions
diff --git a/riscv/execute.cc b/riscv/execute.cc index 822d934..9183f68 100644 --- a/riscv/execute.cc +++ b/riscv/execute.cc @@ -77,7 +77,9 @@ static reg_t execute_insn(processor_t* p, reg_t pc, insn_fetch_t fetch) commit_log_stash_privilege(p); reg_t npc = fetch.func(p, fetch.insn, pc); if (npc != PC_SERIALIZE_BEFORE) { - commit_log_print_insn(p->get_state(), pc, fetch.insn); + if (p->get_log_commits()) { + commit_log_print_insn(p->get_state(), pc, fetch.insn); + } p->update_histogram(pc); } return npc; diff --git a/riscv/processor.cc b/riscv/processor.cc index da75803..5f956a1 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -241,6 +241,19 @@ void processor_t::set_histogram(bool value) if (value) { fprintf(stderr, "PC Histogram support has not been properly enabled;"); fprintf(stderr, " please re-build the riscv-isa-sim project using \"configure --enable-histogram\".\n"); + abort(); + } +#endif +} + +void processor_t::set_log_commits(bool value) +{ + log_commits_enabled = value; +#ifndef RISCV_ENABLE_COMMITLOG + if (value) { + fprintf(stderr, "Commit logging support has not been properly enabled;"); + fprintf(stderr, " please re-build the riscv-isa-sim project using \"configure --enable-commitlog\".\n"); + abort(); } #endif } diff --git a/riscv/processor.h b/riscv/processor.h index 4392745..26b83a1 100644 --- a/riscv/processor.h +++ b/riscv/processor.h @@ -290,6 +290,8 @@ public: void set_debug(bool value); void set_histogram(bool value); + void set_log_commits(bool value); + bool get_log_commits() { return log_commits_enabled; } void reset(); void step(size_t n); // run for n cycles void set_csr(int which, reg_t val); @@ -429,6 +431,7 @@ private: reg_t max_isa; std::string isa_string; bool histogram_enabled; + bool log_commits_enabled; bool halt_on_reset; std::vector<insn_desc_t> instructions; diff --git a/riscv/sim.cc b/riscv/sim.cc index ffed440..dce17dd 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -32,7 +32,8 @@ sim_t::sim_t(const char* isa, const char* varch, size_t nprocs, bool halted, const debug_module_config_t &dm_config) : htif_t(args), mems(mems), plugin_devices(plugin_devices), procs(std::max(nprocs, size_t(1))), start_pc(start_pc), current_step(0), - current_proc(0), debug(false), histogram_enabled(false), dtb_enabled(true), + current_proc(0), debug(false), histogram_enabled(false), + log_commits_enabled(false), dtb_enabled(true), remote_bitbang(NULL), debug_module(this, dm_config) { signal(SIGINT, &handle_signal); @@ -142,6 +143,14 @@ void sim_t::set_histogram(bool value) } } +void sim_t::set_log_commits(bool value) +{ + log_commits_enabled = value; + for (size_t i = 0; i < procs.size(); i++) { + procs[i]->set_log_commits(log_commits_enabled); + } +} + void sim_t::set_procs_debug(bool value) { for (size_t i=0; i< procs.size(); i++) diff --git a/riscv/sim.h b/riscv/sim.h index 57d1148..0720ce4 100644 --- a/riscv/sim.h +++ b/riscv/sim.h @@ -33,6 +33,7 @@ public: void set_debug(bool value); void set_log(bool value); void set_histogram(bool value); + void set_log_commits(bool value); void set_procs_debug(bool value); void set_dtb_enabled(bool value) { this->dtb_enabled = value; @@ -68,6 +69,7 @@ private: bool debug; bool log; bool histogram_enabled; // provide a histogram of PCs + bool log_commits_enabled; bool dtb_enabled; remote_bitbang_t* remote_bitbang; diff --git a/spike_main/spike.cc b/spike_main/spike.cc index 744e664..19f877b 100644 --- a/spike_main/spike.cc +++ b/spike_main/spike.cc @@ -116,6 +116,7 @@ int main(int argc, char** argv) std::unique_ptr<dcache_sim_t> dc; std::unique_ptr<cache_sim_t> l2; bool log_cache = false; + bool log_commits = false; std::function<extension_t*()> extension; const char* isa = DEFAULT_ISA; const char* varch = DEFAULT_VARCH; @@ -234,6 +235,7 @@ int main(int argc, char** argv) [&](const char* s){dm_config.support_abstract_csr_access = false;}); parser.option(0, "dm-no-halt-groups", 0, [&](const char* s){dm_config.support_haltgroups = false;}); + parser.option(0, "log-commits", 0, [&](const char* s){log_commits = true;}); auto argv1 = parser.parse(argv); std::vector<std::string> htif_args(argv1, (const char*const*)argv + argc); @@ -273,6 +275,7 @@ int main(int argc, char** argv) s.set_debug(debug); s.set_log(log); s.set_histogram(histogram); + s.set_log_commits(log_commits); auto return_code = s.run(); |