From 3322aa0845f7fe9cc98aa4e429bd5ecf72a5c27e Mon Sep 17 00:00:00 2001 From: bd Date: Thu, 6 Mar 2025 00:34:35 -0500 Subject: dram write (no delay, no accessor tracking --- src/storage/cache.cc | 3 ++- src/storage/dram.cc | 12 ++++++++++-- src/storage/storage.cc | 8 +++++--- 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src/storage') 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 Cache::Cache(int lines, Storage *lower, int delay) { - this->data = new std::vector>; + this->data = new std::vector>; 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 Dram::Dram(int lines, int delay) { - this->data = new std::vector>; + this->data = new std::vector>; 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 -std::vector> Storage::view(int base, int lines) +std::vector> +Storage::view(int base, int lines) { - base = (base / 4) * 4; - std::vector> ret(lines + 1); + base = (base / LINE_SIZE) * LINE_SIZE; + std::vector> ret(lines + 1); std::copy( this->data->begin() + base, this->data->begin() + base + lines, ret.begin()); -- cgit v1.2.3