-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsim.h
106 lines (80 loc) · 1.6 KB
/
sim.h
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
#ifndef SIM_H
#define SIM_H
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <sys/sysinfo.h>
#include <sched.h>
FILE* hexin;
FILE* svgout;
FILE* resout;
char* svgfile;
int numins;//number of instructions
long long int* ins;// ins as ints
char** ins_string;// ins as bit strings
int reg[35];
char mem[74000005];
int iacc,dacc,numcycles,icache;
int curr,st;
int p11,p12,p21,p22,p3;
int print;
int core_id[7];
struct INST{
int type;
int Rs,Rt,Rd;
int s,t,d;
int Offset;
int invalid;
int stall;
int id;
};
struct INST *decoded;
struct IF{
struct INST Ins;
};
struct ID{
int branch_target;
int vrs,vrt,vrd;
struct INST Ins;
};
struct EX{
int vrs,vrt,vrd;
long long int address;
struct INST Ins;
};
struct MA{
int vrs,vrt,vrd;
struct INST Ins;
};
struct IF inf[2];
struct ID id[2];
struct EX ex[2];
struct MA ma[2];
//nothing for type=0
//type=[1..23]
//char * operaons[24]={"","lw","sw","add","sub","addi","and","or","ori","lui","mult","madd","nor","lb","sb","sllv","sltu","slti","sll","beq","bgez","bgtz","blez","bltz"};
void yyerror(char* );
void print_regdump();
void print_memdump(int addr,int num);
void print_result();
void input_hexin();
void test_hexin();
void test_decode();
char * subst(char *a, int start,int num);
void llinttobinary(long long int a,int num);
int yyparse();
void stalling();
void forwarding();
void step();
void printsvg();
void simulate();
void execute();
void execute2();
int* isbreak;
void Add_Break(int pc);
void Delete_Break(int pc);
int find(int currr);
#endif