summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-11 19:02:55 -0400
committerbd <bdunahu@operationnull.com>2025-03-11 19:02:55 -0400
commitfb7735049f571ac45a193481e962f497b4759fa4 (patch)
tree8721f192b627001a3d47af2157ba14b97c52d645 /src
parentdf803d2ccc6a3e1e112cc88feb6c8b84743073b6 (diff)
fix lots of bugs
Diffstat (limited to 'src')
-rw-r--r--src/storage/cache.cc10
-rw-r--r--src/utils/utils.cc7
2 files changed, 9 insertions, 8 deletions
diff --git a/src/storage/cache.cc b/src/storage/cache.cc
index 14a6e61..ea90f50 100644
--- a/src/storage/cache.cc
+++ b/src/storage/cache.cc
@@ -138,6 +138,7 @@ void Cache::fetch_resource(int expected)
(meta->at(0) << (L1_CACHE_LINE_SPEC + LINE_SPEC))));
if (r == OK) {
meta->at(1) = -1;
+ r = WAIT;
}
} else {
r = this->lower->read_line(L1CACHE, expected, actual);
@@ -165,11 +166,12 @@ std::ostream &operator<<(std::ostream &os, const Cache &c)
std::vector<std::array<signed int, LINE_SIZE>> data =
c.view(0, L1_CACHE_LINES);
std::array<std::array<int, 2>, L1_CACHE_LINES> meta = c.get_meta();
+ std::cout << "FOO " << meta.at(31)[0];
os << " " << std::setfill(' ') << std::setw(L1_CACHE_LINE_SPEC + 2) << "INDEX"
<< " | " << std::setfill(' ') << std::setw((8 + 3) * 4 - 1) << "DATA"
<< " | " << std::setfill(' ')
- << std::setw(MEM_LINE_SPEC - LINE_SPEC - L1_CACHE_LINE_SPEC + 2) << "TAG"
+ << std::setw(MEM_LINE_SPEC - L1_CACHE_LINE_SPEC + 2) << "TAG"
<< " | D" << std::endl;
for (int i = 0; i < L1_CACHE_LINES; ++i) {
os << " 0b" << std::setw(L1_CACHE_LINE_SPEC) << std::bitset<L1_CACHE_LINE_SPEC>(i)
@@ -178,12 +180,12 @@ std::ostream &operator<<(std::ostream &os, const Cache &c)
os << "0x" << std::setfill('0') << std::setw(8) << std::hex
<< data.at(i).at(j) << " ";
}
- os << "| 0x" << std::setfill(' ');
+ os << "| 0b" << std::setfill(' ');
if (meta.at(i)[0] < 0)
- os << "?";
+ os << std::setfill('?') << std::setw(MEM_LINE_SPEC - L1_CACHE_LINE_SPEC) << "";
else
- os << std::bitset<MEM_LINE_SPEC - LINE_SPEC - L1_CACHE_LINE_SPEC>(meta.at(i)[0]);
+ os << std::bitset<MEM_LINE_SPEC - L1_CACHE_LINE_SPEC>(meta.at(i)[0]);
os << " | " << (int)(meta.at(i)[0] >= 0) << std::endl;
}
diff --git a/src/utils/utils.cc b/src/utils/utils.cc
index 87ce488..ebbc1e9 100644
--- a/src/utils/utils.cc
+++ b/src/utils/utils.cc
@@ -7,8 +7,7 @@
void get_bit_fields(int address, int *tag, int *index, int *offset)
{
*tag = GET_MID_BITS(
- address, LINE_SPEC + L1_CACHE_LINE_SPEC,
- MEM_LINE_SPEC + LINE_SPEC + L1_CACHE_LINE_SPEC);
+ address, L1_CACHE_LINE_SPEC + LINE_SPEC, MEM_WORD_SPEC);
*index = GET_MID_BITS(address, LINE_SPEC, L1_CACHE_LINE_SPEC + LINE_SPEC);
*offset = GET_LS_BITS(address, LINE_SPEC);
}
@@ -31,7 +30,7 @@ const std::string string_format(const char *const zcFormat, ...)
int wrap_address(int address) {
if (address < 0){
- return ((address % MEM_LINES) + MEM_LINES) % MEM_LINES;
+ return ((address % MEM_WORDS) + MEM_WORDS) % MEM_WORDS;
}
- return address % MEM_LINES;
+ return address % MEM_WORDS;
}