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

Subversion Repositories theia_gpu

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

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

powered by: WebSVN 2.1.0

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