summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-11 10:50:11 -0400
committerbd <bdunahu@operationnull.com>2025-03-11 10:50:11 -0400
commitacb0bc357a9dfe6d89321d127b72693031435e65 (patch)
tree68ed796714aee612e7e244c2672326e586f2795b /src
parentf34156105801c81677c54d1713104ac3d7c1c112 (diff)
fix namespace issues with match function
Diffstat (limited to 'src')
-rw-r--r--src/cli/cli.cc42
-rw-r--r--src/main.cc3
-rw-r--r--src/storage/cache.cc4
-rw-r--r--src/storage/dram.cc10
4 files changed, 36 insertions, 23 deletions
diff --git a/src/cli/cli.cc b/src/cli/cli.cc
index 033849e..0729e00 100644
--- a/src/cli/cli.cc
+++ b/src/cli/cli.cc
@@ -82,6 +82,9 @@ void Cli::help()
<< std::endl
<< " [s]tore <accessor> <data> <address> - Stores data into memory at "
"specified address. Acessor must be one of: [f]etch, [m]em"
+ << " [p]eek <storage-level> <base> <lines> - side door function that "
+ "peeks the current status of the entire memory subsystem"
+ << std::endl
<< std::endl
<< " [c]ycle - manually advances the clock" << std::endl
<< " [f]orce - advances the clock until one operation reports "
@@ -91,19 +94,30 @@ void Cli::help()
"configuration and "
"cycles"
<< std::endl
- << " [p]eek <storage-level> <base> <lines> - side door function that "
- "peeks the current status of the entire memory subsystem"
- << std::endl
- << " [h]elp - Prints this help text" << std::endl
- << " [q]uit - Quits the program" << std::endl;
+ << " [h]elp - prints this help text" << std::endl
+ << " [q]uit - quits the program" << std::endl;
}
-void Cli::load(Accessor accessor, int address) { ; }
+void Cli::load(Accessor accessor, int address)
+{
+ const auto default_flags = std::cout.flags();
+ 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;
+
+ std::cout.flags(default_flags);
+ std::cout.fill(default_fill);
+}
void Cli::store(Accessor accessor, int data, int address)
{
Response r = this->cache->write(accessor, data, address);
- std::cout << r << " to " << accessor << " storing " << data << '\n';
+ std::cout << r << " to " << accessor << " storing " << data << " in"
+ << address << std::endl;
}
void Cli::clock()
@@ -115,7 +129,7 @@ void Cli::clock()
void Cli::reset()
{
this->initialize();
- std::cout << "Done.\n";
+ std::cout << "Done." << std::endl;
}
void Cli::peek(int level)
@@ -123,7 +137,8 @@ void Cli::peek(int level)
Storage *curr = this->cache;
for (int i = 0; i < level; ++i) {
if (!curr) {
- std::cerr << "Level " << level << " of storage does not exist.\n";
+ std::cerr << "Level " << level << " of storage does not exist."
+ << std::endl;
return;
}
curr = curr->get_lower();
@@ -131,9 +146,9 @@ void Cli::peek(int level)
Cache *c = dynamic_cast<Cache *>(curr);
if (c) {
- std::cout << *c;
+ std::cout << *c << std::endl;
} else {
- std::cout << *dynamic_cast<Dram *>(curr);
+ std::cout << *dynamic_cast<Dram *>(curr) << std::endl;
;
}
}
@@ -141,7 +156,8 @@ void Cli::peek(int level)
void Cli::run()
{
std::cout << "Memory Command Processor Started. Type 'h' for a list of "
- "commands.\n";
+ "commands."
+ << std::endl;
std::string input;
bool run = true;
@@ -198,7 +214,7 @@ void Cli::initialize()
this->cycle = 1;
}
-Accessor match_accessor_or_die(std::string s)
+Accessor Cli::match_accessor_or_die(std::string s)
{
if (tolower(s[0]) == 'f')
return FETCH;
diff --git a/src/main.cc b/src/main.cc
index 1259729..08b38e6 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -53,9 +53,6 @@ static void parseArguments(int argc, char **argv, bool &python)
global_log->log(INFO, "Python will NOT be started!");
python = false;
break;
- case 'v':
- print_version_number();
- exit(EXIT_SUCCESS);
default:
err();
exit(EXIT_FAILURE);
diff --git a/src/storage/cache.cc b/src/storage/cache.cc
index d382c3d..1a8a10b 100644
--- a/src/storage/cache.cc
+++ b/src/storage/cache.cc
@@ -104,7 +104,7 @@ std::ostream &operator<<(std::ostream &os, const Cache &c)
<< " | " << std::setfill(' ') << std::setw((8 + 3) * 4 - 1) << "DATA"
<< " | " << std::setfill(' ')
<< std::setw(MEM_SPEC - LINE_SPEC - L1_CACHE_SPEC + 2) << "TAG"
- << " | D\n";
+ << " | D" << std::endl;
for (int i = 0; i < L1_CACHE_SIZE; ++i) {
os << " 0b" << std::setw(L1_CACHE_SPEC) << std::bitset<L1_CACHE_SPEC>(i)
<< " | ";
@@ -114,7 +114,7 @@ std::ostream &operator<<(std::ostream &os, const Cache &c)
}
os << "| 0x" << std::setfill(' ')
<< std::bitset<MEM_SPEC - LINE_SPEC - L1_CACHE_SPEC>(meta.at(i)[0])
- << " | " << (int)(meta.at(i)[0] >= 0) << '\n';
+ << " | " << (int)(meta.at(i)[0] >= 0) << std::endl;
}
std::cout.flags(default_flags);
diff --git a/src/storage/dram.cc b/src/storage/dram.cc
index 7353bce..e755c2a 100644
--- a/src/storage/dram.cc
+++ b/src/storage/dram.cc
@@ -1,8 +1,8 @@
#include "dram.h"
#include "definitions.h"
#include "response.h"
-#include <bits/stdc++.h>
#include <algorithm>
+#include <bits/stdc++.h>
#include <bitset>
#include <iostream>
#include <iterator>
@@ -80,18 +80,18 @@ 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);
+ std::vector<std::array<signed int, LINE_SIZE>> data = d.view(0, MEM_SIZE);
os << " " << std::setfill(' ') << std::setw(MEM_SPEC + 2) << "INDEX"
- << " | " << std::setfill(' ') << std::setw((8 + 3) * 4 - 1) << "DATA" << '\n';
+ << " | " << std::setfill(' ') << std::setw((8 + 3) * 4 - 1) << "DATA"
+ << std::endl;
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';
+ os << std::endl;
}
std::cout.flags(default_flags);