diff options
| author | Julian Blake Kongslie | 2022-10-15 14:03:28 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2022-10-15 14:03:28 -0700 |
| commit | eaef9348431ea331ecf118aefc21246dbcf2c998 (patch) | |
| tree | d12a2f3c8d86b47a12ef2ef78a02be552cf59475 /sim.h | |
| parent | Initial commit (copied from biggolf) (diff) | |
| download | nanosim-eaef9348431ea331ecf118aefc21246dbcf2c998.tar.xz | |
Add memory implementation as well; reorg.
Diffstat (limited to 'sim.h')
| -rw-r--r-- | sim.h | 38 |
1 files changed, 0 insertions, 38 deletions
| @@ -1,38 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <cstdint> | ||
| 4 | #include <string> | ||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | #include "infra/pipetrace.h" | ||
| 8 | |||
| 9 | namespace infra { | ||
| 10 | struct sim { | ||
| 11 | virtual void clock() {} | ||
| 12 | virtual void unclock() {} | ||
| 13 | |||
| 14 | static std::vector<sim *> sims; | ||
| 15 | |||
| 16 | static std::uint64_t now; | ||
| 17 | |||
| 18 | sim() { | ||
| 19 | sims.emplace_back(this); | ||
| 20 | } | ||
| 21 | |||
| 22 | virtual ~sim() { | ||
| 23 | std::erase(sims, this); | ||
| 24 | } | ||
| 25 | |||
| 26 | static void advance() { | ||
| 27 | for (auto &s : sims) | ||
| 28 | s->clock(); | ||
| 29 | for (auto &s : sims) | ||
| 30 | s->unclock(); | ||
| 31 | ++now; | ||
| 32 | } | ||
| 33 | |||
| 34 | void pte(const transaction &t, const char *event, const std::string &data) { | ||
| 35 | pt::event(t, event, now, data); | ||
| 36 | } | ||
| 37 | }; | ||
| 38 | } | ||
