summaryrefslogtreecommitdiff
path: root/src/storage
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-10 22:07:36 -0400
committerbd <bdunahu@operationnull.com>2025-03-10 22:07:36 -0400
commit85078b99e4cf652fcbd5f4d36b061674a2fe8aa6 (patch)
tree1e3097ec91c7fcd7fc9d00f912b46814900201f0 /src/storage
parent25d6d41af95cc2a2db3ba2651e5d784413c7058f (diff)
overload << operator for dram
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/cache.cc1
-rw-r--r--src/storage/dram.cc29
2 files changed, 30 insertions, 0 deletions
diff --git a/src/storage/cache.cc b/src/storage/cache.cc
index d382c3d..6dd0b8a 100644
--- a/src/storage/cache.cc
+++ b/src/storage/cache.cc
@@ -100,6 +100,7 @@ std::ostream &operator<<(std::ostream &os, const Cache &c)
c.view(0, L1_CACHE_SIZE);
std::array<std::array<int, 2>, L1_CACHE_SIZE> meta = c.get_meta();
+ cout << data.capacity();
os << " " << std::setfill(' ') << std::setw(L1_CACHE_SPEC + 2) << "INDEX"
<< " | " << std::setfill(' ') << std::setw((8 + 3) * 4 - 1) << "DATA"
<< " | " << std::setfill(' ')
diff --git a/src/storage/dram.cc b/src/storage/dram.cc
index 441f10b..5c6d719 100644
--- a/src/storage/dram.cc
+++ b/src/storage/dram.cc
@@ -1,7 +1,11 @@
#include "dram.h"
#include "definitions.h"
#include "response.h"
+#include <bits/stdc++.h>
#include <algorithm>
+#include <bitset>
+#include <iostream>
+#include <iterator>
Dram::Dram(int lines, int delay)
{
@@ -70,3 +74,28 @@ Response Dram::read(
return r;
}
+
+std::ostream &operator<<(std::ostream &os, const Dram &d)
+{
+ const auto default_flags = std::cout.flags();
+ const auto default_fill = std::cout.fill();
+
+ std::vector<std::array<signed int, LINE_SIZE>> data =
+ d.view(0, MEM_SIZE);
+
+ cout << data.capacity();
+ os << " " << std::setfill(' ') << std::setw(MEM_SPEC + 2) << "INDEX"
+ << " | " << std::setfill(' ') << std::setw((8 + 3) * 4 - 1) << "DATA" << '\n';
+ for (int i = 0; i < MEM_SIZE; ++i) {
+ os << " 0b" << std::setw(MEM_SPEC) << std::bitset<MEM_SPEC>(i) << " | ";
+ for (int j = 0; j < LINE_SIZE; ++j) {
+ os << "0x" << std::setfill('0') << std::setw(8) << std::hex
+ << data.at(i).at(j) << ' ';
+ }
+ os << '\n';
+ }
+
+ std::cout.flags(default_flags);
+ std::cout.fill(default_fill);
+ return os;
+}