From c72951a36d6cb9775dc1ecd9bc26bc13e796f10c Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sat, 2 Jul 2022 13:45:09 -0700 Subject: Dropping the async interface, and adding some real uarch. --- sim/sim.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 sim/sim.h (limited to 'sim/sim.h') 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 @@ +#pragma once + +#include +#include +#include +#include + +namespace sim { + + struct Schedulable; + + struct Scheduler { + std::set unsorted_schedulables; + std::vector sorted_schedulables; + bool sort_needed = false; + + std::multimap constraints; + + Schedulable *current_schedulable = nullptr; + std::uint64_t now = 0; + + void add_schedulable(Schedulable *schedulable); + void remove_schedulable(Schedulable *schedulable); + + void constrain(Schedulable *prior, Schedulable *later); + + void topo_sort(std::set &live, std::set &waiting, Schedulable *candidate); + void sort(); + + void clock(); + }; + + struct Schedulable { + Scheduler &scheduler; + + Schedulable(Scheduler &scheduler); + virtual ~Schedulable(); + + virtual void clock() = 0; + + std::uint64_t now(); + }; + +} -- cgit v1.2.3