summaryrefslogtreecommitdiff
path: root/inc/storage.h
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-08 12:51:01 -0500
committerbd <bdunahu@operationnull.com>2025-03-08 12:51:01 -0500
commit2c424d29fd813b1fbef3b07595713611a1684903 (patch)
treefc5e0f85af22003dce16abd06a131cac7c1d8b5c /inc/storage.h
parentc5f26a0bfdaafc8d49c88d2016df1724b64e5271 (diff)
enforce single unit per clock cycle, order to serve storage requests
Diffstat (limited to 'inc/storage.h')
-rw-r--r--inc/storage.h31
1 files changed, 26 insertions, 5 deletions
diff --git a/inc/storage.h b/inc/storage.h
index a38f17d..95b6749 100644
--- a/inc/storage.h
+++ b/inc/storage.h
@@ -2,18 +2,35 @@
#define STORAGE_H
#include "definitions.h"
#include "response.h"
+#include <algorithm>
#include <array>
-#include <unordered_map>
+#include <deque>
#include <vector>
enum Accessor {
MEM,
FETCH,
L1CACHE,
- IDLE,
SIDE,
};
+/**
+ * Wrapper class for std::deque.
+ *
+ * Implements a deque that does not push duplicate objects.
+ */
+template <typename T> class Deque : public std::deque<T>
+{
+ public:
+ using std::deque<T>::deque;
+
+ void push_back(const T &value)
+ {
+ if (std::find(this->begin(), this->end(), value) == this->end())
+ std::deque<T>::push_back(value);
+ }
+};
+
class Storage
{
public:
@@ -41,6 +58,10 @@ class Storage
* is a word.
*/
std::vector<std::array<signed int, LINE_SIZE>> view(int base, int lines);
+ /**
+ * Advances to the next job if the current job is completed.
+ */
+ void resolve();
protected:
/**
@@ -62,11 +83,11 @@ class Storage
*/
int delay;
/**
- * The accessor currently being serviced.
+ * The accessors currently being serviced, in first come first serve order.
*/
- enum Accessor servicing;
+ Deque<enum Accessor> deque;
/**
- * The number of cycles until the currently request is completed.
+ * The number of cycles until the current request is completed.
*/
int wait_time;
};