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] - Diff between revs 30 and 58

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 30 Rev 58
/**********************************************************************************
/**********************************************************************************
Theaia, Ray Cast Programable graphic Processing Unit.
Theaia, Ray Cast Programable graphic Processing Unit.
Copyright (C) 2009  Diego Valverde (diego.valverde.g@gmail.com)
Copyright (C) 2009  Diego Valverde (diego.valverde.g@gmail.com)
 
 
This program is free software; you can redistribute it and/or
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
of the License, or (at your option) any later version.
 
 
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
GNU General Public License for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 
***********************************************************************************/
***********************************************************************************/
 
 
/**********************************************************************************
/**********************************************************************************
Module Description:
Module Description:
 
 
WIP
WIP
**********************************************************************************/
**********************************************************************************/
 
 
 
 
`timescale 1ns / 1ps
`timescale 1ns / 1ps
`include "aDefinitions.v"
`include "aDefinitions.v"
 
 
`define GFSM_AFTER_RESET                       0
`define GFSM_AFTER_RESET                       0
`define GFSM_INITIAL_STATE                     1
`define GFSM_INITIAL_STATE                     1
`define GFSM_TRIGGER_AABBIU                    2
`define GFSM_TRIGGER_AABBIU                    2
`define GFSM_WAIT_FOR_AABBIU                   3
`define GFSM_WAIT_FOR_AABBIU                   3
`define GFSM_ACK_AABBIU                       10
`define GFSM_ACK_AABBIU                       10
`define GFSM_AABBIU_HIT                        4
`define GFSM_AABBIU_HIT                        4
`define GFSM_AABBIU_NO_HIT                     5
`define GFSM_AABBIU_NO_HIT                     5
`define GFSM_TRIGGER_TRIANGLE_FETCH            6
`define GFSM_TRIGGER_TRIANGLE_FETCH            6
`define GFSM_WAIT_FOR_TRIANGLE_FETCH           7
`define GFSM_WAIT_FOR_TRIANGLE_FETCH           7
`define GFSM_TRIGGER_BIU_REQUSET               8
`define GFSM_TRIGGER_BIU_REQUSET               8
`define GFSM_WAIT_FOR_BIU                      9
`define GFSM_WAIT_FOR_BIU                      9
`define GFSM_GET_FIRST_CHILD                  11
`define GFSM_GET_FIRST_CHILD                  11
`define GFSM_CHECK_TRIANGLE_COUNT             12
`define GFSM_CHECK_TRIANGLE_COUNT             12
`define GFSM_CHECK_NEXT_BROTHER               13
`define GFSM_CHECK_NEXT_BROTHER               13
`define GFSM_GET_BROTHER                      14
`define GFSM_GET_BROTHER                      14
`define GFSM_TRIGGER_NODE_FETCH               15
`define GFSM_TRIGGER_NODE_FETCH               15
`define GFSM_FETCH_NEXT_BROTHER               16
`define GFSM_FETCH_NEXT_BROTHER               16
`define GFSM_CHECK_PARENTS_BROTHER            18
`define GFSM_CHECK_PARENTS_BROTHER            18
`define GFSM_GET_PARENTS_BROTHER              19
`define GFSM_GET_PARENTS_BROTHER              19
`define GFSM_WAIT_FOR_NODE_FETCH              20
`define GFSM_WAIT_FOR_NODE_FETCH              20
`define GFSM_POST_BLOCK_READ_DELAY            21
`define GFSM_POST_BLOCK_READ_DELAY            21
`define GFSM_TRIGGER_ROOT_NODE_FETCH          23
`define GFSM_TRIGGER_ROOT_NODE_FETCH          23
`define GFSM_WAIT_FOR_ROOT_NODE_FETCH         24
`define GFSM_WAIT_FOR_ROOT_NODE_FETCH         24
`define GFSM_FETCH_DATA                       25
`define GFSM_FETCH_DATA                       25
`define GFSM_WAITF_FOR_BIU_AVAILABLE          26
`define GFSM_WAITF_FOR_BIU_AVAILABLE          26
`define GFSM_SWAP_TRIANGLE_POINTER            27
`define GFSM_SWAP_TRIANGLE_POINTER            27
`define GFSM_DONE                             28
`define GFSM_DONE                             28
`define GFSM_SET_TRIANGLE_LIST_INITIAL_OFFSET 29
`define GFSM_SET_TRIANGLE_LIST_INITIAL_OFFSET 29
`define GFSM_REQUEST_TCC                      30
`define GFSM_REQUEST_TCC                      30
`define GFSM_WAIT_FOR_TCC                     31
`define GFSM_WAIT_FOR_TCC                     31
`define GFSM_WAIT_STATE_PRE_TCC               32
`define GFSM_WAIT_STATE_PRE_TCC               32
`define GFSM_INITIAL_STATE_TEXTURE            33
`define GFSM_INITIAL_STATE_TEXTURE            33
`define GFSM_SET_WBM_INITIAL_ADDRESS          34
`define GFSM_SET_WBM_INITIAL_ADDRESS          34
`define GFSM_REQUEST_TEXTURE                  35
`define GFSM_REQUEST_TEXTURE                  35
`define GFSM_WAIT_FOR_TEXTURE                 36
`define GFSM_WAIT_FOR_TEXTURE                 36
`define GFSM_REQUEST_NEXT_TEXTURE             37
`define GFSM_REQUEST_NEXT_TEXTURE             37
`define GFSM_WAIT_FOR_NEXT_TEXTURE            38
`define GFSM_WAIT_FOR_NEXT_TEXTURE            38
`define GFSM_INC_TEXTURE_ADDRESS              39
`define GFSM_INC_TEXTURE_ADDRESS              39
`define GFSM_SET_NEXT_TEXTURE_ADDR            42
`define GFSM_SET_NEXT_TEXTURE_ADDR            42
 
 
module GeometryFetchFSM
module GeometryFetchFSM
(
(
        input wire                    Clock,
        input wire                    Clock,
        input wire                    Reset,
        input wire                    Reset,
        //Input control signals
        //Input control signals
        input wire                    iEnable,
        input wire                    iEnable,
        input   wire                    iAABBIUHit,
        input   wire                    iAABBIUHit,
        input wire                    iBIUHit,
        input wire                    iBIUHit,
        input   wire                    iUCodeDone,
        input   wire                    iUCodeDone,
        input wire                    iTexturingEnable,
        input wire                    iTexturingEnable,
        input   wire                    iTriangleReadDone,
        input   wire                    iTriangleReadDone,
        //input wire                 iTextureReadDone,
        //input wire                 iTextureReadDone,
        input   wire                    iNodeReadDone,
        input   wire                    iNodeReadDone,
 
 
        //Current Node info
        //Current Node info
        input   wire                    iNode_IsLeaf,
        input   wire                    iNode_IsLeaf,
        input wire[`WIDTH-1:0]        iNode_Brother_Address,
        input wire[`WIDTH-1:0]        iNode_Brother_Address,
        input wire[`WIDTH-1:0]        iNode_TriangleCount,
        input wire[`WIDTH-1:0]        iNode_TriangleCount,
        input wire[`WIDTH-1:0]        iNode_Parents_Brother_Address,
        input wire[`WIDTH-1:0]        iNode_Parents_Brother_Address,
        //input wire[`WIDTH-1:0]                Node_OffsetData_Address,
        //input wire[`WIDTH-1:0]                Node_OffsetData_Address,
        input wire[`WIDTH-1:0]        iNode_FirstChild_Address,
        input wire[`WIDTH-1:0]        iNode_FirstChild_Address,
        //input wire                                            iBIUAvailable,
        //input wire                                            iBIUAvailable,
        //input wire                                            Node_MaxBlocks,
        //input wire                                            Node_MaxBlocks,
 
 
        //Control output signals
        //Control output signals
        output reg                                                                              oEnable_WBM,        //Activate the WBM in I/O
        output reg                                                                              oEnable_WBM,        //Activate the WBM in I/O
        output wire[`DATA_ADDRESS_WIDTH-1:0]        oAddressWBM,        //This is the address that we want to read from in I/O
        output wire[`DATA_ADDRESS_WIDTH-1:0]        oAddressWBM,        //This is the address that we want to read from in I/O
        output reg                                                                              oSetAddressWBM,     //This uis to tell I/O to use the adress we just set
        output reg                                                                              oSetAddressWBM,     //This uis to tell I/O to use the adress we just set
        output reg                             oSetIOWriteBackAddr,
        output reg                             oSetIOWriteBackAddr,
        output wire[`DATA_ADDRESS_WIDTH-1:0]     oRAMTextureStoreLocation,   //This is where we want to store the data comming from I/O
        output wire[`DATA_ADDRESS_WIDTH-1:0]     oRAMTextureStoreLocation,   //This is where we want to store the data comming from I/O
        input   wire                                                   iDataAvailable,
        input   wire                                                   iDataAvailable,
 
 
 
 
        output reg      [`WIDTH-1:0]      oNodeAddress,
        output reg      [`WIDTH-1:0]      oNodeAddress,
        input wire                                                      iTrigger_TFF,
        input wire                                                      iTrigger_TFF,
 
 
        output reg                    oRequest_AABBIU,
        output reg                    oRequest_AABBIU,
        output reg                    oRequest_BIU,
        output reg                    oRequest_BIU,
        output reg                    oRequest_TCC,
        output reg                    oRequest_TCC,
        output reg                    oTrigger_TFU,
        output reg                    oTrigger_TFU,
        output reg                    oTrigger_TNF,
        output reg                    oTrigger_TNF,
        output reg [1:0]              oWBM_Addr_Selector, //0 = TNF, 1 = TFU, 2 = TCC 
        output reg [1:0]              oWBM_Addr_Selector, //0 = TNF, 1 = TFU, 2 = TCC 
        output reg                    oSync,
        output reg                    oSync,
        output reg                    oSetTFUAddressOffset,
        output reg                    oSetTFUAddressOffset,
        output reg                    oDone
        output reg                    oDone
 
 
 
 
);
);
 
 
 
 
 
 
 
 
 
 
reg [6:0] CurrentState;
reg [6:0] CurrentState;
reg [6:0] NextState;
reg [6:0] NextState;
//reg //IncTextureWriteAddress;
//reg //IncTextureWriteAddress;
reg IncTextureCoordRegrAddr,IncTextureCount;
reg IncTextureCoordRegrAddr,IncTextureCount;
wire [2:0]  wTextureCount;
wire [2:0]  wTextureCount;
 
 
reg IncTriangleCount,ClearTriangleCount;
reg IncTriangleCount,ClearTriangleCount;
wire [`WIDTH-1:0] wTriangleCount;
wire [`WIDTH-1:0] wTriangleCount;
 
 
//----------------------------------------
//----------------------------------------
UpCounter_32 UP32_Tricount
UpCounter_32 UP32_Tricount
(
(
 
 
.Clock( Clock ),
.Clock( Clock ),
.Reset( ClearTriangleCount ),
.Reset( ClearTriangleCount ),
.Initial( 0 ),
.Initial( 0 ),
.Enable( IncTriangleCount ),
.Enable( IncTriangleCount ),
.Q( wTriangleCount )
.Q( wTriangleCount )
 
 
);
);
//-----------------------------
//-----------------------------
 
 
UpCounter_16E TFF_VC1a
UpCounter_16E TFF_VC1a
(
(
.Clock( Clock ),
.Clock( Clock ),
.Reset( iTrigger_TFF | Reset ),
.Reset( iTrigger_TFF | Reset ),
.Initial( `OREG_TEX_COORD1 ),
.Initial( `OREG_TEX_COORD1 ),
.Enable( IncTextureCoordRegrAddr ),
.Enable( IncTextureCoordRegrAddr ),
.Q( oAddressWBM )
.Q( oAddressWBM )
);
);
 
 
//assign oAddressWBM = `OREG_TEX_COORD1;
//assign oAddressWBM = `OREG_TEX_COORD1;
 
 
//-----------------------------
//-----------------------------
 
 
UPCOUNTER_POSEDGE # (3) TFF_VC1
UPCOUNTER_POSEDGE # (3) TFF_VC1
(
(
.Clock( Clock ),
.Clock( Clock ),
.Reset( iTrigger_TFF ),
.Reset( iTrigger_TFF ),
.Initial( 3'b0 ),
.Initial( 3'b0 ),
.Enable( IncTextureCount ),
.Enable( IncTextureCount ),
.Q(  wTextureCount )
.Q(  wTextureCount )
);
);
 
 
//-----------------------------
//-----------------------------
assign oRAMTextureStoreLocation = `CREG_TEX_COLOR1;
assign oRAMTextureStoreLocation = `CREG_TEX_COLOR1;
/*
/*
UPCOUNTER_POSEDGE # (16) TNF_TFU_2
UPCOUNTER_POSEDGE # (16) TNF_TFU_2
(
(
 
 
.Clock( Clock ),
.Clock( Clock ),
.Reset( iTrigger_TFF ),
.Reset( iTrigger_TFF ),
.Initial( `CREG_TEX_COLOR1 ),
.Initial( `CREG_TEX_COLOR1 ),
.Enable(  //IncTextureWriteAddress ),
.Enable(  //IncTextureWriteAddress ),
.Q( oRAMTextureStoreLocation )
.Q( oRAMTextureStoreLocation )
 
 
);
);
*/
*/
 
 
//----------------------------------------
//----------------------------------------
`define GFSM_SELECT_TFU 2'b00  //Triangle Fetch
`define GFSM_SELECT_TFU 2'b00  //Triangle Fetch
`define GFSM_SELECT_TFF 2'b01  //Texture Fetch     
`define GFSM_SELECT_TFF 2'b01  //Texture Fetch     
`define GFSM_SELECT_TNF 2'b10  //Tree node fetch
`define GFSM_SELECT_TNF 2'b10  //Tree node fetch
`define GFSM_SELECT_NULL 2'b11
`define GFSM_SELECT_NULL 2'b11
 
 
        //------------------------------------------------
        //------------------------------------------------
  always @(posedge Clock or posedge Reset)
  always @(posedge Clock or posedge Reset)
  begin
  begin
 
 
 
 
 
 
    if (Reset)
    if (Reset)
                CurrentState <= `GFSM_AFTER_RESET;
                CurrentState <= `GFSM_AFTER_RESET;
    else
    else
                CurrentState <= NextState;
                CurrentState <= NextState;
 
 
  end
  end
  //------------------------------------------------
  //------------------------------------------------
 
 
        always @( * )
        always @( * )
   begin
   begin
        case (CurrentState)
        case (CurrentState)
                  //------------------------------------------
                  //------------------------------------------
                  `GFSM_AFTER_RESET:
                  `GFSM_AFTER_RESET:
                  begin
                  begin
 
 
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
                                IncTextureCoordRegrAddr       <= 0;
                                IncTextureCoordRegrAddr       <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                NextState       <= `GFSM_INITIAL_STATE;
                                NextState       <= `GFSM_INITIAL_STATE;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  /*
                  /*
                  Here two things ca happen:
                  Here two things ca happen:
                  1) We are onGeometry Fetch Mode (iTrigger_TFF == 0)
                  1) We are onGeometry Fetch Mode (iTrigger_TFF == 0)
                  then get the first node in the Octant Tree, or,
                  then get the first node in the Octant Tree, or,
                  2)We are on Texture Fetch Mode (iTrigger_TFF == 1)
                  2)We are on Texture Fetch Mode (iTrigger_TFF == 1)
                  then do texture fetch stuff...
                  then do texture fetch stuff...
                  */
                  */
                  `GFSM_INITIAL_STATE:
                  `GFSM_INITIAL_STATE:
                  begin
                  begin
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                ClearTriangleCount      <= 1;   //*
                                ClearTriangleCount      <= 1;   //*
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
                                IncTextureCoordRegrAddr       <= 0;
                                IncTextureCoordRegrAddr       <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                if ( iEnable && !iTrigger_TFF )
                                if ( iEnable && !iTrigger_TFF )
                                        NextState <= `GFSM_TRIGGER_ROOT_NODE_FETCH;
                                        NextState <= `GFSM_TRIGGER_ROOT_NODE_FETCH;
                                else if (iEnable && iTrigger_TFF)
                                else if (iEnable && iTrigger_TFF)
                                        NextState <= `GFSM_SET_WBM_INITIAL_ADDRESS;
                                        NextState <= `GFSM_SET_WBM_INITIAL_ADDRESS;
                                else
                                else
                                        NextState <= `GFSM_INITIAL_STATE;
                                        NextState <= `GFSM_INITIAL_STATE;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  `GFSM_SET_WBM_INITIAL_ADDRESS:
                  `GFSM_SET_WBM_INITIAL_ADDRESS:
                  begin
                  begin
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
 
 
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 1; //*
                                oSetAddressWBM                <= 1; //*
                                oSetIOWriteBackAddr     <= 1; //Make sure we set write back address
                                oSetIOWriteBackAddr     <= 1; //Make sure we set write back address
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr       <= 0;
                                IncTextureCoordRegrAddr       <= 0;
                                //oRAMTextureStoreLocation <= `CREG_TEX_COLOR1;
                                //oRAMTextureStoreLocation <= `CREG_TEX_COLOR1;
 
 
                                NextState <= `GFSM_REQUEST_TEXTURE;
                                NextState <= `GFSM_REQUEST_TEXTURE;
 
 
                end
                end
                //------------------------------------
                //------------------------------------
                `GFSM_REQUEST_TEXTURE:
                `GFSM_REQUEST_TEXTURE:
                begin
                begin
                        oNodeAddress                    <= 0;
                        oNodeAddress                    <= 0;
                        oRequest_AABBIU         <= 0;
                        oRequest_AABBIU         <= 0;
                        oRequest_BIU                    <= 0;
                        oRequest_BIU                    <= 0;
                        oTrigger_TFU                    <= 0;
                        oTrigger_TFU                    <= 0;
                        oTrigger_TNF                    <= 0;
                        oTrigger_TNF                    <= 0;
                        ClearTriangleCount      <= 0;
                        ClearTriangleCount      <= 0;
                        IncTriangleCount                <= 0;
                        IncTriangleCount                <= 0;
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
                        oSync                                           <= 0;
                        oSync                                           <= 0;
                        oDone                                           <= 0;
                        oDone                                           <= 0;
                        oSetTFUAddressOffset <= 0;
                        oSetTFUAddressOffset <= 0;
                        oRequest_TCC         <= 0;
                        oRequest_TCC         <= 0;
 
 
                //      $display("GFSM_REQUEST_TEXTURE: Texture Addr in Reg: %d",oAddressWBM);
                //      $display("GFSM_REQUEST_TEXTURE: Texture Addr in Reg: %d",oAddressWBM);
                        oEnable_WBM             <= 1; //*
                        oEnable_WBM             <= 1; //*
                        oSetAddressWBM                 <= 0;
                        oSetAddressWBM                 <= 0;
                        //IncTextureWriteAddress        <= 0;
                        //IncTextureWriteAddress        <= 0;
                        IncTextureCount        <= 0; //*
                        IncTextureCount        <= 0; //*
                        IncTextureCoordRegrAddr  <= 0;
                        IncTextureCoordRegrAddr  <= 0;
                        oSetIOWriteBackAddr <= 0;
                        oSetIOWriteBackAddr <= 0;
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR1;
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR1;
 
 
                        NextState <= `GFSM_WAIT_FOR_TEXTURE;
                        NextState <= `GFSM_WAIT_FOR_TEXTURE;
                end
                end
                //------------------------------------
                //------------------------------------
                `GFSM_WAIT_FOR_TEXTURE:
                `GFSM_WAIT_FOR_TEXTURE:
                begin
                begin
         oNodeAddress                   <= 0;
         oNodeAddress                   <= 0;
                        oRequest_AABBIU         <= 0;
                        oRequest_AABBIU         <= 0;
                        oRequest_BIU                    <= 0;
                        oRequest_BIU                    <= 0;
                        oTrigger_TFU                    <= 0;
                        oTrigger_TFU                    <= 0;
                        oTrigger_TNF                    <= 0;
                        oTrigger_TNF                    <= 0;
                        ClearTriangleCount      <= 0;
                        ClearTriangleCount      <= 0;
                        IncTriangleCount                <= 0;
                        IncTriangleCount                <= 0;
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
                        oSync                                           <= 0;
                        oSync                                           <= 0;
                        oDone                                           <= 0;
                        oDone                                           <= 0;
                        oSetTFUAddressOffset <= 0;
                        oSetTFUAddressOffset <= 0;
                        oRequest_TCC         <= 0;
                        oRequest_TCC         <= 0;
 
 
 
 
                        oEnable_WBM                <= 1;
                        oEnable_WBM                <= 1;
                        oSetAddressWBM                   <= 0;
                        oSetAddressWBM                   <= 0;
                        //IncTextureWriteAddress           <= 0;
                        //IncTextureWriteAddress           <= 0;
                        IncTextureCount            <= 0;
                        IncTextureCount            <= 0;
                        IncTextureCoordRegrAddr      <= 0;
                        IncTextureCoordRegrAddr      <= 0;
                        oSetIOWriteBackAddr <= 0;
                        oSetIOWriteBackAddr <= 0;
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR1;
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR1;
 
 
                if ( iDataAvailable )
                if ( iDataAvailable )
                        NextState <= `GFSM_INC_TEXTURE_ADDRESS;
                        NextState <= `GFSM_INC_TEXTURE_ADDRESS;
                else
                else
                        NextState <= `GFSM_WAIT_FOR_TEXTURE;
                        NextState <= `GFSM_WAIT_FOR_TEXTURE;
 
 
                end
                end
                //------------------------------------
                //------------------------------------
                `GFSM_INC_TEXTURE_ADDRESS:
                `GFSM_INC_TEXTURE_ADDRESS:
                begin
                begin
        //      $display("***** GFSM_REQUEST_NEXT_TEXTURE: Texture Addr in Reg: %d",oAddressWBM);
        //      $display("***** GFSM_REQUEST_NEXT_TEXTURE: Texture Addr in Reg: %d",oAddressWBM);
                   oNodeAddress                 <= 0;
                   oNodeAddress                 <= 0;
                        oRequest_AABBIU         <= 0;
                        oRequest_AABBIU         <= 0;
                        oRequest_BIU                    <= 0;
                        oRequest_BIU                    <= 0;
                        oTrigger_TFU                    <= 0;
                        oTrigger_TFU                    <= 0;
                        oTrigger_TNF                    <= 0;
                        oTrigger_TNF                    <= 0;
                        ClearTriangleCount      <= 0;
                        ClearTriangleCount      <= 0;
                        IncTriangleCount                <= 0;
                        IncTriangleCount                <= 0;
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
                        oSync                                           <= 0;
                        oSync                                           <= 0;
                        oDone                                           <= 0;
                        oDone                                           <= 0;
                        oSetTFUAddressOffset <= 0;
                        oSetTFUAddressOffset <= 0;
                        oRequest_TCC         <= 0;
                        oRequest_TCC         <= 0;
 
 
                        oEnable_WBM            <= 0;
                        oEnable_WBM            <= 0;
                        oSetAddressWBM                <= 0;
                        oSetAddressWBM                <= 0;
                        IncTextureCount       <= 1;
                        IncTextureCount       <= 1;
                        //IncTextureWriteAddress        <= 0;//1;
                        //IncTextureWriteAddress        <= 0;//1;
         IncTextureCoordRegrAddr <= 1; //*              
         IncTextureCoordRegrAddr <= 1; //*              
                        oSetIOWriteBackAddr <= 0;
                        oSetIOWriteBackAddr <= 0;
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR4;                 
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR4;                 
 
 
                        NextState <= `GFSM_SET_NEXT_TEXTURE_ADDR;
                        NextState <= `GFSM_SET_NEXT_TEXTURE_ADDR;
                end
                end
                //------------------------------------
                //------------------------------------
                `GFSM_SET_NEXT_TEXTURE_ADDR:
                `GFSM_SET_NEXT_TEXTURE_ADDR:
                begin
                begin
 
 
        //      $display("***** GFSM_REQUEST_NEXT_TEXTURE: Texture Addr in Reg: %d",oAddressWBM);
        //      $display("***** GFSM_REQUEST_NEXT_TEXTURE: Texture Addr in Reg: %d",oAddressWBM);
                   oNodeAddress                 <= 0;
                   oNodeAddress                 <= 0;
                        oRequest_AABBIU         <= 0;
                        oRequest_AABBIU         <= 0;
                        oRequest_BIU                    <= 0;
                        oRequest_BIU                    <= 0;
                        oTrigger_TFU                    <= 0;
                        oTrigger_TFU                    <= 0;
                        oTrigger_TNF                    <= 0;
                        oTrigger_TNF                    <= 0;
                        ClearTriangleCount      <= 0;
                        ClearTriangleCount      <= 0;
                        IncTriangleCount                <= 0;
                        IncTriangleCount                <= 0;
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
                        oSync                                           <= 0;
                        oSync                                           <= 0;
                        oDone                                           <= 0;
                        oDone                                           <= 0;
                        oSetTFUAddressOffset <= 0;
                        oSetTFUAddressOffset <= 0;
                        oRequest_TCC         <= 0;
                        oRequest_TCC         <= 0;
 
 
                        oEnable_WBM            <= 0; //*
                        oEnable_WBM            <= 0; //*
                        oSetAddressWBM                <= 1;
                        oSetAddressWBM                <= 1;
                        IncTextureCount       <= 0; //*
                        IncTextureCount       <= 0; //*
         IncTextureCoordRegrAddr <= 0;
         IncTextureCoordRegrAddr <= 0;
                        oSetIOWriteBackAddr <= 0;
                        oSetIOWriteBackAddr <= 0;
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR4;                 
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR4;                 
 
 
 
 
                        NextState <= `GFSM_REQUEST_NEXT_TEXTURE;
                        NextState <= `GFSM_REQUEST_NEXT_TEXTURE;
                end
                end
                //------------------------------------
                //------------------------------------
                /*
                /*
                We request 6 textures (ie. six colors from
                We request 6 textures (ie. six colors from
                the texture coordinates, it should be actually 4
                the texture coordinates, it should be actually 4
                instead of 6, but the hardwardware works better
                instead of 6, but the hardwardware works better
                with numbers that are power of 3. But read 3 at
                with numbers that are power of 3. But read 3 at
                a time, so when TextureCount Reaches 2 then we
                a time, so when TextureCount Reaches 2 then we
                are done
                are done
                */
                */
                `GFSM_REQUEST_NEXT_TEXTURE:
                `GFSM_REQUEST_NEXT_TEXTURE:
                begin
                begin
 
 
        //      $display("***** GFSM_REQUEST_NEXT_TEXTURE: Texture Addr in Reg: %d",oAddressWBM);
        //      $display("***** GFSM_REQUEST_NEXT_TEXTURE: Texture Addr in Reg: %d",oAddressWBM);
                   oNodeAddress                 <= 0;
                   oNodeAddress                 <= 0;
                        oRequest_AABBIU         <= 0;
                        oRequest_AABBIU         <= 0;
                        oRequest_BIU                    <= 0;
                        oRequest_BIU                    <= 0;
                        oTrigger_TFU                    <= 0;
                        oTrigger_TFU                    <= 0;
                        oTrigger_TNF                    <= 0;
                        oTrigger_TNF                    <= 0;
                        ClearTriangleCount      <= 0;
                        ClearTriangleCount      <= 0;
                        IncTriangleCount                <= 0;
                        IncTriangleCount                <= 0;
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
                        oSync                                           <= 0;
                        oSync                                           <= 0;
                        oDone                                           <= 0;
                        oDone                                           <= 0;
                        oSetTFUAddressOffset <= 0;
                        oSetTFUAddressOffset <= 0;
                        oRequest_TCC         <= 0;
                        oRequest_TCC         <= 0;
 
 
                        oEnable_WBM            <= 1; //*
                        oEnable_WBM            <= 1; //*
                        oSetAddressWBM                <= 0;
                        oSetAddressWBM                <= 0;
                        IncTextureCount       <= 1; //*
                        IncTextureCount       <= 1; //*
         IncTextureCoordRegrAddr <= 0;
         IncTextureCoordRegrAddr <= 0;
                        oSetIOWriteBackAddr <= 0;
                        oSetIOWriteBackAddr <= 0;
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR4;                 
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR4;                 
 
 
 
 
                        NextState <= `GFSM_WAIT_FOR_NEXT_TEXTURE;
                        NextState <= `GFSM_WAIT_FOR_NEXT_TEXTURE;
                end
                end
 
 
                //----------------------------------------
                //----------------------------------------
                `GFSM_WAIT_FOR_NEXT_TEXTURE:
                `GFSM_WAIT_FOR_NEXT_TEXTURE:
                begin
                begin
                        oNodeAddress                    <= 0;
                        oNodeAddress                    <= 0;
                        oRequest_AABBIU         <= 0;
                        oRequest_AABBIU         <= 0;
                        oRequest_BIU                    <= 0;
                        oRequest_BIU                    <= 0;
                        oTrigger_TFU                    <= 0;
                        oTrigger_TFU                    <= 0;
                        oTrigger_TNF                    <= 0;
                        oTrigger_TNF                    <= 0;
                        ClearTriangleCount      <= 0;
                        ClearTriangleCount      <= 0;
                        IncTriangleCount                <= 0;
                        IncTriangleCount                <= 0;
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
                        oWBM_Addr_Selector      <= `GFSM_SELECT_TFF;
                        oSync                                           <= 0;
                        oSync                                           <= 0;
                        oDone                                           <= 0;
                        oDone                                           <= 0;
                        oSetTFUAddressOffset <= 0;
                        oSetTFUAddressOffset <= 0;
                        oRequest_TCC         <= 0;
                        oRequest_TCC         <= 0;
 
 
 
 
                        oEnable_WBM                 <= 1;
                        oEnable_WBM                 <= 1;
                        oSetAddressWBM                     <= 0;
                        oSetAddressWBM                     <= 0;
                        IncTextureCount            <= 0; //*
                        IncTextureCount            <= 0; //*
                        IncTextureCoordRegrAddr      <= 0;
                        IncTextureCoordRegrAddr      <= 0;
                        oSetIOWriteBackAddr <= 0;
                        oSetIOWriteBackAddr <= 0;
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR4;
                        //oRAMTextureStoreLocation <= `CREG_TEX_COLOR4;
 
 
                if ( iDataAvailable )
                if ( iDataAvailable )
                        NextState <= `GFSM_DONE;
                        NextState <= `GFSM_DONE;
                else
                else
                        NextState <= `GFSM_WAIT_FOR_NEXT_TEXTURE;
                        NextState <= `GFSM_WAIT_FOR_NEXT_TEXTURE;
 
 
                end
                end
                        /****************************************/
                        /****************************************/
                        /*
                        /*
                        Texture Fetch Logic Ends Here.
                        Texture Fetch Logic Ends Here.
                        Geometry Fetch Logic Starts Here (Duh!)
                        Geometry Fetch Logic Starts Here (Duh!)
                        */
                        */
                        //------------------------------------
                        //------------------------------------
                   /*
                   /*
                        Lets request the Root Node read in here.
                        Lets request the Root Node read in here.
                        The tree node function will fetch info such as
                        The tree node function will fetch info such as
                        the type of node, the address of the first
                        the type of node, the address of the first
                        data block as well as the boundaries of the
                        data block as well as the boundaries of the
                        AABB.
                        AABB.
                  */
                  */
                  `GFSM_TRIGGER_ROOT_NODE_FETCH:
                  `GFSM_TRIGGER_ROOT_NODE_FETCH:
                  begin
                  begin
                        //      $display("GFSM_TRIGGER_ROOT_NODE_FETCH");
                        //      $display("GFSM_TRIGGER_ROOT_NODE_FETCH");
                                oNodeAddress                    <= 0;     //Address of root node is always zero
                                oNodeAddress                    <= 0;     //Address of root node is always zero
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 1;   //*
                                oTrigger_TNF                    <= 1;   //*
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TNF;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TNF;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                NextState <= `GFSM_WAIT_FOR_ROOT_NODE_FETCH;
                                NextState <= `GFSM_WAIT_FOR_ROOT_NODE_FETCH;
 
 
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  /*
                  /*
                        OK once we have the data the first ting is
                        OK once we have the data the first ting is
                        to test if the ray hits the AABB.
                        to test if the ray hits the AABB.
                  */
                  */
                  `GFSM_WAIT_FOR_ROOT_NODE_FETCH:
                  `GFSM_WAIT_FOR_ROOT_NODE_FETCH:
                  begin
                  begin
 
 
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;//* 
                                oTrigger_TNF                    <= 0;//* 
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TNF;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TNF;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                if (iNodeReadDone)
                                if (iNodeReadDone)
                                        NextState <= `GFSM_TRIGGER_AABBIU;
                                        NextState <= `GFSM_TRIGGER_AABBIU;
                                else
                                else
                                        NextState <= `GFSM_WAIT_FOR_ROOT_NODE_FETCH;
                                        NextState <= `GFSM_WAIT_FOR_ROOT_NODE_FETCH;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  `GFSM_TRIGGER_AABBIU:
                  `GFSM_TRIGGER_AABBIU:
                  begin
                  begin
                //      $display("GFSM_TRIGGER_AABBIU");
                //      $display("GFSM_TRIGGER_AABBIU");
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_AABBIU         <= 1;   //*
                                oRequest_AABBIU         <= 1;   //*
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oSync                                           <= 1; //*
                                oSync                                           <= 1; //*
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;                           
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;                           
 
 
                                NextState <= `GFSM_WAIT_FOR_AABBIU;
                                NextState <= `GFSM_WAIT_FOR_AABBIU;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  `GFSM_WAIT_FOR_AABBIU:
                  `GFSM_WAIT_FOR_AABBIU:
                  begin
                  begin
 
 
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_AABBIU         <= 1;
                                oRequest_AABBIU         <= 1;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                if ( iUCodeDone )
                                if ( iUCodeDone )
                                        NextState <= `GFSM_ACK_AABBIU;
                                        NextState <= `GFSM_ACK_AABBIU;
                                else
                                else
                                        NextState <= `GFSM_WAIT_FOR_AABBIU;
                                        NextState <= `GFSM_WAIT_FOR_AABBIU;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  `GFSM_ACK_AABBIU:
                  `GFSM_ACK_AABBIU:
                  begin
                  begin
 
 
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_AABBIU         <= 0;    //*
                                oRequest_AABBIU         <= 0;    //*
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                if ( iAABBIUHit )
                                if ( iAABBIUHit )
                                        NextState <= `GFSM_AABBIU_HIT;
                                        NextState <= `GFSM_AABBIU_HIT;
                                else
                                else
                                        NextState <= `GFSM_AABBIU_NO_HIT;
                                        NextState <= `GFSM_AABBIU_NO_HIT;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  `GFSM_AABBIU_NO_HIT:
                  `GFSM_AABBIU_NO_HIT:
                  begin
                  begin
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_AABBIU         <= 0;    //*
                                oRequest_AABBIU         <= 0;    //*
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
 
 
                                NextState <= `GFSM_DONE;
                                NextState <= `GFSM_DONE;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  /*
                  /*
                   Ok there is a hit, two things can happen:
                   Ok there is a hit, two things can happen:
                   if the Node is not a leaf, then the child nodes
                   if the Node is not a leaf, then the child nodes
                   need to be tested.
                   need to be tested.
                   Else this node's data linked list needs
                   Else this node's data linked list needs
                   to be tested for instersections.
                   to be tested for instersections.
                        Since we have a new Node, lets start by
                        Since we have a new Node, lets start by
                        reading the first 3 blocks of data. The
                        reading the first 3 blocks of data. The
                        first block is pointed by
                        first block is pointed by
                        'Node_OffsetData_Address'.
                        'Node_OffsetData_Address'.
                  */
                  */
                  `GFSM_AABBIU_HIT:
                  `GFSM_AABBIU_HIT:
                  begin
                  begin
 
 
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                if ( iNode_IsLeaf )
                                if ( iNode_IsLeaf )
                                        NextState  <= `GFSM_SET_TRIANGLE_LIST_INITIAL_OFFSET;
                                        NextState  <= `GFSM_SET_TRIANGLE_LIST_INITIAL_OFFSET;
                                else
                                else
                                        NextState  <= `GFSM_GET_FIRST_CHILD;
                                        NextState  <= `GFSM_GET_FIRST_CHILD;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  `GFSM_SET_TRIANGLE_LIST_INITIAL_OFFSET:
                  `GFSM_SET_TRIANGLE_LIST_INITIAL_OFFSET:
                  begin
                  begin
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 1; //*
                                oSetTFUAddressOffset <= 1; //*
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                NextState  <= `GFSM_TRIGGER_TRIANGLE_FETCH;
                                NextState  <= `GFSM_TRIGGER_TRIANGLE_FETCH;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  /*
                  /*
                        Since this node is not a leaf, we keep depth
                        Since this node is not a leaf, we keep depth
                        first deep traversing the hierchy
                        first deep traversing the hierchy
                  */
                  */
                  `GFSM_GET_FIRST_CHILD:
                  `GFSM_GET_FIRST_CHILD:
                  begin
                  begin
 
 
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oNodeAddress                    <= iNode_FirstChild_Address; //*
                                oNodeAddress                    <= iNode_FirstChild_Address; //*
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU         <= 0;
                                oTrigger_TFU         <= 0;
                                oTrigger_TNF         <= 0;
                                oTrigger_TNF         <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
 
 
                                NextState       <= `GFSM_TRIGGER_NODE_FETCH;
                                NextState       <= `GFSM_TRIGGER_NODE_FETCH;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  /*
                  /*
 
 
                  */
                  */
                  `GFSM_CHECK_TRIANGLE_COUNT:
                  `GFSM_CHECK_TRIANGLE_COUNT:
                  begin
                  begin
 
 
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                `ifdef DEBUG2
                                `ifdef DEBUG2
                                        $display("Fetching triangle %d of %d ", wTriangleCount,iNode_TriangleCount);
                                        $display("Fetching triangle %d of %d ", wTriangleCount,iNode_TriangleCount);
                                `endif
                                `endif
 
 
                                if ( wTriangleCount == iNode_TriangleCount )
                                if ( wTriangleCount == iNode_TriangleCount )
                                        NextState <= `GFSM_CHECK_NEXT_BROTHER;
                                        NextState <= `GFSM_CHECK_NEXT_BROTHER;
                                else
                                else
                                        NextState <= `GFSM_TRIGGER_TRIANGLE_FETCH;
                                        NextState <= `GFSM_TRIGGER_TRIANGLE_FETCH;
                  end
                  end
                   //------------------------------------------
                   //------------------------------------------
                  `GFSM_TRIGGER_TRIANGLE_FETCH:
                  `GFSM_TRIGGER_TRIANGLE_FETCH:
                  begin
                  begin
 
 
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 1; //*
                                oTrigger_TFU                    <= 1; //*
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TFU;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TFU;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                NextState       <= `GFSM_WAIT_FOR_TRIANGLE_FETCH;
                                NextState       <= `GFSM_WAIT_FOR_TRIANGLE_FETCH;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
 
 
                  /*
                  /*
                        iEnable the data fetch and wait for the
                        iEnable the data fetch and wait for the
                        operation to complete.
                        operation to complete.
                  */
                  */
                  `GFSM_WAIT_FOR_TRIANGLE_FETCH:
                  `GFSM_WAIT_FOR_TRIANGLE_FETCH:
                  begin
                  begin
 
 
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0; //*
                                oTrigger_TFU                    <= 0; //*
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TFU;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TFU;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                if ( iTriangleReadDone )
                                if ( iTriangleReadDone )
                                        NextState       <= `GFSM_TRIGGER_BIU_REQUSET;
                                        NextState       <= `GFSM_TRIGGER_BIU_REQUSET;
                                else
                                else
                                        NextState       <= `GFSM_WAIT_FOR_TRIANGLE_FETCH;
                                        NextState       <= `GFSM_WAIT_FOR_TRIANGLE_FETCH;
                  end
                  end
 
 
                  //------------------------------------------
                  //------------------------------------------
                  /*
                  /*
                        Now that we got the traingle vertices in RAM,
                        Now that we got the traingle vertices in RAM,
                        lets iEnable the BIU micro-code sub.
                        lets iEnable the BIU micro-code sub.
                        */
                        */
                  `GFSM_TRIGGER_BIU_REQUSET:
                  `GFSM_TRIGGER_BIU_REQUSET:
                  begin
                  begin
 
 
                        `ifdef DEBUG2
                        `ifdef DEBUG2
                                $display("******* GFSM_TRIGGER_BIU_REQUSET *******");
                                $display("******* GFSM_TRIGGER_BIU_REQUSET *******");
                        `endif
                        `endif
 
 
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_BIU          <= 1; //*
                                oRequest_BIU          <= 1; //*
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                IncTriangleCount                <= 1;   //*             
                                IncTriangleCount                <= 1;   //*             
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oSync                                           <= 1;//*
                                oSync                                           <= 1;//*
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                NextState       <= `GFSM_WAIT_FOR_BIU;
                                NextState       <= `GFSM_WAIT_FOR_BIU;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  /*
                  /*
                  Once BIU finishes see have a hit.
                  Once BIU finishes see have a hit.
                  There are severals paths to go here depnending on
                  There are severals paths to go here depnending on
                  wethher there was a Hit or Not, and also depending
                  wethher there was a Hit or Not, and also depending
                  on whether we the texturing capability enabled.
                  on whether we the texturing capability enabled.
                  1) If there was a Hit, but the textures are not enabled,
                  1) If there was a Hit, but the textures are not enabled,
                  then keep interating the triangle list.
                  then keep interating the triangle list.
                  2) If there was a Hit and the texturing is enabled,
                  2) If there was a Hit and the texturing is enabled,
                  then go to the state that request the texture
                  then go to the state that request the texture
                  coordiantes calculation
                  coordiantes calculation
                  3) If there was not a Hit, then keep traversong the
                  3) If there was not a Hit, then keep traversong the
                  triangle list.
                  triangle list.
                  4) If there is neither Hit or no-Hit yet, then keep
                  4) If there is neither Hit or no-Hit yet, then keep
                  waiting is this state.
                  waiting is this state.
                  */
                  */
                  `GFSM_WAIT_FOR_BIU:
                  `GFSM_WAIT_FOR_BIU:
                  begin
                  begin
 
 
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_BIU                    <= 1; //*
                                oRequest_BIU                    <= 1; //*
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                IncTriangleCount                <= 0;    //*
                                IncTriangleCount                <= 0;    //*
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                if (iUCodeDone && iBIUHit && !iTexturingEnable)
                                if (iUCodeDone && iBIUHit && !iTexturingEnable)
                                        NextState <= `GFSM_CHECK_TRIANGLE_COUNT;
                                        NextState <= `GFSM_CHECK_TRIANGLE_COUNT;
                                else if (iUCodeDone && iBIUHit && iTexturingEnable)
                                else if (iUCodeDone && iBIUHit && iTexturingEnable)
                                   NextState <= `GFSM_WAIT_STATE_PRE_TCC;
                                   NextState <= `GFSM_WAIT_STATE_PRE_TCC;
                                else if (iUCodeDone && !iBIUHit)
                                else if (iUCodeDone && !iBIUHit)
                                        NextState <= `GFSM_CHECK_TRIANGLE_COUNT;
                                        NextState <= `GFSM_CHECK_TRIANGLE_COUNT;
                                else
                                else
                                        NextState <= `GFSM_WAIT_FOR_BIU;
                                        NextState <= `GFSM_WAIT_FOR_BIU;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  /*
                  /*
                  Need to wait a extra cycle so that control unit will be able
                  Need to wait a extra cycle so that control unit will be able
                  to get into the wait from geo sync state...it sucks I know...
                  to get into the wait from geo sync state...it sucks I know...
                  */
                  */
                  `GFSM_WAIT_STATE_PRE_TCC:
                  `GFSM_WAIT_STATE_PRE_TCC:
                  begin
                  begin
                      oRequest_AABBIU           <= 0;
                      oRequest_AABBIU           <= 0;
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_BIU                    <= 1; //*
                                oRequest_BIU                    <= 1; //*
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                IncTriangleCount                <= 0;    //*
                                IncTriangleCount                <= 0;    //*
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                NextState <= `GFSM_REQUEST_TCC;
                                NextState <= `GFSM_REQUEST_TCC;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
 
 
                  /*
                  /*
                   This state request CU to trigger TCC, ie the code
                   This state request CU to trigger TCC, ie the code
                        that is responsible of generating the 4
                        that is responsible of generating the 4
                        memory addresses to get the texture coordinates:
                        memory addresses to get the texture coordinates:
                        ie: OREG_TEX_COORD1 and OREG_TEX_COORD2, this coordinates are stored, and
                        ie: OREG_TEX_COORD1 and OREG_TEX_COORD2, this coordinates are stored, and
                   they replace the previous coordinates values only
                   they replace the previous coordinates values only
                        if the current traingle is closer to the camera.
                        if the current traingle is closer to the camera.
                  */
                  */
                  `GFSM_REQUEST_TCC:
                  `GFSM_REQUEST_TCC:
                  begin
                  begin
 
 
                        //      $display("%d GFSM_REQUEST_TCC",$time);
                        //      $display("%d GFSM_REQUEST_TCC",$time);
                        //      $display("GFSM_REQUEST_TCC %d oRequest_TCC = %d",$time,oRequest_TCC);
                        //      $display("GFSM_REQUEST_TCC %d oRequest_TCC = %d",$time,oRequest_TCC);
 
 
 
 
                           oRequest_AABBIU              <= 0;
                           oRequest_AABBIU              <= 0;
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                oSync                                           <= 1; //*
                                oSync                                           <= 1; //*
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 1; //*
                                oRequest_TCC         <= 1; //*
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
 
 
                                NextState <= `GFSM_WAIT_FOR_TCC;
                                NextState <= `GFSM_WAIT_FOR_TCC;
 
 
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  /*
                  /*
                  If the textures coordinates are calculted then
                  If the textures coordinates are calculted then
                  move into the next triangle.
                  move into the next triangle.
                  */
                  */
                  `GFSM_WAIT_FOR_TCC:
                  `GFSM_WAIT_FOR_TCC:
                  begin
                  begin
 
 
                //              $display("GFSM_WAIT_FOR_TCC %d oSync = %d",$time,oSync);
                //              $display("GFSM_WAIT_FOR_TCC %d oSync = %d",$time,oSync);
                //              $display("GFSM_WAIT_FOR_TCC %d oRequest_TCC = %d",$time,oRequest_TCC);
                //              $display("GFSM_WAIT_FOR_TCC %d oRequest_TCC = %d",$time,oRequest_TCC);
 
 
                           oRequest_AABBIU              <= 0;
                           oRequest_AABBIU              <= 0;
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 1;
                                oRequest_TCC         <= 1;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                          if (iUCodeDone)
                          if (iUCodeDone)
                                        NextState <= `GFSM_CHECK_TRIANGLE_COUNT;
                                        NextState <= `GFSM_CHECK_TRIANGLE_COUNT;
                                else
                                else
                                        NextState <= `GFSM_WAIT_FOR_TCC;
                                        NextState <= `GFSM_WAIT_FOR_TCC;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
/*                `GFM_TRIGGER_TEXTURE_FETCH:
/*                `GFM_TRIGGER_TEXTURE_FETCH:
                  begin
                  begin
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= 0;
                                oWBM_Addr_Selector      <= 0;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oTrigger_TFF                    <= 1;
                                oTrigger_TFF                    <= 1;
 
 
                                NextState <= `GFSM_WAIT_FOR_TEXTURE_FETCH;
                                NextState <= `GFSM_WAIT_FOR_TEXTURE_FETCH;
                  end
                  end
 
 
                  //------------------------------------------
                  //------------------------------------------
                  `GFSM_WAIT_FOR_TEXTURE_FETCH:
                  `GFSM_WAIT_FOR_TEXTURE_FETCH:
                  begin
                  begin
 
 
                      oRequest_AABBIU           <= 0;
                      oRequest_AABBIU           <= 0;
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                IncTriangleCount                <= 0;
                                IncTriangleCount                <= 0;
                                oWBM_Addr_Selector      <= 0;
                                oWBM_Addr_Selector      <= 0;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oTrigger_TFF                    <= 0;
                                oTrigger_TFF                    <= 0;
 
 
                     if (iTextureReadDone == 1'b1)
                     if (iTextureReadDone == 1'b1)
                                        NextState <= `GFSM_CHECK_TRIANGLE_COUNT;
                                        NextState <= `GFSM_CHECK_TRIANGLE_COUNT;
                          else
                          else
                                        NextState <= `GFSM_WAIT_FOR_TEXTURE_FETCH;
                                        NextState <= `GFSM_WAIT_FOR_TEXTURE_FETCH;
 
 
                  end
                  end
                  */
                  */
                  //------------------------------------------
                  //------------------------------------------
                  `GFSM_CHECK_NEXT_BROTHER:
                  `GFSM_CHECK_NEXT_BROTHER:
                  begin
                  begin
 
 
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                IncTriangleCount                <= 0;    //*
                                IncTriangleCount                <= 0;    //*
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                if ( iNode_Brother_Address == 0 )
                                if ( iNode_Brother_Address == 0 )
                                        NextState <= `GFSM_CHECK_PARENTS_BROTHER;
                                        NextState <= `GFSM_CHECK_PARENTS_BROTHER;
                                else
                                else
                                        NextState <= `GFSM_GET_BROTHER;
                                        NextState <= `GFSM_GET_BROTHER;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  `GFSM_GET_BROTHER:
                  `GFSM_GET_BROTHER:
                  begin
                  begin
 
 
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oNodeAddress                    <= iNode_Brother_Address;       //*
                                oNodeAddress                    <= iNode_Brother_Address;       //*
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                IncTriangleCount                <= 0;    //*
                                IncTriangleCount                <= 0;    //*
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
 
 
                                NextState <= `GFSM_TRIGGER_NODE_FETCH;
                                NextState <= `GFSM_TRIGGER_NODE_FETCH;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  `GFSM_CHECK_PARENTS_BROTHER:
                  `GFSM_CHECK_PARENTS_BROTHER:
                  begin
                  begin
 
 
 
 
                                oNodeAddress                            <= 0;
                                oNodeAddress                            <= 0;
                                oRequest_AABBIU                 <= 0;
                                oRequest_AABBIU                 <= 0;
                                oRequest_BIU                            <= 0;
                                oRequest_BIU                            <= 0;
                                oTrigger_TFU                            <= 0;
                                oTrigger_TFU                            <= 0;
                                oTrigger_TNF                            <= 0;
                                oTrigger_TNF                            <= 0;
                                IncTriangleCount                <= 0;    //*
                                IncTriangleCount                <= 0;    //*
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                if ( iNode_Parents_Brother_Address == 0)
                                if ( iNode_Parents_Brother_Address == 0)
                                        NextState <= `GFSM_DONE;
                                        NextState <= `GFSM_DONE;
                                else
                                else
                                        NextState <= `GFSM_GET_PARENTS_BROTHER;
                                        NextState <= `GFSM_GET_PARENTS_BROTHER;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  `GFSM_GET_PARENTS_BROTHER:
                  `GFSM_GET_PARENTS_BROTHER:
                  begin
                  begin
                                oRequest_AABBIU                 <= 0;
                                oRequest_AABBIU                 <= 0;
                                oNodeAddress                    <= iNode_Parents_Brother_Address;       //*
                                oNodeAddress                    <= iNode_Parents_Brother_Address;       //*
                                oRequest_BIU                            <= 0;
                                oRequest_BIU                            <= 0;
                                oTrigger_TFU            <= 0;
                                oTrigger_TFU            <= 0;
                                oTrigger_TNF            <= 0;
                                oTrigger_TNF            <= 0;
                                IncTriangleCount                <= 0;    //*
                                IncTriangleCount                <= 0;    //*
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
 
 
                                NextState       <= `GFSM_TRIGGER_NODE_FETCH;
                                NextState       <= `GFSM_TRIGGER_NODE_FETCH;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  `GFSM_TRIGGER_NODE_FETCH:
                  `GFSM_TRIGGER_NODE_FETCH:
                  begin
                  begin
 
 
                                oRequest_AABBIU                 <= 0;
                                oRequest_AABBIU                 <= 0;
                                oNodeAddress                            <= iNode_Brother_Address;
                                oNodeAddress                            <= iNode_Brother_Address;
                                oRequest_BIU                            <= 0;
                                oRequest_BIU                            <= 0;
                                oTrigger_TFU            <= 1;   //*
                                oTrigger_TFU            <= 1;   //*
                                oTrigger_TNF            <= 0;
                                oTrigger_TNF            <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                IncTriangleCount                <= 0;    //*
                                IncTriangleCount                <= 0;    //*
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
 
 
                                NextState       <= `GFSM_WAIT_FOR_NODE_FETCH;
                                NextState       <= `GFSM_WAIT_FOR_NODE_FETCH;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  /*
                  /*
                                Lets read the new node in our linked list.
                                Lets read the new node in our linked list.
                                Once we got it we need to check AABB intersect,
                                Once we got it we need to check AABB intersect,
                                fetch traingles, etc, etc.
                                fetch traingles, etc, etc.
                  */
                  */
                  `GFSM_WAIT_FOR_NODE_FETCH:
                  `GFSM_WAIT_FOR_NODE_FETCH:
                  begin
                  begin
 
 
                                oRequest_AABBIU                 <= 0;
                                oRequest_AABBIU                 <= 0;
                                oNodeAddress                            <= iNode_Brother_Address;
                                oNodeAddress                            <= iNode_Brother_Address;
                                oRequest_BIU                            <= 0;
                                oRequest_BIU                            <= 0;
                                oTrigger_TFU            <= 1;
                                oTrigger_TFU            <= 1;
                                oTrigger_TNF            <= 0;
                                oTrigger_TNF            <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TFU;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_TFU;
                                IncTriangleCount                <= 0;    //*
                                IncTriangleCount                <= 0;    //*
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
                                if (iNodeReadDone)
                                if (iNodeReadDone)
                                        NextState <= `GFSM_TRIGGER_AABBIU;
                                        NextState <= `GFSM_TRIGGER_AABBIU;
                                else
                                else
                                        NextState <= `GFSM_WAIT_FOR_NODE_FETCH;
                                        NextState <= `GFSM_WAIT_FOR_NODE_FETCH;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  `GFSM_DONE:
                  `GFSM_DONE:
                  begin
                  begin
 
 
                        `ifdef DEBUG2
                        `ifdef DEBUG2
                                $display(" **** GFSM_DONE ***");
                                $display(" **** GFSM_DONE ***");
                        `endif
                        `endif
                                oNodeAddress                            <= 0;
                                oNodeAddress                            <= 0;
                                oRequest_AABBIU                 <= 0;
                                oRequest_AABBIU                 <= 0;
                                oRequest_BIU                            <= 0;
                                oRequest_BIU                            <= 0;
                                oTrigger_TFU                            <= 0;
                                oTrigger_TFU                            <= 0;
                                oTrigger_TNF                            <= 0;
                                oTrigger_TNF                            <= 0;
                                IncTriangleCount                <= 0;    //*
                                IncTriangleCount                <= 0;    //*
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                oSync                                           <= 1; //*
                                oSync                                           <= 1; //*
                                oDone                                           <= 1; //*
                                oDone                                           <= 1; //*
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
 
 
                                if (iEnable == 0 )
                                if (iEnable == 0 )
                                        NextState <= `GFSM_INITIAL_STATE;
                                        NextState <= `GFSM_INITIAL_STATE;
                                else
                                else
                                        NextState <= `GFSM_DONE;
                                        NextState <= `GFSM_DONE;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  default:
                  default:
                  begin
                  begin
 
 
 
 
                                oRequest_AABBIU         <= 0;
                                oRequest_AABBIU         <= 0;
                                oNodeAddress                    <= 0;
                                oNodeAddress                    <= 0;
                                oRequest_BIU                    <= 0;
                                oRequest_BIU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TFU                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oTrigger_TNF                    <= 0;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                oWBM_Addr_Selector      <= `GFSM_SELECT_NULL;
                                IncTriangleCount                <= 0;    //*
                                IncTriangleCount                <= 0;    //*
                                oWBM_Addr_Selector      <= 0;
                                oWBM_Addr_Selector      <= 0;
                                ClearTriangleCount      <= 0;
                                ClearTriangleCount      <= 0;
                                oSync                                           <= 0;
                                oSync                                           <= 0;
                                oDone                                           <= 0;
                                oDone                                           <= 0;
                                oSetTFUAddressOffset <= 0;
                                oSetTFUAddressOffset <= 0;
                                oRequest_TCC         <= 0;
                                oRequest_TCC         <= 0;
 
 
                                oEnable_WBM                   <= 0;
                                oEnable_WBM                   <= 0;
                                oSetAddressWBM                <= 0;
                                oSetAddressWBM                <= 0;
                                //IncTextureWriteAddress        <= 0;
                                //IncTextureWriteAddress        <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCount       <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                IncTextureCoordRegrAddr      <= 0;
                                oSetIOWriteBackAddr <= 0;
                                oSetIOWriteBackAddr <= 0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
                                //oRAMTextureStoreLocation <= `DATA_ADDRESS_WIDTH'd0;
 
 
 
 
                                NextState <= `GFSM_AFTER_RESET;
                                NextState <= `GFSM_AFTER_RESET;
                  end
                  end
                  endcase
                  endcase
        end
        end
        //------------------------------------------------
        //------------------------------------------------
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

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