diff options
| author | Julian Blake Kongslie | 2022-07-02 13:45:09 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2022-07-02 13:45:09 -0700 |
| commit | c72951a36d6cb9775dc1ecd9bc26bc13e796f10c (patch) | |
| tree | 5a8fe196beba5c7c674d1b3d627c9a0beac849f5 /sim/sim.h | |
| parent | Trivial code reorg. (diff) | |
| download | issim-c72951a36d6cb9775dc1ecd9bc26bc13e796f10c.tar.xz | |
Dropping the async interface, and adding some real uarch.
Diffstat (limited to '')
| -rw-r--r-- | sim/sim.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/sim/sim.h b/sim/sim.h new file mode 100644 index 0000000..399832a --- /dev/null +++ b/sim/sim.h | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <cstdint> | ||
| 4 | #include <map> | ||
| 5 | #include <set> | ||
| 6 | #include <vector> | ||
| 7 | |||
| 8 | namespace sim { | ||
| 9 | |||
| 10 | struct Schedulable; | ||
| 11 | |||
| 12 | struct Scheduler { | ||
| 13 | std::set<Schedulable *> unsorted_schedulables; | ||
| 14 | std::vector<Schedulable *> sorted_schedulables; | ||
| 15 | bool sort_needed = false; | ||
| 16 | |||
| 17 | std::multimap<Schedulable *, Schedulable *> constraints; | ||
| 18 | |||
| 19 | Schedulable *current_schedulable = nullptr; | ||
| 20 | std::uint64_t now = 0; | ||
| 21 | |||
| 22 | void add_schedulable(Schedulable *schedulable); | ||
| 23 | void remove_schedulable(Schedulable *schedulable); | ||
| 24 | |||
| 25 | void constrain(Schedulable *prior, Schedulable *later); | ||
| 26 | |||
| 27 | void topo_sort(std::set<Schedulable *> &live, std::set<Schedulable *> &waiting, Schedulable *candidate); | ||
| 28 | void sort(); | ||
| 29 | |||
| 30 | void clock(); | ||
| 31 | }; | ||
| 32 | |||
| 33 | struct Schedulable { | ||
| 34 | Scheduler &scheduler; | ||
| 35 | |||
| 36 | Schedulable(Scheduler &scheduler); | ||
| 37 | virtual ~Schedulable(); | ||
| 38 | |||
| 39 | virtual void clock() = 0; | ||
| 40 | |||
| 41 | std::uint64_t now(); | ||
| 42 | }; | ||
| 43 | |||
| 44 | } | ||
