forked from bakhshalipour/Bingo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblock.cc
133 lines (122 loc) · 6.21 KB
/
block.cc
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
#include "block.h"
int PACKET_QUEUE::check_queue(PACKET *packet) {
if ((head == tail) && occupancy == 0)
return -1;
if (head < tail) {
for (uint32_t i = head; i < tail; i++) {
if (NAME == "L1D_WQ") {
if (entry[i].full_addr == packet->full_addr && entry[i].cpu == packet->cpu) {
DP(if (warmup_complete[packet->cpu]) {
cout << "[" << NAME << "] " << __func__ << " cpu: " << packet->cpu
<< " instr_id: " << packet->instr_id << " same address: " << hex << packet->address;
cout << " full_addr: " << packet->full_addr << dec << " by instr_id: " << entry[i].instr_id
<< " index: " << i;
cout << " cycle " << packet->event_cycle << "\tpacket->cpu = " << packet->cpu << endl;
});
return i;
}
} else {
if (entry[i].address == packet->address && entry[i].cpu == packet->cpu) {
DP(if (warmup_complete[packet->cpu]) {
cout << "[" << NAME << "] " << __func__ << " cpu: " << packet->cpu
<< " instr_id: " << packet->instr_id << " same address: " << hex << packet->address;
cout << " full_addr: " << packet->full_addr << dec << " by instr_id: " << entry[i].instr_id
<< " index: " << i;
cout << " cycle " << packet->event_cycle << "\tpacket->cpu = " << packet->cpu << endl;
});
return i;
}
}
}
} else {
for (uint32_t i = head; i < SIZE; i++) {
if (NAME == "L1D_WQ") {
if (entry[i].full_addr == packet->full_addr && entry[i].cpu == packet->cpu) {
DP(if (warmup_complete[packet->cpu]) {
cout << "[" << NAME << "] " << __func__ << " cpu: " << packet->cpu
<< " instr_id: " << packet->instr_id << " same address: " << hex << packet->address;
cout << " full_addr: " << packet->full_addr << dec << " by instr_id: " << entry[i].instr_id
<< " index: " << i;
cout << " cycle " << packet->event_cycle << "\tpacket->cpu = " << packet->cpu << endl;
});
return i;
}
} else {
if (entry[i].address == packet->address && entry[i].cpu == packet->cpu) {
DP(if (warmup_complete[packet->cpu]) {
cout << "[" << NAME << "] " << __func__ << " cpu: " << packet->cpu
<< " instr_id: " << packet->instr_id << " same address: " << hex << packet->address;
cout << " full_addr: " << packet->full_addr << dec << " by instr_id: " << entry[i].instr_id
<< " index: " << i;
cout << " cycle " << packet->event_cycle << "\tpacket->cpu = " << packet->cpu << endl;
});
return i;
}
}
}
for (uint32_t i = 0; i < tail; i++) {
if (NAME == "L1D_WQ") {
if (entry[i].full_addr == packet->full_addr && entry[i].cpu == packet->cpu) {
DP(if (warmup_complete[packet->cpu]) {
cout << "[" << NAME << "] " << __func__ << " cpu: " << packet->cpu
<< " instr_id: " << packet->instr_id << " same address: " << hex << packet->address;
cout << " full_addr: " << packet->full_addr << dec << " by instr_id: " << entry[i].instr_id
<< " index: " << i;
cout << " cycle " << packet->event_cycle << "\tpacket->cpu = " << packet->cpu << endl;
});
return i;
}
} else {
if (entry[i].address == packet->address && entry[i].cpu == packet->cpu) {
DP(if (warmup_complete[packet->cpu]) {
cout << "[" << NAME << "] " << __func__ << " cpu: " << packet->cpu
<< " instr_id: " << packet->instr_id << " same address: " << hex << packet->address;
cout << " full_addr: " << packet->full_addr << dec << " by instr_id: " << entry[i].instr_id
<< " index: " << i;
cout << " cycle " << packet->event_cycle << "\tpacket->cpu = " << packet->cpu << endl;
});
return i;
}
}
}
}
return -1;
}
void PACKET_QUEUE::add_queue(PACKET *packet) {
#ifdef SANITY_CHECK
if (occupancy && (head == tail))
assert(0);
#endif
// add entry
memcpy(&entry[tail], packet, sizeof(PACKET));
DP(if (warmup_complete[packet->cpu]) {
cout << "[" << NAME << "] " << __func__ << " cpu: " << packet->cpu << " instr_id: " << packet->instr_id;
cout << " address: " << hex << entry[tail].address << " full_addr: " << entry[tail].full_addr << dec;
cout << " head: " << head << " tail: " << tail << " occupancy: " << occupancy
<< " event_cycle: " << entry[tail].event_cycle << "\tpacket->cpu = " << packet->cpu << endl;
});
occupancy++;
tail++;
if (tail >= SIZE)
tail = 0;
}
void PACKET_QUEUE::remove_queue(PACKET *packet) {
#ifdef SANITY_CHECK
if ((occupancy == 0) && (head == tail))
assert(0);
#endif
DP(if (warmup_complete[packet->cpu]) {
cout << "[" << NAME << "] " << __func__ << " cpu: " << packet->cpu << " instr_id: " << packet->instr_id;
cout << " address: " << hex << packet->address << " full_addr: " << packet->full_addr << dec
<< " fill_level: " << packet->fill_level;
cout << " head: " << head << " tail: " << tail << " occupancy: " << occupancy
<< " event_cycle: " << packet->event_cycle << "\tpacket->cpu = " << packet->cpu << endl;
});
// reset entry
PACKET empty_packet;
memcpy(packet, &empty_packet, sizeof(PACKET));
occupancy--;
head++;
if (head >= SIZE)
head = 0;
}