summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-11 17:24:37 -0400
committerbd <bdunahu@operationnull.com>2025-03-11 17:24:37 -0400
commitd743af4b5df01e3a75725912bee1d00b8fe573dd (patch)
tree4de529c2e8a762503b99db77efc73cdc98104bb0 /inc
parent97173af3651138db50cc42df25b474af2b6ece43 (diff)
parent92e8c2583695a3bf652e0e8dedb79e7a99922f5f (diff)
Merge remote-tracking branch 'origin/master' into bdunahu
Diffstat (limited to 'inc')
-rw-r--r--inc/cache.h13
-rw-r--r--inc/dram.h26
-rw-r--r--inc/storage.h21
-rw-r--r--inc/utils.h2
4 files changed, 50 insertions, 12 deletions
diff --git a/inc/cache.h b/inc/cache.h
index a566f24..31602ca 100644
--- a/inc/cache.h
+++ b/inc/cache.h
@@ -20,11 +20,18 @@ class Cache : public Storage
Cache(Storage *lower, int delay);
~Cache();
- Response write(Accessor accessor, signed int data, int address) override;
- Response read(
+ Response
+ write_word(Accessor accessor, signed int data, int address) override;
+ Response write_line(
+ Accessor accessor,
+ std::array<signed int, LINE_SIZE> data_line,
+ int address) override;
+ Response read_line(
Accessor accessor,
int address,
- std::array<signed int, LINE_SIZE> &data) override;
+ std::array<signed int, LINE_SIZE> &data_line) override;
+ Response
+ read_word(Accessor accessor, int address, signed int &data) override;
/**
* Getter for the meta attribute.
diff --git a/inc/dram.h b/inc/dram.h
index 2d4088f..2771c3e 100644
--- a/inc/dram.h
+++ b/inc/dram.h
@@ -17,21 +17,37 @@ class Dram : public Storage
Dram(int lines, int delay);
~Dram();
- Response write(Accessor accessor, signed int data, int address) override;
- Response read(
+ Response
+ write_word(Accessor accessor, signed int data, int address) override;
+ Response read_line(
Accessor accessor,
int address,
- std::array<signed int, LINE_SIZE> &data) override;
+ std::array<signed int, LINE_SIZE> &data_line) override;
+ Response write_line(
+ Accessor accessor,
+ std::array<signed int, LINE_SIZE> data_line,
+ int address) override;
+ Response
+ read_word(Accessor accessor, int address, signed int &data) override;
private:
/**
- * Helper for `write`.
+ * Helper for `write` a word
*/
void do_write(signed int, int);
/**
- * Helper for `read`.
+ * Helper for writing a line.
+ */
+ void
+ do_write_line(std::array<signed int, LINE_SIZE> data_line, int address);
+ /**
+ * Helper for `read` a line
*/
void do_read(std::array<signed int, LINE_SIZE> &data_line, int address);
+ /**
+ * Helper for reading a word.
+ */
+ void do_read_word(signed int &data, int address);
};
std::ostream &operator<<(std::ostream &os, const Dram &d);
diff --git a/inc/storage.h b/inc/storage.h
index a30e74d..b54a6f7 100644
--- a/inc/storage.h
+++ b/inc/storage.h
@@ -14,24 +14,37 @@ class Storage
virtual ~Storage() = default;
/**
- * Write `data` into `address`.
+ * Write `data` word into `address`.
* @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 request.
*/
- virtual Response write(Accessor accessor, signed int data, int address) = 0;
+ virtual Response write_word(Accessor accessor, signed int data, int address) = 0;
+
+ /**
+ * Write a data line to given address in this level of storage
+ */
+ virtual Response write_line(Accessor accessor, std::array<signed int, LINE_SIZE> data_line, int address) = 0;
+
+
/**
- * Get the data at `address`.
+ * Get the data line at `address`.
* @param the source making the request.
* @param the address being accessed.
* @return a status code reflecting the state of the request, and the
* data being returned.
*/
- virtual Response read(
+ virtual Response read_line(
Accessor accessor,
int address,
std::array<signed int, LINE_SIZE> &data) = 0;
+
+ /**
+ * Read a word from given address in this level of storage
+ */
+ virtual Response read_word(Accessor accessor, int address, signed int &data) = 0;
+
/**
* Sidedoor view of `lines` of memory starting at `base`.
* @param The base line to start getting memory from.
diff --git a/inc/utils.h b/inc/utils.h
index 71e515b..aa8831b 100644
--- a/inc/utils.h
+++ b/inc/utils.h
@@ -20,4 +20,6 @@ void get_bit_fields(int address, int *tag, int *index, int *offset);
*/
const std::string string_format(const char *const zcFormat, ...);
+int wrap_address(int address);
+
#endif /* UTILS_H_INCLUDED */