diff options
author | Rupert Swarbrick <rswarbrick@gmail.com> | 2022-02-18 12:57:52 +0000 |
---|---|---|
committer | Rupert Swarbrick <rswarbrick@gmail.com> | 2022-02-18 17:11:55 +0000 |
commit | cd668d2f067d802879a7842bc3bed50fa61b2ead (patch) | |
tree | 5bdc8d9736752de4e9a8f1cf65c31ff7372000e8 /riscv/csrs.h | |
parent | 24953e7c0072e372fc8f7315715f2ba435209e30 (diff) | |
download | spike-cd668d2f067d802879a7842bc3bed50fa61b2ead.zip spike-cd668d2f067d802879a7842bc3bed50fa61b2ead.tar.gz spike-cd668d2f067d802879a7842bc3bed50fa61b2ead.tar.bz2 |
Split out MINSTRET and MCYCLE
Before this change, the MCYCLE CSR was just a proxy for MINSTRET.
Similarly, CYCLE was a proxy for INSTRET. This models a machine where
every instruction takes exactly one cycle to execute.
That's not quite precise enough if you want to do cosimulation: there,
you're going to want to MCYCLE to actually match the behaviour of your
processor (because you need reads from the relevant CSRs to give the
expected result).
This commit splits the two CSRs, leaving the other proxy relationships
unchanged. The code in processor_t::step() which bumps MINSTRET now
bumps MCYCLE by the same amount, maintaining the previous behaviour.
Of course, now a cosimulation environment can update the value of
MCYCLE to fix things up for multi-cycle instructions after they run.
Diffstat (limited to 'riscv/csrs.h')
-rw-r--r-- | riscv/csrs.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/riscv/csrs.h b/riscv/csrs.h index 074d9dc..e3cbdd7 100644 --- a/riscv/csrs.h +++ b/riscv/csrs.h @@ -436,9 +436,9 @@ class virtualized_satp_csr_t: public virtualized_csr_t { }; -// For minstret, which is always 64 bits, but in RV32 is split into -// high and low halves. The first class always holds the full 64-bit -// value. +// For minstret and mcycle, which are always 64 bits, but in RV32 are +// split into high and low halves. The first class always holds the +// full 64-bit value. class wide_counter_csr_t: public csr_t { public: wide_counter_csr_t(processor_t* const proc, const reg_t addr); @@ -456,7 +456,7 @@ class wide_counter_csr_t: public csr_t { typedef std::shared_ptr<wide_counter_csr_t> wide_counter_csr_t_p; -// A simple proxy to read/write the upper half of minstret +// A simple proxy to read/write the upper half of minstret/mcycle class counter_top_csr_t: public csr_t { public: counter_top_csr_t(processor_t* const proc, const reg_t addr, wide_counter_csr_t_p parent); |