diff options
Diffstat (limited to 'inc')
-rw-r--r-- | inc/cache.h | 7 | ||||
-rw-r--r-- | inc/cli.h | 171 | ||||
-rw-r--r-- | inc/definitions.h | 10 | ||||
-rw-r--r-- | inc/storage.h | 9 |
4 files changed, 112 insertions, 85 deletions
diff --git a/inc/cache.h b/inc/cache.h index e8b7030..b7b72cf 100644 --- a/inc/cache.h +++ b/inc/cache.h @@ -25,6 +25,13 @@ class Cache : public Storage int address, std::array<signed int, LINE_SIZE> &data) override; + /** + * Getter for the meta attribute. + * TODO this doesn't seem like good object-oriented practice. + * @return this->meta + */ + std::array<std::array<int, 2>, L1_CACHE_SIZE> *get_meta(); + private: /** * Fetches `address` from a lower level of storage if it is not already @@ -1,95 +1,96 @@ #ifndef CLI_H #define CLI_H -#include <unordered_map> +#include "cache.h" #include <functional> #include <string> +#include <unordered_map> + +class Cli +{ + public: + /** + * Constructor. + * @return A newly allocated CLI object. + */ + Cli(); + ~Cli(); + + /** + * Prints all available commands to the console. + */ + void help(); + + /** + * Loads data from memory from the specified memory address. + * @param memory_address address of the memory where data needs to be loaded + * from + */ + void load(int memory_address); + + /** + * Stores data into memory at the specified address. + * @param memory_address address of the memory where data needs to be stored + * @param data data value to be written to the memory + */ + void store(int memory_address, int data); + + /** + * Resets the memory configuration and cycles to their initial state. + * This function provides a side door reset interface to the memory system, + * allowing the user to reset the memory configuration directly. + */ + void reset(); + + /** + * Updates the memory at the specified address with the given data. + * This function provides a side door modification interface to the memory + * system, allowing the user to modify the memory configuration directly. + * @param memory_address address of the memory to be updated + * @param data data value to be written to the memory + */ + void update(int memory_address, int data); -class Cli { - public: - - Cli(); - - ~Cli(); - - /** - * Prints all available commands to the console. - */ - void help(); - - /** - * Loads data from memory from the specified memory address. - * @param memory_address address of the memory where data needs to be loaded from - * @param pipeline_stage pipeline stage to be served by memory subsystem - */ - void load(int memory_address, int pipeline_stage); - - /** - * Stores data into memory at the specified address. - * @param memory_address address of the memory where data needs to be stored - * @param pipeline_stage pipeline stage to be served by memory subsystem - * @param data data value to be written to the memory - */ - void store(int memory_address, int pipeline_stage, int data); - - /** - * Loads a memory image from a file and configures memory to the image. - * This function provides a side door memory image loading interface to the memory system, - * allowing the user to load a memory image from a file and configure the memory subsystem to the image. - * @param filename name of file containing memory image - */ - void load_memory_image(const std::string& filename); - - /** - * Resets the memory configuration and cycles to their initial state. - * This function provides a side door reset interface to the memory system, - * allowing the user to reset the memory configuration directly. - */ - void reset(); - - /** - * Updates the memory at the specified address with the given data. - * This function provides a side door modification interface to the memory system, - * allowing the user to modify the memory configuration directly. - * @param memory_address address of the memory to be updated - * @param data data value to be written to the memory - */ - void update_memory(int memory_address, int data); - - /** - * Displays the current status of the entire memory subsystem. - * This function provides a side door view into the memory system, - * showing its current state and configuration. - */ - void view_memory(); - - /** - * Displays the data at the specified memory address. - * This function provides a side door view into the memory system, - * showing the data at the specified memory address. - * @param memory_address address of the memory to be viewed - */ - void view_memory_address(int memory_address); - - /** - * Updates the controls using a configuration file. - * This function provides a side door modification interface to the control system, - * allowing the user to update the controls directly. - * @param config_file name of file containing control configuration - */ - void update_controls(const std::string& config_file); + /** + * Advance the clock one cycle, refreshing the storage devices. + */ + void clock(); - /** - * Runs the command line interface - * This function is the main entry point for the command line interface. - */ - void run(); + /** + * Displays `lines` lines of the data in `level`, starting from `base`. + * + * + * This function provides a side door view into the storage system, showing + * its current state and configuration. + * @param level the level specifying the storage device. The first level + * one cache is level zero, with descending levels incrementing by a factor + * of one. + * @param base the first index to be printed + * @param the number of lines to be printed + */ + void view(int level, int base, int lines); - private: + /** + * Runs the command line interface + * This function is the main entry point for the command line interface. + */ + void run(); - /** Map of commands and their corresponding functions. - * This map is used to store the commands and their corresponding functions. - */ - std::unordered_map<std::string, std::function<void(std::vector<std::string>)>> commands; + private: + /** + * Initializes the cache object. + */ + void initialize(); + /** Map of commands and their corresponding functions. + * This map is used to store the commands and their corresponding functions. + */ + std::unordered_map< + std::string, + std::function<void(std::vector<std::string>)>> + commands; + /** + * The cache object to interface with. + */ + Cache *cache; }; -#endif /* CLI_H_INCLUDED */
\ No newline at end of file +#endif /* CLI_H_INCLUDED */ diff --git a/inc/definitions.h b/inc/definitions.h index 877065e..8cafab3 100644 --- a/inc/definitions.h +++ b/inc/definitions.h @@ -31,6 +31,16 @@ #define L1_CACHE_SIZE (int)pow(2, L1_CACHE_SPEC) /** + * The total number of cycles a memory access takes. + */ +#define MEM_DELAY 4 + +/** + * The total number of cycles a level one cache access takes + */ +#define L1_CACHE_DELAY 1 + +/** * Return the N least-significant bits from integer K using a bit mask * @param the integer to be parsed * @param the number of bits to be parsed diff --git a/inc/storage.h b/inc/storage.h index 793b982..0ab16e4 100644 --- a/inc/storage.h +++ b/inc/storage.h @@ -17,6 +17,8 @@ enum Accessor { class Storage { public: + virtual ~Storage() = default; + /** * Write `data` into `address`. * @param the source making the request. @@ -49,6 +51,13 @@ class Storage */ void resolve(); + /** + * 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. |