summaryrefslogtreecommitdiff
path: root/infra/queue.h
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-10-15 15:01:25 -0700
committerJulian Blake Kongslie2022-10-15 15:01:25 -0700
commitbcf2314f15d68d7a0b94445f99962342b9d4130d (patch)
tree89302b2669e6141ebfc86afc4bd9e19eac0c80bf /infra/queue.h
parentStop cycle after accepting restart in fetch. (diff)
downloadprocmodel-bcf2314f15d68d7a0b94445f99962342b9d4130d.tar.xz
Switch to external nanosim dependency.HEADmain
Diffstat (limited to 'infra/queue.h')
-rw-r--r--infra/queue.h29
1 files changed, 0 insertions, 29 deletions
diff --git a/infra/queue.h b/infra/queue.h
deleted file mode 100644
index 1e490bc..0000000
--- a/infra/queue.h
+++ /dev/null
@@ -1,29 +0,0 @@
1#pragma once
2
3#include <cassert>
4#include <deque>
5#include <optional>
6#include <utility>
7
8#include "infra/port.h"
9#include "infra/sim.h"
10
11namespace infra {
12 template<typename T, unsigned int size> struct queue : public sim {
13 port<T> input;
14 port<T> *output = nullptr;
15 std::deque<T> elements;
16
17 void clock() {
18 if (input.can_read() && elements.size() < size) {
19 auto x = input.read();
20 elements.emplace_back(std::move(x));
21 }
22 if (output->can_write() && !elements.empty()) {
23 auto &x = elements.front();
24 output->write(std::move(x));
25 elements.pop_front();
26 }
27 }
28 };
29}