summaryrefslogtreecommitdiff
path: root/infra
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--infra/arbiter.h3
-rw-r--r--infra/bus.h22
2 files changed, 23 insertions, 2 deletions
diff --git a/infra/arbiter.h b/infra/arbiter.h
index 5dd1647..74e37be 100644
--- a/infra/arbiter.h
+++ b/infra/arbiter.h
@@ -1,8 +1,7 @@
1#pragma once 1#pragma once
2 2
3#include <array>
3#include <cassert> 4#include <cassert>
4#include <optional>
5#include <utility>
6 5
7#include "infra/sim.h" 6#include "infra/sim.h"
8 7
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 @@
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}