-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
81 lines (75 loc) · 1.87 KB
/
main.c
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "interface.h"
#include "IF.h"
#include "ID.h"
#include "RN.h"
#include "IS.h"
#include "EX.h"
#include "CMT.h"
#include "fakeCMT.h"
#include "ram.h"
#include "diff.h"
extern struct if_to_id if_to_id_sig[2];
extern struct id_to_if id_to_if_sig[2];
extern struct id_to_rn id_to_rn_sig[2];
extern struct rn_to_id rn_to_id_sig[2];
extern struct rn_to_is rn_to_is_sig[2];
extern struct is_to_rn is_to_rn_sig[2];
extern struct is_to_ex is_to_ex_sig[2];
extern struct ex_to_is ex_to_is_sig[2];
extern struct cmt_wakeup_info cmt_wakeup_sig[2];
extern struct is_to_ex is_to_ex_sig[2];
extern struct ex_to_is ex_to_is_sig[2];
extern struct jmp_redirectInfo jmp_to_is_sig[2];
char ram_file[PATH_LEN] = "./test.bin";
void parse_arg(int argc, char* argv[]) {
if (argc > 1) {
// with actual args
// the first arg must be a mem file
strcpy(ram_file, argv[1]);
}
}
void move_sigs() {
if (jmp_to_is_sig[0].redirect_valid) {
jmp_to_is_sig[1].redirect_valid = false;
}
// move sigs from 1 to 0
if_to_id_sig[0] = if_to_id_sig[1];
id_to_if_sig[0] = id_to_if_sig[1];
id_to_rn_sig[0] = id_to_rn_sig[1];
rn_to_id_sig[0] = rn_to_id_sig[1];
rn_to_is_sig[0] = rn_to_is_sig[1];
is_to_rn_sig[0] = is_to_rn_sig[1];
is_to_ex_sig[0] = is_to_ex_sig[1];
ex_to_is_sig[0] = ex_to_is_sig[1];
cmt_wakeup_sig[0] = cmt_wakeup_sig[1];
ex_to_is_sig[0] = ex_to_is_sig[1];
ex_to_cmt_sig[0] = ex_to_cmt_sig[1];
cmt_to_ex_sig[0] = cmt_to_ex_sig[1];
jmp_to_is_sig[0] = jmp_to_is_sig[1];
}
int main(int argc, char* argv[]) {
parse_arg(argc, argv);
init_ram();
#ifdef DIFFTEST
init_diff();
#endif
RN_init();
uint64_t global_cycle = 0;
while (1) {
#ifdef DEBUG
printf("Cycle %llu\n", global_cycle++);
#endif // DEBUG
IF_step();
ID_step();
RN_step();
IS_step();
EX_step();
CMT_step();
move_sigs();
}
return 0;
}