blob: 3eb07482f8fc94f7e3f7819423e6c22c12eee89f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#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, LINE_SIZE>>;
this->data->resize(lines);
this->delay = delay;
this->lower = nullptr;
this->servicing = IDLE;
}
Dram::~Dram() { delete this->data; }
Response *Dram::write(Accessor accessor, signed int data, int address)
{
struct Response *r = new Response();
r->status = WAIT;
if (accessor == SIDE) {
this->do_write(data, address);
r->status = OK;
} else {
/* Do this first--then process the first cycle immediately. */
if (this->servicing == IDLE) {
this->servicing = accessor;
this->wait_time = delay;
}
if (this->servicing == accessor) {
if (this->wait_time == 0) {
this->do_write(data, address);
r->status = OK;
} else {
--this->wait_time;
}
}
}
return r;
}
Response *Dram::read(Accessor accessor, int address) { return nullptr; }
|