From 5cf5ebce233cc49cc04ac8c7713e12e87bab7798 Mon Sep 17 00:00:00 2001 From: bd Date: Sun, 9 Mar 2025 18:28:08 -0400 Subject: Move do_write to dram.h, is_blocked flag --- inc/cache.h | 7 +++++++ inc/dram.h | 8 ++++++++ inc/storage.h | 14 +++++++++----- 3 files changed, 24 insertions(+), 5 deletions(-) (limited to 'inc') diff --git a/inc/cache.h b/inc/cache.h index 4e4b48d..a317f5d 100644 --- a/inc/cache.h +++ b/inc/cache.h @@ -27,6 +27,13 @@ class Cache : public Storage std::array &data) override; private: + /** + * Fetches `address` from a lower level of storage if it is not already + * present. If it is not, temporarily sets the is_blocked attribute of this + * cache level to true. + * @param the address that must be present in cache. + */ + void fetch_resource(int address); /** * An array of paired bits. * If the least significant bit of an element is set, the corresponding diff --git a/inc/dram.h b/inc/dram.h index 1061d6b..20221b7 100644 --- a/inc/dram.h +++ b/inc/dram.h @@ -19,7 +19,15 @@ class Dram : public Storage Response read(Accessor accessor, int address, std::array& data) override; private: + /** + * Helper for `write`. + */ + void do_write(signed int, int); + /** + * Helper for `read`. + */ void do_read(std::array& data_line, int address); }; #endif /* DRAM_H_INCLUDED */ + diff --git a/inc/storage.h b/inc/storage.h index 1fb41b0..9707041 100644 --- a/inc/storage.h +++ b/inc/storage.h @@ -32,7 +32,10 @@ class Storage * @return a status code reflecting the state of the request, and the * data being returned. */ - virtual Response read(Accessor accessor, int address, std::array& data) = 0; + virtual Response read( + Accessor accessor, + int address, + std::array &data) = 0; /** * Sidedoor view of `lines` of memory starting at `base`. * @param The base line to start getting memory from. @@ -47,10 +50,6 @@ class Storage void resolve(); protected: - /** - * Helper for `write`. - */ - void do_write(signed int, int); /** * The data currently stored in this level of storage. */ @@ -73,6 +72,11 @@ class Storage * The number of cycles until the current request is completed. */ int wait_time; + /** + * A flag indicating whether this level of storage is currently blocked by a + * lower level. + */ + int is_blocked; }; #endif /* STORAGE_H_INCLUDED */ -- cgit v1.2.3