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.cc72
1 files changed, 64 insertions, 8 deletions
diff --git a/src/storage/dram.cc b/src/storage/dram.cc
index 8513147..c244da5 100644
--- a/src/storage/dram.cc
+++ b/src/storage/dram.cc
@@ -20,7 +20,7 @@ Dram::Dram(int lines, int delay)
Dram::~Dram() { delete this->data; }
-void Dram::do_write(signed data, int address)
+void Dram::do_write(signed int data, int address)
{
int line = address / LINE_SIZE;
int word = address % LINE_SIZE;
@@ -28,7 +28,50 @@ void Dram::do_write(signed data, int address)
this->data->at(line).at(word) = data;
}
-Response Dram::write(Accessor accessor, signed int data, int address)
+void Dram::do_write_line(
+ std::array<signed int, LINE_SIZE> data_line, int 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)
+{
+ int line = address / LINE_SIZE;
+ data_line = this->data->at(line);
+}
+
+void Dram::do_read_word(signed int &data, int address)
+{
+ int line = address / LINE_SIZE;
+ int word = address % LINE_SIZE;
+ data = this->data->at(line).at(word);
+}
+
+Response Dram::write_line(
+ Accessor accessor, std::array<signed int, LINE_SIZE> data_line, int address)
+{
+ Response r = WAIT;
+
+ if (accessor == SIDE) {
+ this->do_write_line(data_line, address);
+ r = OK;
+ } else {
+ /* Do this first--then process the first cycle immediately. */
+ if (this->requester == IDLE)
+ this->requester = accessor;
+
+ if (this->requester == accessor) {
+ if (this->wait_time == 0) {
+ this->do_write_line(data_line, address);
+ r = OK;
+ }
+ }
+ }
+ return r;
+}
+
+Response Dram::write_word(Accessor accessor, signed int data, int address)
{
Response r = WAIT;
@@ -51,14 +94,27 @@ Response Dram::write(Accessor accessor, signed int data, int address)
return r;
}
-void Dram::do_read(std::array<signed int, LINE_SIZE> &data_line, int address)
+Response Dram::read_line(
+ Accessor accessor,
+ int address,
+ std::array<signed int, LINE_SIZE> &data_line)
{
- int line = address / LINE_SIZE;
- data_line = this->data->at(line);
+ Response r = WAIT;
+
+ if (this->requester == IDLE)
+ this->requester = accessor;
+
+ if (this->requester == accessor) {
+ if (this->wait_time == 0) {
+ this->do_read(data_line, address);
+ r = OK;
+ }
+ }
+
+ return r;
}
-Response Dram::read(
- Accessor accessor, int address, std::array<signed int, LINE_SIZE> &data)
+Response Dram::read_word(Accessor accessor, int address, signed int &data)
{
Response r = WAIT;
@@ -67,7 +123,7 @@ Response Dram::read(
if (this->requester == accessor) {
if (this->wait_time == 0) {
- this->do_read(data, address);
+ this->do_read_word(data, address);
r = OK;
}
}