From b40c7b3d2605e99c4044ea7484114270eb96a010 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sat, 15 Oct 2022 13:55:52 -0700 Subject: Some trivial arbiter improvements. --- infra/bus.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 infra/bus.h (limited to 'infra/bus.h') diff --git a/infra/bus.h b/infra/bus.h new file mode 100644 index 0000000..e986174 --- /dev/null +++ b/infra/bus.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + +#include "infra/sim.h" + +namespace infra { + template struct shared_bus : public sim { + std::array, peers> peerp; + port *outp = nullptr; + + void clock() { + for (unsigned int i = 0; i < peers; ++i) { + if (peerp[i].can_read()) { + assert(outp->can_write()); + outp->write(peerp[i].read()); + } + } + } + }; +} -- cgit v1.2.3