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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_1.1/] [rtl/] [GEO/] [Unit_GEO.v] - Diff between revs 27 and 58

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

Rev 27 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:
 
 
The scene geomtry is assumed to be grouped in a balance tree, specifically a
The scene geomtry is assumed to be grouped in a balance tree, specifically a
OCT tree.
OCT tree.
Geometry unit is responsible for traversing this tree and requesting the geoemtry
Geometry unit is responsible for traversing this tree and requesting the geoemtry
primitives accordingly.
primitives accordingly.
The root of the tree has global information on the scene, and each node
The root of the tree has global information on the scene, and each node
can have up to 8 child nodes. Leafs can have geometry on it or not depending on the
can have up to 8 child nodes. Leafs can have geometry on it or not depending on the
tree generation algorith.
tree generation algorith.
In the scenario where AABBIU is not used, the tree has a single node and a single leaf,
In the scenario where AABBIU is not used, the tree has a single node and a single leaf,
which is the the root of the tree.
which is the the root of the tree.
The geomrty unit groups a series of modules that are in charge of fetching
The geomrty unit groups a series of modules that are in charge of fetching
the various types of geometry. Depending on weather you are using AABBIU or not
the various types of geometry. Depending on weather you are using AABBIU or not
and wether you have texturing enabled or not, the way in which the primitives
and wether you have texturing enabled or not, the way in which the primitives
and data structures are requested varies.
and data structures are requested varies.
 
 
***********************************************************************************/
***********************************************************************************/
 
 
 
 
`timescale 1ns / 1ps
`timescale 1ns / 1ps
`include "aDefinitions.v"
`include "aDefinitions.v"
 
 
`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
 
 
module GeometryUnit
module GeometryUnit
(
(
 
 
        input  wire                           Clock,
        input  wire                           Clock,
        input  wire                           Reset,
        input  wire                           Reset,
        input  wire                           iEnable,
        input  wire                           iEnable,
        input wire                            iTexturingEnable,
        input wire                            iTexturingEnable,
        input   wire [`WIDTH-1:0]               iData_WBM,
        input   wire [`WIDTH-1:0]               iData_WBM,
        input wire                            iDataReady_WBM,
        input wire                            iDataReady_WBM,
        output wire [`WIDTH-1:0]              oAddressWBM_Imm,
        output wire [`WIDTH-1:0]              oAddressWBM_Imm,
        output wire                           oAddressWBM_IsImm,
        output wire                           oAddressWBM_IsImm,
        output wire [`DATA_ADDRESS_WIDTH-1:0] oAddressWBM_fromMEM,
        output wire [`DATA_ADDRESS_WIDTH-1:0] oAddressWBM_fromMEM,
        output wire                           oEnable_WBM,
        output wire                           oEnable_WBM,
        output wire                           oSetAddressWBM,
        output wire                           oSetAddressWBM,
        output wire                           oRequest_AABBIU,
        output wire                           oRequest_AABBIU,
        output wire                           oRequest_BIU,
        output wire                           oRequest_BIU,
        output wire                           oRequest_TCC,
        output wire                           oRequest_TCC,
        output wire[`DATA_ADDRESS_WIDTH-1:0]  oRAMWriteAddress,
        output wire[`DATA_ADDRESS_WIDTH-1:0]  oRAMWriteAddress,
        output wire                           oRAMWriteEnable,
        output wire                           oRAMWriteEnable,
        input wire                            iMicrocodeExecutionDone,
        input wire                            iMicrocodeExecutionDone,
        input wire                            iMicroCodeReturnValue,
        input wire                            iMicroCodeReturnValue,
        output wire                           oRequestingTextures,
        output wire                           oRequestingTextures,
        input wire                            iTrigger_TFF,
        input wire                            iTrigger_TFF,
        input wire                            iBIUHit,
        input wire                            iBIUHit,
        output wire                           oTFFDone,
        output wire                           oTFFDone,
        output wire                           oSync,
        output wire                           oSync,
        output wire                           oSetIOWriteBackAddr,
        output wire                           oSetIOWriteBackAddr,
        output wire                           oDone
        output wire                           oDone
);
);
 
 
 
 
 
 
 
 
        //Unit interconnections 
        //Unit interconnections 
        wire wTrigger_TNF;                                 //Trigger Tree Node Fetch Unit.      GSFM -> TNF
        wire wTrigger_TNF;                                 //Trigger Tree Node Fetch Unit.      GSFM -> TNF
        wire wTrigger_TFU;                                 //Trigger Data Fetch Unit.                   GFSM -> TFU     
        wire wTrigger_TFU;                                 //Trigger Data Fetch Unit.                   GFSM -> TFU     
        //wire wTrigger_TFF;                                                                                    //Trigger testure Fetch Unit.           GFSM -> TFF     
        //wire wTrigger_TFF;                                                                                    //Trigger testure Fetch Unit.           GFSM -> TFF     
        wire [`WIDTH-1:0] wNodeAddress;                    //Address of the current Node.        GFSM -> TNF
        wire [`WIDTH-1:0] wNodeAddress;                    //Address of the current Node.        GFSM -> TNF
        wire [`WIDTH-1:0] wTNF2_TFU__TriangleDataOffset;   //Offset of the vertex Data.          TNF  -> GFSM
        wire [`WIDTH-1:0] wTNF2_TFU__TriangleDataOffset;   //Offset of the vertex Data.          TNF  -> GFSM
        wire [`WIDTH-1:0] wNode_TriangleCount;             //Number of traingles in this node. TNF -> GFSM
        wire [`WIDTH-1:0] wNode_TriangleCount;             //Number of traingles in this node. TNF -> GFSM
        wire [`WIDTH-1:0] wNode_Brother_Address;           //Address of the currents Node Brother. TNF -> GFSM
        wire [`WIDTH-1:0] wNode_Brother_Address;           //Address of the currents Node Brother. TNF -> GFSM
        wire [`WIDTH-1:0] wParents_Brother_Address;        //Address of the Brother of current node's parent. TNF -> GFSM
        wire [`WIDTH-1:0] wParents_Brother_Address;        //Address of the Brother of current node's parent. TNF -> GFSM
        wire [`WIDTH-1:0] wAddress_TFU;
        wire [`WIDTH-1:0] wAddress_TFU;
        //wire [`DATA_ADDRESS_WIDTH-1:0] wAddress_TFF;
        //wire [`DATA_ADDRESS_WIDTH-1:0] wAddress_TFF;
        wire [`WIDTH-1:0] wAddress_TNF;
        wire [`WIDTH-1:0] wAddress_TNF;
        wire [`DATA_ADDRESS_WIDTH-1:0] wRAMWriteAddress_TFU;
        wire [`DATA_ADDRESS_WIDTH-1:0] wRAMWriteAddress_TFU;
        wire [`DATA_ADDRESS_WIDTH-1:0] wRAMWriteAddress_TFF;
        wire [`DATA_ADDRESS_WIDTH-1:0] wRAMWriteAddress_TFF;
        wire [`DATA_ADDRESS_WIDTH-1:0] wRAMWriteAddress_TNF;
        wire [`DATA_ADDRESS_WIDTH-1:0] wRAMWriteAddress_TNF;
        wire [1:0] wWBM_Address_Selector;
        wire [1:0] wWBM_Address_Selector;
        wire wTFN_Enable_WBM,wNode_IsLeaf;
        wire wTFN_Enable_WBM,wNode_IsLeaf;
        wire wTNF2__SetAddressWBM, wTFU2__SetAddressWBM,wTFF2__SetAddressWBM;
        wire wTNF2__SetAddressWBM, wTFU2__SetAddressWBM,wTFF2__SetAddressWBM;
        wire wRAMWriteEnable_TFF;
        wire wRAMWriteEnable_TFF;
        wire wNodeReadDone,wRAMWriteEnable_TNF,wTriangleReadDone,wTextureFetchDone;
        wire wNodeReadDone,wRAMWriteEnable_TNF,wTriangleReadDone,wTextureFetchDone;
        wire wTFU_Trigger_WBM,wTFF_Trigger_WBM,wRAMWriteEnable_TFU;
        wire wTFU_Trigger_WBM,wTFF_Trigger_WBM,wRAMWriteEnable_TFU;
        wire wGFSM2_TFU__SetAddressOffset;
        wire wGFSM2_TFU__SetAddressOffset;
 
 
assign oEnable_WBM = wTFN_Enable_WBM ^ wTFU_Trigger_WBM ^ wTFF_Trigger_WBM; //XXX TODO: Wath out!
assign oEnable_WBM = wTFN_Enable_WBM ^ wTFU_Trigger_WBM ^ wTFF_Trigger_WBM; //XXX TODO: Wath out!
 
 
 
 
assign oRequestingTextures = (wWBM_Address_Selector == `GFSM_SELECT_TFF ) ? 1 : 0;
assign oRequestingTextures = (wWBM_Address_Selector == `GFSM_SELECT_TFF ) ? 1 : 0;
assign oAddressWBM_Imm = ( wWBM_Address_Selector == `GFSM_SELECT_TFU ) ? wAddress_TFU : wAddress_TNF;
assign oAddressWBM_Imm = ( wWBM_Address_Selector == `GFSM_SELECT_TFU ) ? wAddress_TFU : wAddress_TNF;
assign oRAMWriteEnable = ( wWBM_Address_Selector == `GFSM_SELECT_TFU ) ? wRAMWriteEnable_TFU : wRAMWriteEnable_TNF;
assign oRAMWriteEnable = ( wWBM_Address_Selector == `GFSM_SELECT_TFU ) ? wRAMWriteEnable_TFU : wRAMWriteEnable_TNF;
 
 
assign oAddressWBM_IsImm =
assign oAddressWBM_IsImm =
( !iTexturingEnable || (iTexturingEnable &&
( !iTexturingEnable || (iTexturingEnable &&
 (wWBM_Address_Selector == `GFSM_SELECT_TFU || wWBM_Address_Selector == `GFSM_SELECT_TNF) ))
 (wWBM_Address_Selector == `GFSM_SELECT_TFU || wWBM_Address_Selector == `GFSM_SELECT_TNF) ))
 ? 1'b1 : 1'b0;
 ? 1'b1 : 1'b0;
 
 
//--------------------------------------------------------
//--------------------------------------------------------
//Mux for oRAMWriteAddress
//Mux for oRAMWriteAddress
MUXFULLPARALELL_16bits_2SEL_X MUXGE_1B
MUXFULLPARALELL_16bits_2SEL_X MUXGE_1B
(
(
        .I1( wRAMWriteAddress_TFU ),
        .I1( wRAMWriteAddress_TFU ),
        .I2( wRAMWriteAddress_TFF ),
        .I2( wRAMWriteAddress_TFF ),
        .I3( wRAMWriteAddress_TNF ),
        .I3( wRAMWriteAddress_TNF ),
        .O1( oRAMWriteAddress ),
        .O1( oRAMWriteAddress ),
        .Sel( wWBM_Address_Selector )
        .Sel( wWBM_Address_Selector )
);
);
 
 
//--------------------------------------------------------
//--------------------------------------------------------
 
 
assign oSetAddressWBM = wTNF2__SetAddressWBM | wTFU2__SetAddressWBM | wTFF2__SetAddressWBM;
assign oSetAddressWBM = wTNF2__SetAddressWBM | wTFU2__SetAddressWBM | wTFF2__SetAddressWBM;
 
 
 
 
//------------------------------------------------      
//------------------------------------------------      
 
 
/*
/*
        Tree node fetcher: Takes care of resquesting
        Tree node fetcher: Takes care of resquesting
        node information. TNF requests Read Bus Cycles
        node information. TNF requests Read Bus Cycles
        from the Wish Bone Master Unit. TNF is controlled
        from the Wish Bone Master Unit. TNF is controlled
        by the GFSM.
        by the GFSM.
*/
*/
TreeNodeFetcher TNF
TreeNodeFetcher TNF
(
(
        .Clock( Clock ),
        .Clock( Clock ),
        .Reset( Reset ),
        .Reset( Reset ),
        .iData(                    iData_WBM                     ),
        .iData(                    iData_WBM                     ),
        .iDataAvailable(           iDataReady_WBM                ),
        .iDataAvailable(           iDataReady_WBM                ),
        .oEnableWBM(         wTFN_Enable_WBM              ),
        .oEnableWBM(         wTFN_Enable_WBM              ),
        .oSetAddressWBM(           wTNF2__SetAddressWBM          ),
        .oSetAddressWBM(           wTNF2__SetAddressWBM          ),
        .oAddressWBM(              wAddress_TNF                  ),
        .oAddressWBM(              wAddress_TNF                  ),
        .iInitialAddress(          wNodeAddress                  ),
        .iInitialAddress(          wNodeAddress                  ),
        .iTrigger(                 wTrigger_TNF                  ),
        .iTrigger(                 wTrigger_TNF                  ),
        .oNode_IsLeaf(             wNode_IsLeaf                  ),
        .oNode_IsLeaf(             wNode_IsLeaf                  ),
        .oNodeReadDone(            wNodeReadDone                 ),
        .oNodeReadDone(            wNodeReadDone                 ),
        .oNode_TriangleCount(      wNode_TriangleCount           ),
        .oNode_TriangleCount(      wNode_TriangleCount           ),
        .oNode_Brother_Address(    wNode_Brother_Address         ),
        .oNode_Brother_Address(    wNode_Brother_Address         ),
        .oParents_Brother_Address( wParents_Brother_Address      ),
        .oParents_Brother_Address( wParents_Brother_Address      ),
        .oNode_DataOffset(         wTNF2_TFU__TriangleDataOffset ),
        .oNode_DataOffset(         wTNF2_TFU__TriangleDataOffset ),
        .oRAMWriteEnable(          wRAMWriteEnable_TNF           ),
        .oRAMWriteEnable(          wRAMWriteEnable_TNF           ),
        .oRAMWriteAddress(         wRAMWriteAddress_TNF          )
        .oRAMWriteAddress(         wRAMWriteAddress_TNF          )
 
 
);
);
//------------------------------------------------
//------------------------------------------------
/*
/*
        Triangle Fetch Unit: Takes care of resquesting
        Triangle Fetch Unit: Takes care of resquesting
        triangle information. TFU requests Read Bus Cycles
        triangle information. TFU requests Read Bus Cycles
        from the Wish Bone Master Unit. TFU is controlled
        from the Wish Bone Master Unit. TFU is controlled
        by the GFSM.
        by the GFSM.
*/
*/
TriangleFetchUnit TFU
TriangleFetchUnit TFU
(
(
        .Clock( Clock ),
        .Clock( Clock ),
        .Reset( Reset ),
        .Reset( Reset ),
        .iTrigger(                     wTrigger_TFU                  ),
        .iTrigger(                     wTrigger_TFU                  ),
        .iInitialAddress(              wTNF2_TFU__TriangleDataOffset ),
        .iInitialAddress(              wTNF2_TFU__TriangleDataOffset ),
        .iSetAddressOffset(            wGFSM2_TFU__SetAddressOffset  ),
        .iSetAddressOffset(            wGFSM2_TFU__SetAddressOffset  ),
        .iDataAvailable(               iDataReady_WBM                ),
        .iDataAvailable(               iDataReady_WBM                ),
        .oAddressWBM(                  wAddress_TFU                  ),
        .oAddressWBM(                  wAddress_TFU                  ),
        .oSetAddressWBM(               wTFU2__SetAddressWBM          ),
        .oSetAddressWBM(               wTFU2__SetAddressWBM          ),
        .oTriggerWBM(                  wTFU_Trigger_WBM              ),
        .oTriggerWBM(                  wTFU_Trigger_WBM              ),
        .oRAMWriteEnable(              wRAMWriteEnable_TFU           ),
        .oRAMWriteEnable(              wRAMWriteEnable_TFU           ),
        .iCR_TextureMappingEnabled(    iTexturingEnable              ),
        .iCR_TextureMappingEnabled(    iTexturingEnable              ),
        .oRAMWriteAddress(             wRAMWriteAddress_TFU          ),
        .oRAMWriteAddress(             wRAMWriteAddress_TFU          ),
        .oDone(                        wTriangleReadDone             )
        .oDone(                        wTriangleReadDone             )
);
);
 
 
//------------------------------------------------      
//------------------------------------------------      
/*
/*
        Geometry Fetch Finite State Machine: Takes care of resquesting
        Geometry Fetch Finite State Machine: Takes care of resquesting
        the control of the various geometry fetching routines. It controls
        the control of the various geometry fetching routines. It controls
        TFF,TFU and TNF.
        TFF,TFU and TNF.
*/
*/
GeometryFetchFSM  GFSM //TODO: Add new states to fetch the texures
GeometryFetchFSM  GFSM //TODO: Add new states to fetch the texures
(
(
        .Clock( Clock ),
        .Clock( Clock ),
        .Reset( Reset ),
        .Reset( Reset ),
        .iBIUHit(                       iBIUHit                      ),
        .iBIUHit(                       iBIUHit                      ),
        .iTexturingEnable(              iTexturingEnable             ),
        .iTexturingEnable(              iTexturingEnable             ),
        .iEnable(                       iEnable                      ),
        .iEnable(                       iEnable                      ),
        .iAABBIUHit(                    iMicroCodeReturnValue        ),
        .iAABBIUHit(                    iMicroCodeReturnValue        ),
        .iUCodeDone(                    iMicrocodeExecutionDone      ),
        .iUCodeDone(                    iMicrocodeExecutionDone      ),
        .iTriangleReadDone(             wTriangleReadDone            ),
        .iTriangleReadDone(             wTriangleReadDone            ),
        .iNode_TriangleCount(           wNode_TriangleCount          ),
        .iNode_TriangleCount(           wNode_TriangleCount          ),
        .iNode_Brother_Address(         wNode_Brother_Address        ),
        .iNode_Brother_Address(         wNode_Brother_Address        ),
        .iNode_Parents_Brother_Address( wParents_Brother_Address     ),
        .iNode_Parents_Brother_Address( wParents_Brother_Address     ),
        .iNode_IsLeaf(                  wNode_IsLeaf                 ),
        .iNode_IsLeaf(                  wNode_IsLeaf                 ),
        .iNodeReadDone(                 wNodeReadDone                ),
        .iNodeReadDone(                 wNodeReadDone                ),
        .oTrigger_TNF(                  wTrigger_TNF                 ),
        .oTrigger_TNF(                  wTrigger_TNF                 ),
        .oTrigger_TFU(                  wTrigger_TFU                 ),
        .oTrigger_TFU(                  wTrigger_TFU                 ),
        .oNodeAddress(                  wNodeAddress                 ),
        .oNodeAddress(                  wNodeAddress                 ),
        .oRequest_AABBIU(               oRequest_AABBIU              ),
        .oRequest_AABBIU(               oRequest_AABBIU              ),
        .oRequest_BIU(                  oRequest_BIU                 ),
        .oRequest_BIU(                  oRequest_BIU                 ),
        .oRequest_TCC(                  oRequest_TCC                 ),
        .oRequest_TCC(                  oRequest_TCC                 ),
        .oWBM_Addr_Selector(            wWBM_Address_Selector        ),
        .oWBM_Addr_Selector(            wWBM_Address_Selector        ),
        .oSync(                         oSync                        ),
        .oSync(                         oSync                        ),
        .oSetTFUAddressOffset(          wGFSM2_TFU__SetAddressOffset ),
        .oSetTFUAddressOffset(          wGFSM2_TFU__SetAddressOffset ),
        .oDone(                         oDone                        ),
        .oDone(                         oDone                        ),
        .iDataAvailable(                                  iDataReady_WBM               ),
        .iDataAvailable(                                  iDataReady_WBM               ),
        .oEnable_WBM(                             wTFF_Trigger_WBM             ),
        .oEnable_WBM(                             wTFF_Trigger_WBM             ),
        .oAddressWBM(                                     oAddressWBM_fromMEM          ),
        .oAddressWBM(                                     oAddressWBM_fromMEM          ),
        .oSetAddressWBM(                                  wTFF2__SetAddressWBM         ),
        .oSetAddressWBM(                                  wTFF2__SetAddressWBM         ),
        .iTrigger_TFF(                  iTrigger_TFF                 ),
        .iTrigger_TFF(                  iTrigger_TFF                 ),
        .oSetIOWriteBackAddr(           oSetIOWriteBackAddr          ),
        .oSetIOWriteBackAddr(           oSetIOWriteBackAddr          ),
        .oRAMTextureStoreLocation(      wRAMWriteAddress_TFF         )
        .oRAMTextureStoreLocation(      wRAMWriteAddress_TFF         )
 
 
);
);
assign oTFFDone = oDone;
assign oTFFDone = oDone;
 
 
//-------------------------------------------------     
//-------------------------------------------------     
 
 
 
 
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

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