From 93b010dbbcdc921bfccae673918eb9fbf354538a Mon Sep 17 00:00:00 2001 From: Siddarth-Suresh <65844402+Siddarth-Suresh@users.noreply.github.com> Date: Tue, 11 Mar 2025 11:18:01 -0400 Subject: support for reading word, writing line to storage, dirty cache eviction, cache load --- inc/cache.h | 3 ++- inc/dram.h | 17 ++++++++++++++--- inc/storage.h | 17 +++++++++++++++-- 3 files changed, 31 insertions(+), 6 deletions(-) (limited to 'inc') 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 data_line, int address) override; Response read( Accessor accessor, int address, std::array &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 &data) override; + Response write_line(Accessor accessor, std::array data_line, int address) override; - void write_line(std::array data_line, int address); + Response read(Accessor accessor, int address, std::array& 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 data_line, int address); + /** + * Helper for `read` a line */ void do_read(std::array &data_line, int address); + void do_read(std::array& 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 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 &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. -- cgit v1.2.3