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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [gpu_4_cores/] [rtl/] [Collaterals/] [aDefinitions.v] - Blame information for rev 76

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

Line No. Rev Author Line
1 37 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 know you have may noticed that all
27
        constants are pre-compilation define directives. This is
28
        for simulation perfomance reasons mainly.
29
*******************************************************************************/
30
 
31 76 diegovalve
`define MAX_CORES 4
32 37 diegovalve
//---------------------------------------------------------------------------------
33
//Verilog provides a `default_nettype none compiler directive.  When
34
//this directive is set, implicit data types are disabled, which will make any
35
//undeclared signal name a syntax error.This is very usefull to avoid annoying
36
//automatic 1 bit long wire declaration where you don't want them to be!
37
`default_nettype none
38 60 diegovalve
 
39
//The clock cycle
40
`define CLOCK_CYCLE 5
41
`define CLOCK_PERIOD 10
42 37 diegovalve
//---------------------------------------------------------------------------------
43
//Defines the Scale. This very important because it sets the fixed point precsision.
44
//The Scale defines the number bits that are used as the decimal part of the number.
45
//The code has been written in such a way that allows you to change the value of the
46
//Scale, so that it is possible to experimet with different scenarios. SCALE can be
47
//no smaller that 1 and no bigger that WIDTH.
48
`define SCALE                   17
49
 
50
//The next 2 defines the length of the registers, buses and other structures, 
51
//do not change this valued unless you really know what you are doing (seriously!)
52
`define WIDTH                   32
53
`define WB_WIDTH     32  //width of wish-bone buses             
54
`define LONG_WIDTH      64
55
 
56
`define WB_SIMPLE_READ_CYCLE 0
57
`define WB_SIMPLE_WRITE_CYCLE 1
58
//---------------------------------------------------------------------------------
59
//Next are the constants that define the size of the instructions.
60
//instructions are formed like this:
61
// Tupe I:
62
// Operand                       (of size INSTRUCTION_OP_LENGTH )
63
// DestinationAddr (of size DATA_ADDRESS_WIDTH )
64
// SourceAddrr1  (of size DATA_ADDRESS_WIDTH )
65
// SourceAddrr2  (of size DATA_ADDRESS_WIDTH )  
66
//Type II:
67
// Operand                       (of size INSTRUCTION_OP_LENGTH )
68
// DestinationAddr (of size DATA_ADDRESS_WIDTH )
69
// InmeadiateValue (of size WIDTH = DATA_ADDRESS_WIDTH * 2 )
70
//You can play around with the size of instuctions, but keep
71
//in mind that Bits 3 and 4 of the Operand have a special meaning
72
//that is used for the jump familiy of instructions (see Documentation).
73
//Also the MSB of Operand is used by the decoder to distinguish 
74
//between Type I and Type II instructions.
75
`define INSTRUCTION_WIDTH               64//55
76
`define INSTRUCTION_OP_LENGTH 16//7
77 60 diegovalve
`define INSTRUCTION_IMM_BITPOS 54
78 37 diegovalve
`define INSTRUCTION_IMM_BIT     6               //don't change this!
79
 
80
//Defines the Lenght of Memory blocks
81
`define DATA_ROW_WIDTH  96
82
`define DATA_ADDRESS_WIDTH              16
83
`define ROM_ADDRESS_WIDTH               16
84 60 diegovalve
`define ROM_ADDRESS_SEL_MASK  `ROM_ADDRESS_WIDTH'h8000
85 37 diegovalve
 
86
//---------------------------------------------------------------------------------
87
//Defines the ucode memory entry point for the various ucode routines
88 63 diegovalve
//Please keep this syntax ENTRYPOINT_ADDR_* because the perl script that
89
//parses the user code expects this pattern in order to read in the tokens
90 37 diegovalve
 
91 63 diegovalve
//Internal Entry points (default ROM Address)
92 60 diegovalve
`define ENTRYPOINT_ADRR_INITIAL                                         `ROM_ADDRESS_WIDTH'd0   //0 - This should always be zero
93 76 diegovalve
`define ENTRYPOINT_ADRR_CPPU                                                    `ROM_ADDRESS_WIDTH'd29  //E 
94
`define ENTRYPOINT_ADRR_RGU                                                     `ROM_ADDRESS_WIDTH'd32  //11
95
`define ENTRYPOINT_ADRR_AABBIU                                          `ROM_ADDRESS_WIDTH'd53  //21
96
`define ENTRYPOINT_ADRR_BIU                                                     `ROM_ADDRESS_WIDTH'd141 //79
97
`define ENTRYPOINT_ADRR_PSU                                                     `ROM_ADDRESS_WIDTH'd216 //C4
98
`define ENTRYPOINT_ADRR_PSU2                                       `ROM_ADDRESS_WIDTH'd232   //D4
99
`define ENTRYPOINT_ADRR_TCC                                        `ROM_ADDRESS_WIDTH'd174   //9A
100
`define ENTRYPOINT_ADRR_NPG                                                     `ROM_ADDRESS_WIDTH'd39  //18
101 63 diegovalve
//User Entry points (default ROM Address)
102 76 diegovalve
`define ENTRYPOINT_ADRR_USERCONSTANTS           `ROM_ADDRESS_WIDTH'd241 //DD
103
`define ENTRYPOINT_ADRR_PIXELSHADER             `ROM_ADDRESS_WIDTH'd243 //DF
104 60 diegovalve
 
105 63 diegovalve
//Please keep this syntax ENTRYPOINT_INDEX_* because the perl script that
106
//parses the user code expects this pattern in order to read in the tokens
107
//Internal subroutines
108 60 diegovalve
`define ENTRYPOINT_INDEX_INITIAL                                                `ROM_ADDRESS_WIDTH'h8000
109
`define ENTRYPOINT_INDEX_CPPU                                                   `ROM_ADDRESS_WIDTH'h8001
110
`define ENTRYPOINT_INDEX_RGU                                                    `ROM_ADDRESS_WIDTH'h8002
111
`define ENTRYPOINT_INDEX_AABBIU                                         `ROM_ADDRESS_WIDTH'h8003
112
`define ENTRYPOINT_INDEX_BIU                                                    `ROM_ADDRESS_WIDTH'h8004
113
`define ENTRYPOINT_INDEX_PSU                                                    `ROM_ADDRESS_WIDTH'h8005
114
`define ENTRYPOINT_INDEX_PSU2                                   `ROM_ADDRESS_WIDTH'h8006
115
`define ENTRYPOINT_INDEX_TCC                                    `ROM_ADDRESS_WIDTH'h8007
116 63 diegovalve
`define ENTRYPOINT_INDEX_NPG                                                    `ROM_ADDRESS_WIDTH'h8008
117
//User defined subroutines
118
`define ENTRYPOINT_INDEX_USERCONSTANTS          `ROM_ADDRESS_WIDTH'h8009
119
`define ENTRYPOINT_INDEX_PIXELSHADER            `ROM_ADDRESS_WIDTH'h800A
120 60 diegovalve
 
121 37 diegovalve
`define USER_AABBIU_UCODE_ADDRESS `ROM_ADDRESS_WIDTH'b1000000000000000
122
//---------------------------------------------------------------------------------
123
//This handy little macro allows me to print stuff either to STDOUT or a file.
124
//Notice that the compilation vairable DUMP_CODE must be set if you want to print
125
//to a file. In XILINX right click 'Simulate Beahvioral Model' -> Properties and
126
//under 'Speceify `define macro name and value' type 'DEBUG=1|DUMP_CODE=1'
127
`ifdef DUMP_CODE
128
 
129
        `define LOGME  $fwrite(ucode_file,
130
`else
131
        `define LOGME  $write(
132
`endif
133
//---------------------------------------------------------------------------------     
134
`define RT_TRUE 48'b1
135
`define RT_FALSE 48'b0
136
//---------------------------------------------------------------------------------     
137 70 diegovalve
 
138
`define GENERAL_PURPOSE_REG_ADDR_MASK  `DATA_ADDRESS_WIDTH'h1F
139 37 diegovalve
`define VOID                                                                    `DATA_ADDRESS_WIDTH'd0  //0000
140
//** Control register bits **//
141
`define CR_EN_LIGHTS   0
142
`define CR_EN_TEXTURE  1
143
`define CR_USER_AABBIU 2
144 70 diegovalve
/** Swapping registers **/
145
//** Configuration Registers **//
146
`define CREG_LIGHT_INFO                                                 `DATA_ADDRESS_WIDTH'd0
147
`define CREG_CAMERA_POSITION                                    `DATA_ADDRESS_WIDTH'd1
148
`define CREG_PROJECTION_WINDOW_MIN                      `DATA_ADDRESS_WIDTH'd2
149
`define CREG_PROJECTION_WINDOW_MAX                      `DATA_ADDRESS_WIDTH'd3
150
`define CREG_RESOLUTION                                                 `DATA_ADDRESS_WIDTH'd4
151
`define CREG_TEXTURE_SIZE                                               `DATA_ADDRESS_WIDTH'd5
152
`define CREG_PIXEL_2D_INITIAL_POSITION          `DATA_ADDRESS_WIDTH'd6
153 76 diegovalve
`define CREG_PIXEL_2D_FINAL_POSITION            `DATA_ADDRESS_WIDTH'd7
154
`define CREG_FIRST_LIGTH                `DATA_ADDRESS_WIDTH'd8
155
`define CREG_FIRST_LIGTH_DIFFUSE        `DATA_ADDRESS_WIDTH'd8
156 37 diegovalve
//OK, so from address 0x06 to 0x0F is where the lights are,watch out values are harcoded
157
//for now!! (look in ROM.v for hardcoded values!!!)
158
 
159
 
160 70 diegovalve
//Don't change the order of the registers. CREG_V* and CREG_UV* registers
161
//need to be in that specific order for the triangle fetcher to work 
162
//correctly!
163 37 diegovalve
 
164 70 diegovalve
`define CREG_AABBMIN                                                    `DATA_ADDRESS_WIDTH'd42
165
`define CREG_AABBMAX                                                    `DATA_ADDRESS_WIDTH'd43
166
`define CREG_V0                                                         `DATA_ADDRESS_WIDTH'd44 //002a
167
`define CREG_UV0                                                                `DATA_ADDRESS_WIDTH'd45 //002b  
168
`define CREG_V1                                                         `DATA_ADDRESS_WIDTH'd46 //002c
169
`define CREG_UV1                                                                `DATA_ADDRESS_WIDTH'd47 //002d
170
`define CREG_V2                                                         `DATA_ADDRESS_WIDTH'd48 //002e
171
`define CREG_UV2                                                                `DATA_ADDRESS_WIDTH'd49 //002f
172
`define CREG_TRI_DIFFUSE                                        `DATA_ADDRESS_WIDTH'd50 //0030
173
`define CREG_TEX_COLOR1                                         `DATA_ADDRESS_WIDTH'd53
174
`define CREG_TEX_COLOR2                                         `DATA_ADDRESS_WIDTH'd54
175
`define CREG_TEX_COLOR3                                         `DATA_ADDRESS_WIDTH'd55
176
`define CREG_TEX_COLOR4                                         `DATA_ADDRESS_WIDTH'd56
177
`define CREG_TEX_COLOR5                                         `DATA_ADDRESS_WIDTH'd57
178
`define CREG_TEX_COLOR6                                         `DATA_ADDRESS_WIDTH'd58
179
`define CREG_TEX_COLOR7                                         `DATA_ADDRESS_WIDTH'd59
180 37 diegovalve
 
181
 
182 70 diegovalve
/** Non-Swapping registers **/
183 37 diegovalve
// ** User Registers **//
184
//General Purpose registers, the user may put what ever he/she
185
//wants in here...
186 70 diegovalve
`define C1     `DATA_ADDRESS_WIDTH'd64
187
`define C2     `DATA_ADDRESS_WIDTH'd65
188
`define C3     `DATA_ADDRESS_WIDTH'd66
189
`define C4     `DATA_ADDRESS_WIDTH'd67
190
`define C5     `DATA_ADDRESS_WIDTH'd68
191
`define C6     `DATA_ADDRESS_WIDTH'd69
192
`define C7     `DATA_ADDRESS_WIDTH'd70
193
`define R1              `DATA_ADDRESS_WIDTH'd71
194
`define R2              `DATA_ADDRESS_WIDTH'd72
195
`define R3              `DATA_ADDRESS_WIDTH'd73
196
`define R4              `DATA_ADDRESS_WIDTH'd74
197
`define R5              `DATA_ADDRESS_WIDTH'd75
198
`define R6              `DATA_ADDRESS_WIDTH'd76
199
`define R7              `DATA_ADDRESS_WIDTH'd77
200
`define R8              `DATA_ADDRESS_WIDTH'd78
201
`define R9              `DATA_ADDRESS_WIDTH'd79
202
`define R10             `DATA_ADDRESS_WIDTH'd80
203
`define R11             `DATA_ADDRESS_WIDTH'd81
204
`define R12             `DATA_ADDRESS_WIDTH'd82
205 37 diegovalve
 
206 70 diegovalve
//** Internal Registers **//
207
`define CREG_PROJECTION_WINDOW_SCALE    `DATA_ADDRESS_WIDTH'd83
208
`define CREG_UNORMALIZED_DIRECTION              `DATA_ADDRESS_WIDTH'd84
209
`define CREG_RAY_DIRECTION                                      `DATA_ADDRESS_WIDTH'd85
210
`define CREG_E1_LAST                                                    `DATA_ADDRESS_WIDTH'd86
211
`define CREG_E2_LAST                                                    `DATA_ADDRESS_WIDTH'd87
212
`define CREG_T                                                                  `DATA_ADDRESS_WIDTH'd88
213
`define CREG_P                                                                  `DATA_ADDRESS_WIDTH'd89
214
`define CREG_Q                                                                  `DATA_ADDRESS_WIDTH'd90
215
`define CREG_UV0_LAST                                           `DATA_ADDRESS_WIDTH'd91
216
`define CREG_UV1_LAST                                           `DATA_ADDRESS_WIDTH'd92
217
`define CREG_UV2_LAST                                           `DATA_ADDRESS_WIDTH'd93
218
`define CREG_TRI_DIFFUSE_LAST                           `DATA_ADDRESS_WIDTH'd94
219
`define CREG_LAST_t                                                     `DATA_ADDRESS_WIDTH'd95
220
`define CREG_LAST_u                                                     `DATA_ADDRESS_WIDTH'd96
221
`define CREG_LAST_v                                                     `DATA_ADDRESS_WIDTH'd97
222
`define CREG_COLOR_ACC                                          `DATA_ADDRESS_WIDTH'd98
223
`define CREG_t                                                                  `DATA_ADDRESS_WIDTH'd99
224
`define CREG_E1                                                         `DATA_ADDRESS_WIDTH'd100
225
`define CREG_E2                                                         `DATA_ADDRESS_WIDTH'd101
226
`define CREG_DELTA                                                      `DATA_ADDRESS_WIDTH'd102
227
`define CREG_u                                                                  `DATA_ADDRESS_WIDTH'd103
228
`define CREG_v                                                                  `DATA_ADDRESS_WIDTH'd104
229
`define CREG_H1                               `DATA_ADDRESS_WIDTH'd105
230
`define CREG_H2                             `DATA_ADDRESS_WIDTH'd106
231
`define CREG_H3                                   `DATA_ADDRESS_WIDTH'd107
232 76 diegovalve
`define CREG_PIXEL_PITCH                        `DATA_ADDRESS_WIDTH'd108
233
 
234 70 diegovalve
`define CREG_LAST_COL                                           `DATA_ADDRESS_WIDTH'd109 //the last valid column, simply CREG_RESOLUTIONX - 1
235
`define CREG_TEXTURE_COLOR             `DATA_ADDRESS_WIDTH'd110
236
`define CREG_PIXEL_2D_POSITION                  `DATA_ADDRESS_WIDTH'd111
237
`define CREG_TEXWEIGHT1                                         `DATA_ADDRESS_WIDTH'd112
238
`define CREG_TEXWEIGHT2                                         `DATA_ADDRESS_WIDTH'd113
239
`define CREG_TEXWEIGHT3                                         `DATA_ADDRESS_WIDTH'd114
240
`define CREG_TEXWEIGHT4                                         `DATA_ADDRESS_WIDTH'd115
241 37 diegovalve
 
242 70 diegovalve
//** Ouput registers **//
243 37 diegovalve
 
244 70 diegovalve
`define OREG_PIXEL_COLOR                                        `DATA_ADDRESS_WIDTH'd128
245
`define OREG_TEX_COORD1                                         `DATA_ADDRESS_WIDTH'd129
246
`define OREG_TEX_COORD2                                         `DATA_ADDRESS_WIDTH'd130
247 76 diegovalve
`define OREG_ADDR_O                                     `DATA_ADDRESS_WIDTH'd131
248 37 diegovalve
//-------------------------------------------------------------
249
//*** Instruction Set ***
250
//The order of the instrucitons is important here!. Don't change
251
//it unles you know what you are doing. For example all the 'SET'
252
//family of instructions have the MSB bit in 1. This means that
253
//if you add an instruction and the MSB=1, this instruction will treated
254
//as type II (see manual) meaning the second 32bit argument is expected to be
255
//an inmediate value instead of a register address!
256
//Another example is that in the JUMP family Bits 3 and 4 have a special
257
//meaning: b4b3 = 01 => X jump type, b4b3 = 10 => Y jump type, finally 
258
//b4b3 = 11 means Z jump type.
259
//All this is just to tell you: Don't play with these values!
260
 
261
// *** Type I Instructions (OP DST REG1 REG2) ***
262 60 diegovalve
`define NOP `INSTRUCTION_OP_LENGTH'b0_000000    //0
263 37 diegovalve
`define ADD     `INSTRUCTION_OP_LENGTH'b0_000001        //1
264
`define SUB             `INSTRUCTION_OP_LENGTH'b0_000010        //2
265
`define DIV             `INSTRUCTION_OP_LENGTH'b0_000011        //3
266
`define MUL     `INSTRUCTION_OP_LENGTH'b0_000100        //4
267
`define MAG             `INSTRUCTION_OP_LENGTH'b0_000101        //5
268 60 diegovalve
//`define NOP           `INSTRUCTION_OP_LENGTH'b0_000110        //6
269 37 diegovalve
`define COPY    `INSTRUCTION_OP_LENGTH'b0_000111        //7
270
`define JGX             `INSTRUCTION_OP_LENGTH'b0_001_000       //8
271
`define JLX             `INSTRUCTION_OP_LENGTH'b0_001_001       //9
272 70 diegovalve
`define JEQX    `INSTRUCTION_OP_LENGTH'b0_001_010       //10 - A
273
`define JNEX    `INSTRUCTION_OP_LENGTH'b0_001_011       //11 - B
274
`define JGEX    `INSTRUCTION_OP_LENGTH'b0_001_100       //12 - C
275
`define JLEX    `INSTRUCTION_OP_LENGTH'b0_001_101       //13 - D
276
`define INC             `INSTRUCTION_OP_LENGTH'b0_001_110       //14 - E
277
`define ZERO    `INSTRUCTION_OP_LENGTH'b0_001_111       //15 - F
278 37 diegovalve
`define JGY             `INSTRUCTION_OP_LENGTH'b0_010_000       //16
279
`define JLY             `INSTRUCTION_OP_LENGTH'b0_010_001       //17
280
`define JEQY    `INSTRUCTION_OP_LENGTH'b0_010_010       //18
281
`define JNEY    `INSTRUCTION_OP_LENGTH'b0_010_011       //19
282
`define JGEY    `INSTRUCTION_OP_LENGTH'b0_010_100       //20
283
`define JLEY    `INSTRUCTION_OP_LENGTH'b0_010_101       //21
284
`define CROSS   `INSTRUCTION_OP_LENGTH'b0_010_110       //22
285
`define DOT             `INSTRUCTION_OP_LENGTH'b0_010_111       //23
286
`define JGZ             `INSTRUCTION_OP_LENGTH'b0_011_000       //24
287
`define JLZ             `INSTRUCTION_OP_LENGTH'b0_011_001       //25
288
`define JEQZ    `INSTRUCTION_OP_LENGTH'b0_011_010       //26
289
`define JNEZ    `INSTRUCTION_OP_LENGTH'b0_011_011       //27
290
`define JGEZ    `INSTRUCTION_OP_LENGTH'b0_011_100       //28
291
`define JLEZ    `INSTRUCTION_OP_LENGTH'b0_011_101       //29
292
 
293
//The next instruction is for simulation debug only
294
//not to be synthetized! Pretty much behaves the same
295
//as a NOP, only that prints the register value to
296
//a log file called 'Registers.log'
297
`ifdef DEBUG
298
`define DEBUG_PRINT `INSTRUCTION_OP_LENGTH'b0_011_110   //30
299
`endif
300
 
301
`define MULP `INSTRUCTION_OP_LENGTH'b0_011_111                  //31    R1.z = S1.x * S1.y
302
`define MOD `INSTRUCTION_OP_LENGTH'b0_100_000                   //32    R = MODULO( S1,S2 )
303
`define FRAC `INSTRUCTION_OP_LENGTH'b0_100_001                  //33    R =FractionalPart( S1 )
304
`define INTP `INSTRUCTION_OP_LENGTH'b0_100_010                  //34    R =IntergerPart( S1 )
305
`define NEG  `INSTRUCTION_OP_LENGTH'b0_100_011                  //35    R = -S1
306
`define DEC  `INSTRUCTION_OP_LENGTH'b0_100_100                  //36    R = S1--
307
`define XCHANGEX `INSTRUCTION_OP_LENGTH'b0_100_101              //              R.x = S2.x, R.y = S1.y, R.z = S1.z
308
`define XCHANGEY `INSTRUCTION_OP_LENGTH'b0_100_110              //              R.x = S1.x, R.y = S2.y, R.z = S1.z
309
`define XCHANGEZ `INSTRUCTION_OP_LENGTH'b0_100_111              //              R.x = S1.x, R.y = S1.y, R.z = S2.z
310
`define IMUL     `INSTRUCTION_OP_LENGTH'b0_101_000              //              R = INTEGER( S1 * S2 )
311
`define UNSCALE  `INSTRUCTION_OP_LENGTH'b0_101_001              //              R = S1 >> SCALE
312
`define RESCALE  `INSTRUCTION_OP_LENGTH'b0_101_010              //              R = S1 << SCALE
313
`define INCX     `INSTRUCTION_OP_LENGTH'b0_101_011         //    R.X = S1.X + 1
314
`define INCY     `INSTRUCTION_OP_LENGTH'b0_101_100         //    R.Y = S1.Y + 1
315
`define INCZ     `INSTRUCTION_OP_LENGTH'b0_101_101         //    R.Z = S1.Z + 1
316
 
317
 
318
//*** Type II Instructions (OP DST REG1 IMM) ***
319 60 diegovalve
`define RETURN          `INSTRUCTION_OP_LENGTH'b1_000000 //64  0x40
320
`define SETX                            `INSTRUCTION_OP_LENGTH'b1_000001 //65  0x41
321
`define SETY                            `INSTRUCTION_OP_LENGTH'b1_000010 //66
322
`define SETZ                            `INSTRUCTION_OP_LENGTH'b1_000011 //67
323
`define SWIZZLE3D                       `INSTRUCTION_OP_LENGTH'b1_000100 //68 
324
`define JMP                                     `INSTRUCTION_OP_LENGTH'b1_011000 //56
325
 
326 37 diegovalve
//-------------------------------------------------------------
327
 
328
 
329
`define SWIZZLE_XXX             32'd0
330
`define SWIZZLE_YYY             32'd1
331
`define SWIZZLE_ZZZ             32'd2
332
`define SWIZZLE_XYY             32'd3
333
`define SWIZZLE_XXY             32'd4
334
`define SWIZZLE_XZZ             32'd5
335
`define SWIZZLE_XXZ             32'd6
336
`define SWIZZLE_YXX             32'd7
337
`define SWIZZLE_YYX             32'd8
338
`define SWIZZLE_YZZ             32'd9
339
`define SWIZZLE_YYZ             32'd10
340
`define SWIZZLE_ZXX             32'd11
341
`define SWIZZLE_ZZX             32'd12
342
`define SWIZZLE_ZYY             32'd13
343
`define SWIZZLE_ZZY             32'd14
344
`define SWIZZLE_XZX             32'd15
345
`define SWIZZLE_XYX             32'd16
346
`define SWIZZLE_YXY             32'd17
347
`define SWIZZLE_YZY             32'd18
348
`define SWIZZLE_ZXZ             32'd19
349
`define SWIZZLE_ZYZ             32'd20
350
`define SWIZZLE_YXZ             32'd21
351
 
352
 
353
 
354
 
355 76 diegovalve
//`define REG_BUS_OWNED_BY_BCU   0      //0000
356 37 diegovalve
`define REG_BUS_OWNED_BY_NULL  0 //0010
357
`define REG_BUS_OWNED_BY_GFU     1 //0001
358
`define REG_BUS_OWNED_BY_UCODE 2 //0011
359
 
360
 
361
`define OP_WIDTH                                `INSTRUCTION_OP_LENGTH
362
`define INST_WIDTH                      5
363
 
364
 
365
`define MULTIPLICATION  0
366
`define DIVISION                        1
367
 
368
 
369
`define ENABLE_ALU_AB   3'b001
370
`define ENABLE_ALU_CD   3'b010
371
`define ENABLE_ALU_EF   3'b100
372
`define ALU_CONTROL_IS_NULL     0
373
`define ALU_CONTROL_IS_RGU      1
374
`define ALU_CONTROL_IS_AABBIU 2
375
`define ALU_CONTROL_IS_CPPU     3
376
 
377
`define UCODE_CONTROL_IS_CU             0
378
`define UCODE_CONTROL_IS_IFU            1
379
 
380
 
381
 
382
`define FLOATING_POINT_WIDTH 32
383
`define FIXED_POINT_WIDTH        32//128
384
`define IEEE754_BIAS             127
385
`define NORMAL_EXIT                      0
386
`define DIVISION_BY_ZERO         1
387
`define NULL                                     0
388
`define RAY_TYPE_I              1
389
`define RAY_TYPE_II             2
390
`define RAY_TYPE_III            3
391
 
392
//Scheduler commands
393
`define SCHEDULER_NULL_COMMAND          0
394
`define REG_SELECTOR_WIDTH                              5
395
//Main state machine control values
396
`define READ_CONFIGURATION_DATA                         2
397
`define WRITE_NO_HIT                                                                            20
398
//Control values for BusUnitInterface
399
`define INITIAL_PROTOCOL_STATE                                          0
400
`define GET_NEXT_CONFIGURATION_PACKET                   4
401
`define READ_COMMAND_DATA                                                       5
402
`define WAIT_FOR_CONTROL_UNIT_COMMAND                   6
403
`define READ_COMMAND                                                                    7
404
`define GET_NEXT_DATA_PACKET                                            8
405
`define IDLE                                                                                    9
406
`define READ_CONFIGURATION_DATA_FROM_BUS                10
407
`define READ_TASK_DATA_FROM_BUS                                 12
408
`define WRITE_TASK_RESULTS_TO_BUS                               13
409
`define ACK_LAST_GO_IDLE                                                14
410
`define REQUEST_BUS_FOR_WRITE_OPERATION 23
411
`define WAIT_FOR_BUS_WRITE_PERMISSION           24
412
`define WRITE_DATA_TO_BUS                                               25
413
`define ACK_BUS_READ_OPERATION                          26
414
`define WAIT_FOR_NEXT_DATA_PACKET                       27
415
`define BCU_READ_LANES                                                  28
416
`define CONFIGURATION_3LANE_DATA_PACKET         12
417
`define BCU_WAIT_FOR_RAM_WRITE                          29
418
`define BCU_READ_DATA_LANE_C                                    30
419
`define BCU_READ_DATA_LANE_D                                    31
420
`define BCU_WRITE_LAST_LANE_TO_RAM                      32
421
`define BCU_WRITE_NO_HIT_TO_BUS                         33
422
`define BCU_ACK_BUS_WRITE_DATA                          34
423
`define BCU_REQUEST_COLOR_ACC_FROM_RAM          35
424
`define BCU_READ_COLOR_ACC_FROM_RAM                     36
425
`define WAIT_FOR_CONTROL_UNIT_ACK                       37
426
`define BCU_REQUEST_COLOR_FROM_RAM                      38
427
`define BCU_RAM_READ_DELAY                                              39
428
`define BCU_READ_COLOR_FROM_RAM                         40
429
 
430
`define FETCH_GEOMETRY                                                  1
431
 
432
//Controlo values for RGU
433
`define RG_AFTER_RESET_STATE                                    1
434
`define RG_WAIT_FOR_CONTROL_UNIT_COMMAND        2
435
`define EXECUTE_TASK_STEP1                                              3
436
`define EXECUTE_TASK_STEP2                                              4
437
`define EXECUTE_TASK_STEP3                                              5
438
`define EXECUTE_TASK_STEP4                                              6
439
`define EXECUTE_TASK_STEP5                                              7
440
 
441
 
442
//Cnotrol values for GFU
443
`define REQUSET_PARENT_CUBE                                     5
444
`define FETCH_CUBE_STAGE_I                                              6
445
`define FETCH_CUBE_STAGE_I_ACK                          7
446
`define FETCH_CUBE_STAGE_II                                     8
447
`define FETCH_CUBE_STAGE_II_ACK                         9
448
`define TRIGGER_CUBE_INTERSECTION_UNIT          10
449
 
450
//Control values for AABBIU
451
`define RAY_INSIDE_BOX_TEST                                     5
452
`define WAIT_FOR_T_DIVISION_RESULTS                     6
453
`define CALCULE_AABB_INTERSECTION                       7
454
`define WAIT_FOR_T_MULTIPLICATION_RESULTS       8
455
`define CALCULATE_AABB_HIT                                              9
456
`define AABB_WRITE_RESULTS                                              10
457
 
458
//RegisterFileVariables
459
`define AGENT_WRITING_VALUE_TO_REGISTER_BUS             1
460
`define AGENT_READING_VALUE_FROM_REGISTER_BUS           0
461
 
462
//Division State Machine Constants
463
`define INITIAL_DIVISION_STATE                                  6'd1
464
`define DIVISION_REVERSE_LAST_ITERATION         6'd2
465
`define PRE_CALCULATE_REMAINDER                                 6'd3
466
`define CALCULATE_REMAINDER                                             6'd4
467
`define WRITE_DIVISION_RESULT                                           6'd5
468
 
469
//Square Root State Machine Constants
470
`define SQUARE_ROOT_LOOP                                        1
471
`define WRITE_SQUARE_ROOT_RESULT                        2
472
 
473
//Multiplication State Machine Constants
474
`define MULTIPLCATION_LOOP                                      1
475
`define WRITE_MULTIPLCATION_RESULT              2
476
 
477
//------------------------------------
478
 
479
//endmodule

powered by: WebSVN 2.1.0

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