-
Notifications
You must be signed in to change notification settings - Fork 5
/
instruction.h
66 lines (59 loc) · 1.01 KB
/
instruction.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
#pragma once
typedef struct InstructionAny {
int opcode : 7;
int data : 25;
} InstructionAny;
// U-type
typedef struct InstructionU {
int opcode : 7;
int rd : 5;
int data : 20;
} InstructionU;
//I immediate format
typedef struct InstructionI {
int opcode : 7;
int rd : 5;
int func : 3;
int rs1 : 5;
int imm : 12;
} InstructionI;
//I immediate format
typedef struct InstructionIShift {
int opcode : 7;
int rd : 5;
int func : 3;
int rs1 : 5;
int shamt : 5;
int imm : 7;
} InstructionIShift;
//R-type
typedef struct InstructionR {
int opcode : 7;
int rd : 5;
int funct3 : 3;
int rs1 : 5;
int rs2 : 5;
int funct7 : 3;
} InstructionR;
//S-type
typedef struct InstructionS {
int opcode : 7;
int imm1 : 5;
int funct3 : 3;
int rs1 : 5;
int rs2 : 5;
int imm2 : 7;
} InstructionS;
//B-type
typedef struct InstructionB {
int opcode : 7;
int rd : 5;
int funct3 : 3;
int rs1 : 5;
int rs2 : 5;
int imm : 3;
} InstructionB;
typedef struct StoreOffset {
int nothing : 20;
int offset : 12;
} StoreOffset;