-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReorder_buffer.cpp
More file actions
56 lines (50 loc) · 1.06 KB
/
Copy pathReorder_buffer.cpp
File metadata and controls
56 lines (50 loc) · 1.06 KB
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
#include "Reorder_buffer.h"
Reorder_buffer::Reorder_buffer()
{
schedule = NULL;
reorder = NULL;
busy = NULL;
commited = 1;
back = 1;
for (int i = 1; i < 15; i++) {
table[i].entry = i;
}
}
bool Reorder_buffer::check_update() // 当有指令需要commit的时候,触发更新操作
{
if (table[commited].state == 3) {
return true;
}
else {
return false;
}
}
void Reorder_buffer::issue(Instruction instruction)
{
ROB_data rob_data(instruction, back);
rob_data.busy = 1;
table[back] = rob_data;
/*更新busy和reorder数组*/
busy[rob_data.dest_reg] = 1;
reorder[rob_data.dest_reg] = back;
back++;
}
bool Reorder_buffer::cycle()
{
if (table[commited].state == 3) { // 提交数据
table[commited].state = 4;
table[commited].busy = 0;
busy[table[commited].dest_reg] = 0;
reorder[table[commited].dest_reg] = -1;
schedule->commit(commited);
commited++;
return true;
}
return false;
}
void Reorder_buffer::print(ofstream& outputfile, int num)
{
for (int i = 1; i <= num; i++) {
table[i].print(outputfile);
}
}