-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparameters.hpp
104 lines (91 loc) · 2.52 KB
/
parameters.hpp
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
#include <cmath>
#include "ap_fixed.h"
using namespace std;
//#define EXTRA
#define LEGAL
#define DEBUG
//#define FIRSTDESIGN
#define XLEN 32
#define BYTE 8
#define BIT 1
#define STACKSIZE 100
#define DATAMEMSIZE 100
#define RF_PNTR_WIDTH 5
#define OPCODE_WIDTH 7
#define FUNC3_WIDTH 3
#define FUNC7_WIDTH 7
#define LOG_NO_OF_HART 1
//#define
//#define AUIPC 0010111
#define OP_AL_I 0b0010011
#define OP_AL_R 0b0110011
#define OP_AL_B 0b1100011
#define OP_AL_Load 0b0000011
#define OP_AL_Save 0b0100011
#define OP_AL_U 0b1101111
#define OP_LUI 0b0110111
#define OP_AUIPC 0b0010111
#define OP_JAL 0b1101111
#define OP_JALR 0b1100111
#define FUNC7_0 0
#define FUNC7_32 32
typedef ap_int<XLEN> inst_type ;
typedef ap_uint<RF_PNTR_WIDTH> rf_pntr_type ;
typedef ap_uint<OPCODE_WIDTH> opcode_type ;
typedef ap_uint<FUNC3_WIDTH> func3_type ;
typedef ap_int<FUNC7_WIDTH> func7_type ;
typedef ap_int<XLEN> imm_type ;
typedef ap_uint<XLEN> pc_type ;
typedef ap_int<XLEN> r_type ;
typedef ap_int<XLEN+BIT> r_e_type;
typedef ap_uint<XLEN> uns ;
typedef ap_int<XLEN> data_type ;
typedef ap_uint<BIT> bit_type;
typedef ap_uint<LOG_NO_OF_HART> hart_id;
typedef ap_uint<2> hazard_type;
//typedef ap_uint<
#define ADD 0
#define SUB 0
#define SLL 1
#define SLT 2
#define SLTU 3
#define XOR 4
#define SRL 5
#define SRA 5
#define OR 6
#define AND 7
#define BEQ 0
#define BNE 1
#define BLT 4
#define BGE 5
#define BLTU 6
#define BGEU 7
#define LB 0
#define LH 1
#define LW 2
#define LBU 4
#define LHU 5
#define SB 0
#define SH 1
#define SW 2
typedef struct {
r_type register_ret;
pc_type next_pc;
}hart_return;
pc_type top_module(inst_type inst1, inst_type inst2, pc_type current_pc);
hazard_type data_hazard_detection(inst_type inst1, inst_type inst2);
hart_return hart(inst_type inst, r_type r1, r_type r2, pc_type pc);
r_e_type OP_AL_32I(inst_type opcode, func7_type func7, func3_type func3, r_type op1, r_type op2);
imm_type OP_AL_32B(r_type offset, func3_type func3, r_type op1, r_type op2);
r_type mem(r_type addr, func3_type func3, r_type waddr, bit_type we);
imm_type ALU_SUM(imm_type op1, imm_type op2);
imm_type ALU_NEG(imm_type op1);
imm_type ALU_SLL(imm_type op1, rf_pntr_type op2);
imm_type ALU_SLT(imm_type op1, imm_type op2);
imm_type ALU_SLTU(uns op1, uns op2);
imm_type ALU_XOR(imm_type op1, imm_type op2);
imm_type ALU_SRL(uns op1, rf_pntr_type op2);
imm_type ALU_SRA(imm_type op1, rf_pntr_type op2);
imm_type ALU_OR(imm_type op1, imm_type op2);
imm_type ALU_AND(imm_type op1, imm_type op2);
//r_type OP_AL_32Load(r_type imm, func3_type func3, r_type op1);