summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorSiddarth-Suresh <65844402+Siddarth-Suresh@users.noreply.github.com>2025-03-11 11:18:01 -0400
committerSiddarth-Suresh <65844402+Siddarth-Suresh@users.noreply.github.com>2025-03-11 11:34:13 -0400
commitd7d24031e6df2529ba5c447da0393807be3e3e81 (patch)
treeba813d226ae916abfef2502d3746f8fa3fbc40dc /inc
parent7284cc1391dbb250cd6738a75853be7e3576fa41 (diff)
support for reading word, writing line to storage, dirty cache eviction, cache load
Diffstat (limited to 'inc')
-rw-r--r--inc/cache.h3
-rw-r--r--inc/dram.h17
-rw-r--r--inc/storage.h17
3 files changed, 31 insertions, 6 deletions
diff --git a/inc/cache.h b/inc/cache.h
index 5cdcea4..bc37f54 100644
--- a/inc/cache.h
+++ b/inc/cache.h
@@ -21,11 +21,12 @@ class Cache : public Storage
~Cache();
Response write(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(
Accessor accessor,
int address,
std::array<signed int, LINE_SIZE> &data) override;
- Response read_word(Accessor accessor, int address, signed int &data);
+ 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 d68797f..427500c 100644
--- a/inc/dram.h
+++ b/inc/dram.h
@@ -22,18 +22,29 @@ class Dram : public Storage
Accessor accessor,
int address,
std::array<signed int, LINE_SIZE> &data) override;
+ Response write_line(Accessor accessor, std::array<signed int, LINE_SIZE> data_line, int address) override;
- void write_line(std::array<signed int, LINE_SIZE> data_line, int address);
+ Response read(Accessor accessor, int address, std::array<signed int, LINE_SIZE>& data) 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);
+ 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..fc93d7a 100644
--- a/inc/storage.h
+++ b/inc/storage.h
@@ -14,15 +14,22 @@ 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;
+
+ /**
+ * 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
@@ -32,6 +39,12 @@ class Storage
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.