-
Notifications
You must be signed in to change notification settings - Fork 0
/
define.vh
87 lines (78 loc) · 1.82 KB
/
define.vh
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
`define ENABLE 1'b1
`define DISABLE 1'b0
// 命令形式
`define TYPE_NONE 3'd0
`define TYPE_U 3'd1
`define TYPE_J 3'd2
`define TYPE_I 3'd3
`define TYPE_B 3'd4
`define TYPE_S 3'd5
`define TYPE_R 3'd6
// OPコード
`define LUI 7'b0110111
`define AUIPC 7'b0010111
`define JAL 7'b1101111
`define JALR 7'b1100111
`define BRANCH 7'b1100011
`define LOAD 7'b0000011
`define STORE 7'b0100011
`define OPIMM 7'b0010011
`define OP 7'b0110011
// DSTレジスタの有無
`define REG_NONE 1'd0
`define REG_RD 1'd1
// ALUコード
`define ALU_LUI 6'd0
`define ALU_JAL 6'd1
`define ALU_JALR 6'd2
`define ALU_BEQ 6'd3
`define ALU_BNE 6'd4
`define ALU_BLT 6'd5
`define ALU_BGE 6'd6
`define ALU_BLTU 6'd7
`define ALU_BGEU 6'd8
`define ALU_LB 6'd9
`define ALU_LH 6'd10
`define ALU_LW 6'd11
`define ALU_LBU 6'd12
`define ALU_LHU 6'd13
`define ALU_SB 6'd14
`define ALU_SH 6'd15
`define ALU_SW 6'd16
`define ALU_ADD 6'd17
`define ALU_SUB 6'd18
`define ALU_SLT 6'd19
`define ALU_SLTU 6'd20
`define ALU_XOR 6'd21
`define ALU_OR 6'd22
`define ALU_AND 6'd23
`define ALU_SLL 6'd24
`define ALU_SRL 6'd25
`define ALU_SRA 6'd26
`define ALU_NOP 6'd63
// TODO: implement additional codes
// `define ALU_MUL
// `define ALU_MULH
// `define ALU_MULHSU
// `define ALU_DIV
// `define ALU_DIVU
// `define ALU_REM
// `define ALU_REMU
// ALU入力タイプ
`define OP_TYPE_NONE 2'd0
`define OP_TYPE_REG 2'd1
`define OP_TYPE_IMM 2'd2
`define OP_TYPE_PC 2'd3
// パイプラインステージ
`define IF_STAGE 3'd0
`define RR_STAGE 3'd1
`define EX_STAGE 3'd2
`define MA_STAGE 3'd3
`define RW_STAGE 3'd4
// address for hardware counter
`define HARDWARE_COUNTER_ADDR 32'hffffff00
// address for UART
`define UART_ADDR 32'hf6fff070
// size of the memories
`define MAX_MEM 64000
`define MAX_D_MEM 64000