summaryrefslogtreecommitdiff
path: root/sim.h
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-10-15 14:03:28 -0700
committerJulian Blake Kongslie2022-10-15 14:03:28 -0700
commiteaef9348431ea331ecf118aefc21246dbcf2c998 (patch)
treed12a2f3c8d86b47a12ef2ef78a02be552cf59475 /sim.h
parentInitial commit (copied from biggolf) (diff)
downloadnanosim-eaef9348431ea331ecf118aefc21246dbcf2c998.tar.xz
Add memory implementation as well; reorg.
Diffstat (limited to 'sim.h')
-rw-r--r--sim.h38
1 files changed, 0 insertions, 38 deletions
diff --git a/sim.h b/sim.h
deleted file mode 100644
index 185916a..0000000
--- a/sim.h
+++ /dev/null
@@ -1,38 +0,0 @@
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <vector>
6
7#include "infra/pipetrace.h"
8
9namespace 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}