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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_1.2/] [rtl/] [GEO/] [Unit_GEO.v] - Blame information for rev 116

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 82 diegovalve
        output wire                           oSetIOWriteBackAddr,
76
        input wire                            iIOBusy,
77
 
78
        `ifdef DEBUG
79
        input wire[`MAX_CORES-1:0]            iDebug_CoreID,
80
        `endif
81 27 diegovalve
        output wire                           oDone
82
);
83
 
84
 
85
 
86
 
87
        //Unit interconnections 
88
        wire wTrigger_TNF;                                 //Trigger Tree Node Fetch Unit.      GSFM -> TNF
89
        wire wTrigger_TFU;                                 //Trigger Data Fetch Unit.                   GFSM -> TFU     
90
        //wire wTrigger_TFF;                                                                                    //Trigger testure Fetch Unit.           GFSM -> TFF     
91
        wire [`WIDTH-1:0] wNodeAddress;                    //Address of the current Node.        GFSM -> TNF
92
        wire [`WIDTH-1:0] wTNF2_TFU__TriangleDataOffset;   //Offset of the vertex Data.          TNF  -> GFSM
93
        wire [`WIDTH-1:0] wNode_TriangleCount;             //Number of traingles in this node. TNF -> GFSM
94
        wire [`WIDTH-1:0] wNode_Brother_Address;           //Address of the currents Node Brother. TNF -> GFSM
95
        wire [`WIDTH-1:0] wParents_Brother_Address;        //Address of the Brother of current node's parent. TNF -> GFSM
96
        wire [`WIDTH-1:0] wAddress_TFU;
97
        //wire [`DATA_ADDRESS_WIDTH-1:0] wAddress_TFF;
98
        wire [`WIDTH-1:0] wAddress_TNF;
99
        wire [`DATA_ADDRESS_WIDTH-1:0] wRAMWriteAddress_TFU;
100
        wire [`DATA_ADDRESS_WIDTH-1:0] wRAMWriteAddress_TFF;
101
        wire [`DATA_ADDRESS_WIDTH-1:0] wRAMWriteAddress_TNF;
102
        wire [1:0] wWBM_Address_Selector;
103
        wire wTFN_Enable_WBM,wNode_IsLeaf;
104
        wire wTNF2__SetAddressWBM, wTFU2__SetAddressWBM,wTFF2__SetAddressWBM;
105
        wire wRAMWriteEnable_TFF;
106
        wire wNodeReadDone,wRAMWriteEnable_TNF,wTriangleReadDone,wTextureFetchDone;
107
        wire wTFU_Trigger_WBM,wTFF_Trigger_WBM,wRAMWriteEnable_TFU;
108
        wire wGFSM2_TFU__SetAddressOffset;
109
 
110
assign oEnable_WBM = wTFN_Enable_WBM ^ wTFU_Trigger_WBM ^ wTFF_Trigger_WBM; //XXX TODO: Wath out!
111
 
112
 
113
assign oRequestingTextures = (wWBM_Address_Selector == `GFSM_SELECT_TFF ) ? 1 : 0;
114
assign oAddressWBM_Imm = ( wWBM_Address_Selector == `GFSM_SELECT_TFU ) ? wAddress_TFU : wAddress_TNF;
115
assign oRAMWriteEnable = ( wWBM_Address_Selector == `GFSM_SELECT_TFU ) ? wRAMWriteEnable_TFU : wRAMWriteEnable_TNF;
116
 
117
assign oAddressWBM_IsImm =
118
( !iTexturingEnable || (iTexturingEnable &&
119
 (wWBM_Address_Selector == `GFSM_SELECT_TFU || wWBM_Address_Selector == `GFSM_SELECT_TNF) ))
120
 ? 1'b1 : 1'b0;
121
 
122
//--------------------------------------------------------
123
//Mux for oRAMWriteAddress
124
MUXFULLPARALELL_16bits_2SEL_X MUXGE_1B
125
(
126
        .I1( wRAMWriteAddress_TFU ),
127
        .I2( wRAMWriteAddress_TFF ),
128
        .I3( wRAMWriteAddress_TNF ),
129
        .O1( oRAMWriteAddress ),
130
        .Sel( wWBM_Address_Selector )
131
);
132
 
133
//--------------------------------------------------------
134
 
135
assign oSetAddressWBM = wTNF2__SetAddressWBM | wTFU2__SetAddressWBM | wTFF2__SetAddressWBM;
136
 
137
 
138
//------------------------------------------------      
139
 
140
/*
141
        Tree node fetcher: Takes care of resquesting
142
        node information. TNF requests Read Bus Cycles
143
        from the Wish Bone Master Unit. TNF is controlled
144
        by the GFSM.
145
*/
146
TreeNodeFetcher TNF
147
(
148
        .Clock( Clock ),
149
        .Reset( Reset ),
150
        .iData(                    iData_WBM                     ),
151
        .iDataAvailable(           iDataReady_WBM                ),
152 82 diegovalve
        .oEnableWBM(                wTFN_Enable_WBM              ),
153 27 diegovalve
        .oSetAddressWBM(           wTNF2__SetAddressWBM          ),
154
        .oAddressWBM(              wAddress_TNF                  ),
155
        .iInitialAddress(          wNodeAddress                  ),
156
        .iTrigger(                 wTrigger_TNF                  ),
157
        .oNode_IsLeaf(             wNode_IsLeaf                  ),
158
        .oNodeReadDone(            wNodeReadDone                 ),
159
        .oNode_TriangleCount(      wNode_TriangleCount           ),
160
        .oNode_Brother_Address(    wNode_Brother_Address         ),
161
        .oParents_Brother_Address( wParents_Brother_Address      ),
162
        .oNode_DataOffset(         wTNF2_TFU__TriangleDataOffset ),
163 82 diegovalve
        .oRAMWriteEnable(          wRAMWriteEnable_TNF           ),
164
        `ifdef DEBUG
165
        .iDebug_CoreID(                         iDebug_CoreID                 ),
166
        `endif
167 27 diegovalve
        .oRAMWriteAddress(         wRAMWriteAddress_TNF          )
168
 
169
);
170
//------------------------------------------------
171
/*
172
        Triangle Fetch Unit: Takes care of resquesting
173
        triangle information. TFU requests Read Bus Cycles
174
        from the Wish Bone Master Unit. TFU is controlled
175
        by the GFSM.
176
*/
177
TriangleFetchUnit TFU
178
(
179
        .Clock( Clock ),
180
        .Reset( Reset ),
181
        .iTrigger(                     wTrigger_TFU                  ),
182
        .iInitialAddress(              wTNF2_TFU__TriangleDataOffset ),
183
        .iSetAddressOffset(            wGFSM2_TFU__SetAddressOffset  ),
184
        .iDataAvailable(               iDataReady_WBM                ),
185
        .oAddressWBM(                  wAddress_TFU                  ),
186
        .oSetAddressWBM(               wTFU2__SetAddressWBM          ),
187
        .oTriggerWBM(                  wTFU_Trigger_WBM              ),
188
        .oRAMWriteEnable(              wRAMWriteEnable_TFU           ),
189
        .iCR_TextureMappingEnabled(    iTexturingEnable              ),
190 82 diegovalve
        .oRAMWriteAddress(             wRAMWriteAddress_TFU          ),
191
        `ifdef DEBUG
192
        .iDebug_CoreID(                             iDebug_CoreID                 ),
193
        `endif
194 27 diegovalve
        .oDone(                        wTriangleReadDone             )
195
);
196
 
197
//------------------------------------------------      
198
/*
199
        Geometry Fetch Finite State Machine: Takes care of resquesting
200
        the control of the various geometry fetching routines. It controls
201
        TFF,TFU and TNF.
202
*/
203
GeometryFetchFSM  GFSM //TODO: Add new states to fetch the texures
204
(
205
        .Clock( Clock ),
206
        .Reset( Reset ),
207 82 diegovalve
        .iBIUHit(                       iBIUHit                      ),
208
        .iIOBusy(                        iIOBusy                      ),
209 27 diegovalve
        .iTexturingEnable(              iTexturingEnable             ),
210
        .iEnable(                       iEnable                      ),
211
        .iAABBIUHit(                    iMicroCodeReturnValue        ),
212
        .iUCodeDone(                    iMicrocodeExecutionDone      ),
213
        .iTriangleReadDone(             wTriangleReadDone            ),
214
        .iNode_TriangleCount(           wNode_TriangleCount          ),
215
        .iNode_Brother_Address(         wNode_Brother_Address        ),
216
        .iNode_Parents_Brother_Address( wParents_Brother_Address     ),
217
        .iNode_IsLeaf(                  wNode_IsLeaf                 ),
218
        .iNodeReadDone(                 wNodeReadDone                ),
219
        .oTrigger_TNF(                  wTrigger_TNF                 ),
220
        .oTrigger_TFU(                  wTrigger_TFU                 ),
221
        .oNodeAddress(                  wNodeAddress                 ),
222
        .oRequest_AABBIU(               oRequest_AABBIU              ),
223
        .oRequest_BIU(                  oRequest_BIU                 ),
224
        .oRequest_TCC(                  oRequest_TCC                 ),
225
        .oWBM_Addr_Selector(            wWBM_Address_Selector        ),
226
        .oSync(                         oSync                        ),
227
        .oSetTFUAddressOffset(          wGFSM2_TFU__SetAddressOffset ),
228
        .oDone(                         oDone                        ),
229
        .iDataAvailable(                                  iDataReady_WBM               ),
230
        .oEnable_WBM(                             wTFF_Trigger_WBM             ),
231
        .oAddressWBM(                                     oAddressWBM_fromMEM          ),
232
        .oSetAddressWBM(                                  wTFF2__SetAddressWBM         ),
233
        .iTrigger_TFF(                  iTrigger_TFF                 ),
234 82 diegovalve
        .oSetIOWriteBackAddr(           oSetIOWriteBackAddr          ),
235
        `ifdef DEBUG
236
        .iDebug_CoreID(                             iDebug_CoreID                 ),
237
        `endif
238 27 diegovalve
        .oRAMTextureStoreLocation(      wRAMWriteAddress_TFF         )
239
 
240
);
241
assign oTFFDone = oDone;
242
 
243
//-------------------------------------------------     
244
 
245
 
246
endmodule

powered by: WebSVN 2.1.0

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