-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.h
64 lines (56 loc) · 1.32 KB
/
functions.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
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
// structures
typedef struct _signals{
int aluop;
int mw;
int mr;
int mtr;
int asrc;
int btype;
int rdst;
int rw;
} Signals;
/* these are the decoded fields for a single instruction */
typedef struct _fields{
int rd;
int rs;
int rt;
int imm;
int op;
int func;
} Fields;
/* this is all of the information for a single instruction */
typedef struct _instinfo{
int inst;
Signals signals;
Fields fields;
int pc;
int aluout;
int memout;
int sourcereg;
int targetreg;
int destreg;
int destdata;
char string[30];
int s1data;
int s2data;
int input1;
int input2;
} InstInfo;
// You need to fill in
int load(char *filename);
void fetch(InstInfo *);
void decode(InstInfo *);
void execute(InstInfo *);
void memory(InstInfo *);
void writeback(InstInfo *);
// this function is provided for you
void print(InstInfo *, int);
void printLoad(int);
extern int pc;
extern int instmem[100];
extern int datamem[1024];
extern int regfile[32];
extern void printP2(InstInfo *fetchInst, InstInfo *decodeInst, InstInfo *executeInst, InstInfo *memoryInst, InstInfo *writebackInst, int cycle);
#endif