-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cc
52 lines (48 loc) · 1.05 KB
/
main.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
#include <iostream>
#include <cstdint>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include "bpu.h"
using namespace std;
using ll = long long;
void start_sim(string filename, ll m, ll n){
BPU bpu = BPU(m,n);
ifstream instream(filename);
string direction;
string pc_s;
while(instream >> pc_s >> direction){
uint32_t pc = strtol(pc_s.c_str(), NULL, 16);
char d = direction[0];
bpu.predict_branch(pc, d);
}
cout<<"OUTPUT"<<endl;
bpu.stat.output_stats();
bpu.dump_contents();
}
int main(int argc, char **argv){
// Output configuration
cout<<"COMMAND"<<endl;
for(int i = 0; i < argc; i++){
cout<<argv[i]<<" ";
}
cout<<endl;
ll m,n;
string filename;
// Check predictor type:
// Bimodal type: argc == 4, gshare: argc == 5
if(argc == 4){
m = stoi(argv[2]);
n = 0;
filename = argv[3];
}else if (argc == 5){
m = stoi(argv[2]);
n = stoi(argv[3]);
filename = argv[4];
}else{
cout<<"Wrong number of arguments specified";
exit(1);
}
start_sim(filename, m, n);
return 0;
}