-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparameters.hpp
111 lines (91 loc) · 2.25 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
104
105
106
107
108
109
110
111
#include <cmath>
#include "ap_fixed.h"
using namespace std;
#define XLEN 32
#define STACKSIZE 100
#define RF_PNTR_WIDTH 5
#define OPCODE_WIDTH 7
#define FUNC3_WIDTH 3
#define FUNC7_WIDTH 7
#define CTL_WIDTH 1
#define AUIPC 0b0010111
#define LUI 0b0110111
#define OP_AL_I 0b0010011
#define OP_AL_R 0b0110011
#define OP_AL_B 0b1100011
#define JAL 0b1101111
#define JALR 0b1100111
#define R_0TYPE 0b01100110000000
#define R_32TYPE 0b01100110100000
#define I_0TYPE 0b00100110000000
#define I_32TYPE 0b00100110100000
#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_int<XLEN> pc_type ;
typedef ap_int<XLEN> r_type ;
typedef ap_uint<XLEN> uns ;
typedef ap_int<XLEN> sgn;
typedef ap_uint<CTL_WIDTH> ctl_type ;
typedef ap_int<12> imm_12_type;
typedef ap_int<20> imm_20_type;
typedef struct {
ap_uint<32> result;
pc_type next_pc;
ctl_type valid;
} hart_return_type;
typedef struct {
r_type value;
ctl_type valid;
} arith_type;
typedef struct {
pc_type value;
ctl_type valid;
} jump_type;
typedef struct {
pc_type next_pc;
ctl_type first_valid;
ctl_type second_valid;
ctl_type data_hazard;
} superscalar_type;
typedef struct {
ctl_type write1;
ctl_type write2;
ctl_type pc1;
ctl_type pc2;
ctl_type set_cycle;
} hazard_type;
#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 ADDI 0
#define SLTI 2
#define SLTIU 3
#define XORI 4
#define ORI 6
#define ANDI 7
#define SLLI 1
#define SRI 5
#define BEQ 0
#define BNE 1
#define BLT 4
#define BGE 5
#define BLTU 6
#define BGEU 7
superscalar_type top_module(pc_type pc, inst_type inst1, inst_type inst2);
hart_return_type hart(inst_type inst, pc_type pc, r_type op1, r_type op2);
hart_return_type OP_AL_32I(inst_type inst1, func7_type func7, func3_type func3, r_type op1, r_type op2);
hart_return_type OP_AL_32B(imm_type imm, func3_type func3, r_type op1, r_type op2);
hazard_type hazard_detector(inst_type inst1, inst_type inst2, pc_type next_pc1, ctl_type valid1, ctl_type valid2, ctl_type d_haz);