-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
56 lines (51 loc) · 1.43 KB
/
Copy pathmain.cpp
File metadata and controls
56 lines (51 loc) · 1.43 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 <iostream>
#include "memory.hpp"
#include "register.hpp"
#include "instruction.hpp"
#include <string>
int main() {
// read to memory
unsigned int address = 0;
std::string input;
while (std::cin >> input) {
if (input[0] == '@') { // update address
input.erase(0,1);
address = std::stoi(input, nullptr, 16);
} else {
if (input[0] == EOF) break;
memory.mem[address] = Byte(std::stoi(input, nullptr, 16));
address++;
}
}
// run
Register.Setpc(Word(0));
while (Register.pc.num >= 0 || id_exe.p || exe_mem.p || mem_wb.p) {
if (WriteBack()) { // continue means stall here
continue;
}
if (MemoryAccess()) {
continue;
}
if (Execute()) {
continue;
}
if (InstructionDecode()) {
continue;
}
if (InstructionFetch()) {
continue;
}
if (if_id.ins.num == 0x0ff00513) {
if_id.ins.num = 0;
Register.Setpc(Word(-1));
}
};
std::cout << (Register.GetReg(10).u_num & 255u) << std::endl;
int count = 0, countCorrect = 0;
for (int i = 0; i < 32; i++) {
count += predictor[i].count;
countCorrect += predictor[i].countCorrect;
}
//std::cout << double(countCorrect) / double(count) << std::endl;
return 0;
}