summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-11 17:33:27 -0400
committerbd <bdunahu@operationnull.com>2025-03-11 17:33:27 -0400
commitdf803d2ccc6a3e1e112cc88feb6c8b84743073b6 (patch)
tree97f5628e53672ca63e1a7fa86972e4b0fb9ed5b0 /src
parent256fd73b42ae7d10fe0190984d032f839a2127bd (diff)
Call memory wrapping functions properly
Diffstat (limited to 'src')
-rw-r--r--src/cli/cli.cc4
-rw-r--r--src/storage/dram.cc5
2 files changed, 8 insertions, 1 deletions
diff --git a/src/cli/cli.cc b/src/cli/cli.cc
index 8dc7e2e..41ac57c 100644
--- a/src/cli/cli.cc
+++ b/src/cli/cli.cc
@@ -100,6 +100,7 @@ void Cli::help()
void Cli::load(Accessor accessor, int address)
{
+ address = wrap_address(address);
const auto default_flags = std::cout.flags();
const auto default_fill = std::cout.fill();
@@ -107,7 +108,7 @@ void Cli::load(Accessor accessor, int address)
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 << " Got: " << std::hex << data << std::endl;
std::cout.flags(default_flags);
std::cout.fill(default_fill);
@@ -115,6 +116,7 @@ void Cli::load(Accessor accessor, int address)
void Cli::store(Accessor accessor, int data, int address)
{
+ address = wrap_address(address);
Response r = this->cache->write_word(accessor, data, address);
std::cout << r << " to " << accessor << " storing " << data << " in "
<< address << std::endl;
diff --git a/src/storage/dram.cc b/src/storage/dram.cc
index c244da5..60b4ae5 100644
--- a/src/storage/dram.cc
+++ b/src/storage/dram.cc
@@ -6,6 +6,7 @@
#include <bitset>
#include <iostream>
#include <iterator>
+#include <utils.h>
Dram::Dram(int lines, int delay)
{
@@ -22,6 +23,7 @@ Dram::~Dram() { delete this->data; }
void Dram::do_write(signed int data, int address)
{
+ address = wrap_address(address);
int line = address / LINE_SIZE;
int word = address % LINE_SIZE;
@@ -31,18 +33,21 @@ void Dram::do_write(signed int data, int address)
void Dram::do_write_line(
std::array<signed int, LINE_SIZE> data_line, int address)
{
+ address = wrap_address(address);
int line = address / LINE_SIZE;
this->data->at(line) = data_line;
}
void Dram::do_read(std::array<signed int, LINE_SIZE> &data_line, int address)
{
+ address = wrap_address(address);
int line = address / LINE_SIZE;
data_line = this->data->at(line);
}
void Dram::do_read_word(signed int &data, int address)
{
+ address = wrap_address(address);
int line = address / LINE_SIZE;
int word = address % LINE_SIZE;
data = this->data->at(line).at(word);