From db158de830e4fd4ab20ef5d357e24147c7a9281d Mon Sep 17 00:00:00 2001 From: bd Date: Wed, 5 Mar 2025 14:17:45 -0500 Subject: constructors + method declarations for cache, dram, reponse, storage --- inc/storage.h | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'inc/storage.h') diff --git a/inc/storage.h b/inc/storage.h index 8973016..bad9d10 100644 --- a/inc/storage.h +++ b/inc/storage.h @@ -1,15 +1,59 @@ #ifndef STORAGE_H #define STORAGE_H +#include "response.h" #include #include +enum Accessor { + MEMORY, + FETCH, + L1CACHE, +}; + class Storage { public: - int **view(int base) { return nullptr; } - virtual bool store(); + /** + * Write `data` 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 storage level. + */ + 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 + * data being returned. + */ + 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. + * @param The amount of lines to fetch. + * @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> address_space; + protected: + /** + * The data currently stored in this level of storage. + */ + std::vector> *data; + /** + * A pointer to the next lowest level of storage. + * Used in case of cache misses. + */ + Storage *lower; + /** + * The number of clock cycles this level of storage takes to complete + * requests. + */ + int delay; }; #endif /* STORAGE_H_INCLUDED */ -- cgit v1.2.3