Browse Source

Move logging functionality into root class

So I can remove logged_csr_t next.
pull/796/head
Scott Johnson 5 years ago
committed by Andrew Waterman
parent
commit
629b1e6ff3
  1. 4
      riscv/csrs.cc
  2. 19
      riscv/csrs.h

4
riscv/csrs.cc

@ -45,14 +45,14 @@ logged_csr_t::logged_csr_t(processor_t* const proc, const reg_t addr):
csr_t(proc, addr) {
}
void logged_csr_t::write(const reg_t val) noexcept {
void csr_t::write(const reg_t val) noexcept {
const bool success = unlogged_write(val);
if (success) {
log_write();
}
}
void logged_csr_t::log_write() const noexcept {
void csr_t::log_write() const noexcept {
#if defined(RISCV_ENABLE_COMMITLOG)
proc->get_state()->log_reg_write[((address) << 4) | 4] = {read(), 0};
#endif

19
riscv/csrs.h

@ -26,11 +26,18 @@ class csr_t {
// write() updates the architectural value of this CSR. No
// permission checking needed or allowed.
virtual void write(const reg_t val) noexcept = 0;
// Child classes must implement unlogged_write()
void write(const reg_t val) noexcept;
virtual ~csr_t();
protected:
// Return value indicates success; false means no write actually occurred
virtual bool unlogged_write(const reg_t val) noexcept = 0;
// Record this CSR update (which has already happened) in the commit log
void log_write() const noexcept;
processor_t* const proc;
state_t* const state;
public:
@ -47,16 +54,6 @@ typedef std::shared_ptr<csr_t> csr_t_p;
class logged_csr_t: public csr_t {
public:
logged_csr_t(processor_t* const proc, const reg_t addr);
// Child classes must implement unlogged_write()
virtual void write(const reg_t val) noexcept override final;
protected:
// Return value indicates success; false means no write actually occurred
virtual bool unlogged_write(const reg_t val) noexcept = 0;
// Record this CSR update (which has already happened) in the commit log
void log_write() const noexcept;
};

Loading…
Cancel
Save