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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_1.2/] [rtl/] [GEO/] [Module_GeometryFetchFSM.v] - Blame information for rev 230

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

Line No. Rev Author Line
1 30 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
Module Description:
23
 
24
WIP
25
**********************************************************************************/
26
 
27
 
28
`timescale 1ns / 1ps
29
`include "aDefinitions.v"
30
 
31
`define GFSM_AFTER_RESET                       0
32
`define GFSM_INITIAL_STATE                     1
33
`define GFSM_TRIGGER_AABBIU                    2
34
`define GFSM_WAIT_FOR_AABBIU                   3
35
`define GFSM_ACK_AABBIU                       10
36
`define GFSM_AABBIU_HIT                        4
37
`define GFSM_AABBIU_NO_HIT                     5
38
`define GFSM_TRIGGER_TRIANGLE_FETCH            6
39
`define GFSM_WAIT_FOR_TRIANGLE_FETCH           7
40
`define GFSM_TRIGGER_BIU_REQUSET               8
41
`define GFSM_WAIT_FOR_BIU                      9
42
`define GFSM_GET_FIRST_CHILD                  11
43
`define GFSM_CHECK_TRIANGLE_COUNT             12
44
`define GFSM_CHECK_NEXT_BROTHER               13
45
`define GFSM_GET_BROTHER                      14
46
`define GFSM_TRIGGER_NODE_FETCH               15
47
`define GFSM_FETCH_NEXT_BROTHER               16
48
`define GFSM_CHECK_PARENTS_BROTHER            18
49
`define GFSM_GET_PARENTS_BROTHER              19
50
`define GFSM_WAIT_FOR_NODE_FETCH              20
51
`define GFSM_POST_BLOCK_READ_DELAY            21
52
`define GFSM_TRIGGER_ROOT_NODE_FETCH          23
53
`define GFSM_WAIT_FOR_ROOT_NODE_FETCH         24
54
`define GFSM_FETCH_DATA                       25
55
`define GFSM_WAITF_FOR_BIU_AVAILABLE          26
56
`define GFSM_SWAP_TRIANGLE_POINTER            27
57
`define GFSM_DONE                             28
58
`define GFSM_SET_TRIANGLE_LIST_INITIAL_OFFSET 29
59
`define GFSM_REQUEST_TCC                      30
60
`define GFSM_WAIT_FOR_TCC                     31
61
`define GFSM_WAIT_STATE_PRE_TCC               32
62
`define GFSM_INITIAL_STATE_TEXTURE            33
63
`define GFSM_SET_WBM_INITIAL_ADDRESS          34
64
`define GFSM_REQUEST_TEXTURE                  35
65
`define GFSM_WAIT_FOR_TEXTURE                 36
66
`define GFSM_REQUEST_NEXT_TEXTURE             37
67
`define GFSM_WAIT_FOR_NEXT_TEXTURE            38
68
`define GFSM_INC_TEXTURE_ADDRESS              39
69 82 diegovalve
`define GFSM_SET_NEXT_TEXTURE_ADDR            42
70
`define GFSM_WAIT_FOR_IO_HIT                  43
71
`define GFSM_WAIT_FOR_IO_NO_HIT               44
72 30 diegovalve
 
73 73 diegovalve
 
74 30 diegovalve
module GeometryFetchFSM
75
(
76
        input wire                    Clock,
77
        input wire                    Reset,
78
        //Input control signals
79
        input wire                    iEnable,
80
        input   wire                    iAABBIUHit,
81
        input wire                    iBIUHit,
82
        input   wire                    iUCodeDone,
83
        input wire                    iTexturingEnable,
84
        input   wire                    iTriangleReadDone,
85
        //input wire                 iTextureReadDone,
86
        input   wire                    iNodeReadDone,
87
 
88
        //Current Node info
89
        input   wire                    iNode_IsLeaf,
90
        input wire[`WIDTH-1:0]        iNode_Brother_Address,
91
        input wire[`WIDTH-1:0]        iNode_TriangleCount,
92
        input wire[`WIDTH-1:0]        iNode_Parents_Brother_Address,
93
        //input wire[`WIDTH-1:0]                Node_OffsetData_Address,
94
        input wire[`WIDTH-1:0]        iNode_FirstChild_Address,
95
        //input wire                                            iBIUAvailable,
96
        //input wire                                            Node_MaxBlocks,
97
 
98
        //Control output signals
99
        output reg                                                                              oEnable_WBM,        //Activate the WBM in I/O
100 76 diegovalve
        output wire[`DATA_ADDRESS_WIDTH-1:0]     oAddressWBM,        //This is the address that we want to read from in I/O
101 30 diegovalve
        output reg                                                                              oSetAddressWBM,     //This uis to tell I/O to use the adress we just set
102
        output reg                             oSetIOWriteBackAddr,
103
        output wire[`DATA_ADDRESS_WIDTH-1:0]     oRAMTextureStoreLocation,   //This is where we want to store the data comming from I/O
104 82 diegovalve
        input   wire                                                   iDataAvailable,
105
        input wire                             iIOBusy,
106 30 diegovalve
 
107
 
108
        output reg      [`WIDTH-1:0]      oNodeAddress,
109
        input wire                                                      iTrigger_TFF,
110
 
111
        output reg                    oRequest_AABBIU,
112
        output reg                    oRequest_BIU,
113
        output reg                    oRequest_TCC,
114
        output reg                    oTrigger_TFU,
115
        output reg                    oTrigger_TNF,
116
        output reg [1:0]              oWBM_Addr_Selector, //0 = TNF, 1 = TFU, 2 = TCC 
117
        output reg                    oSync,
118 82 diegovalve
        output reg                    oSetTFUAddressOffset,
119
        `ifdef DEBUG
120
        input wire[`MAX_CORES-1:0]            iDebug_CoreID,
121
        `endif
122 30 diegovalve
        output reg                    oDone
123
 
124
 
125
);
126
 
127
 
128
 
129
 
130
 
131
reg [6:0] CurrentState;
132
reg [6:0] NextState;
133
//reg //IncTextureWriteAddress;
134
reg IncTextureCoordRegrAddr,IncTextureCount;
135
wire [2:0]  wTextureCount;
136
 
137
reg IncTriangleCount,ClearTriangleCount;
138
wire [`WIDTH-1:0] wTriangleCount;
139
 
140
//----------------------------------------
141
UpCounter_32 UP32_Tricount
142
(
143
 
144
.Clock( Clock ),
145
.Reset( ClearTriangleCount ),
146
.Initial( 0 ),
147
.Enable( IncTriangleCount ),
148
.Q( wTriangleCount )
149
 
150
);
151
//-----------------------------
152
 
153
UpCounter_16E TFF_VC1a
154
(
155
.Clock( Clock ),
156
.Reset( iTrigger_TFF | Reset ),
157
.Initial( `OREG_TEX_COORD1 ),
158
.Enable( IncTextureCoordRegrAddr ),
159
.Q( oAddressWBM )
160
);
161
 
162
//assign oAddressWBM = `OREG_TEX_COORD1;
163
 
164
//-----------------------------
165
 
166
UPCOUNTER_POSEDGE # (3) TFF_VC1
167
(
168
.Clock( Clock ),
169
.Reset( iTrigger_TFF ),
170
.Initial( 3'b0 ),
171
.Enable( IncTextureCount ),
172
.Q(  wTextureCount )
173
);
174
 
175
//-----------------------------
176
assign oRAMTextureStoreLocation = `CREG_TEX_COLOR1;
177
/*
178
UPCOUNTER_POSEDGE # (16) TNF_TFU_2
179
(
180
 
181
.Clock( Clock ),
182
.Reset( iTrigger_TFF ),
183
.Initial( `CREG_TEX_COLOR1 ),
184
.Enable(  //IncTextureWriteAddress ),
185
.Q( oRAMTextureStoreLocation )
186
 
187
);
188
*/
189
 
190
//----------------------------------------
191
`define GFSM_SELECT_TFU 2'b00  //Triangle Fetch
192
`define GFSM_SELECT_TFF 2'b01  //Texture Fetch     
193
`define GFSM_SELECT_TNF 2'b10  //Tree node fetch
194
`define GFSM_SELECT_NULL 2'b11
195
 
196
        //------------------------------------------------
197
  always @(posedge Clock or posedge Reset)
198
  begin
199
 
200
 
201
 
202
    if (Reset)
203
                CurrentState <= `GFSM_AFTER_RESET;
204
    else
205
                CurrentState <= NextState;
206
 
207
  end
208
  //------------------------------------------------
209
 
210
        always @( * )
211
   begin
212
        case (CurrentState)
213
                  //------------------------------------------
214
                  `GFSM_AFTER_RESET:
215
                  begin
216
 
217
                                oNodeAddress                    <= 0;
218
                                oRequest_AABBIU         <= 0;
219
                                oRequest_BIU                    <= 0;
220
                                oTrigger_TFU                    <= 0;
221
                                oTrigger_TNF                    <= 0;
222
                                ClearTriangleCount      <= 0;
223
                                IncTriangleCount                <= 0;
224
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
225
                                oSync                                           <= 0;
226
                                oDone                                           <= 0;
227
                                oSetTFUAddressOffset <= 0;
228
                                oRequest_TCC         <= 0;
229
                                IncTextureCoordRegrAddr       <= 0;
230
                                oSetIOWriteBackAddr <= 0;
231
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
232
 
233
                                NextState       <= `GFSM_INITIAL_STATE;
234
                  end
235
                  //------------------------------------------
236
                  /*
237
                  Here two things ca happen:
238
                  1) We are onGeometry Fetch Mode (iTrigger_TFF == 0)
239
                  then get the first node in the Octant Tree, or,
240
                  2)We are on Texture Fetch Mode (iTrigger_TFF == 1)
241
                  then do texture fetch stuff...
242
                  */
243
                  `GFSM_INITIAL_STATE:
244
                  begin
245
                                oNodeAddress                    <= 0;
246
                                oRequest_AABBIU         <= 0;
247
                                oRequest_BIU                    <= 0;
248
                                oTrigger_TFU                    <= 0;
249
                                oTrigger_TNF                    <= 0;
250
                                ClearTriangleCount      <= 1;   //*
251
                                IncTriangleCount                <= 0;
252
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
253
                                oSync                                           <= 0;
254
                                oDone                                           <= 0;
255
                                oSetTFUAddressOffset <= 0;
256
                                oRequest_TCC         <= 0;
257
                                IncTextureCoordRegrAddr       <= 0;
258
                                oSetIOWriteBackAddr <= 0;
259
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
260
 
261
                                if ( iEnable && !iTrigger_TFF )
262
                                        NextState <= `GFSM_TRIGGER_ROOT_NODE_FETCH;
263
                                else if (iEnable && iTrigger_TFF)
264
                                        NextState <= `GFSM_SET_WBM_INITIAL_ADDRESS;
265
                                else
266
                                        NextState <= `GFSM_INITIAL_STATE;
267
                  end
268
                  //------------------------------------------
269
                  `GFSM_SET_WBM_INITIAL_ADDRESS:
270
                  begin
271
                                oNodeAddress                    <= 0;
272
                                oRequest_AABBIU         <= 0;
273
                                oRequest_BIU                    <= 0;
274
                                oTrigger_TFU                    <= 0;
275
                                oTrigger_TNF                    <= 0;
276
                                ClearTriangleCount      <= 0;
277
                                IncTriangleCount                <= 0;
278
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
279
                                oSync                                           <= 0;
280
                                oDone                                           <= 0;
281
                                oSetTFUAddressOffset <= 0;
282
                                oRequest_TCC         <= 0;
283
 
284
 
285 73 diegovalve
                                oEnable_WBM                      <= 0;
286 30 diegovalve
                                oSetAddressWBM                <= 1; //*
287
                                oSetIOWriteBackAddr     <= 1; //Make sure we set write back address
288
                                IncTextureCount       <= 0;
289 73 diegovalve
                                IncTextureCoordRegrAddr <= 0;
290 30 diegovalve
 
291 73 diegovalve
 
292 30 diegovalve
                                NextState <= `GFSM_REQUEST_TEXTURE;
293
 
294
                end
295
                //------------------------------------
296
                `GFSM_REQUEST_TEXTURE:
297
                begin
298
                        oNodeAddress                    <= 0;
299
                        oRequest_AABBIU         <= 0;
300
                        oRequest_BIU                    <= 0;
301
                        oTrigger_TFU                    <= 0;
302
                        oTrigger_TNF                    <= 0;
303
                        ClearTriangleCount      <= 0;
304
                        IncTriangleCount                <= 0;
305
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
306
                        oSync                                           <= 0;
307
                        oDone                                           <= 0;
308
                        oSetTFUAddressOffset <= 0;
309
                        oRequest_TCC         <= 0;
310
 
311 73 diegovalve
                        //$display("GFSM_REQUEST_TEXTURE: Texture Addr in Reg: %d",oAddressWBM);
312
                        oEnable_WBM              <= 1; //*
313 30 diegovalve
                        oSetAddressWBM                 <= 0;
314
                        IncTextureCount        <= 0; //*
315
                        IncTextureCoordRegrAddr  <= 0;
316
                        oSetIOWriteBackAddr <= 0;
317 73 diegovalve
 
318 30 diegovalve
 
319
                        NextState <= `GFSM_WAIT_FOR_TEXTURE;
320
                end
321
                //------------------------------------
322
                `GFSM_WAIT_FOR_TEXTURE:
323
                begin
324
         oNodeAddress                   <= 0;
325
                        oRequest_AABBIU         <= 0;
326
                        oRequest_BIU                    <= 0;
327
                        oTrigger_TFU                    <= 0;
328
                        oTrigger_TNF                    <= 0;
329
                        ClearTriangleCount      <= 0;
330
                        IncTriangleCount                <= 0;
331
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
332
                        oSync                                           <= 0;
333
                        oDone                                           <= 0;
334
                        oSetTFUAddressOffset <= 0;
335
                        oRequest_TCC         <= 0;
336
 
337
 
338
                        oEnable_WBM                <= 1;
339
                        oSetAddressWBM                   <= 0;
340
                        //IncTextureWriteAddress           <= 0;
341
                        IncTextureCount            <= 0;
342
                        IncTextureCoordRegrAddr      <= 0;
343
                        oSetIOWriteBackAddr <= 0;
344
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR1;
345
 
346
                if ( iDataAvailable )
347
                        NextState <= `GFSM_INC_TEXTURE_ADDRESS;
348
                else
349
                        NextState <= `GFSM_WAIT_FOR_TEXTURE;
350
 
351
                end
352
                //------------------------------------
353
                `GFSM_INC_TEXTURE_ADDRESS:
354
                begin
355 73 diegovalve
                //$display("***** GFSM_REQUEST_NEXT_TEXTURE: Texture Addr in Reg: %d",oAddressWBM);
356 30 diegovalve
                   oNodeAddress                 <= 0;
357
                        oRequest_AABBIU         <= 0;
358
                        oRequest_BIU                    <= 0;
359
                        oTrigger_TFU                    <= 0;
360
                        oTrigger_TNF                    <= 0;
361
                        ClearTriangleCount      <= 0;
362
                        IncTriangleCount                <= 0;
363
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
364
                        oSync                                           <= 0;
365
                        oDone                                           <= 0;
366
                        oSetTFUAddressOffset <= 0;
367
                        oRequest_TCC         <= 0;
368
 
369
                        oEnable_WBM            <= 0;
370
                        oSetAddressWBM                <= 0;
371
                        IncTextureCount       <= 1;
372
                        //IncTextureWriteAddress        <= 0;//1;
373
         IncTextureCoordRegrAddr <= 1; //*              
374
                        oSetIOWriteBackAddr <= 0;
375
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR4;                 
376
 
377
                        NextState <= `GFSM_SET_NEXT_TEXTURE_ADDR;
378
                end
379
                //------------------------------------
380
                `GFSM_SET_NEXT_TEXTURE_ADDR:
381
                begin
382
 
383 73 diegovalve
                //$display("***** GFSM_REQUEST_NEXT_TEXTURE: Texture Addr in Reg: %d",oAddressWBM);
384 30 diegovalve
                   oNodeAddress                 <= 0;
385
                        oRequest_AABBIU         <= 0;
386
                        oRequest_BIU                    <= 0;
387
                        oTrigger_TFU                    <= 0;
388
                        oTrigger_TNF                    <= 0;
389
                        ClearTriangleCount      <= 0;
390
                        IncTriangleCount                <= 0;
391
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
392
                        oSync                                           <= 0;
393
                        oDone                                           <= 0;
394
                        oSetTFUAddressOffset <= 0;
395
                        oRequest_TCC         <= 0;
396
 
397
                        oEnable_WBM            <= 0; //*
398
                        oSetAddressWBM                <= 1;
399
                        IncTextureCount       <= 0; //*
400
         IncTextureCoordRegrAddr <= 0;
401
                        oSetIOWriteBackAddr <= 0;
402
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR4;                 
403
 
404
 
405
                        NextState <= `GFSM_REQUEST_NEXT_TEXTURE;
406
                end
407
                //------------------------------------
408
                /*
409
                We request 6 textures (ie. six colors from
410
                the texture coordinates, it should be actually 4
411
                instead of 6, but the hardwardware works better
412
                with numbers that are power of 3. But read 3 at
413
                a time, so when TextureCount Reaches 2 then we
414
                are done
415
                */
416
                `GFSM_REQUEST_NEXT_TEXTURE:
417
                begin
418
 
419 73 diegovalve
                //$display("***** GFSM_REQUEST_NEXT_TEXTURE: Texture Addr in Reg: %d",oAddressWBM);
420 30 diegovalve
                   oNodeAddress                 <= 0;
421
                        oRequest_AABBIU         <= 0;
422
                        oRequest_BIU                    <= 0;
423
                        oTrigger_TFU                    <= 0;
424
                        oTrigger_TNF                    <= 0;
425
                        ClearTriangleCount      <= 0;
426
                        IncTriangleCount                <= 0;
427
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
428
                        oSync                                           <= 0;
429
                        oDone                                           <= 0;
430
                        oSetTFUAddressOffset <= 0;
431
                        oRequest_TCC         <= 0;
432
 
433
                        oEnable_WBM            <= 1; //*
434
                        oSetAddressWBM                <= 0;
435
                        IncTextureCount       <= 1; //*
436
         IncTextureCoordRegrAddr <= 0;
437
                        oSetIOWriteBackAddr <= 0;
438
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR4;                 
439
 
440
 
441
                        NextState <= `GFSM_WAIT_FOR_NEXT_TEXTURE;
442
                end
443
 
444
                //----------------------------------------
445
                `GFSM_WAIT_FOR_NEXT_TEXTURE:
446
                begin
447
                        oNodeAddress                    <= 0;
448
                        oRequest_AABBIU         <= 0;
449
                        oRequest_BIU                    <= 0;
450
                        oTrigger_TFU                    <= 0;
451
                        oTrigger_TNF                    <= 0;
452
                        ClearTriangleCount      <= 0;
453
                        IncTriangleCount                <= 0;
454
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
455
                        oSync                                           <= 0;
456
                        oDone                                           <= 0;
457
                        oSetTFUAddressOffset <= 0;
458
                        oRequest_TCC         <= 0;
459
 
460
 
461
                        oEnable_WBM                 <= 1;
462
                        oSetAddressWBM                     <= 0;
463
                        IncTextureCount            <= 0; //*
464
                        IncTextureCoordRegrAddr      <= 0;
465
                        oSetIOWriteBackAddr <= 0;
466
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR4;
467
 
468
                if ( iDataAvailable )
469
                        NextState <= `GFSM_DONE;
470
                else
471
                        NextState <= `GFSM_WAIT_FOR_NEXT_TEXTURE;
472
 
473
                end
474
                        /****************************************/
475
                        /*
476
                        Texture Fetch Logic Ends Here.
477
                        Geometry Fetch Logic Starts Here (Duh!)
478
                        */
479
                        //------------------------------------
480
                   /*
481
                        Lets request the Root Node read in here.
482
                        The tree node function will fetch info such as
483
                        the type of node, the address of the first
484
                        data block as well as the boundaries of the
485
                        AABB.
486
                  */
487
                  `GFSM_TRIGGER_ROOT_NODE_FETCH:
488 82 diegovalve
                  begin
489
 
490
                  `ifdef DEBUG_GFSM
491
                   if (iDebug_CoreID == `DEBUG_CORE)
492
                                $display("CORE %d GFSM_TRIGGER_ROOT_NODE_FETCH",iDebug_CoreID);
493
                        `endif
494
 
495
 
496 30 diegovalve
                                oNodeAddress                    <= 0;     //Address of root node is always zero
497
                                oRequest_AABBIU         <= 0;
498
                                oRequest_BIU                    <= 0;
499
                                oTrigger_TFU                    <= 0;
500
                                oTrigger_TNF                    <= 1;   //*
501
                                ClearTriangleCount      <= 0;
502
                                IncTriangleCount                <= 0;
503
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TNF;
504
                                oSync                                           <= 0;
505
                                oDone                                           <= 0;
506
                                oSetTFUAddressOffset <= 0;
507
                                oRequest_TCC         <= 0;
508
 
509
                                oEnable_WBM                   <= 0;
510
                                oSetAddressWBM                <= 0;
511
                                //IncTextureWriteAddress        <= 0;
512
                                IncTextureCount       <= 0;
513
                                IncTextureCoordRegrAddr      <= 0;
514
                                oSetIOWriteBackAddr <= 0;
515
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
516
 
517
                                NextState <= `GFSM_WAIT_FOR_ROOT_NODE_FETCH;
518
 
519
                  end
520
                  //------------------------------------------
521
                  /*
522
                        OK once we have the data the first ting is
523
                        to test if the ray hits the AABB.
524
                  */
525
                  `GFSM_WAIT_FOR_ROOT_NODE_FETCH:
526
                  begin
527
 
528
                                oNodeAddress                    <= 0;
529
                                oRequest_AABBIU         <= 0;
530
                                oRequest_BIU                    <= 0;
531
                                oTrigger_TFU                    <= 0;
532
                                oTrigger_TNF                    <= 0;//* 
533
                                ClearTriangleCount      <= 0;
534
                                IncTriangleCount                <= 0;
535
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TNF;
536
                                oSync                                           <= 0;
537
                                oDone                                           <= 0;
538
                                oSetTFUAddressOffset <= 0;
539
                                oRequest_TCC         <= 0;
540
 
541
                                oEnable_WBM                   <= 0;
542
                                oSetAddressWBM                <= 0;
543
                                //IncTextureWriteAddress        <= 0;
544
                                IncTextureCount       <= 0;
545
                                IncTextureCoordRegrAddr      <= 0;
546
                                oSetIOWriteBackAddr <= 0;
547
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
548
 
549
                                if (iNodeReadDone)
550
                                        NextState <= `GFSM_TRIGGER_AABBIU;
551
                                else
552
                                        NextState <= `GFSM_WAIT_FOR_ROOT_NODE_FETCH;
553
                  end
554
                  //------------------------------------------
555 73 diegovalve
                  /*
556
                  So, while we request AABBIU, we should be requesting
557
                  the info for the Next triangle as well...
558
                  */
559 30 diegovalve
                  `GFSM_TRIGGER_AABBIU:
560 82 diegovalve
                  begin
561
 
562 30 diegovalve
                                oNodeAddress                    <= 0;
563
                                oRequest_AABBIU         <= 1;   //*
564
                                oRequest_BIU                    <= 0;
565 73 diegovalve
                                oTrigger_TFU                    <= 0;   //WIP!!!!!!!!
566 30 diegovalve
                                oTrigger_TNF                    <= 0;
567
                                ClearTriangleCount      <= 0;
568
                                IncTriangleCount                <= 0;
569
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
570
                                oSync                                           <= 1; //*
571
                                oDone                                           <= 0;
572
                                oSetTFUAddressOffset <= 0;
573
                                oRequest_TCC         <= 0;
574
 
575
                                oEnable_WBM                   <= 0;
576
                                oSetAddressWBM                <= 0;
577
                                //IncTextureWriteAddress        <= 0;
578
                                IncTextureCount       <= 0;
579
                                IncTextureCoordRegrAddr      <= 0;
580
                                oSetIOWriteBackAddr <= 0;
581
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;                           
582
 
583
                                NextState <= `GFSM_WAIT_FOR_AABBIU;
584
                  end
585
                  //------------------------------------------
586
                  `GFSM_WAIT_FOR_AABBIU:
587
                  begin
588
 
589
                                oNodeAddress                    <= 0;
590
                                oRequest_AABBIU         <= 1;
591
                                oRequest_BIU                    <= 0;
592
                                oTrigger_TFU                    <= 0;
593
                                oTrigger_TNF                    <= 0;
594
                                ClearTriangleCount      <= 0;
595
                                IncTriangleCount                <= 0;
596
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
597
                                oSync                                           <= 0;
598
                                oDone                                           <= 0;
599
                                oSetTFUAddressOffset <= 0;
600
                                oRequest_TCC         <= 0;
601
 
602
                                oEnable_WBM                   <= 0;
603
                                oSetAddressWBM                <= 0;
604
                                //IncTextureWriteAddress        <= 0;
605
                                IncTextureCount       <= 0;
606
                                IncTextureCoordRegrAddr      <= 0;
607
                                oSetIOWriteBackAddr <= 0;
608
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
609
 
610
                                if ( iUCodeDone )
611
                                        NextState <= `GFSM_ACK_AABBIU;
612
                                else
613
                                        NextState <= `GFSM_WAIT_FOR_AABBIU;
614
                  end
615
                  //------------------------------------------
616
                  `GFSM_ACK_AABBIU:
617
                  begin
618
 
619
                                oNodeAddress                    <= 0;
620
                                oRequest_AABBIU         <= 0;    //*
621
                                oRequest_BIU                    <= 0;
622
                                oTrigger_TFU                    <= 0;
623
                                oTrigger_TNF                    <= 0;
624
                                ClearTriangleCount      <= 0;
625
                                IncTriangleCount                <= 0;
626
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
627
                                oSync                                           <= 0;
628
                                oDone                                           <= 0;
629
                                oSetTFUAddressOffset <= 0;
630
                                oRequest_TCC         <= 0;
631
 
632
                                oEnable_WBM                   <= 0;
633
                                oSetAddressWBM                <= 0;
634
                                //IncTextureWriteAddress        <= 0;
635
                                IncTextureCount       <= 0;
636
                                IncTextureCoordRegrAddr      <= 0;
637
                                oSetIOWriteBackAddr <= 0;
638
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
639
 
640
                                if ( iAABBIUHit )
641
                                        NextState <= `GFSM_AABBIU_HIT;
642
                                else
643
                                        NextState <= `GFSM_AABBIU_NO_HIT;
644
                  end
645
                  //------------------------------------------
646
                  `GFSM_AABBIU_NO_HIT:
647
                  begin
648
                                oNodeAddress                    <= 0;
649
                                oRequest_AABBIU         <= 0;    //*
650
                                oRequest_BIU                    <= 0;
651
                                oTrigger_TFU                    <= 0;
652
                                oTrigger_TNF                    <= 0;
653
                                ClearTriangleCount      <= 0;
654
                                IncTriangleCount                <= 0;
655
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
656
                                oSync                                           <= 0;
657
                                oDone                                           <= 0;
658
                                oSetTFUAddressOffset <= 0;
659
                                oRequest_TCC         <= 0;
660
 
661
                                oEnable_WBM                   <= 0;
662
                                oSetAddressWBM                <= 0;
663
                                //IncTextureWriteAddress        <= 0;
664
                                IncTextureCount       <= 0;
665
                                IncTextureCoordRegrAddr      <= 0;
666
                                oSetIOWriteBackAddr <= 0;
667
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
668
 
669
 
670
                                NextState <= `GFSM_DONE;
671
                  end
672
                  //------------------------------------------
673
                  /*
674
                   Ok there is a hit, two things can happen:
675
                   if the Node is not a leaf, then the child nodes
676
                   need to be tested.
677
                   Else this node's data linked list needs
678
                   to be tested for instersections.
679
                        Since we have a new Node, lets start by
680
                        reading the first 3 blocks of data. The
681
                        first block is pointed by
682
                        'Node_OffsetData_Address'.
683
                  */
684
                  `GFSM_AABBIU_HIT:
685
                  begin
686 82 diegovalve
 
687 30 diegovalve
                                oNodeAddress                    <= 0;
688
                                oRequest_AABBIU         <= 0;
689
                                oRequest_BIU                    <= 0;
690
                                oTrigger_TFU                    <= 0;
691
                                oTrigger_TNF                    <= 0;
692
                                ClearTriangleCount      <= 0;
693
                                IncTriangleCount                <= 0;
694
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
695
                                oSync                                           <= 0;
696
                                oDone                                           <= 0;
697
                                oSetTFUAddressOffset <= 0;
698
                                oRequest_TCC         <= 0;
699
 
700
                                oEnable_WBM                   <= 0;
701
                                oSetAddressWBM                <= 0;
702
                                //IncTextureWriteAddress        <= 0;
703
                                IncTextureCount       <= 0;
704
                                IncTextureCoordRegrAddr      <= 0;
705
                                oSetIOWriteBackAddr <= 0;
706
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
707
 
708
                                if ( iNode_IsLeaf )
709
                                        NextState  <= `GFSM_SET_TRIANGLE_LIST_INITIAL_OFFSET;
710
                                else
711
                                        NextState  <= `GFSM_GET_FIRST_CHILD;
712
                  end
713
                  //------------------------------------------
714
                  `GFSM_SET_TRIANGLE_LIST_INITIAL_OFFSET:
715 82 diegovalve
                  begin
716
 
717 30 diegovalve
                                oNodeAddress                    <= 0;
718
                                oRequest_AABBIU         <= 0;
719
                                oRequest_BIU                    <= 0;
720
                                oTrigger_TFU                    <= 0;
721
                                oTrigger_TNF                    <= 0;
722
                                ClearTriangleCount      <= 0;
723
                                IncTriangleCount                <= 0;
724
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
725
                                oSync                                           <= 0;
726
                                oDone                                           <= 0;
727
                                oSetTFUAddressOffset <= 1; //*
728
                                oRequest_TCC         <= 0;
729
 
730
                                oEnable_WBM                   <= 0;
731
                                oSetAddressWBM                <= 0;
732
                                //IncTextureWriteAddress        <= 0;
733
                                IncTextureCount       <= 0;
734
                                IncTextureCoordRegrAddr      <= 0;
735
                                oSetIOWriteBackAddr <= 0;
736
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
737
 
738
                                NextState  <= `GFSM_TRIGGER_TRIANGLE_FETCH;
739
                  end
740
                  //------------------------------------------
741
                  /*
742
                        Since this node is not a leaf, we keep depth
743
                        first deep traversing the hierchy
744
                  */
745
                  `GFSM_GET_FIRST_CHILD:
746
                  begin
747
 
748
                                oRequest_AABBIU         <= 0;
749
                                oNodeAddress                    <= iNode_FirstChild_Address; //*
750
                                oRequest_BIU                    <= 0;
751
                                oTrigger_TFU         <= 0;
752
                                oTrigger_TNF         <= 0;
753
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
754
                                ClearTriangleCount      <= 0;
755
                                IncTriangleCount                <= 0;
756
                                oSync                                           <= 0;
757
                                oDone                                           <= 0;
758
                                oSetTFUAddressOffset <= 0;
759
                                oRequest_TCC         <= 0;
760
 
761
                                oEnable_WBM                   <= 0;
762
                                oSetAddressWBM                <= 0;
763
                                //IncTextureWriteAddress        <= 0;
764
                                IncTextureCount       <= 0;
765
                                IncTextureCoordRegrAddr      <= 0;
766
                                oSetIOWriteBackAddr <= 0;
767
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
768
 
769
 
770
                                NextState       <= `GFSM_TRIGGER_NODE_FETCH;
771
                  end
772
                  //------------------------------------------
773
                  /*
774
 
775
                  */
776
                  `GFSM_CHECK_TRIANGLE_COUNT:
777
                  begin
778
 
779
                                oNodeAddress                    <= 0;
780
                                oRequest_AABBIU         <= 0;
781
                                oRequest_BIU                    <= 0;
782
                                oTrigger_TFU                    <= 0;
783
                                oTrigger_TNF                    <= 0;
784
                                ClearTriangleCount      <= 0;
785
                                IncTriangleCount                <= 0;
786
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
787
                                oSync                                           <= 0;
788
                                oDone                                           <= 0;
789
                                oSetTFUAddressOffset <= 0;
790
                                oRequest_TCC         <= 0;
791
 
792
                                oEnable_WBM                   <= 0;
793
                                oSetAddressWBM                <= 0;
794
                                //IncTextureWriteAddress        <= 0;
795
                                IncTextureCount       <= 0;
796
                                IncTextureCoordRegrAddr      <= 0;
797
                                oSetIOWriteBackAddr <= 0;
798
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
799
 
800
 
801 82 diegovalve
 
802 30 diegovalve
                                if ( wTriangleCount == iNode_TriangleCount )
803
                                        NextState <= `GFSM_CHECK_NEXT_BROTHER;
804
                                else
805 73 diegovalve
                                        NextState <=
806
                                        //`GFSM_TRIGGER_TRIANGLE_FETCH;
807
                                        `GFSM_TRIGGER_BIU_REQUSET;                      //NEW NEW PARALLEL IO
808 30 diegovalve
                  end
809
                   //------------------------------------------
810
                  `GFSM_TRIGGER_TRIANGLE_FETCH:
811
                  begin
812 82 diegovalve
 
813
 
814 30 diegovalve
 
815
                                oNodeAddress                    <= 0;
816
                                oRequest_AABBIU         <= 0;
817
                                oRequest_BIU                    <= 0;
818
                                oTrigger_TFU                    <= 1; //*
819
                                oTrigger_TNF                    <= 0;
820
                                ClearTriangleCount      <= 0;
821
                                IncTriangleCount                <= 0;
822
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TFU;
823
                                oSync                                           <= 0;
824
                                oDone                                           <= 0;
825
                                oSetTFUAddressOffset <= 0;
826
                                oRequest_TCC         <= 0;
827
 
828
                                oEnable_WBM                   <= 0;
829
                                oSetAddressWBM                <= 0;
830
                                //IncTextureWriteAddress        <= 0;
831
                                IncTextureCount       <= 0;
832
                                IncTextureCoordRegrAddr      <= 0;
833
                                oSetIOWriteBackAddr <= 0;
834
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
835
 
836
                                NextState       <= `GFSM_WAIT_FOR_TRIANGLE_FETCH;
837
                  end
838
                  //------------------------------------------
839
 
840
                  /*
841
                        iEnable the data fetch and wait for the
842
                        operation to complete.
843
                  */
844
                  `GFSM_WAIT_FOR_TRIANGLE_FETCH:
845
                  begin
846
 
847
                                oNodeAddress                    <= 0;
848
                                oRequest_AABBIU         <= 0;
849
                                oRequest_BIU                    <= 0;
850
                                oTrigger_TFU                    <= 0; //*
851
                                oTrigger_TNF                    <= 0;
852
                                ClearTriangleCount      <= 0;
853
                                IncTriangleCount                <= 0;
854
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TFU;
855
                                oSync                                           <= 0;
856
                                oDone                                           <= 0;
857
                                oSetTFUAddressOffset <= 0;
858
                                oRequest_TCC         <= 0;
859
 
860
                                oEnable_WBM                   <= 0;
861
                                oSetAddressWBM                <= 0;
862
                                //IncTextureWriteAddress        <= 0;
863
                                IncTextureCount       <= 0;
864
                                IncTextureCoordRegrAddr      <= 0;
865
                                oSetIOWriteBackAddr <= 0;
866
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
867
 
868
                                if ( iTriangleReadDone )
869
                                        NextState       <= `GFSM_TRIGGER_BIU_REQUSET;
870
                                else
871
                                        NextState       <= `GFSM_WAIT_FOR_TRIANGLE_FETCH;
872
                  end
873
 
874
                  //------------------------------------------
875
                  /*
876
                        Now that we got the traingle vertices in RAM,
877
                        lets iEnable the BIU micro-code sub.
878
                        */
879
                  `GFSM_TRIGGER_BIU_REQUSET:
880
                  begin
881
 
882
 
883
                                oRequest_AABBIU         <= 0;
884
                                oNodeAddress                    <= 0;
885
                                oRequest_BIU          <= 1; //*
886 73 diegovalve
                                oTrigger_TFU                    <=
887
                                //0;
888
                                1;      ///NEW NEW NEW Jan 25 2010, try to put this to 1
889 30 diegovalve
                                oTrigger_TNF                    <= 0;
890
                                IncTriangleCount                <= 1;   //*             
891
                                ClearTriangleCount      <= 0;
892 73 diegovalve
                                oWBM_Addr_Selector      <=
893
                                //`GFSM_SELECT_NULL;
894
                                `GFSM_SELECT_TFU; //NEW NEW Paralell IO
895 30 diegovalve
                                oSync                                           <= 1;//*
896
                                oDone                                           <= 0;
897
                                oSetTFUAddressOffset <= 0;
898
                                oRequest_TCC         <= 0;
899
 
900
                                oEnable_WBM                   <= 0;
901
                                oSetAddressWBM                <= 0;
902
                                //IncTextureWriteAddress        <= 0;
903
                                IncTextureCount       <= 0;
904
                                IncTextureCoordRegrAddr      <= 0;
905
                                oSetIOWriteBackAddr <= 0;
906
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
907
 
908
                                NextState       <= `GFSM_WAIT_FOR_BIU;
909
                  end
910
                  //------------------------------------------
911
                  /*
912
                  Once BIU finishes see have a hit.
913
                  There are severals paths to go here depnending on
914
                  wethher there was a Hit or Not, and also depending
915
                  on whether we the texturing capability enabled.
916
                  1) If there was a Hit, but the textures are not enabled,
917
                  then keep interating the triangle list.
918
                  2) If there was a Hit and the texturing is enabled,
919
                  then go to the state that request the texture
920
                  coordiantes calculation
921
                  3) If there was not a Hit, then keep traversong the
922
                  triangle list.
923
                  4) If there is neither Hit or no-Hit yet, then keep
924
                  waiting is this state.
925
                  */
926
                  `GFSM_WAIT_FOR_BIU:
927
                  begin
928
 
929
                                oRequest_AABBIU         <= 0;
930
                                oNodeAddress                    <= 0;
931
                                oRequest_BIU                    <= 1; //*
932
                                oTrigger_TFU                    <= 0;
933
                                oTrigger_TNF                    <= 0;
934
                                IncTriangleCount                <= 0;    //*
935 73 diegovalve
                                oWBM_Addr_Selector      <=
936
                                //`GFSM_SELECT_NULL;
937
                                `GFSM_SELECT_TFU; //NEW NEW Paralell IO
938 30 diegovalve
                                ClearTriangleCount      <= 0;
939
                                oSync                                           <= 0;
940
                                oDone                                           <= 0;
941
                                oSetTFUAddressOffset <= 0;
942
                                oRequest_TCC         <= 0;
943
 
944
                                oEnable_WBM                   <= 0;
945
                                oSetAddressWBM                <= 0;
946
                                //IncTextureWriteAddress        <= 0;
947
                                IncTextureCount       <= 0;
948
                                IncTextureCoordRegrAddr      <= 0;
949
                                oSetIOWriteBackAddr <= 0;
950 82 diegovalve
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
951
                                /*
952
                                if (iUCodeDone & iBIUHit & ~iTriangleReadDone & iTexturingEnable)
953
                                        NextState <= `GFSM_WAIT_FOR_IO_HIT;
954
                                else if         (iUCodeDone & ~iBIUHit & ~iTriangleReadDone & iTexturingEnable)
955
                                        NextState <= `GFSM_WAIT_FOR_IO_NO_HIT;
956
                                else
957
                                        NextState <= `GFSM_WAIT_FOR_BIU;
958
                                */
959 30 diegovalve
 
960 82 diegovalve
                                if (iUCodeDone && iBIUHit && !iTexturingEnable && !iIOBusy)//Change IOBusy for TFUDone!!!
961 30 diegovalve
                                        NextState <= `GFSM_CHECK_TRIANGLE_COUNT;
962 82 diegovalve
                                else if (iUCodeDone && iBIUHit && iTexturingEnable && !iIOBusy)
963
                                   NextState <= `GFSM_WAIT_STATE_PRE_TCC;
964
                                else if (iUCodeDone && iBIUHit && iTexturingEnable && iIOBusy)
965
                                        NextState <= `GFSM_WAIT_FOR_IO_HIT;
966
                                else if (iUCodeDone && !iBIUHit  &&  !iIOBusy)
967
                                        NextState <= `GFSM_CHECK_TRIANGLE_COUNT;
968
                                else if (iUCodeDone && !iBIUHit && iIOBusy)
969
                                        NextState <= `GFSM_WAIT_FOR_IO_NO_HIT;
970 30 diegovalve
                                else
971 82 diegovalve
                                        NextState <= `GFSM_WAIT_FOR_BIU;
972
 
973
 
974 30 diegovalve
                  end
975 82 diegovalve
                  //------------------------------------------
976
                  `GFSM_WAIT_FOR_IO_HIT:
977
                  begin
978
                                oRequest_AABBIU         <= 0;
979
                                oNodeAddress                    <= 0;
980
                                oRequest_BIU                    <= 1; //*
981
                                oTrigger_TFU                    <= 0;
982
                                oTrigger_TNF                    <= 0;
983
                                IncTriangleCount                <= 0;    //*
984
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TFU;
985
                                ClearTriangleCount      <= 0;
986
                                oSync                                           <= 0;
987
                                oDone                                           <= 0;
988
                                oSetTFUAddressOffset <= 0;
989
                                oRequest_TCC         <= 0;
990
 
991
                                oEnable_WBM                   <= 0;
992
                                oSetAddressWBM                <= 0;
993
                                IncTextureCount       <= 0;
994
                                IncTextureCoordRegrAddr      <= 0;
995
                                oSetIOWriteBackAddr <= 0;
996
 
997
                                if (iTriangleReadDone )
998
                                        NextState <= `GFSM_WAIT_STATE_PRE_TCC;
999
                                else
1000
                                        NextState <= `GFSM_WAIT_FOR_IO_HIT;
1001
 
1002
                  end
1003
                   //------------------------------------------
1004
                  `GFSM_WAIT_FOR_IO_NO_HIT:
1005
                  begin
1006
                                oRequest_AABBIU         <= 0;
1007
                                oNodeAddress                    <= 0;
1008
                                oRequest_BIU                    <= 1; //*
1009
                                oTrigger_TFU                    <= 0;
1010
                                oTrigger_TNF                    <= 0;
1011
                                IncTriangleCount                <= 0;    //*
1012
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TFU;
1013
                                ClearTriangleCount      <= 0;
1014
                                oSync                                           <= 0;
1015
                                oDone                                           <= 0;
1016
                                oSetTFUAddressOffset <= 0;
1017
                                oRequest_TCC         <= 0;
1018
 
1019
                                oEnable_WBM                   <= 0;
1020
                                oSetAddressWBM                <= 0;
1021
                                IncTextureCount       <= 0;
1022
                                IncTextureCoordRegrAddr      <= 0;
1023
                                oSetIOWriteBackAddr <= 0;
1024
 
1025
                                if (iTriangleReadDone )
1026
                                        NextState <= `GFSM_CHECK_TRIANGLE_COUNT;
1027
                                else
1028
                                        NextState <= `GFSM_WAIT_FOR_IO_NO_HIT;
1029
 
1030
                  end
1031 30 diegovalve
                  //------------------------------------------
1032
                  /*
1033
                  Need to wait a extra cycle so that control unit will be able
1034
                  to get into the wait from geo sync state...it sucks I know...
1035
                  */
1036
                  `GFSM_WAIT_STATE_PRE_TCC:
1037
                  begin
1038
                      oRequest_AABBIU           <= 0;
1039
                                oNodeAddress                    <= 0;
1040
                                oRequest_BIU                    <= 1; //*
1041
                                oTrigger_TFU                    <= 0;
1042
                                oTrigger_TNF                    <= 0;
1043
                                IncTriangleCount                <= 0;    //*
1044
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
1045
                                ClearTriangleCount      <= 0;
1046
                                oSync                                           <= 0;
1047
                                oDone                                           <= 0;
1048
                                oSetTFUAddressOffset <= 0;
1049
                                oRequest_TCC         <= 0;
1050
 
1051
                                oEnable_WBM                   <= 0;
1052
                                oSetAddressWBM                <= 0;
1053
                                //IncTextureWriteAddress        <= 0;
1054
                                IncTextureCount       <= 0;
1055
                                IncTextureCoordRegrAddr      <= 0;
1056
                                oSetIOWriteBackAddr <= 0;
1057
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
1058
 
1059
                                NextState <= `GFSM_REQUEST_TCC;
1060
                  end
1061
                  //------------------------------------------
1062
 
1063
                  /*
1064
                   This state request CU to trigger TCC, ie the code
1065
                        that is responsible of generating the 4
1066
                        memory addresses to get the texture coordinates:
1067
                        ie: OREG_TEX_COORD1 and OREG_TEX_COORD2, this coordinates are stored, and
1068
                   they replace the previous coordinates values only
1069
                        if the current traingle is closer to the camera.
1070
                  */
1071
                  `GFSM_REQUEST_TCC:
1072
                  begin
1073
 
1074
                        //      $display("%d GFSM_REQUEST_TCC",$time);
1075
                        //      $display("GFSM_REQUEST_TCC %d oRequest_TCC = %d",$time,oRequest_TCC);
1076
 
1077
 
1078
                           oRequest_AABBIU              <= 0;
1079
                                oNodeAddress                    <= 0;
1080
                                oRequest_BIU                    <= 0;
1081
                                oTrigger_TFU                    <= 0;
1082
                                oTrigger_TNF                    <= 0;
1083
                                IncTriangleCount                <= 0;
1084
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
1085
                                ClearTriangleCount      <= 0;
1086
                                oSync                                           <= 1; //*
1087
                                oDone                                           <= 0;
1088
                                oSetTFUAddressOffset <= 0;
1089
                                oRequest_TCC         <= 1; //*
1090
 
1091
                                oEnable_WBM                   <= 0;
1092
                                oSetAddressWBM                <= 0;
1093
                                //IncTextureWriteAddress        <= 0;
1094
                                IncTextureCount       <= 0;
1095
                                IncTextureCoordRegrAddr      <= 0;
1096
                                oSetIOWriteBackAddr <= 0;
1097
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
1098
 
1099
 
1100
                                NextState <= `GFSM_WAIT_FOR_TCC;
1101
 
1102
                  end
1103
                  //------------------------------------------
1104
                  /*
1105
                  If the textures coordinates are calculted then
1106
                  move into the next triangle.
1107
                  */
1108
                  `GFSM_WAIT_FOR_TCC:
1109
                  begin
1110
 
1111
                //              $display("GFSM_WAIT_FOR_TCC %d oSync = %d",$time,oSync);
1112
                //              $display("GFSM_WAIT_FOR_TCC %d oRequest_TCC = %d",$time,oRequest_TCC);
1113
 
1114
                           oRequest_AABBIU              <= 0;
1115
                                oNodeAddress                    <= 0;
1116
                                oRequest_BIU                    <= 0;
1117
                                oTrigger_TFU                    <= 0;
1118
                                oTrigger_TNF                    <= 0;
1119
                                IncTriangleCount                <= 0;
1120
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
1121
                                ClearTriangleCount      <= 0;
1122
                                oSync                                           <= 0;
1123
                                oDone                                           <= 0;
1124
                                oSetTFUAddressOffset <= 0;
1125
                                oRequest_TCC         <= 1;
1126
 
1127
                                oEnable_WBM                   <= 0;
1128
                                oSetAddressWBM                <= 0;
1129
                                //IncTextureWriteAddress        <= 0;
1130
                                IncTextureCount       <= 0;
1131
                                IncTextureCoordRegrAddr      <= 0;
1132
                                oSetIOWriteBackAddr <= 0;
1133
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
1134
 
1135
                          if (iUCodeDone)
1136
                                        NextState <= `GFSM_CHECK_TRIANGLE_COUNT;
1137
                                else
1138
                                        NextState <= `GFSM_WAIT_FOR_TCC;
1139
                  end
1140
                  //------------------------------------------
1141
/*                `GFM_TRIGGER_TEXTURE_FETCH:
1142
                  begin
1143
                                oRequest_AABBIU         <= 0;
1144
                                oNodeAddress                    <= 0;
1145
                                oRequest_BIU                    <= 0;
1146
                                oTrigger_TFU                    <= 0;
1147
                                oTrigger_TNF                    <= 0;
1148
                                IncTriangleCount                <= 0;
1149
                                oWBM_Addr_Selector      <= 0;
1150
                                ClearTriangleCount      <= 0;
1151
                                oSync                                           <= 0;
1152
                                oDone                                           <= 0;
1153
                                oSetTFUAddressOffset <= 0;
1154
                                oTrigger_TFF                    <= 1;
1155
 
1156
                                NextState <= `GFSM_WAIT_FOR_TEXTURE_FETCH;
1157
                  end
1158
 
1159
                  //------------------------------------------
1160
                  `GFSM_WAIT_FOR_TEXTURE_FETCH:
1161
                  begin
1162
 
1163
                      oRequest_AABBIU           <= 0;
1164
                                oNodeAddress                    <= 0;
1165
                                oRequest_BIU                    <= 0;
1166
                                oTrigger_TFU                    <= 0;
1167
                                oTrigger_TNF                    <= 0;
1168
                                IncTriangleCount                <= 0;
1169
                                oWBM_Addr_Selector      <= 0;
1170
                                ClearTriangleCount      <= 0;
1171
                                oSync                                           <= 0;
1172
                                oDone                                           <= 0;
1173
                                oSetTFUAddressOffset <= 0;
1174
                                oTrigger_TFF                    <= 0;
1175
 
1176
                     if (iTextureReadDone == 1'b1)
1177
                                        NextState <= `GFSM_CHECK_TRIANGLE_COUNT;
1178
                          else
1179
                                        NextState <= `GFSM_WAIT_FOR_TEXTURE_FETCH;
1180
 
1181
                  end
1182
                  */
1183
                  //------------------------------------------
1184
                  `GFSM_CHECK_NEXT_BROTHER:
1185
                  begin
1186
 
1187
                                oRequest_AABBIU         <= 0;
1188
                                oNodeAddress                    <= 0;
1189
                                oRequest_BIU                    <= 0;
1190
                                oTrigger_TFU                    <= 0;
1191
                                oTrigger_TNF                    <= 0;
1192
                                IncTriangleCount                <= 0;    //*
1193
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
1194
                                ClearTriangleCount      <= 0;
1195
                                oSync                                           <= 0;
1196
                                oDone                                           <= 0;
1197
                                oSetTFUAddressOffset <= 0;
1198
                                oRequest_TCC         <= 0;
1199
 
1200
                                oEnable_WBM                   <= 0;
1201
                                oSetAddressWBM                <= 0;
1202
                                //IncTextureWriteAddress        <= 0;
1203
                                IncTextureCount       <= 0;
1204
                                IncTextureCoordRegrAddr      <= 0;
1205
                                oSetIOWriteBackAddr <= 0;
1206
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
1207
 
1208
                                if ( iNode_Brother_Address == 0 )
1209
                                        NextState <= `GFSM_CHECK_PARENTS_BROTHER;
1210
                                else
1211
                                        NextState <= `GFSM_GET_BROTHER;
1212
                  end
1213
                  //------------------------------------------
1214
                  `GFSM_GET_BROTHER:
1215
                  begin
1216
 
1217
                                oRequest_AABBIU         <= 0;
1218
                                oNodeAddress                    <= iNode_Brother_Address;       //*
1219
                                oRequest_BIU                    <= 0;
1220
                                oTrigger_TFU                    <= 0;
1221
                                oTrigger_TNF                    <= 0;
1222
                                IncTriangleCount                <= 0;    //*
1223
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
1224
                                ClearTriangleCount      <= 0;
1225
                                oSync                                           <= 0;
1226
                                oDone                                           <= 0;
1227
                                oSetTFUAddressOffset <= 0;
1228
                                oRequest_TCC         <= 0;
1229
 
1230
                                oEnable_WBM                   <= 0;
1231
                                oSetAddressWBM                <= 0;
1232
                                //IncTextureWriteAddress        <= 0;
1233
                                IncTextureCount       <= 0;
1234
                                IncTextureCoordRegrAddr      <= 0;
1235
                                oSetIOWriteBackAddr <= 0;
1236
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
1237
 
1238
 
1239
                                NextState <= `GFSM_TRIGGER_NODE_FETCH;
1240
                  end
1241
                  //------------------------------------------
1242
                  `GFSM_CHECK_PARENTS_BROTHER:
1243
                  begin
1244
 
1245
 
1246
                                oNodeAddress                            <= 0;
1247
                                oRequest_AABBIU                 <= 0;
1248
                                oRequest_BIU                            <= 0;
1249
                                oTrigger_TFU                            <= 0;
1250
                                oTrigger_TNF                            <= 0;
1251
                                IncTriangleCount                <= 0;    //*
1252
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
1253
                                ClearTriangleCount      <= 0;
1254
                                oSync                                           <= 0;
1255
                                oDone                                           <= 0;
1256
                                oSetTFUAddressOffset <= 0;
1257
                                oRequest_TCC         <= 0;
1258
 
1259
                                oEnable_WBM                   <= 0;
1260
                                oSetAddressWBM                <= 0;
1261
                                //IncTextureWriteAddress        <= 0;
1262
                                IncTextureCount       <= 0;
1263
                                IncTextureCoordRegrAddr      <= 0;
1264
                                oSetIOWriteBackAddr <= 0;
1265
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
1266
 
1267
                                if ( iNode_Parents_Brother_Address == 0)
1268
                                        NextState <= `GFSM_DONE;
1269
                                else
1270
                                        NextState <= `GFSM_GET_PARENTS_BROTHER;
1271
                  end
1272
                  //------------------------------------------
1273
                  `GFSM_GET_PARENTS_BROTHER:
1274
                  begin
1275
                                oRequest_AABBIU                 <= 0;
1276
                                oNodeAddress                    <= iNode_Parents_Brother_Address;       //*
1277
                                oRequest_BIU                            <= 0;
1278
                                oTrigger_TFU            <= 0;
1279
                                oTrigger_TNF            <= 0;
1280
                                IncTriangleCount                <= 0;    //*
1281
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
1282
                                ClearTriangleCount      <= 0;
1283
                                oSync                                           <= 0;
1284
                                oDone                                           <= 0;
1285
                                oSetTFUAddressOffset <= 0;
1286
                                oRequest_TCC         <= 0;
1287
 
1288
                                oEnable_WBM                   <= 0;
1289
                                oSetAddressWBM                <= 0;
1290
                                //IncTextureWriteAddress        <= 0;
1291
                                IncTextureCount       <= 0;
1292
                                IncTextureCoordRegrAddr      <= 0;
1293
                                oSetIOWriteBackAddr <= 0;
1294
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
1295
 
1296
 
1297
                                NextState       <= `GFSM_TRIGGER_NODE_FETCH;
1298
                  end
1299
                  //------------------------------------------
1300
                  `GFSM_TRIGGER_NODE_FETCH:
1301
                  begin
1302
 
1303
                                oRequest_AABBIU                 <= 0;
1304
                                oNodeAddress                            <= iNode_Brother_Address;
1305
                                oRequest_BIU                            <= 0;
1306
                                oTrigger_TFU            <= 1;   //*
1307
                                oTrigger_TNF            <= 0;
1308
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
1309
                                IncTriangleCount                <= 0;    //*
1310
                                ClearTriangleCount      <= 0;
1311
                                oSync                                           <= 0;
1312
                                oDone                                           <= 0;
1313
                                oSetTFUAddressOffset <= 0;
1314
                                oRequest_TCC         <= 0;
1315
 
1316
                                oEnable_WBM                   <= 0;
1317
                                oSetAddressWBM                <= 0;
1318
                                //IncTextureWriteAddress        <= 0;
1319
                                IncTextureCount       <= 0;
1320
                                IncTextureCoordRegrAddr      <= 0;
1321
                                oSetIOWriteBackAddr <= 0;
1322
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
1323
 
1324
 
1325
                                NextState       <= `GFSM_WAIT_FOR_NODE_FETCH;
1326
                  end
1327
                  //------------------------------------------
1328
                  /*
1329
                                Lets read the new node in our linked list.
1330
                                Once we got it we need to check AABB intersect,
1331
                                fetch traingles, etc, etc.
1332
                  */
1333
                  `GFSM_WAIT_FOR_NODE_FETCH:
1334
                  begin
1335
 
1336
                                oRequest_AABBIU                 <= 0;
1337
                                oNodeAddress                            <= iNode_Brother_Address;
1338
                                oRequest_BIU                            <= 0;
1339
                                oTrigger_TFU            <= 1;
1340
                                oTrigger_TNF            <= 0;
1341
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TFU;
1342
                                IncTriangleCount                <= 0;    //*
1343
                                ClearTriangleCount      <= 0;
1344
                                oSync                                           <= 0;
1345
                                oDone                                           <= 0;
1346
                                oSetTFUAddressOffset <= 0;
1347
                                oRequest_TCC         <= 0;
1348
 
1349
                                oEnable_WBM                   <= 0;
1350
                                oSetAddressWBM                <= 0;
1351
                                //IncTextureWriteAddress        <= 0;
1352
                                IncTextureCount       <= 0;
1353
                                IncTextureCoordRegrAddr      <= 0;
1354
                                oSetIOWriteBackAddr <= 0;
1355
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
1356
 
1357
                                if (iNodeReadDone)
1358
                                        NextState <= `GFSM_TRIGGER_AABBIU;
1359
                                else
1360
                                        NextState <= `GFSM_WAIT_FOR_NODE_FETCH;
1361
                  end
1362
                  //------------------------------------------
1363
                  `GFSM_DONE:
1364
                  begin
1365
 
1366
                        `ifdef DEBUG2
1367
                                $display(" **** GFSM_DONE ***");
1368
                        `endif
1369
                                oNodeAddress                            <= 0;
1370
                                oRequest_AABBIU                 <= 0;
1371
                                oRequest_BIU                            <= 0;
1372
                                oTrigger_TFU                            <= 0;
1373
                                oTrigger_TNF                            <= 0;
1374
                                IncTriangleCount                <= 0;    //*
1375
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
1376
                                ClearTriangleCount      <= 0;
1377
                                oSync                                           <= 1; //*
1378
                                oDone                                           <= 1; //*
1379
                                oSetTFUAddressOffset <= 0;
1380
                                oRequest_TCC         <= 0;
1381
 
1382
                                oEnable_WBM                   <= 0;
1383
                                oSetAddressWBM                <= 0;
1384
                                //IncTextureWriteAddress        <= 0;
1385
                                IncTextureCount       <= 0;
1386
                                IncTextureCoordRegrAddr      <= 0;
1387
                                oSetIOWriteBackAddr <= 0;
1388
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
1389
 
1390
 
1391
                                if (iEnable == 0 )
1392
                                        NextState <= `GFSM_INITIAL_STATE;
1393
                                else
1394
                                        NextState <= `GFSM_DONE;
1395
                  end
1396
                  //------------------------------------------
1397
                  default:
1398
                  begin
1399
 
1400
 
1401
                                oRequest_AABBIU         <= 0;
1402
                                oNodeAddress                    <= 0;
1403
                                oRequest_BIU                    <= 0;
1404
                                oTrigger_TFU                    <= 0;
1405
                                oTrigger_TNF                    <= 0;
1406
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
1407
                                IncTriangleCount                <= 0;    //*
1408
                                oWBM_Addr_Selector      <= 0;
1409
                                ClearTriangleCount      <= 0;
1410
                                oSync                                           <= 0;
1411
                                oDone                                           <= 0;
1412
                                oSetTFUAddressOffset <= 0;
1413
                                oRequest_TCC         <= 0;
1414
 
1415
                                oEnable_WBM                   <= 0;
1416
                                oSetAddressWBM                <= 0;
1417
                                //IncTextureWriteAddress        <= 0;
1418
                                IncTextureCount       <= 0;
1419
                                IncTextureCoordRegrAddr      <= 0;
1420
                                oSetIOWriteBackAddr <= 0;
1421
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
1422
 
1423
 
1424
                                NextState <= `GFSM_AFTER_RESET;
1425
                  end
1426
                  endcase
1427
        end
1428
        //------------------------------------------------
1429
endmodule

powered by: WebSVN 2.1.0

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