From 1fb7a9bd5eb41e87871bcbb3423caaabdd8ce1d9 Mon Sep 17 00:00:00 2001 From: bd Date: Fri, 11 Apr 2025 21:22:18 -0400 Subject: First part of storage rework (see description) - Removed response enum. - Removed messy ostream override, and cli.cc test class - Removed accessor enum, and instead used unique pointer to identify accessor. - Simplified storage by removing is_waiting variables. - Rewrote DRAM and Cache to use Storage constructor. --- inc/storage.h | 58 +++++++++++++++++++++------------------------------------- 1 file changed, 21 insertions(+), 37 deletions(-) (limited to 'inc/storage.h') diff --git a/inc/storage.h b/inc/storage.h index d6fa094..81194da 100644 --- a/inc/storage.h +++ b/inc/storage.h @@ -1,8 +1,6 @@ #ifndef STORAGE_H #define STORAGE_H -#include "accessor.h" #include "definitions.h" -#include "response.h" #include #include #include @@ -11,6 +9,12 @@ class Storage { public: + /** + * Constructor. + * @param The time an access to this storage device takes. + * @return A newly allocated storage object. + */ + Storage(int delay); virtual ~Storage() = default; /** @@ -18,33 +22,25 @@ 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 request. - */ - virtual Response write_word(Accessor accessor, signed int data, int address) = 0; - - /** - * Write a data line to given address in this level of storage + * @return 1 if the request was completed, 0 otherwise. */ - virtual Response write_line(Accessor accessor, std::array data_line, int address) = 0; + virtual int + write_word(void *id, signed int data, int address) = 0; + virtual int + write_line(void *id, std::array data_line, int address) = 0; - /** * 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. + * @param the data being returned + * @return 1 if the request was completed, 0 otherwise */ - virtual Response read_line( - Accessor accessor, - int address, - std::array &data) = 0; + virtual int + read_line(void *id, int address, std::array &data) = 0; + virtual int + read_word(void *id, int address, signed int &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. @@ -55,13 +51,6 @@ class Storage std::vector> view(int base, int lines) const; - /** - * Getter for lower attribute. - * TODO this doesn't seem like good object-oriented practice. - * @return this->lower - */ - Storage *get_lower(); - protected: /** * The data currently stored in this level of storage. @@ -72,24 +61,19 @@ class Storage * Used in case of cache misses. */ Storage *lower; + /** + * The id currently being serviced. + */ + void *current_request; /** * The number of clock cycles this level of storage takes to complete * requests. */ int delay; - /** - * The accessor currently being serviced. - */ - Accessor requester; /** * The number of cycles until the current request is completed. */ int wait_time; - /** - * A flag indicating whether this level of storage is currently waiting for - * a lower level. - */ - int is_waiting; }; #endif /* STORAGE_H_INCLUDED */ -- cgit v1.2.3