-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBusPacket.cpp
executable file
·155 lines (142 loc) · 4.42 KB
/
BusPacket.cpp
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/****************************************************************************
* DRAMSim2: A Cycle Accurate DRAM simulator
*
* Copyright (C) 2010 Elliott Cooper-Balis
* Paul Rosenfeld
* Bruce Jacob
* University of Maryland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*****************************************************************************/
//BusPacket.cpp
//
//Class file for bus packet object
//
#include "BusPacket.h"
using namespace DRAMSim;
using namespace std;
#if (USE_SCIC_MEMSYS_QUERY == 1)
BusPacket::BusPacket(BusPacketType packtype, uint64_t physicalAddr, uint col, uint rw, uint r, uint b, void *dat, uint64_t txID, uint64_t timeTracker) :
_timeTracker(timeTracker)
#else
BusPacket::BusPacket(BusPacketType packtype, uint64_t physicalAddr, uint col, uint rw, uint r, uint b, uint64_t txID, void *dat)
#endif
{
physicalAddress = physicalAddr;
busPacketType = packtype;
data = dat;
rank = r;
bank = b;
column = col;
row = rw;
transID = txID;
}
BusPacket::BusPacket() {}
void BusPacket::print(uint64_t currentClockCycle, bool dataStart)
{
if (this == NULL)
{
return;
}
if (VERIFICATION_OUTPUT)
{
switch (busPacketType)
{
case READ:
cmd_verify_out << currentClockCycle << ": read ("<<rank<<","<<bank<<","<<column<<",0);"<<endl;
break;
case READ_P:
cmd_verify_out << currentClockCycle << ": read ("<<rank<<","<<bank<<","<<column<<",1);"<<endl;
break;
case WRITE:
cmd_verify_out << currentClockCycle << ": write ("<<rank<<","<<bank<<","<<column<<",0 , 0, 'h0);"<<endl;
break;
case WRITE_P:
cmd_verify_out << currentClockCycle << ": write ("<<rank<<","<<bank<<","<<column<<",1, 0, 'h0);"<<endl;
break;
case ACTIVATE:
cmd_verify_out << currentClockCycle <<": activate (" << rank << "," << bank << "," << row <<");"<<endl;
break;
case PRECHARGE:
cmd_verify_out << currentClockCycle <<": precharge (" << rank << "," << bank << "," << row <<");"<<endl;
break;
case REFRESH:
cmd_verify_out << currentClockCycle <<": refresh (" << rank << ");"<<endl;
break;
case DATA:
//TODO: data verification?
break;
default:
ERROR("Trying to print unknown kind of bus packet");
exit(-1);
}
}
}
void BusPacket::print()
{
if (this == NULL) //pointer use makes this a necessary precaution
{
return;
}
else
{
switch (busPacketType)
{
case READ:
PRINT("BP [READ] pa[0x"<<hex<<physicalAddress<<dec<<"] r["<<rank<<"] b["<<bank<<"] row["<<row<<"] col["<<column<<"]");
break;
case READ_P:
PRINT("BP [READ_P] pa[0x"<<hex<<physicalAddress<<dec<<"] r["<<rank<<"] b["<<bank<<"] row["<<row<<"] col["<<column<<"]");
break;
case WRITE:
PRINT("BP [WRITE] pa[0x"<<hex<<physicalAddress<<dec<<"] r["<<rank<<"] b["<<bank<<"] row["<<row<<"] col["<<column<<"]");
break;
case WRITE_P:
PRINT("BP [WRITE_P] pa[0x"<<hex<<physicalAddress<<dec<<"] r["<<rank<<"] b["<<bank<<"] row["<<row<<"] col["<<column<<"]");
break;
case ACTIVATE:
PRINT("BP [ACT] pa[0x"<<hex<<physicalAddress<<dec<<"] r["<<rank<<"] b["<<bank<<"] row["<<row<<"] col["<<column<<"]");
break;
case PRECHARGE:
PRINT("BP [PRE] pa[0x"<<hex<<physicalAddress<<dec<<"] r["<<rank<<"] b["<<bank<<"] row["<<row<<"] col["<<column<<"]");
break;
case REFRESH:
PRINT("BP [REF] pa[0x"<<hex<<physicalAddress<<dec<<"] r["<<rank<<"] b["<<bank<<"] row["<<row<<"] col["<<column<<"]");
break;
case DATA:
PRINTN("BP [DATA] pa[0x"<<hex<<physicalAddress<<dec<<"] r["<<rank<<"] b["<<bank<<"] row["<<row<<"] col["<<column<<"] data["<<data<<"]=");
BusPacket::printData(data);
PRINT("");
break;
default:
ERROR("Trying to print unknown kind of bus packet");
exit(-1);
}
}
}
void BusPacket::printData(const void *data)
{
if (data == NULL)
{
PRINTN("NO DATA");
return;
}
PRINTN("'" << hex);
for (int i=0; i < 4; i++)
{
PRINTN(((uint64_t *)data)[i]);
}
PRINTN("'" << dec);
}