-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsys_defs.vh
318 lines (281 loc) · 7.68 KB
/
sys_defs.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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/////////////////////////////////////////////////////////////////////////
// //
// Modulename : sys_defs.vh //
// //
// Description : This file has the macro-defines for macros used in //
// the pipeline design. //
// //
/////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////
//
// Mmeory/testbench attribute definitions
//
//////////////////////////////////////////////
`define NUM_MEM_TAGS 15
`define MEM_SIZE_IN_BYTES (64*1024)
`define MEM_64BIT_LINES (`MEM_SIZE_IN_BYTES/8)
// probably not a good idea to change this second one
`define VIRTUAL_CLOCK_PERIOD 30.0 // Clock period from dc_shell
`define VERILOG_CLOCK_PERIOD 10.0 // Clock period from test bench
`define MEM_LATENCY_IN_CYCLES (100.0/`VIRTUAL_CLOCK_PERIOD+0.49999)
// the 0.49999 is to force ceiling(100/period). The default behavior for
// float to integer conversion is rounding to nearest
//////////////////////////////////////////////
//
// Error codes
//
//////////////////////////////////////////////
`define NO_ERROR 4'h0
`define HALTED_ON_MEMORY_ERROR 4'h1
`define HALTED_ON_HALT 4'h2
`define HALTED_ON_ILLEGAL 4'h3
//////////////////////////////////////////////
//
// Datapath control signals
//
//////////////////////////////////////////////
//
// ALU opA input mux selects
//
`define ALU_OPA_IS_REGA 2'h0
`define ALU_OPA_IS_MEM_DISP 2'h1
`define ALU_OPA_IS_NPC 2'h2
`define ALU_OPA_IS_NOT3 2'h3
//
// ALU opB input mux selects
//
`define ALU_OPB_IS_REGB 2'h0
`define ALU_OPB_IS_ALU_IMM 2'h1
`define ALU_OPB_IS_BR_DISP 2'h2
//
// Destination register select
//
`define DEST_IS_REGC 2'h0
`define DEST_IS_REGA 2'h1
`define DEST_NONE 2'h2
//
// ALU function code input
// probably want to leave these alone
//
`define ALU_ADDQ 5'h00
`define ALU_SUBQ 5'h01
`define ALU_AND 5'h02
`define ALU_BIC 5'h03
`define ALU_BIS 5'h04
`define ALU_ORNOT 5'h05
`define ALU_XOR 5'h06
`define ALU_EQV 5'h07
`define ALU_SRL 5'h08
`define ALU_SLL 5'h09
`define ALU_SRA 5'h0a
`define ALU_MULQ 5'h0b
`define ALU_CMPEQ 5'h0c
`define ALU_CMPLT 5'h0d
`define ALU_CMPLE 5'h0e
`define ALU_CMPULT 5'h0f
`define ALU_CMPULE 5'h10
//////////////////////////////////////////////
//
// Assorted things it is not wise to change
//
//////////////////////////////////////////////
//
// actually, you might have to change this if you change VERILOG_CLOCK_PERIOD
//
`define SD #1
// the Alpha register file zero register, any read of this register always
// returns a zero value, and any write to this register is thrown away
//
`define ZERO_REG 5'd31
//
// Memory bus commands control signals
//
`define BUS_NONE 2'h0
`define BUS_LOAD 2'h1
`define BUS_STORE 2'h2
//
// useful boolean single-bit definitions
//
`define FALSE 1'h0
`define TRUE 1'h1
//
// Basic NOOP instruction. Allows pipline registers to clearly be reset with
// an instruction that does nothing instead of Zero which is really a PAL_INST
//
`define NOOP_INST 32'h47ff041f
//
// top level opcodes, used by the IF stage to decode Alpha instructions
//
`define PAL_INST 6'h00
`define LDA_INST 6'h08
`define LDAH_INST 6'h09
`define LDBU_INST 6'h0a
`define LDQ_U_INST 6'h0b
`define LDWU_INST 6'h0c
`define STW_INST 6'h0d
`define STB_INST 6'h0e
`define STQ_U_INST 6'h0f
`define INTA_GRP 6'h10
`define INTL_GRP 6'h11
`define INTS_GRP 6'h12
`define INTM_GRP 6'h13
`define ITFP_GRP 6'h14 // unimplemented
`define FLTV_GRP 6'h15 // unimplemented
`define FLTI_GRP 6'h16 // unimplemented
`define FLTL_GRP 6'h17 // unimplemented
`define MISC_GRP 6'h18
`define JSR_GRP 6'h1a
`define FTPI_GRP 6'h1c
`define LDF_INST 6'h20
`define LDG_INST 6'h21
`define LDS_INST 6'h22
`define LDT_INST 6'h23
`define STF_INST 6'h24
`define STG_INST 6'h25
`define STS_INST 6'h26
`define STT_INST 6'h27
`define LDL_INST 6'h28
`define LDQ_INST 6'h29
`define LDL_L_INST 6'h2a
`define LDQ_L_INST 6'h2b
`define STL_INST 6'h2c
`define STQ_INST 6'h2d
`define STL_C_INST 6'h2e
`define STQ_C_INST 6'h2f
`define BR_INST 6'h30
`define FBEQ_INST 6'h31
`define FBLT_INST 6'h32
`define FBLE_INST 6'h33
`define BSR_INST 6'h34
`define FBNE_INST 6'h35
`define FBGE_INST 6'h36
`define FBGT_INST 6'h37
`define BLBC_INST 6'h38
`define BEQ_INST 6'h39
`define BLT_INST 6'h3a
`define BLE_INST 6'h3b
`define BLBS_INST 6'h3c
`define BNE_INST 6'h3d
`define BGE_INST 6'h3e
`define BGT_INST 6'h3f
// PALcode opcodes
`define PAL_HALT 26'h555
`define PAL_WHAMI 26'h3c
// INTA (10.xx) opcodes
`define ADDL_INST 7'h00
`define S4ADDL_INST 7'h02
`define SUBL_INST 7'h09
`define S4SUBL_INST 7'h0b
`define CMPBGE_INST 7'h0f
`define S8ADDL_INST 7'h12
`define S8SUBL_INST 7'h1b
`define CMPULT_INST 7'h1d
`define ADDQ_INST 7'h20
`define S4ADDQ_INST 7'h22
`define SUBQ_INST 7'h29
`define S4SUBQ_INST 7'h2b
`define CMPEQ_INST 7'h2d
`define S8ADDQ_INST 7'h32
`define S8SUBQ_INST 7'h3b
`define CMPULE_INST 7'h3d
`define ADDLV_INST 7'h40
`define SUBLV_INST 7'h49
`define CMPLT_INST 7'h4d
`define ADDQV_INST 7'h60
`define SUBQV_INST 7'h69
`define CMPLE_INST 7'h6d
// INTL (11.xx) opcodes
`define AND_INST 7'h00
`define BIC_INST 7'h08
`define CMOVLBS_INST 7'h14
`define CMOVLBC_INST 7'h16
`define BIS_INST 7'h20
`define CMOVEQ_INST 7'h24
`define CMOVNE_INST 7'h26
`define ORNOT_INST 7'h28
`define XOR_INST 7'h40
`define CMOVLT_INST 7'h44
`define CMOVGE_INST 7'h46
`define EQV_INST 7'h48
`define AMASK_INST 7'h61
`define CMOVLE_INST 7'h64
`define CMOVGT_INST 7'h66
`define IMPLVER_INST 7'h6c
// INTS (12.xx) opcodes
`define MSKBL_INST 7'h02
`define EXTBL_INST 7'h06
`define INSBL_INST 7'h0b
`define MSKWL_INST 7'h12
`define EXTWL_INST 7'h16
`define INSWL_INST 7'h1b
`define MSKLL_INST 7'h22
`define EXTLL_INST 7'h26
`define INSLL_INST 7'h2b
`define ZAP_INST 7'h30
`define ZAPNOT_INST 7'h31
`define MSKQL_INST 7'h32
`define SRL_INST 7'h34
`define EXTQL_INST 7'h36
`define SLL_INST 7'h39
`define INSQL_INST 7'h3b
`define SRA_INST 7'h3c
`define MSKWH_INST 7'h52
`define INSWH_INST 7'h57
`define EXTWH_INST 7'h5a
`define MSKLH_INST 7'h62
`define INSLH_INST 7'h67
`define EXTLH_INST 7'h6a
`define MSKQH_INST 7'h72
`define INSQH_INST 7'h77
`define EXTQH_INST 7'h7a
// INTM (13.xx) opcodes
`define MULL_INST 7'h00
`define MULQ_INST 7'h20
`define UMULH_INST 7'h30
`define MULLV_INST 7'h40
`define MULQV_INST 7'h60
// MISC (18.xx) opcodes
`define TRAPB_INST 16'h0000
`define EXCB_INST 16'h0400
`define MB_INST 16'h4000
`define WMB_INST 16'h4400
`define FETCH_INST 16'h8000
`define FETCH_M_INST 16'ha000
`define RPCC_INST 16'hc000
`define RC_INST 16'he000
`define ECB_INST 16'he800
`define RS_INST 16'hf000
`define WH64_INST 16'hf800
// JSR (1a.xx) opcodes
`define JMP_INST 2'h0
`define JSR_INST 2'h1
`define RET_INST 2'h2
`define JSR_CO_INST 2'h3
/*****************************************
*
* New defined
*
*****************************************/
`define CDB_WIDTH 6
`define ALU_INV 2'b00 // invalid
`define ALU_SIM 2'b01
`define ALU_MUL 2'b10
`define ALU_MEM 2'b11
`define ZERO_VAL 64'b0 // zero values
/****************************************
*
* LSQ
*
****************************************/
`define LEN_STQ 8
`define BIT_STQ 3
`define LEN_LDQ 4
`define BIT_LDQ 2
`define ZERO_VAL 64'b0 // zero values'
/****************************************
*
* BHT
*
****************************************/
`define NUM_BHT_PATTERN_ENTRIES 64
`define LOG_NUM_BHT_PATTERN_ENTRIES 6