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 73

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

powered by: WebSVN 2.1.0

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