diff options
author | bd <bdunahu@operationnull.com> | 2025-03-11 17:24:49 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-03-11 17:24:49 -0400 |
commit | 256fd73b42ae7d10fe0190984d032f839a2127bd (patch) | |
tree | 99ffd87c42c7179561877254431cb78fca02a5f3 | |
parent | d743af4b5df01e3a75725912bee1d00b8fe573dd (diff) |
clarify macro names, implement load in CLI, fix many display issues
-rw-r--r-- | src/cli/cli.cc | 8 | ||||
-rw-r--r-- | src/storage/cache.cc | 2 | ||||
-rw-r--r-- | src/utils/utils.cc | 4 | ||||
-rw-r--r-- | tests/utils.cc | 16 |
4 files changed, 15 insertions, 15 deletions
diff --git a/src/cli/cli.cc b/src/cli/cli.cc index d90edef..8dc7e2e 100644 --- a/src/cli/cli.cc +++ b/src/cli/cli.cc @@ -104,10 +104,10 @@ void Cli::load(Accessor accessor, int address) const auto default_fill = std::cout.fill(); signed int data; - // Response r = this->cache->read_word(accessor, address, data); - // std::cout << r << " to " << accessor << " reading " << address << std::endl; - // if (r == OK) - // std::cout << "\tGot:" << std::hex << data; + Response r = this->cache->read_word(accessor, address, data); + std::cout << r << " to " << accessor << " reading " << address << std::endl; + if (r == OK) + std::cout << " Got:" << std::hex << data << std::endl; std::cout.flags(default_flags); std::cout.fill(default_fill); diff --git a/src/storage/cache.cc b/src/storage/cache.cc index a73390b..14a6e61 100644 --- a/src/storage/cache.cc +++ b/src/storage/cache.cc @@ -135,7 +135,7 @@ void Cache::fetch_resource(int expected) r = this->lower->write_line( L1CACHE, actual, ((index << LINE_SPEC) + - (meta->at(0) << (L1_CACHE_SPEC + LINE_SPEC)))); + (meta->at(0) << (L1_CACHE_LINE_SPEC + LINE_SPEC)))); if (r == OK) { meta->at(1) = -1; } diff --git a/src/utils/utils.cc b/src/utils/utils.cc index b5a4d55..87ce488 100644 --- a/src/utils/utils.cc +++ b/src/utils/utils.cc @@ -31,7 +31,7 @@ const std::string string_format(const char *const zcFormat, ...) int wrap_address(int address) { if (address < 0){ - return ((address % MEM_SIZE) + MEM_SIZE) % MEM_SIZE; + return ((address % MEM_LINES) + MEM_LINES) % MEM_LINES; } - return address % MEM_SIZE; + return address % MEM_LINES; } diff --git a/tests/utils.cc b/tests/utils.cc index f0e4c24..900db1a 100644 --- a/tests/utils.cc +++ b/tests/utils.cc @@ -24,21 +24,21 @@ TEST_CASE("Parse arbitrary fields # two", "[cache]") TEST_CASE("wrap address outside upper bound", "[utils]") { - int address = MEM_SIZE + 25; + int address = MEM_LINES + 25; int wrapped = wrap_address(address); REQUIRE(wrapped == 25); } TEST_CASE("wrap address inside upper bound", "[utils]") { - int address = MEM_SIZE - 25; + int address = MEM_LINES - 25; int wrapped = wrap_address(address); - REQUIRE(wrapped == MEM_SIZE - 25); + REQUIRE(wrapped == MEM_LINES - 25); } TEST_CASE("wrap address at upper bound", "[utils]") { - int address = MEM_SIZE; + int address = MEM_LINES; int wrapped = wrap_address(address); REQUIRE(wrapped == 0); } @@ -47,14 +47,14 @@ TEST_CASE("wrap address lower than 0 with magnitude lesser than mem size", "[uti { int address = -10; int wrapped = wrap_address(address); - REQUIRE(wrapped == MEM_SIZE - 10); + REQUIRE(wrapped == MEM_LINES - 10); } TEST_CASE("wrap address lower than 0 but with magnitude greater than mem size", "[utils]") { - int address = -(MEM_SIZE + 10); + int address = -(MEM_LINES + 10); int wrapped = wrap_address(address); - REQUIRE(wrapped == MEM_SIZE - 10); + REQUIRE(wrapped == MEM_LINES - 10); } TEST_CASE("wrap address at 0", "[utils]") @@ -62,4 +62,4 @@ TEST_CASE("wrap address at 0", "[utils]") int address = 0; int wrapped = wrap_address(address); REQUIRE(wrapped == 0); -}
\ No newline at end of file +} |