diff options
Diffstat (limited to 'src/storage')
-rw-r--r-- | src/storage/cache.cc | 3 | ||||
-rw-r--r-- | src/storage/dram.cc | 12 | ||||
-rw-r--r-- | src/storage/storage.cc | 8 |
3 files changed, 17 insertions, 6 deletions
diff --git a/src/storage/cache.cc b/src/storage/cache.cc index a4df820..f4f60ba 100644 --- a/src/storage/cache.cc +++ b/src/storage/cache.cc @@ -1,10 +1,11 @@ #include "cache.h" +#include "definitions.h" #include "response.h" #include <bits/stdc++.h> Cache::Cache(int lines, Storage *lower, int delay) { - this->data = new std::vector<std::array<signed int, 4>>; + this->data = new std::vector<std::array<signed int, LINE_SIZE>>; this->data->resize(lines); this->lower = lower; this->delay = delay; diff --git a/src/storage/dram.cc b/src/storage/dram.cc index 89c7316..845db21 100644 --- a/src/storage/dram.cc +++ b/src/storage/dram.cc @@ -1,10 +1,11 @@ #include "dram.h" +#include "definitions.h" #include "response.h" #include <algorithm> Dram::Dram(int lines, int delay) { - this->data = new std::vector<std::array<signed int, 4>>; + this->data = new std::vector<std::array<signed int, LINE_SIZE>>; this->data->resize(lines); this->delay = delay; this->lower = nullptr; @@ -14,7 +15,14 @@ Dram::~Dram() { delete this->data; } Response *Dram::write(Accessor accessor, signed int data, int address) { - return new Response(); + struct Response *r = new Response(); + int line = address / LINE_SIZE; + int word = address % LINE_SIZE; + + this->data->at(line).at(word) = data; + + r->status = OK; + return r; } Response *Dram::read(Accessor accessor, int address) { return nullptr; } diff --git a/src/storage/storage.cc b/src/storage/storage.cc index 49d8e7e..a9a883a 100644 --- a/src/storage/storage.cc +++ b/src/storage/storage.cc @@ -1,10 +1,12 @@ #include "storage.h" +#include "definitions.h" #include <algorithm> -std::vector<std::array<signed int, 4>> Storage::view(int base, int lines) +std::vector<std::array<signed int, LINE_SIZE>> +Storage::view(int base, int lines) { - base = (base / 4) * 4; - std::vector<std::array<signed int, 4>> ret(lines + 1); + base = (base / LINE_SIZE) * LINE_SIZE; + std::vector<std::array<signed int, LINE_SIZE>> ret(lines + 1); std::copy( this->data->begin() + base, this->data->begin() + base + lines, ret.begin()); |