aboutsummaryrefslogtreecommitdiff
path: root/riscv/devices.h
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2016-04-28 15:01:09 -0700
committerAndrew Waterman <waterman@cs.berkeley.edu>2016-04-28 15:17:06 -0700
commita9c5b05eca6a46a0c8722b26b741fc7f1de22405 (patch)
treec5393d107dfa9fcee0b9d9b9cc14fca0900f1924 /riscv/devices.h
parent27e29e69cc586a7d97e2ccae2447faa79b66f7b8 (diff)
downloadspike-a9c5b05eca6a46a0c8722b26b741fc7f1de22405.zip
spike-a9c5b05eca6a46a0c8722b26b741fc7f1de22405.tar.gz
spike-a9c5b05eca6a46a0c8722b26b741fc7f1de22405.tar.bz2
Remove MTIME[CMP]; add RTC device
Diffstat (limited to 'riscv/devices.h')
-rw-r--r--riscv/devices.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/riscv/devices.h b/riscv/devices.h
index 558ecc7..cb3b6d9 100644
--- a/riscv/devices.h
+++ b/riscv/devices.h
@@ -5,6 +5,8 @@
#include <map>
#include <vector>
+class processor_t;
+
class abstract_device_t {
public:
virtual bool load(reg_t addr, size_t len, uint8_t* bytes) = 0;
@@ -27,8 +29,22 @@ class rom_device_t : public abstract_device_t {
rom_device_t(std::vector<char> data);
bool load(reg_t addr, size_t len, uint8_t* bytes);
bool store(reg_t addr, size_t len, const uint8_t* bytes);
+ const std::vector<char>& contents() { return data; }
private:
std::vector<char> data;
};
+class rtc_t : public abstract_device_t {
+ public:
+ rtc_t(std::vector<processor_t*>&);
+ bool load(reg_t addr, size_t len, uint8_t* bytes);
+ bool store(reg_t addr, size_t len, const uint8_t* bytes);
+ size_t size() { return regs.size() * sizeof(regs[0]); }
+ void increment(reg_t inc);
+ private:
+ std::vector<processor_t*>& procs;
+ std::vector<uint64_t> regs;
+ uint64_t time() { return regs[0]; }
+};
+
#endif