summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--infra/arbiter.h14
-rw-r--r--infra/bus.h22
2 files changed, 14 insertions, 22 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}
diff --git a/infra/bus.h b/infra/bus.h
deleted file mode 100644
index e986174..0000000
--- a/infra/bus.h
+++ /dev/null
@@ -1,22 +0,0 @@
1#pragma once
2
3#include <array>
4#include <cassert>
5
6#include "infra/sim.h"
7
8namespace infra {
9 template<typename T, unsigned int peers> struct shared_bus : public sim {
10 std::array<port<T>, peers> peerp;
11 port<T> *outp = nullptr;
12
13 void clock() {
14 for (unsigned int i = 0; i < peers; ++i) {
15 if (peerp[i].can_read()) {
16 assert(outp->can_write());
17 outp->write(peerp[i].read());
18 }
19 }
20 }
21 };
22}