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
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#ifndef DRAM_H
#define DRAM_H
#include "definitions.h"
#include "storage.h"
#include <ostream>
class Dram : public Storage
{
public:
/**
* Constructor.
* @param The number of `lines` contained in memory. The total number of
* words is this number multiplied by LINE_SIZE.
* @param The number of clock cycles each access takes.
* @return A new memory object.
*/
Dram(int delay);
~Dram();
Response
write_word(Accessor accessor, signed int data, int address) override;
Response read_line(
Accessor accessor,
int address,
std::array<signed int, LINE_SIZE> &data_line) override;
Response write_line(
Accessor accessor,
std::array<signed int, LINE_SIZE> data_line,
int address) override;
Response
read_word(Accessor accessor, int address, signed int &data) override;
private:
/**
* Helper for all access methods.
* Calls `request_handler` when `accessor` is allowed to complete its
* request cycle.
* @param the source making the request
* @param the address to write to
* @param the function to call when an access should be completed
*/
Response process(
Accessor accessor,
int address,
std::function<void(int line, int word)> request_handler);
/**
* Returns OK if `accessor` is allowed to complete its request this cycle.
* Handles wait times, side door, and setting the current accessor this
* storage is serving.
* @param the accessor asking for a resource
* @return whether or not the access can be carried out this function call.
*/
Response is_access_cleared(Accessor accessor);
};
std::ostream &operator<<(std::ostream &os, const Dram &d);
#endif /* DRAM_H_INCLUDED */
|