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
107
108
109
110
111
112
113
114
115
116
117
118
119
|
`ifndef __COMMON_SVH__
`define __COMMON_SVH__
`define RV_OP_FIELD 6:0
typedef logic [31:0] rv_t;
typedef logic [31:0] xlen_t;
typedef struct packed {
logic [6:0] funct7;
logic [4:0] rs2;
logic [4:0] rs1;
logic [2:0] funct3;
logic [4:0] rd;
logic [6:0] op;
} rtype_t;
typedef struct packed {
logic [11:0] imm;
logic [4:0] rs1;
logic [2:0] funct3;
logic [4:0] rd;
logic [6:0] op;
} itype_t;
typedef struct packed {
logic [6:0] imm1;
logic [4:0] rs2;
logic [4:0] rs1;
logic [2:0] funct3;
logic [4:0] imm0;
logic [6:0] op;
} stype_t;
typedef struct packed {
logic [0:0] imm3;
logic [5:0] imm2;
logic [4:0] rs2;
logic [4:0] rs1;
logic [2:0] funct3;
logic [3:0] imm1;
logic [0:0] imm0;
logic [6:0] op;
} btype_t;
typedef struct packed {
logic [19:0] imm;
logic [4:0] rd;
logic [6:0] op;
} utype_t;
typedef struct packed {
logic [0:0] imm3;
logic [9:0] imm2;
logic [0:0] imm1;
logic [7:0] imm0;
logic [4:0] rd;
logic [6:0] op;
} jtype_t;
typedef enum logic [6:0] {
LOAD = 7'b0000011,
LOAD_FP = 7'b0000111,
MISC_MEM = 7'b0001111,
OP_IMM = 7'b0010011,
AUIPC = 7'b0010111,
OP_IMM_32 = 7'b0011011,
STORE = 7'b0100011,
STORE_FP = 7'b0100111,
AMO = 7'b0101111,
OP = 7'b0110011,
LUI = 7'b0110111,
OP_32 = 7'b0111011,
MADD = 7'b1000011,
MSUB = 7'b1000111,
NMSUB = 7'b1001011,
NMADD = 7'b1001111,
OP_FP = 7'b1010011,
BRANCH = 7'b1100011,
JALR = 7'b1100111,
JAL = 7'b1101111,
SYSTEM = 7'b1110011
} opcode_t;
typedef logic[7:0] port_t;
typedef enum port_t {
NOP = 8'b00000000,
REG = 8'b00100000,
ALU = 8'b01000000
} port_base_t;
typedef struct packed {
port_t src;
port_t dst;
} mov_t;
typedef logic[7:0] op_t;
typedef logic[19:0] imm_t;
typedef struct packed {
mov_t[1:0] in;
mov_t out;
op_t op;
imm_t imm;
} insn_t;
typedef enum op_t {
ALU_ADD,
ALU_SUB,
ALU_ADDI
} alu_op_t;
`define rn(r) (REG + port_t'(r))
`define alu(fu) (ALU + port_t'(fu))
`endif /* __COMMON_SVH__ */
|