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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [gpu_8_cores/] [rtl/] [GPU/] [CORES/] [TOP/] [Theia_Core.v] - Blame information for rev 76

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

Line No. Rev Author Line
1 76 diegovalve
/**********************************************************************************
2
Theia, Ray Cast Programable graphic Processing Unit.
3
Copyright (C) 2010  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
Description:
23
 This is the top level block for THEIA.
24
 THEIA core has 5 main logical blocks called Units.
25
 This module implements the interconections between the Units.
26
 
27
 Units:
28
  > EXE: Mananges execution logic for the SHADERS.
29
  > GEO: Manages geometry data structures.
30
  > IO: Input/Output (Wishbone).
31
  > MEM: Internal memory, separate for Instructions and data.
32
  > CONTROL: Main control Finite state machine.
33
 
34
 Internal Buses:
35
        THEIA has separate instruction and data buses.
36
        THEIA avoids using tri-state buses by having separate input/output
37
        for each bus.
38
        There are 2 separate data buses since the Data memory
39
        has a Dual read channel.
40
   Please see the MEM unit chapter in the documentation for more details.
41
 
42
 External Buses:
43
        External buses are managed by the IO Unit.
44
        External buses follow the wishbone protocol.
45
        Please see the IO unit chapter in the documentation for more details.
46
**********************************************************************************/
47
 
48
`timescale 1ns / 1ps
49
`include "aDefinitions.v"
50
 
51
module THEIACORE
52
(
53
 
54
input wire                    CLK_I,    //Input clock
55
input wire                    RST_I,    //Input reset
56
//Theia Interfaces
57
input wire                    MST_I,    //Master signal, THEIA enters configuration mode
58
                                       //when this gets asserted (see documentation)
59
//Wish Bone Interface
60
input wire [`WB_WIDTH-1:0]    DAT_I,     //Input data bus  (Wishbone)
61
output wire [`WB_WIDTH-1:0]   DAT_O,     //Output data bus (Wishbone)
62
input wire                    ACK_I,    //Input ack
63
output wire                   ACK_O,    //Output ack
64
output wire [`WB_WIDTH-1:0]   ADR_O,     //Output address
65
input wire [`WB_WIDTH-1:0]    ADR_I,     //Input address
66
output wire                   WE_O,             //Output write enable
67
input wire                    WE_I,    //Input write enable
68
output wire                   STB_O,    //Strobe signal, see wishbone documentation
69
input wire                    STB_I,    //Strobe signal, see wishbone documentation
70
output wire                   CYC_O,    //Bus cycle signal, see wishbone documentation
71
input wire                    CYC_I,   //Bus cycle signal, see wishbone documentation
72
output wire     [1:0]             TGC_O,   //Bus cycle tag, see THEAI documentation
73
input wire [1:0]              TGA_I,   //Input address tag, see THEAI documentation
74
output wire [1:0]             TGA_O,   //Output address tag, see THEAI documentation
75
input wire      [1:0]             TGC_I,   //Bus cycle tag, see THEAI documentation
76
input wire                    GNT_I,   //Bus arbiter 'Granted' signal, see THEAI documentation
77
input wire                    RENDREN_I,
78
 
79
`ifdef DEBUG
80
input wire[`MAX_CORES-1:0]    iDebug_CoreID,
81
`endif
82
//Control Register
83
input wire [15:0]                         CREG_I,
84
output wire                   DONE_O
85
 
86
 
87
);
88
 
89
//Alias this signals
90
wire Clock,Reset;
91
assign Clock = CLK_I;
92
assign Reset = RST_I;
93
 
94
wire [`DATA_ROW_WIDTH-1:0]                        wEXE_2__MEM_WriteData;
95
wire [`DATA_ROW_WIDTH-1:0]                        wUCODE_RAMBus;
96
wire [`DATA_ADDRESS_WIDTH-1:0]    wEXE_2__MEM_wDataWriteAddress;
97
wire                              w2IO__AddrIsImm;
98
wire [`DATA_ADDRESS_WIDTH-1:0]    wUCODE_RAMAddress;
99
wire [`DATA_ADDRESS_WIDTH-1:0]    w2IO__Adr_O_Pointer;
100
wire [`DATA_ADDRESS_WIDTH-1:0]    wGEO2_IO__Adr_O_Pointer;
101
wire                                                                             wEXE_2__DataWriteEnable;
102
wire                                                                             wUCODE_RAMWriteEnable;
103
wire [2:0]                                                                RamBusOwner;
104
//Unit intercoanection wires
105
 
106
wire                                                                            wCU2__MicrocodeExecutionDone;
107
wire [`ROM_ADDRESS_WIDTH-1:0]            InitialCodeAddress;
108
wire [`ROM_ADDRESS_WIDTH-1:0]            wInstructionPointer1,wInstructionPointer2;
109
wire [`INSTRUCTION_WIDTH-1:0]    wEncodedInstruction1,wEncodedInstruction2,wIO2_MEM__ExternalInstruction;
110
wire                                                                            wCU2__ExecuteMicroCode;
111
wire  [`ROM_ADDRESS_WIDTH-1:0]   wIO2_MEM__InstructionWriteAddr;
112
wire [95:0]                                                      wMEM_2__EXE_DataRead0, wMEM_2__EXE_DataRead1,wMEM_2__IO_DataRead0, wMEM_2__IO_DataRead1;
113
wire [`DATA_ADDRESS_WIDTH-1:0]   wEXE_2__MEM_DataReadAddress0,wEXE_2__MEM_DataReadAddress1;
114
wire [`DATA_ADDRESS_WIDTH-1:0]   wUCODE_RAMReadAddress0,wUCODE_RAMReadAddress1;
115
 
116
 
117
wire [`WIDTH-1:0]                                        w2IO__AddressOffset;
118
wire [`DATA_ADDRESS_WIDTH-1:0]   w2IO__DataWriteAddress;
119
wire                                                                            w2IO__Store;
120
wire                                                                            w2IO__EnableWBMaster;
121
 
122
wire [`DATA_ADDRESS_WIDTH-1:0]   wIO2_MEM__DataWriteAddress;
123
wire [`DATA_ADDRESS_WIDTH-1:0]   wIO_2_MEM__DataReadAddress0;
124
wire [`DATA_ROW_WIDTH-1:0]               wIO2_MEM__Bus;
125
wire [`WIDTH-1:0]                                        wIO2_MEM__Data;
126
wire [`WIDTH-1:0]                                        wIO2_WBM__Address;
127
wire                                                                            wIO2_MEM__DataWriteEnable;
128
wire                                                                            wIO2__Done;
129
wire                                                                            wCU2_GEO__GeometryFetchEnable;
130
wire                                                                            wIFU2__MicroCodeReturnValue;
131
wire                                                                            wCU2_BCU__ACK;
132
wire                                                                            wGEO2_CU__RequestAABBIU;
133
wire                                                                            wGEO2_CU__RequestBIU;
134
wire                             wGEO2_CU__RequestTCC;
135
wire                                                                            wGEO2_CU__GeometryUnitDone;
136
wire                                                                            wGEO2_CU__Sync;
137
wire                                                                            wEXE2__uCodeDone;
138
wire                                                                            wEXE2_IFU__EXEBusy;
139
wire [`DATA_ADDRESS_WIDTH-1:0]   wEXE2_IDU_DataFordward_LastDestination;
140
wire                                                                            wALU2_EXE__BranchTaken;
141
wire                                                                            wALU2_IFU_BranchNotTaken;
142
wire                                                                            w2IO__SetAddress;
143
wire                                                                            wIDU2_IFU__IDUBusy;
144
//Control Registe wires
145
wire[15:0]                                                               wCR2_ControlRegister;
146
wire                                                                            wCR2_TextureMappingEnabled;
147
wire                             wGEO2_CU__TFFDone;
148
wire                             wCU2_GEO__TriggerTFF;
149
wire                             wIO2_MEM_InstructionWriteEnable;
150
wire                             wCU2_IO__WritePixel;
151
wire                             wGEO2_IO__AddrIsImm;
152
wire[31:0]                       wGEO2_IO__AddressOffset;
153
wire                             wGEO2_IO__EnableWBMaster;
154
wire                             wGEO2_IO__SetAddress;
155
wire[`WIDTH-1:0]                 wGEO2__CurrentPitch,wCU2_GEO_Pitch;
156
wire                             wCU2_GEO__SetPitch,wCU2_GEO__IncPicth;
157
wire wCU2_FlipMemEnabled;
158
wire w2MEM_FlipMemory;
159
 
160
`ifdef DEBUG
161
        wire [`ROM_ADDRESS_WIDTH-1:0] wDEBUG_IDU2_EXE_InstructionPointer;
162
`endif
163
//--------------------------------------------------------
164
 
165
 
166
assign wCR2_TextureMappingEnabled = wCR2_ControlRegister[ `CR_EN_TEXTURE ];
167
wire wCU2_FlipMem;
168
//--------------------------------------------------------
169
//Control Unit Instance
170
        ControlUnit CU
171
        (
172
           .Clock(Clock),
173
                .Reset(Reset),
174
                .oFlipMemEnabled(                   wCU2_FlipMemEnabled            ),
175
                .oFlipMem(                          wCU2_FlipMem                   ),
176
                .iControlRegister(                  wCR2_ControlRegister           ),
177
                .oRamBusOwner(                      RamBusOwner                    ),
178
                .oGFUEnable(                        wCU2_GEO__GeometryFetchEnable  ),
179
                .iTriggerAABBIURequest(             wGEO2_CU__RequestAABBIU        ),
180
                .iTriggerBIURequest(                wGEO2_CU__RequestBIU           ),
181
                .iTriggertTCCRequest(               wGEO2_CU__RequestTCC           ),
182
                .oUCodeEnable(                      wCU2__ExecuteMicroCode         ),
183
                .oCodeInstructioPointer(           InitialCodeAddress             ),
184
                .iUCodeDone(                        wCU2__MicrocodeExecutionDone   ),
185
                .iIODone(                           wIO2__Done                     ),
186
                .oIOWritePixel(                     wCU2_IO__WritePixel            ),
187
                .iUCodeReturnValue(                 wIFU2__MicroCodeReturnValue    ),
188
                .iGEOSync(                          wGEO2_CU__Sync                 ),
189
                .iTFFDone(                          wGEO2_CU__TFFDone              ),
190
                .oTriggerTFF(                       wCU2_GEO__TriggerTFF           ),
191
                .MST_I(                             MST_I                          ),
192
                .oSetCurrentPitch(                  wCU2_GEO__SetPitch             ),
193
                .iGFUDone(                          wGEO2_CU__GeometryUnitDone     ),
194
                .iRenderEnable(                     RENDREN_I                      ),
195
 
196
                `ifdef DEBUG
197
                .iDebug_CoreID( iDebug_CoreID ),
198
                `endif
199
                .oDone(                             DONE_O                         )
200
 
201
        );
202
 
203
 
204
 
205
 
206
//--------------------------------------------------------      
207
 
208
//assign w2MEM_FlipMemory =  (wCU2__ExecuteMicroCode | wCU2_FlipMem ) & wCU2_FlipMemEnabled;
209
assign w2MEM_FlipMemory =  wCU2_FlipMem  & wCU2_FlipMemEnabled;
210
MemoryUnit MEM
211
(
212
.Clock(Clock),
213
.Reset(Reset),
214
 
215
.iFlipMemory( w2MEM_FlipMemory ),
216
 
217
//Data Bus to/from EXE
218
.iDataReadAddress1_EXE(       wEXE_2__MEM_DataReadAddress0        ),
219
.iDataReadAddress2_EXE(       wEXE_2__MEM_DataReadAddress1        ),
220
.oData1_EXE(                  wMEM_2__EXE_DataRead0               ),
221
.oData2_EXE(                  wMEM_2__EXE_DataRead1               ),
222
.iDataWriteEnable_EXE(        wEXE_2__DataWriteEnable          ),
223
.iDataWriteAddress_EXE(       wEXE_2__MEM_wDataWriteAddress        ),
224
.iData_EXE(                   wEXE_2__MEM_WriteData          ),
225
 
226
//Data Bus to/from IO
227
 
228
.iDataReadAddress1_IO(       wIO_2_MEM__DataReadAddress0        ),
229
.iDataReadAddress2_IO(       wIO_2_MEM__DataReadAddress1        ),
230
.oData1_IO(                  wMEM_2__IO_DataRead0               ),
231
.oData2_IO(                  wMEM_2__IO_DataRead1               ),
232
.iDataWriteEnable_IO(        wIO2_MEM__DataWriteEnable          ),
233
.iDataWriteAddress_IO(       wIO2_MEM__DataWriteAddress        ),
234
.iData_IO(                   wIO2_MEM__Bus          ),
235
 
236
 
237
//Instruction Bus
238
.iInstructionReadAddress1(  wInstructionPointer1             ),
239
.iInstructionReadAddress2(  wInstructionPointer2             ),
240
.oInstruction1(             wEncodedInstruction1             ),
241
.oInstruction2(             wEncodedInstruction2             ),
242
.iInstructionWriteEnable(  wIO2_MEM_InstructionWriteEnable ),
243
.iInstructionWriteAddress( wIO2_MEM__InstructionWriteAddr  ),
244
.iInstruction(             wIO2_MEM__ExternalInstruction   ),
245
.iControlRegister(         CREG_I                          ),
246
.oControlRegister(         wCR2_ControlRegister            )
247
 
248
);
249
 
250
////--------------------------------------------------------
251
 
252
 
253
ExecutionUnit EXE
254
(
255
 
256
.Clock( Clock),
257
.Reset( Reset ),
258
.iInitialCodeAddress(    InitialCodeAddress     ),
259
.iInstruction1(          wEncodedInstruction1      ),
260
.iInstruction2(          wEncodedInstruction2      ),
261
.oInstructionPointer1(   wInstructionPointer1    ),
262
.oInstructionPointer2(   wInstructionPointer2    ),
263
.iDataRead0(             wMEM_2__EXE_DataRead0             ),
264
.iDataRead1(             wMEM_2__EXE_DataRead1             ),
265
.iTrigger(               wCU2__ExecuteMicroCode ),
266
.oDataReadAddress0( wEXE_2__MEM_DataReadAddress0 ),
267
.oDataReadAddress1( wEXE_2__MEM_DataReadAddress1 ),
268
.oDataWriteEnable(  wEXE_2__DataWriteEnable  ),
269
.oDataWriteAddress( wEXE_2__MEM_wDataWriteAddress      ),
270
.oDataBus(          wEXE_2__MEM_WriteData          ),
271
.oReturnCode(       wIFU2__MicroCodeReturnValue ),
272
 
273
`ifdef DEBUG
274
.iDebug_CoreID( iDebug_CoreID ),
275
`endif
276
.oDone(             wCU2__MicrocodeExecutionDone )
277
 
278
);
279
 
280
////--------------------------------------------------------
281
wire wGEO2__RequestingTextures;
282
wire w2IO_WriteBack_Set;
283
 
284
GeometryUnit GEO
285
(
286
                .Clock( Clock ),
287
                .Reset( Reset ),
288
                .iEnable(                     wCU2_GEO__GeometryFetchEnable       ),
289
                .iTexturingEnable(            wCR2_TextureMappingEnabled          ),
290
                //Wires from IO
291
                .iData_WBM(                                             wIO2_MEM__Data ),
292
                .iDataReady_WBM(                                        wIO2__Done ),
293
                //Wires to WBM
294
                .oAddressWBM_Imm(                               wGEO2_IO__AddressOffset                                 ),
295
                .oAddressWBM_fromMEM(         wGEO2_IO__Adr_O_Pointer             ),
296
                .oAddressWBM_IsImm(           wGEO2_IO__AddrIsImm                 ),
297
                .oEnable_WBM(                                           wGEO2_IO__EnableWBMaster                                ),
298
                .oSetAddressWBM(                                        wGEO2_IO__SetAddress                                            ),
299
                .oSetIOWriteBackAddr(         w2IO_WriteBack_Set                  ),
300
                //Wires to CU
301
                .oRequest_AABBIU(             wGEO2_CU__RequestAABBIU                ),
302
                .oRequest_BIU(                wGEO2_CU__RequestBIU                   ),
303
                .oRequest_TCC(                wGEO2_CU__RequestTCC                   ),
304
                .oTFFDone(                    wGEO2_CU__TFFDone                      ),
305
                //Wires to RAM-Bus MUX  
306
                .oRAMWriteAddress(                              w2IO__DataWriteAddress                                  ),
307
                .oRAMWriteEnable(                               w2IO__Store ),
308
                //Wires from Execution Unit
309
                .iMicrocodeExecutionDone(               wCU2__MicrocodeExecutionDone                            ),
310
                .iMicroCodeReturnValue(                 wIFU2__MicroCodeReturnValue                             ),
311
                .oSync(                                                         wGEO2_CU__Sync                                                                  ),
312
                .iTrigger_TFF(                wCU2_GEO__TriggerTFF                   ),
313
                .iBIUHit(                     wIFU2__MicroCodeReturnValue            ),
314
                .oRequestingTextures( wGEO2__RequestingTextures ),
315
                .oDone(                                                         wGEO2_CU__GeometryUnitDone                                      )
316
);
317
 
318
 
319
assign TGA_O = (wGEO2__RequestingTextures) ? 2'b1: 2'b0;
320
//---------------------------------------------------------------------------------------------------
321
wire[`DATA_ADDRESS_WIDTH-1:0] wIO_2_MEM__DataReadAddress1;
322
assign wEXE_2__MEM_DataReadAddress1 = (wCU2_IO__WritePixel == 0) ?  wUCODE_RAMReadAddress1 : wIO_2_MEM__DataReadAddress1;
323
assign w2IO__EnableWBMaster = (wCU2_IO__WritePixel == 0 ) ? wGEO2_IO__EnableWBMaster : wCU2_IO__WritePixel;
324
assign w2IO__AddrIsImm       = (wCU2_IO__WritePixel == 0 ) ? wGEO2_IO__AddrIsImm       : 1'b0;
325
assign w2IO__AddressOffset   = (wCU2_IO__WritePixel == 0 ) ? wGEO2_IO__AddressOffset   : 32'b0;
326
assign w2IO__Adr_O_Pointer      = (wCU2_IO__WritePixel == 0 ) ? wGEO2_IO__Adr_O_Pointer : `OREG_ADDR_O;
327
//assign w2IO__Adr_O_Pointer      = (wCU2_IO__WritePixel == 0 ) ? wGEO2_IO__Adr_O_Pointer : `CREG_PIXEL_2D_INITIAL_POSITION; 
328
 
329
wire w2IO_MasterCycleType;
330
assign w2IO_MasterCycleType = (wCU2_IO__WritePixel) ? `WB_SIMPLE_WRITE_CYCLE : `WB_SIMPLE_READ_CYCLE;
331
 
332
 
333
 
334
assign w2IO__SetAddress = (wCU2_IO__WritePixel == 0 )? wGEO2_IO__SetAddress : wCU2_GEO__SetPitch;
335
 
336
 
337
IO_Unit IO
338
(
339
 .Clock(               Clock                            ),
340
 .Reset(               Reset                            ),
341
 .iEnable(            w2IO__EnableWBMaster              ),
342
 .iBusCyc_Type(         w2IO_MasterCycleType            ),
343
 
344
 .iStore(              w2IO__Store                      ),
345
 .iAdr_DataWriteBack(    w2IO__DataWriteAddress         ),
346
 .iAdr_O_Set(      w2IO__SetAddress                     ),
347
 .iAdr_O_Imm(       w2IO__AddressOffset                 ),
348
 .iAdr_O_Type(      w2IO__AddrIsImm                     ),
349
 .iAdr_O_Pointer(  w2IO__Adr_O_Pointer                  ),
350
 .iReadDataBus(        wMEM_2__IO_DataRead0                       ),
351
 .iReadDataBus2(        wMEM_2__IO_DataRead1                       ),
352
 .iDat_O_Pointer(     `OREG_PIXEL_COLOR                 ),
353
 
354
 
355
 .oDataReadAddress(    wIO_2_MEM__DataReadAddress0      ),
356
 .oDataReadAddress2(   wIO_2_MEM__DataReadAddress1       ),
357
 .oDataWriteAddress(   wIO2_MEM__DataWriteAddress    ),
358
 .oDataBus(               wIO2_MEM__Bus                 ),
359
 .oInstructionBus(     wIO2_MEM__ExternalInstruction    ),
360
 
361
 .oDataWriteEnable(         wIO2_MEM__DataWriteEnable    ),
362
 .oData(                    wIO2_MEM__Data                       ),
363
 .oInstructionWriteEnable(  wIO2_MEM_InstructionWriteEnable ),
364
 .oInstructionWriteAddress( wIO2_MEM__InstructionWriteAddr ),
365
 .iWriteBack_Set( w2IO_WriteBack_Set ),
366
 
367
 .oDone(               wIO2__Done                       ),
368
 .MST_I( MST_I ),
369
  //Wish Bone Interface
370
.DAT_I( DAT_I ),
371
.DAT_O( DAT_O ),
372
.ACK_I( ACK_I & GNT_I ),
373
.ACK_O( ACK_O ),
374
.ADR_O( ADR_O ),
375
.ADR_I( ADR_I ),
376
.WE_O(  WE_O  ),
377
.WE_I(  WE_I  ),
378
.STB_O( STB_O ),
379
.STB_I( STB_I ),
380
.CYC_O( CYC_O ),
381
.TGA_I( TGA_I ),
382
.CYC_I( CYC_I ),
383
.GNT_I( GNT_I ),
384
.TGC_O( TGC_O )
385
 
386
 
387
);
388
//---------------------------------------------------------------------------------------------------
389
endmodule

powered by: WebSVN 2.1.0

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