OpenCores
URL https://opencores.org/ocsvn/theia_gpu/theia_gpu/trunk

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_2.0/] [rtl/] [aDefinitions.v] - Blame information for rev 213

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 213 diegovalve
/**********************************************************************************
2
Theaia, Ray Cast Programable graphic Processing Unit.
3
Copyright (C) 2009  Diego Valverde (diego.valverde.g@gmail.com)
4
 
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License
7
as published by the Free Software Foundation; either version 2
8
of the License, or (at your option) any later version.
9
 
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
GNU General Public License for more details.
14
 
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
 
19
***********************************************************************************/
20
 
21
 
22
/*******************************************************************************
23
Module Description:
24
 
25
        This module defines constants that are going to be used
26
        all over the code. By now you have may noticed that all
27
        constants are pre-compilation define directives. This is
28
        for simulation perfomance reasons mainly.
29
*******************************************************************************/
30
 
31
`define THEIA_TOP uut
32
`define CP_TOP `THEIA_TOP.CP
33
`define VP_TOP `THEIA_TOP.VPX[  CVPID ].VP
34
 
35
`define CONTROL_PROCESSOR_OP_WIDTH            5
36
`define CONTROL_PROCESSOR_OP_NOP             `CONTROL_PROCESSOR_OP_WIDTH'd0
37
`define CONTROL_PROCESSOR_OP_DELIVER_COMMAND `CONTROL_PROCESSOR_OP_WIDTH'd1
38
`define CONTROL_PROCESSOR_OP_ADD             `CONTROL_PROCESSOR_OP_WIDTH'd2
39
`define CONTROL_PROCESSOR_OP_SUB             `CONTROL_PROCESSOR_OP_WIDTH'd3
40
`define CONTROL_PROCESSOR_OP_AND             `CONTROL_PROCESSOR_OP_WIDTH'd4
41
`define CONTROL_PROCESSOR_OP_OR              `CONTROL_PROCESSOR_OP_WIDTH'd5
42
`define CONTROL_PROCESSOR_OP_BRANCH          `CONTROL_PROCESSOR_OP_WIDTH'd6
43
`define CONTROL_PROCESSOR_OP_BEQ             `CONTROL_PROCESSOR_OP_WIDTH'd7
44
`define CONTROL_PROCESSOR_OP_BNE             `CONTROL_PROCESSOR_OP_WIDTH'd8
45
`define CONTROL_PROCESSOR_OP_BG              `CONTROL_PROCESSOR_OP_WIDTH'd9
46
`define CONTROL_PROCESSOR_OP_BL              `CONTROL_PROCESSOR_OP_WIDTH'd10
47
`define CONTROL_PROCESSOR_OP_BGE             `CONTROL_PROCESSOR_OP_WIDTH'd11
48
`define CONTROL_PROCESSOR_OP_BLE             `CONTROL_PROCESSOR_OP_WIDTH'd12
49
`define CONTROL_PROCESSOR_ASSIGN             `CONTROL_PROCESSOR_OP_WIDTH'd13
50
`define CONTROL_PROCESSOR_OP_COPYBLOCK       `CONTROL_PROCESSOR_OP_WIDTH'd14
51
`define CONTROL_PROCESSOR_OP_EXIT            `CONTROL_PROCESSOR_OP_WIDTH'd15
52
`define CONTROL_PROCESSOR_OP_NOT             `CONTROL_PROCESSOR_OP_WIDTH'd16
53
`define CONTROL_PROCESSOR_OP_SHL             `CONTROL_PROCESSOR_OP_WIDTH'd17
54
`define CONTROL_PROCESSOR_OP_SHR             `CONTROL_PROCESSOR_OP_WIDTH'd18
55
 
56
`define CONTROL_PROCESSOR_REG_STATUS         `CONTROL_PROCESSOR_OP_WIDTH'd2
57
`define CONTROL_PROCESSOR_REG_BLOCK_DST      `CONTROL_PROCESSOR_OP_WIDTH'd3
58
 
59
 
60
`define VPID_WIDTH                    7
61
`define VP_COMMAND_START_MAIN_THREAD  0
62
`define VP_COMMAND_STOP_MAIN_THREAD   1
63
 
64
//`define VERILATOR 1
65
//`define CONTROL_BUS_WIDTH                     32
66
`define CBC_BUS_WIDTH                     32
67
`define CP_MSG_ARGS_RNG                   15:0
68
`define CP_MSG_OPERATION_RNG              23:16
69
`define CP_MSG_DST_RNG                    31:24
70
`define CP_MSG_BCAST                      31
71
 
72
`define OMEM_SIZE                         250000
73
 
74
`define APR06 1
75
`define MCU_REQUEST_SIZE                      81  //32 + 32 + 8 + 8
76
`define MCU_FIFO_DEPTH                        8
77
`define MCU_COPYMEMBLOCKCMD_DSTOFF_RNG        19:0//23:0
78
`define MCU_COPYMEMBLOCKCMD_BLKLEN_RNG        30:20//31:24
79
`define MCU_COPYMEMBLOCK_TAG_BIT              31
80
`define MCU_COPYMEMBLOCKCMD_SRCOFF_RNG        63:32
81
`define MCU_COPYMEMBLOCKCMD_VPMASK_RNG        79:64
82
//`define MCU_REQUEST_TYPE_BIT                  80           //See if it is CPBLOCKCOPY or VPCOMMAND
83
`define MCU_COPYMEMBLOCKCMD_DSTTYPE_VPCODEMEM 1'b1
84
`define MCU_COPYMEMBLOCKCMD_DSTTYPE_VPDATAMEM 1'b0
85
 
86
`define MCU_TAG_SIZE                          2
87
`define TAG_NULL                              2'b00
88
`define TAG_INSTRUCTION_ADDRESS_TYPE          2'b10
89
`define TAG_DATA_ADDRESS_TYPE                 2'b01
90
 
91
`define MAX_THREADS             2
92
`define MAX_CORES               4               //The number of cores, make sure you update MAX_CORE_BITS!
93
`define MAX_CORE_BITS           2               // 2 ^ MAX_CORE_BITS = MAX_CORES
94
`define MAX_TMEM_BANKS          4               //The number of memory banks for TMEM
95
`define MAX_TMEM_BITS           2               //2 ^ MAX_TMEM_BANKS = MAX_TMEM_BITS
96
`define SELECT_ALL_CORES `MAX_CORES'b1111               //XXX: Change for more cores
97
 
98
//Defnitions for the input file size (avoid nasty warnings about the size of the file being different from the
99
//size of the array which stores the file in verilog
100
`define PARAMS_ARRAY_SIZE 43            //The maximum number of byte in this input file
101
`define VERTEX_ARRAY_SIZE 7000          //The maximum number of byte in this input file
102
`define TEXTURE_BUFFER_SIZE 196608              //The maximum number of byte in this input file
103
//---------------------------------------------------------------------------------
104
//Verilog provides a `default_nettype none compiler directive.  When
105
//this directive is set, implicit data types are disabled, which will make any
106
//undeclared signal name a syntax error.This is very usefull to avoid annoying
107
//automatic 1 bit long wire declaration where you don't want them to be!
108
`default_nettype none
109
 
110
//The clock cycle
111
`define CLOCK_CYCLE  5
112
`define CLOCK_PERIOD 10
113
//---------------------------------------------------------------------------------
114
//Defines the Scale. This very important because it sets the fixed point precision.
115
//The Scale defines the number bits that are used as the decimal part of the number.
116
//The code has been written in such a way that allows you to change the value of the
117
//Scale, so that it is possible to experiment with different scenarios. SCALE can be
118
//no smaller that 1 and no bigger that WIDTH.
119
`define SCALE        17
120
 
121
//The next section defines the length of the registers, buses and other structures, 
122
//do not change this valued unless you really know what you are doing (seriously!)
123
`define WIDTH        32
124
`define WB_WIDTH     32  //width of wish-bone buses             
125
`define LONG_WIDTH   64
126
 
127
`define WB_SIMPLE_READ_CYCLE  0
128
`define WB_SIMPLE_WRITE_CYCLE 1
129
//---------------------------------------------------------------------------------
130
 
131
`define OPERATION_NOP    4'b0000
132
`define OPERATION_ADD    4'b0001
133
`define OPERATION_DIV    4'b0010
134
`define OPERATION_MUL    4'b0011
135
`define OPERATION_SQRT   4'b0100
136
`define OPERATION_LOGIC  4'b0101
137
`define OPERATION_OUT    4'b0110
138
 
139
 
140
`define RS_ADD0                  1      //001
141
`define RS_ADD1                  2  //010
142
`define RS_DIV                   3  //011
143
`define RS_MUL                   4  //100
144
`define RS_SQRT                  5  //101
145
`define RS_LOGIC                 6  //110
146
`define RS_IO                    7  //111
147
//----------------------------------------------------------------
148
//Issue bus packet structure
149
 
150
 
151
`define ISSUE_PACKET_SIZE 237       //The size of the packet
152
`define ISSUE_SRCTAG_SIZE 9
153
 
154
`define ISSUE_RSID_RNG    236:233   //4 bits
155
`define ISSUE_DST_RNG     232:225   //8 bits
156
`define ISSUE_WE_RNG      224:222   //3 bits
157
`define ISSUE_SCALE_OP    221
158
`define ISSUE_SCALER      220
159
`define ISSUE_SCALE0      219
160
`define ISSUE_SCALE1      218
161
`define SCALE_SIZE        4
162
`define ISSUE_SCALE_RNG   221:218    //4 bits
163
`define ISSUE_SRC1RS_RNG  217:214    //4 bits
164
`define ISSUE_SIGN1_RNG   213:211    //3 bits
165
`define ISSUE_SWZZ1_RNG   210:205    //6 bits
166
`define ISSUE_SRC1_DATA_RNG    204:109    //96 bits
167
 
168
`define ISSUE_SRC0RS_RNG  108:105   //4 bits
169
`define ISSUE_SIGN0_RNG   104:102   //3 bits
170
`define ISSUE_SWZZ0_RNG   101:96    //6 bits
171
`define ISSUE_SRC0_DATA_RNG    95:0              //96 bits
172
 
173
`define ISSUE_SRC1_TAG_RNG    213:205
174
`define ISSUE_SRC0_TAG_RNG    104:96
175
`define TAG_SIGNX 8
176
`define TAG_SIGNY 7
177
`define TAG_SIGNZ 6
178
`define TAG_SWLX_RNG 5:4
179
`define TAG_SWLY_RNG 3:2
180
`define TAG_SWLZ_RNG 1:0
181
//----------------------------------------------------------------
182
`define MOD_ISSUE_PACKET_SIZE     219
183
`define MOD_ISSUE_RSID_RNG        218:215
184
`define MOD_ISSUE_DST_RNG         214:207
185
`define MOD_ISSUE_WE_RNG          206:204
186
`define MOD_ISSUE_SCALE_RNG       203:200
187
`define MOD_ISSUE_SRC1RS_RNG      199:196
188
`define MOD_ISSUE_SRC1_DATA_RNG   195:100
189
`define MOD_ISSUE_SRC0RS_RNG      99:96
190
`define MOD_ISSUE_SRC0_DATA_RNG   95:0
191
 
192
`define MOD_ISSUE_TAG1_RNG        8:0
193
`define MOD_ISSUE_TAG0_RNG        8:0
194
 
195
`define MOD_ISSUE_SRC_SIZE 87//`DATA_ROW_WIDTH-`ISSUE_SRCTAG_SIZE
196
//----------------------------------------------------------------
197
// Commit bus packet structure
198
 
199
`define COMMIT_PACKET_SIZE 111      // The size of the packet
200
`define COMMIT_RSID_RNG    110:107  //4 bits
201
`define COMMIT_WE_RNG           106:104  //3 bits
202
`define COMMIT_WE_X        106
203
`define COMMIT_WE_Y        105
204
`define COMMIT_WE_Z        104
205
`define COMMIT_DST_RNG     103:96       //8 bits
206
`define COMMIT_DATA_RNG    95:0     //95 bits
207
`define COMMIT_X_RNG       95:64                //32 bits
208
`define COMMIT_Y_RNG       63:32                //32 bits
209
`define COMMIT_Z_RNG       31:0          //32 bits
210
 
211
`define COMMIT_SIGN_X      95
212
`define COMMIT_SIGN_Y      63
213
`define COMMIT_SIGN_Z      31
214
//----------------------------------------------------------------
215
`define MOD_COMMIT_PACKET_SIZE 114
216
`define MOD_SCALE_RNG          113:110
217
`define MOD_SIGN_RNG           109:106
218
`define MOD_COMMIT_TAG_RNG     109:100
219
`define MOD_COMMIT_SWZ_RNG     105:100
220
`define MOD_COMMIT_RSID_RNG    99:96
221
`define MOD_COMMIT_DATA_RNG    95:0     //95 bits
222
//----------------------------------------------------------------
223
`define OP_SIZE     16             //Size of the operation part of the instruction
224
`define OP_RNG      63:48          //Range of the operation part of the instruction
225
`define OP_BIT_IMM  15
226
//`define OP_WE_RNG   14:12
227
`define OP_BREAK    11
228
`define OP_CODE_RNG 10:0
229
//----------------------------------------------------------------
230
// Source0 structure
231
`define SRC0_SIZE           17
232
`define SRC0_RNG            16:0
233
`define SRC0_ADDR_SIZE      8
234
`define SRC0_SIGN_RNG       16:14
235
`define SRC0_SWZX_RNG       13:8
236
`define SRC0_ADDR_RNG       7:0
237
//----------------------------------------------------------------
238
// Source1 structure 
239
`define SRC1_SIZE           17
240
`define SRC1_RNG            33:17
241
`define SRC1_ADDR_SIZE      8
242
`define SRC1_SIGN_RNG       16:14
243
`define SRC1_SWZX_RNG       13:8
244
`define SRC1_ADDR_RNG       7:0
245
//----------------------------------------------------------------
246
 
247
`define NUMBER_OF_RSVR_STATIONS 7
248
 
249
//---------------------------------------------------------------
250
//Instruction structure
251
`define INST_IMM_RNG          31:0
252
`define INST_SRC0_ADDR_RNG    7:0
253
`define INST_SRC0_SWZL_RNG    13:8
254
`define INST_SRC0_SWLZ_RNG    9:8
255
`define INST_SRC0_SWLY_RNG    11:10
256
`define INST_SRC0_SWLX_RNG    13:12
257
`define INST_SRC0_SIGN_RNG    16:14
258
`define INST_SRC0_SIGNZ       14
259
`define INST_SRC0_SIGNY       15
260
`define INST_SRC0_SIGNX       16
261
`define INST_SCR1_ADDR_RNG    24:17
262
`define INST_SCR1_SWZL_RNG    30:25
263
`define INST_SRC1_SWLZ_RNG    26:25
264
`define INST_SRC1_SWLY_RNG    28:27
265
`define INST_SRC1_SWLX_RNG    30:29
266
`define INST_SRC1_SIGN_RNG    33:31
267
`define INST_SRC1_SIGNZ       31
268
`define INST_SRC1_SIGNY       32
269
`define INST_SRC1_SIGNX       33
270
`define INST_DST_RNG          41:34
271
`define INST_WE_Z             42
272
`define INST_WE_Y             43
273
`define INST_WE_X             44
274
/*
275
`define INST_RESERVED_RNG     46:42
276
*/
277
 
278
`define INST_SRC0_DISPLACED   45
279
`define INST_SRC1_DISPLACED   46
280
`define INST_DEST_ZERO        47
281
`define INST_ADDRMODE_RNG     47:45
282
`define INST_CODE_RNG         50:48
283
//`define INST_SCOP_RNG         53:51
284
`define INST_RESERVED_RNG     51:53
285
`define INST_BRANCH_OP_RNG    56:54
286
`define INST_BRANCH_BIT       57
287
`define INST_EOF_RNG          58           //End of flow
288
`define INST_SCOP_RNG         62:59
289
`define INST_IMM              63
290
 
291
`define INST_WE_RNG           44:42
292
`define SCALE_SRC1_EN  0
293
`define SCALE_SRC0_EN  1
294
`define SCALE_SRCR_EN  2
295
`define SCALE_OP       3
296
//---------------------------------------------------------------
297
//Compiler has to put the WE.x, WE.y and WE.z in zero (no write)
298
//for the branch instructions
299
`define BRANCH_ALWAYS               3'b000      //JMP
300
`define BRANCH_IF_ZERO              3'b001      //==
301
`define BRANCH_IF_NOT_ZERO          3'b010      //!=
302
`define BRANCH_IF_SIGN              3'b011      //<
303
`define BRANCH_IF_NOT_SIGN          3'b100      //>
304
`define BRANCH_IF_ZERO_OR_SIGN      3'b101              //<=
305
`define BRANCH_IF_ZERO_OR_NOT_SIGN  3'b110      //>=
306
//---------------------------------------------------------------
307
 
308
`define SRC_RET_ADDR_RNG 95:64
309
`define X_RNG 95:64
310
`define Y_RNG 63:32
311
`define Z_RNG 31:0
312
 
313
 
314
`define ALU_BIT_ADD     0 //Bit 2 of operation is div bit
315
`define ALU_BIT_ASSIGN  1 //Bit 2 of operation is div bit
316
`define ALU_BIT_DIV     2 //Bit 2 of operation is div bit
317
`define ALU_BIT_MUL     3
318
 
319
 
320
`define OPERAND_BIT_X 15
321
`define OPERAND_BIT_Y 14
322
`define OPERAND_BIT_Z 13
323
 
324
`define NOP  `INSTRUCTION_OP_LENGTH'b0_000000000000000
325
`define ADD  `INSTRUCTION_OP_LENGTH'b0_000000000000001
326
`define AND  `INSTRUCTION_OP_LENGTH'b0_000000000000010
327
`define DIV  `INSTRUCTION_OP_LENGTH'b0_000000000000100
328
`define MUL  `INSTRUCTION_OP_LENGTH'b0_000000000001000
329
 
330
 
331
 
332
//You can play around with the size of instuctions, but keep
333
//in mind that Bits 3 and 4 of the Operand have a special meaning
334
//that is used for the jump familiy of instructions (see Documentation).
335
//Also the MSB of Operand is used by the decoder to distinguish 
336
//between Type I and Type II instructions.
337
 
338
 
339
`define INSTRUCTION_WIDTH       64
340
 
341
//Defines the Lenght of Memory blocks
342
//`define RESOURCE_VECTOR_SIZE  11
343
`define INSTRUCTION_ADDR_WIDTH 16
344
`define DATA_ROW_WIDTH        96
345
`define DATA_ADDRESS_WIDTH    8//7
346
`define ROM_ADDRESS_WIDTH     16
347
`define ROM_ADDRESS_SEL_MASK  `ROM_ADDRESS_WIDTH'h8000
348
 
349
 
350
`define SPR_CONTROL0 `DATA_ADDRESS_WIDTH'd2
351
`define SPR_CONTROL1 `DATA_ADDRESS_WIDTH'd3
352
`define SPR_TCONTROL0_MT_ENABLED              0
353
`define SPR_TCONTROL0_T0_INST_OFFSET_RNG      16:1
354
 
355
`define C1     `DATA_ADDRESS_WIDTH'd64
356
`define C2     `DATA_ADDRESS_WIDTH'd65
357
`define C3     `DATA_ADDRESS_WIDTH'd66
358
`define C4     `DATA_ADDRESS_WIDTH'd67
359
`define C5     `DATA_ADDRESS_WIDTH'd68
360
`define C6     `DATA_ADDRESS_WIDTH'd69
361
`define C7     `DATA_ADDRESS_WIDTH'd70
362
`define R1              `DATA_ADDRESS_WIDTH'd71
363
`define R2              `DATA_ADDRESS_WIDTH'd72
364
`define R3              `DATA_ADDRESS_WIDTH'd73
365
`define R4              `DATA_ADDRESS_WIDTH'd74
366
`define R5              `DATA_ADDRESS_WIDTH'd75
367
`define R6              `DATA_ADDRESS_WIDTH'd76
368
`define R7              `DATA_ADDRESS_WIDTH'd77
369
`define R8              `DATA_ADDRESS_WIDTH'd78
370
`define R9              `DATA_ADDRESS_WIDTH'd79
371
`define R10             `DATA_ADDRESS_WIDTH'd80
372
`define R11             `DATA_ADDRESS_WIDTH'd81
373
`define R12             `DATA_ADDRESS_WIDTH'd82
374
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.