diff options
author | bd <bdunahu@operationnull.com> | 2025-03-11 00:09:12 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-03-11 00:09:12 -0400 |
commit | f34156105801c81677c54d1713104ac3d7c1c112 (patch) | |
tree | a37a0e14ec5cef442d979852876dd307c6d4bf22 /inc | |
parent | 17dfdb2e00b609e3c7e975ce7a7c19da43318b79 (diff) |
cli display clock cycle, parse ';' delimited commands
Diffstat (limited to 'inc')
-rw-r--r-- | inc/cli.h | 28 | ||||
-rw-r--r-- | inc/definitions.h | 6 | ||||
-rw-r--r-- | inc/utils.h | 9 |
3 files changed, 27 insertions, 16 deletions
@@ -25,13 +25,14 @@ class Cli * @param memory_address address of the memory where data needs to be loaded * from */ - void load(int memory_address); + void load(Accessor accessor, int memory_address); /** * Stores data into memory at the specified address. * @param accessor the pipline stage that is making this request * @param data data value to be written to the memory * @param address address of the memory where data needs to be stored + * @return the response from the storage device */ void store(Accessor accessor, int data, int address); @@ -43,15 +44,6 @@ class Cli 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); - - /** * Advance the clock one cycle, refreshing the storage devices. */ void clock(); @@ -79,17 +71,27 @@ class Cli * Initializes the cache object. */ void initialize(); + /** + * Attempts to match string to either fetch or mem, or throws + * std::invalid_argument otherwise. + * @param the string to be converted accessor + * @return the corresponding accessor + * @throws invalid_argument if the string is not fetch or mem + */ + Accessor match_accessor_or_die(std::string s); /** 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>)>> + std::unordered_map<char, std::function<void(std::vector<std::string>)>> commands; /** * The cache object to interface with. */ Cache *cache; + /** + * The current cycle. + */ + int cycle; }; #endif /* CLI_H_INCLUDED */ diff --git a/inc/definitions.h b/inc/definitions.h index 62ed0f6..f015ce9 100644 --- a/inc/definitions.h +++ b/inc/definitions.h @@ -10,7 +10,7 @@ /** * The total number of words in a line */ -#define LINE_SIZE (int)pow(2, 2) +#define LINE_SIZE static_cast<int>(pow(2, 2)) /** * The number of bits to specify a memory line @@ -20,7 +20,7 @@ /** * The total number of words in memory */ -#define MEM_SIZE (int)pow(2, MEM_SPEC) +#define MEM_SIZE static_cast<int>(pow(2, MEM_SPEC)) /** * The number of bits to specify a l1 cache line @@ -29,7 +29,7 @@ /** * The total number of words in l1 cache */ -#define L1_CACHE_SIZE (int)pow(2, L1_CACHE_SPEC) +#define L1_CACHE_SIZE static_cast<int>(pow(2, L1_CACHE_SPEC)) /** * The total number of cycles a memory access takes. diff --git a/inc/utils.h b/inc/utils.h index e258ed8..71e515b 100644 --- a/inc/utils.h +++ b/inc/utils.h @@ -1,5 +1,6 @@ #ifndef UTILS_H #define UTILS_H +#include <string> /** * Parse an address into a tag, index into the cache table, and a line @@ -11,4 +12,12 @@ */ void get_bit_fields(int address, int *tag, int *index, int *offset); +/** + * Formats a string using snprintf. + * @param an object that represents the format string + * @param arguments to be formatted + * @return a string object holding the formatted result + */ +const std::string string_format(const char *const zcFormat, ...); + #endif /* UTILS_H_INCLUDED */ |