-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdram.h
82 lines (66 loc) · 1.55 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* =====================================================================================
*
* Filename: dram.h
*
* Description: Crude DRAM model
*
* Version: 1.0
* Created: 05/31/2014 08:43:15 PM
* Revision: none
* Compiler: gcc
*
* Author: Rakesh Ramesh (Doctoral Candidate), rakeshr1@stanford.edu
* Execution:
*
* =====================================================================================
*/
#ifndef _DRAM_H_
#define _DRAM_H_
#include <queue>
#include <vector>
#include "request.h"
using namespace std;
enum Status {
IDLE=0,
ACTIVE,
POWER_DOWN
};
struct Parameters {
unsigned long int latency;
unsigned long int power_up_latency;
float dynamic_power;
float static_power;
float power_down_power;
};
class DRAM {
private:
vector< queue<Request*> > command_queue; // Command Q per bank
Status status;
vector< Request * > now_serving;
vector<unsigned long int> req_timer;
unsigned long int power_up_timer;
int next_bank; // Round-robin for banks
unsigned long int clock;
// Config
unsigned int num_banks;
Parameters param;
// Stats
unsigned int num_access;
float average_latency;
unsigned long int num_idle_cycles;
unsigned long int num_power_down_cycles;
public:
DRAM(unsigned int num_banks_, unsigned int type);
~DRAM();
void clockTick();
void addRequest(Request *req);
void powerDown();
void powerUp();
unsigned int backlog(unsigned int bank);
unsigned int totalBacklog();
unsigned int numAccess();
float avgLatency();
float avgEnergy();
};
#endif