summaryrefslogtreecommitdiff
path: root/inc/storage.h
diff options
context:
space:
mode:
authorSiddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com>2025-03-08 21:07:09 -0500
committerGitHub <noreply@github.com>2025-03-08 21:07:09 -0500
commit212a47482c5c037720aef726fcb2b7bb3a3acd67 (patch)
treee76871ceee74d36a660d5347c694493411426a7b /inc/storage.h
parentf8ed20ddbcb602ca0c5eea57fb78fb42d008f797 (diff)
parent5a24c4b2012cd2d5fe954deb3b973cb6125e860d (diff)
Merge pull request #14 from bdunahu/bdunahuer
Storage.view + Dram.store methods, tests
Diffstat (limited to 'inc/storage.h')
-rw-r--r--inc/storage.h35
1 files changed, 27 insertions, 8 deletions
diff --git a/inc/storage.h b/inc/storage.h
index 1e512e2..4bf4591 100644
--- a/inc/storage.h
+++ b/inc/storage.h
@@ -1,13 +1,17 @@
#ifndef STORAGE_H
#define STORAGE_H
+#include "definitions.h"
#include "response.h"
+#include <algorithm>
#include <array>
#include <vector>
enum Accessor {
- MEMORY,
+ IDLE,
+ MEM,
FETCH,
L1CACHE,
+ SIDE,
};
class Storage
@@ -18,18 +22,17 @@ class Storage
* @param the source making the request.
* @param the data (hexadecimal) to write.
* @param the address to write to.
- * @return a status code reflecting the state of the storage level.
+ * @return a status code reflecting the state of the request.
*/
- virtual Response *
- write(Accessor accessor, signed int data, int address) = 0;
+ virtual Response write(Accessor accessor, signed int data, int address) = 0;
/**
* Get the data at `address`.
* @param the source making the request.
* @param the address being accessed.
- * @return a status code reflecting the state of the storage level, and the
+ * @return a status code reflecting the state of the request, and the
* data being returned.
*/
- virtual Response *read(Accessor accessor, int address) = 0;
+ virtual Response read(Accessor accessor, int address) = 0;
/**
* Sidedoor view of `lines` of memory starting at `base`.
* @param The base line to start getting memory from.
@@ -37,13 +40,21 @@ class Storage
* @return A matrix of data values, where each row is a line and each column
* is a word.
*/
- virtual int **view(int base, int lines) = 0;
+ 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:
/**
+ * Helper for `write`.
+ */
+ void do_write(signed int, int);
+ /**
* The data currently stored in this level of storage.
*/
- std::vector<std::array<unsigned int, 4>> *data;
+ std::vector<std::array<signed int, LINE_SIZE>> *data;
/**
* A pointer to the next lowest level of storage.
* Used in case of cache misses.
@@ -54,6 +65,14 @@ class Storage
* requests.
*/
int delay;
+ /**
+ * The accessor currently being serviced.
+ */
+ enum Accessor requester;
+ /**
+ * The number of cycles until the current request is completed.
+ */
+ int wait_time;
};
#endif /* STORAGE_H_INCLUDED */