summaryrefslogtreecommitdiff
path: root/src/storage/dram.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/storage/dram.cc')
-rw-r--r--src/storage/dram.cc5
1 files changed, 5 insertions, 0 deletions
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);