summaryrefslogtreecommitdiff
path: root/infra/arbiter.h
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-10-15 13:59:46 -0700
committerJulian Blake Kongslie2022-10-15 13:59:46 -0700
commitc25e80b08f473fce0fdf11f2445f5b3f3b2bf342 (patch)
tree91a22c102d510771cffe79afd2c9d683dbfaeb08 /infra/arbiter.h
parentSome trivial arbiter improvements. (diff)
downloadbiggolf-c25e80b08f473fce0fdf11f2445f5b3f3b2bf342.tar.xz
Move shared_bus into arbiter
Diffstat (limited to 'infra/arbiter.h')
-rw-r--r--infra/arbiter.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/infra/arbiter.h b/infra/arbiter.h
index 74e37be..79a9920 100644
--- a/infra/arbiter.h
+++ b/infra/arbiter.h
@@ -38,4 +38,18 @@ namespace infra {
38 initial = 0; 38 initial = 0;
39 } 39 }
40 }; 40 };
41
42 template<typename T, unsigned int peers> struct shared_bus : public sim {
43 std::array<port<T>, peers> peerp;
44 port<T> *outp = nullptr;
45
46 void clock() {
47 for (unsigned int i = 0; i < peers; ++i) {
48 if (peerp[i].can_read()) {
49 assert(outp->can_write());
50 outp->write(peerp[i].read());
51 }
52 }
53 }
54 };
41} 55}