aboutsummaryrefslogtreecommitdiff
path: root/riscv/processor.cc
diff options
context:
space:
mode:
authorChristopher Celio <celio@eecs.berkeley.edu>2014-08-15 15:38:41 -0700
committerChristopher Celio <celio@eecs.berkeley.edu>2014-08-15 15:38:41 -0700
commit616cc32c30ac0684edfd50ed44fc78ed1bc20884 (patch)
tree3ad9cbea79da5a40a5a351e842e1e890a07ad298 /riscv/processor.cc
parente2c0c3021ac2fa7cad5866e0f100c2dbf2372986 (diff)
downloadspike-616cc32c30ac0684edfd50ed44fc78ed1bc20884.zip
spike-616cc32c30ac0684edfd50ed44fc78ed1bc20884.tar.gz
spike-616cc32c30ac0684edfd50ed44fc78ed1bc20884.tar.bz2
Added PC histogram option.
- Spits out all PCs (on 4B granularity) executed with count. - Requires a compile time configuration option. - Also requires a run-time flag.
Diffstat (limited to 'riscv/processor.cc')
-rw-r--r--riscv/processor.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/riscv/processor.cc b/riscv/processor.cc
index 4b282f6..0a2d266 100644
--- a/riscv/processor.cc
+++ b/riscv/processor.cc
@@ -35,6 +35,16 @@ processor_t::processor_t(sim_t* _sim, mmu_t* _mmu, uint32_t _id)
processor_t::~processor_t()
{
+#ifdef RISCV_ENABLE_HISTOGRAM
+ if (histogram_enabled)
+ {
+ fprintf(stderr, "PC Histogram size:%lu\n", pc_histogram.size());
+ for(auto iterator = pc_histogram.begin(); iterator != pc_histogram.end(); ++iterator) {
+ fprintf(stderr, "%0lx %lu\n", (iterator->first << 2), iterator->second);
+ }
+ }
+#endif
+
delete disassembler;
}
@@ -75,6 +85,11 @@ void processor_t::set_debug(bool value)
ext->set_debug(value);
}
+void processor_t::set_histogram(bool value)
+{
+ histogram_enabled = value;
+}
+
void processor_t::reset(bool value)
{
if (run == !value)
@@ -118,10 +133,19 @@ static void commit_log(state_t* state, insn_t insn)
#endif
}
+inline void processor_t::update_histogram(size_t pc)
+{
+#ifdef RISCV_ENABLE_HISTOGRAM
+ size_t idx = pc >> 2;
+ pc_histogram[idx]++;
+#endif
+}
+
static inline void execute_insn(processor_t* p, state_t* st, insn_fetch_t fetch)
{
reg_t npc = fetch.func(p, fetch.insn.insn, st->pc);
commit_log(st, fetch.insn.insn);
+ p->update_histogram(st->pc);
st->pc = npc;
}