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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [tags/] [Beta_0.2/] [rtl/] [GEO/] [Unit_GEO.v] - Blame information for rev 27

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

Line No. Rev Author Line
1 27 diegovalve
/**********************************************************************************
2
Theaia, Ray Cast Programable graphic Processing Unit.
3
Copyright (C) 2009  Diego Valverde (diego.valverde.g@gmail.com)
4
 
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License
7
as published by the Free Software Foundation; either version 2
8
of the License, or (at your option) any later version.
9
 
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
GNU General Public License for more details.
14
 
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
 
19
***********************************************************************************/
20
 
21
/**********************************************************************************
22
Module Description:
23
 
24
The scene geomtry is assumed to be grouped in a balance tree, specifically a
25
OCT tree.
26
Geometry unit is responsible for traversing this tree and requesting the geoemtry
27
primitives accordingly.
28
The root of the tree has global information on the scene, and each node
29
can have up to 8 child nodes. Leafs can have geometry on it or not depending on the
30
tree generation algorith.
31
In the scenario where AABBIU is not used, the tree has a single node and a single leaf,
32
which is the the root of the tree.
33
The geomrty unit groups a series of modules that are in charge of fetching
34
the various types of geometry. Depending on weather you are using AABBIU or not
35
and wether you have texturing enabled or not, the way in which the primitives
36
and data structures are requested varies.
37
 
38
***********************************************************************************/
39
 
40
 
41
`timescale 1ns / 1ps
42
`include "aDefinitions.v"
43
 
44
`define GFSM_SELECT_TFU 2'b00  //Triangle Fetch
45
`define GFSM_SELECT_TFF 2'b01  //Texture Fetch
46
`define GFSM_SELECT_TNF 2'b10  //Tree node fetch
47
`define GFSM_SELECT_NULL 2'b11
48
 
49
module GeometryUnit
50
(
51
 
52
        input  wire                           Clock,
53
        input  wire                           Reset,
54
        input  wire                           iEnable,
55
        input wire                            iTexturingEnable,
56
        input   wire [`WIDTH-1:0]               iData_WBM,
57
        input wire                            iDataReady_WBM,
58
        output wire [`WIDTH-1:0]              oAddressWBM_Imm,
59
        output wire                           oAddressWBM_IsImm,
60
        output wire [`DATA_ADDRESS_WIDTH-1:0] oAddressWBM_fromMEM,
61
        output wire                           oEnable_WBM,
62
        output wire                           oSetAddressWBM,
63
        output wire                           oRequest_AABBIU,
64
        output wire                           oRequest_BIU,
65
        output wire                           oRequest_TCC,
66
        output wire[`DATA_ADDRESS_WIDTH-1:0]  oRAMWriteAddress,
67
        output wire                           oRAMWriteEnable,
68
        input wire                            iMicrocodeExecutionDone,
69
        input wire                            iMicroCodeReturnValue,
70
        output wire                           oRequestingTextures,
71
        input wire                            iTrigger_TFF,
72
        input wire                            iBIUHit,
73
        output wire                           oTFFDone,
74
        output wire                           oSync,
75
        output wire                           oSetIOWriteBackAddr,
76
        output wire                           oDone
77
);
78
 
79
 
80
 
81
 
82
        //Unit interconnections 
83
        wire wTrigger_TNF;                                 //Trigger Tree Node Fetch Unit.      GSFM -> TNF
84
        wire wTrigger_TFU;                                 //Trigger Data Fetch Unit.                   GFSM -> TFU     
85
        //wire wTrigger_TFF;                                                                                    //Trigger testure Fetch Unit.           GFSM -> TFF     
86
        wire [`WIDTH-1:0] wNodeAddress;                    //Address of the current Node.        GFSM -> TNF
87
        wire [`WIDTH-1:0] wTNF2_TFU__TriangleDataOffset;   //Offset of the vertex Data.          TNF  -> GFSM
88
        wire [`WIDTH-1:0] wNode_TriangleCount;             //Number of traingles in this node. TNF -> GFSM
89
        wire [`WIDTH-1:0] wNode_Brother_Address;           //Address of the currents Node Brother. TNF -> GFSM
90
        wire [`WIDTH-1:0] wParents_Brother_Address;        //Address of the Brother of current node's parent. TNF -> GFSM
91
        wire [`WIDTH-1:0] wAddress_TFU;
92
        //wire [`DATA_ADDRESS_WIDTH-1:0] wAddress_TFF;
93
        wire [`WIDTH-1:0] wAddress_TNF;
94
        wire [`DATA_ADDRESS_WIDTH-1:0] wRAMWriteAddress_TFU;
95
        wire [`DATA_ADDRESS_WIDTH-1:0] wRAMWriteAddress_TFF;
96
        wire [`DATA_ADDRESS_WIDTH-1:0] wRAMWriteAddress_TNF;
97
        wire [1:0] wWBM_Address_Selector;
98
        wire wTFN_Enable_WBM,wNode_IsLeaf;
99
        wire wTNF2__SetAddressWBM, wTFU2__SetAddressWBM,wTFF2__SetAddressWBM;
100
        wire wRAMWriteEnable_TFF;
101
        wire wNodeReadDone,wRAMWriteEnable_TNF,wTriangleReadDone,wTextureFetchDone;
102
        wire wTFU_Trigger_WBM,wTFF_Trigger_WBM,wRAMWriteEnable_TFU;
103
        wire wGFSM2_TFU__SetAddressOffset;
104
 
105
assign oEnable_WBM = wTFN_Enable_WBM ^ wTFU_Trigger_WBM ^ wTFF_Trigger_WBM; //XXX TODO: Wath out!
106
 
107
 
108
assign oRequestingTextures = (wWBM_Address_Selector == `GFSM_SELECT_TFF ) ? 1 : 0;
109
assign oAddressWBM_Imm = ( wWBM_Address_Selector == `GFSM_SELECT_TFU ) ? wAddress_TFU : wAddress_TNF;
110
assign oRAMWriteEnable = ( wWBM_Address_Selector == `GFSM_SELECT_TFU ) ? wRAMWriteEnable_TFU : wRAMWriteEnable_TNF;
111
 
112
assign oAddressWBM_IsImm =
113
( !iTexturingEnable || (iTexturingEnable &&
114
 (wWBM_Address_Selector == `GFSM_SELECT_TFU || wWBM_Address_Selector == `GFSM_SELECT_TNF) ))
115
 ? 1'b1 : 1'b0;
116
 
117
//--------------------------------------------------------
118
//Mux for oRAMWriteAddress
119
MUXFULLPARALELL_16bits_2SEL_X MUXGE_1B
120
(
121
        .I1( wRAMWriteAddress_TFU ),
122
        .I2( wRAMWriteAddress_TFF ),
123
        .I3( wRAMWriteAddress_TNF ),
124
        .O1( oRAMWriteAddress ),
125
        .Sel( wWBM_Address_Selector )
126
);
127
 
128
//--------------------------------------------------------
129
 
130
assign oSetAddressWBM = wTNF2__SetAddressWBM | wTFU2__SetAddressWBM | wTFF2__SetAddressWBM;
131
 
132
 
133
//------------------------------------------------      
134
 
135
/*
136
        Tree node fetcher: Takes care of resquesting
137
        node information. TNF requests Read Bus Cycles
138
        from the Wish Bone Master Unit. TNF is controlled
139
        by the GFSM.
140
*/
141
TreeNodeFetcher TNF
142
(
143
        .Clock( Clock ),
144
        .Reset( Reset ),
145
        .iData(                    iData_WBM                     ),
146
        .iDataAvailable(           iDataReady_WBM                ),
147
        .oEnableWBM(         wTFN_Enable_WBM              ),
148
        .oSetAddressWBM(           wTNF2__SetAddressWBM          ),
149
        .oAddressWBM(              wAddress_TNF                  ),
150
        .iInitialAddress(          wNodeAddress                  ),
151
        .iTrigger(                 wTrigger_TNF                  ),
152
        .oNode_IsLeaf(             wNode_IsLeaf                  ),
153
        .oNodeReadDone(            wNodeReadDone                 ),
154
        .oNode_TriangleCount(      wNode_TriangleCount           ),
155
        .oNode_Brother_Address(    wNode_Brother_Address         ),
156
        .oParents_Brother_Address( wParents_Brother_Address      ),
157
        .oNode_DataOffset(         wTNF2_TFU__TriangleDataOffset ),
158
        .oRAMWriteEnable(          wRAMWriteEnable_TNF           ),
159
        .oRAMWriteAddress(         wRAMWriteAddress_TNF          )
160
 
161
);
162
//------------------------------------------------
163
/*
164
        Triangle Fetch Unit: Takes care of resquesting
165
        triangle information. TFU requests Read Bus Cycles
166
        from the Wish Bone Master Unit. TFU is controlled
167
        by the GFSM.
168
*/
169
TriangleFetchUnit TFU
170
(
171
        .Clock( Clock ),
172
        .Reset( Reset ),
173
        .iTrigger(                     wTrigger_TFU                  ),
174
        .iInitialAddress(              wTNF2_TFU__TriangleDataOffset ),
175
        .iSetAddressOffset(            wGFSM2_TFU__SetAddressOffset  ),
176
        .iDataAvailable(               iDataReady_WBM                ),
177
        .oAddressWBM(                  wAddress_TFU                  ),
178
        .oSetAddressWBM(               wTFU2__SetAddressWBM          ),
179
        .oTriggerWBM(                  wTFU_Trigger_WBM              ),
180
        .oRAMWriteEnable(              wRAMWriteEnable_TFU           ),
181
        .iCR_TextureMappingEnabled(    iTexturingEnable              ),
182
        .oRAMWriteAddress(             wRAMWriteAddress_TFU          ),
183
        .oDone(                        wTriangleReadDone             )
184
);
185
 
186
//------------------------------------------------      
187
/*
188
        Geometry Fetch Finite State Machine: Takes care of resquesting
189
        the control of the various geometry fetching routines. It controls
190
        TFF,TFU and TNF.
191
*/
192
GeometryFetchFSM  GFSM //TODO: Add new states to fetch the texures
193
(
194
        .Clock( Clock ),
195
        .Reset( Reset ),
196
        .iBIUHit(                       iBIUHit                      ),
197
        .iTexturingEnable(              iTexturingEnable             ),
198
        .iEnable(                       iEnable                      ),
199
        .iAABBIUHit(                    iMicroCodeReturnValue        ),
200
        .iUCodeDone(                    iMicrocodeExecutionDone      ),
201
        .iTriangleReadDone(             wTriangleReadDone            ),
202
        .iNode_TriangleCount(           wNode_TriangleCount          ),
203
        .iNode_Brother_Address(         wNode_Brother_Address        ),
204
        .iNode_Parents_Brother_Address( wParents_Brother_Address     ),
205
        .iNode_IsLeaf(                  wNode_IsLeaf                 ),
206
        .iNodeReadDone(                 wNodeReadDone                ),
207
        .oTrigger_TNF(                  wTrigger_TNF                 ),
208
        .oTrigger_TFU(                  wTrigger_TFU                 ),
209
        .oNodeAddress(                  wNodeAddress                 ),
210
        .oRequest_AABBIU(               oRequest_AABBIU              ),
211
        .oRequest_BIU(                  oRequest_BIU                 ),
212
        .oRequest_TCC(                  oRequest_TCC                 ),
213
        .oWBM_Addr_Selector(            wWBM_Address_Selector        ),
214
        .oSync(                         oSync                        ),
215
        .oSetTFUAddressOffset(          wGFSM2_TFU__SetAddressOffset ),
216
        .oDone(                         oDone                        ),
217
        .iDataAvailable(                                  iDataReady_WBM               ),
218
        .oEnable_WBM(                             wTFF_Trigger_WBM             ),
219
        .oAddressWBM(                                     oAddressWBM_fromMEM          ),
220
        .oSetAddressWBM(                                  wTFF2__SetAddressWBM         ),
221
        .iTrigger_TFF(                  iTrigger_TFF                 ),
222
        .oSetIOWriteBackAddr(           oSetIOWriteBackAddr          ),
223
        .oRAMTextureStoreLocation(      wRAMWriteAddress_TFF         )
224
 
225
);
226
assign oTFFDone = oDone;
227
 
228
//-------------------------------------------------     
229
 
230
 
231
endmodule

powered by: WebSVN 2.1.0

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