-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDRAM.h
54 lines (53 loc) · 1.39 KB
/
DRAM.h
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
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <map>
#include <deque>
#include <iomanip>
#include <set>
#include <queue>
#include "print.hpp"
using namespace std;
struct DRAM_ins
{
int ins_number; //stores instruction_number
int type; //0 if lw, 1 if sw
int memory_address; //stores load/store address
int value = 0; //stores the value of register in case of sw instruction, as we are already passing it
int fileNumber;
int memInsNumber;
string reg; //stores the register of instruction
};
class DRAM
{
public:
int dramCycle = 0;
int buffer_updates = 0;
DRAM(int, int); //row access, col access
bool checkIfRunning();
void setRunning(int);
void setDRAM(int, int);
void activateRow(int);
void writeBackRow();
void update_DRAM();
void updateMemory();
void sendToWrite_mrm();
void simulateDRAM();
deque<DRAM_ins> writeBack;
int DRAM_PRIORITY_ROW;
int need_to_writeback;
DRAM_ins DRAMcurrentIns;
int DRAM_ROW_BUFFER;
int ROW_ACCESS_DELAY, COL_ACCESS_DELAY;
int clock_cycles = 0;
bool running = false;
int memory[(1 << 20)]; // = {0}; //memory used to store the data
int ROW_BUFFER[1024];
int start_cycle;
int cycle_type;
int writeback_row_number;
int current_state = 0;
vector<int> instructions_per_core;
vector<string> dramPrint;
};