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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [icarus_version/] [rtl/] [Unit_IO.v] - Blame information for rev 169

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

Line No. Rev Author Line
1 158 diegovalve
`timescale 1ns / 1ps
2
`include "aDefinitions.v"
3
`define ADR_IMM 1
4
`define ADR_POINTER 0
5
/**********************************************************************************
6
Theia, Ray Cast Programable graphic Processing Unit.
7
Copyright (C) 2010  Diego Valverde (diego.valverde.g@gmail.com)
8
 
9
This program is free software; you can redistribute it and/or
10
modify it under the terms of the GNU General Public License
11
as published by the Free Software Foundation; either version 2
12
of the License, or (at your option) any later version.
13
 
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
GNU General Public License for more details.
18
 
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22
 
23
***********************************************************************************/
24
//--------------------------------------------------------------------------
25
module IO_Unit
26
(
27
 input wire                            Clock,
28
 input wire                            Reset,
29
 input wire                            iEnable,
30
 input wire [`DATA_ADDRESS_WIDTH-1:0]  iDat_O_Pointer,     //Pointer to what we want to send via DAT_O
31
 input wire [`WIDTH-1:0]               iAdr_O_Imm,         //Value to assign to ADR_O
32
 input wire [`DATA_ADDRESS_WIDTH-1:0]  iAdr_O_Pointer,     //Pointer to value to assing to ADR_O
33
 input wire                            iAdr_O_Type,        //Should we use iAdr_O_Imm or iAdr_O_Pointer
34
 input wire                            iAdr_O_Set,                   //Should we set 
35
 input wire                            iBusCyc_Type,       //Bus cycle type: simple read/write, etc.
36
 input wire                            iStore,             //Should we store read data into MEM
37
 input wire [`DATA_ROW_WIDTH-1:0]      iReadDataBus,       //MEM Data read bus 1
38
 input wire [`DATA_ROW_WIDTH-1:0]      iReadDataBus2,      //MEM Data read bus 2
39
 input wire[`DATA_ADDRESS_WIDTH-1:0]   iAdr_DataWriteBack, //Where in MEM we want to store DAT_I
40
 input wire                            iWriteBack_Set,     //We want to set the Write back Address?
41
 
42
 
43
 output wire[`DATA_ADDRESS_WIDTH-1:0]  oDataReadAddress,
44
 output wire[`DATA_ADDRESS_WIDTH-1:0]  oDataReadAddress2,
45
 output wire[`DATA_ADDRESS_WIDTH-1:0]  oDataWriteAddress,
46
 output wire                           oDataWriteEnable,
47
 output wire [`DATA_ROW_WIDTH-1:0]     oDataBus,
48
 output wire [`INSTRUCTION_WIDTH-1:0]  oInstructionBus,
49
 output wire                           oInstructionWriteEnable,
50
 output wire [`ROM_ADDRESS_WIDTH-1:0]  oInstructionWriteAddress,
51
 inout wire [`WIDTH-1:0]               oData,
52
 output wire                           oBusy,
53
 output wire                           oDone,
54
 
55
 
56
 input wire [`DATA_ROW_WIDTH-1:0]  iOMEM_WriteAddress,
57
 input wire [`DATA_ROW_WIDTH-1:0]  iOMEM_WriteData,
58
 input wire                  iOMEM_WriteEnable,
59
 output wire [`WB_WIDTH-1:0] OMEM_DAT_O,
60
 output wire [`WB_WIDTH-1:0] OMEM_ADR_O,
61
 output wire                                      OMEM_WE_O,
62
 
63
 //Theia specific interfaces
64
 input wire MST_I,
65
 //Wish Bone Interfaces
66
output wire [31:0]   DAT_O,
67
input wire [31:0]    DAT_I,
68
input wire           ACK_I,
69
output wire          ACK_O,
70
output wire [31:0]   ADR_O,
71
input wire [31:0]   ADR_I,
72
output wire          WE_O,
73
input wire           WE_I,
74
output wire          STB_O,
75
input wire           STB_I,
76
output wire          CYC_O,
77
input wire           CYC_I,
78
input wire  [1:0]    TGA_I,
79
output wire     [1:0]    TGC_O,
80
input wire           GNT_I,
81
 
82
 
83
output wire [`DATA_ROW_WIDTH-1:0] oTMEMReadData,
84
input wire                                                               iTMEMDataRequest,
85
input wire      [`DATA_ROW_WIDTH-1:0] iTMEMReadAddress,
86
output wire                                                      oTMEMDataAvailable,
87
 
88
input wire                  TMEM_ACK_I,
89
input wire [`WB_WIDTH-1:0]  TMEM_DAT_I ,
90
output wire [`WB_WIDTH-1:0] TMEM_ADR_O ,
91
output wire                 TMEM_WE_O,
92
output wire                 TMEM_STB_O,
93
output wire                 TMEM_CYC_O,
94
input wire                  TMEM_GNT_I
95
);
96
 
97
 
98
wire [`WIDTH-1:0]          wMEMToWBM2__ReadDataElement;
99
wire [`WIDTH-1:0]          wMEMToWBM2__ReadDataElement2;
100
wire                       wMEMToWBM_2__Enable;
101
wire                       wWBMToMEM2__Done;
102
wire                       wWBM_2_WBMToMEM_DataAvailable;
103
wire [`WIDTH-1:0]          wWBM_2_WBMToMEM_Data;
104
wire [`WIDTH-1:0]          wWBS_2__WBMToMEM_Frame;
105
wire                       wWBMToMEM_2_WBM_Enable;
106
wire [`WIDTH-1:0]          wWBMToMEM_2_WBM_Address;
107
wire                       wWBMToMEM2__oDataWriteEnable;
108
wire                       wAddrerssSelector2_oDataWriteEnable;
109
wire [`DATA_ROW_WIDTH-1:0] wWBMToMEM2__oDataBus;
110
wire [`DATA_ROW_WIDTH-1:0] wWBSToMEM2__oDataBus;
111
wire                       wAddressSelector_2__SetAddress;
112
wire [`WIDTH-1:0]          wMEMToWBM_2__Address;
113
wire                       wMEMToWBM_2__Done;
114
wire                       w2WBMToMEM__Enable;
115
wire                       w2WBMToMEM__SetAddress;
116
wire                       wWBS_2__WBSToMEM_FrameAvailable;
117
wire[`WIDTH-1:0]           wWBS_2__WBMToMEM_Address;
118
wire                       wWBSToMEM2__oDataWriteEnable;
119
wire[`DATA_ADDRESS_WIDTH-1:0] wWBSToMEM2__oDataWriteAddress;
120
wire[`DATA_ADDRESS_WIDTH-1:0] wWBMToMEM2__oDataWriteAddress;
121
 
122
 
123
 
124
 //***********new*****************/
125
 
126
 
127
Module_OMemInterface OMI
128
(
129
        .Clock( Clock ),
130
        .Reset( Reset ),
131
        .iWriteEnable( iOMEM_WriteEnable  ),
132
        .iData(        iOMEM_WriteData    ),
133
        .iAddress(     iOMEM_WriteAddress ),
134
        .ADR_O(        OMEM_ADR_O         ),
135
        .DAT_O(        OMEM_DAT_O         ),
136
        .WE_O(         OMEM_WE_O          )
137
 
138
);
139
 
140
Module_TMemInterface TMI
141
(
142
        .Clock( Clock ),
143
        .Reset( Reset ),
144
        .iEnable(  iTMEMDataRequest   ),
145
        .iAddress( iTMEMReadAddress   ),
146
        .oData(    oTMEMReadData      ),
147
        .oDone(    oTMEMDataAvailable ),
148
 
149
        .ACK_I( TMEM_ACK_I ),
150
        .GNT_I( TMEM_GNT_I ),
151
        .DAT_I( TMEM_DAT_I ),
152
        .ADR_O( TMEM_ADR_O ),
153
        .WE_O(  TMEM_WE_O  ),
154
        .STB_O( TMEM_STB_O ),
155
        .CYC_O( TMEM_CYC_O )
156
 
157
 
158
);
159
//***********new*****************/
160
 
161
assign oBusy = CYC_O;
162
wire wReadOperation;
163
assign wReadOperation = (iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE) ? 0 : 1;
164
 
165
 
166
assign wMEMToWBM_2__Address    = ( iAdr_O_Type == `ADR_IMM ) ? iAdr_O_Imm  : wMEMToWBM2__ReadDataElement;
167
assign w2WBMToMEM__Enable    = ( iAdr_O_Type == `ADR_IMM ) ? iEnable       : wMEMToWBM_2__Enable;
168
//assign oDone                  = ( (iAdr_O_Type == `ADR_IMM) && !(iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE) ) 
169
//? wWBMToMEM2__Done : wMEMToWBM_2__Done;
170
 
171
//TODO: WHEN ADR_POINTER Then Done is not until we got the 3 values from X,Y,Z in iAdr_O_Pointer
172
assign oDone = (iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE || iAdr_O_Type == `ADR_POINTER ) ? wMEMToWBM_2__Done : wWBMToMEM2__Done;
173
 
174
assign oDataWriteEnable  = (MST_I == 1'b1) ? wWBSToMEM2__oDataWriteEnable : (wWBMToMEM2__oDataWriteEnable);// ^ wAddrerssSelector2_oDataWriteEnable);
175
assign oDataWriteAddress = (MST_I == 1'b1) ? wWBSToMEM2__oDataWriteAddress : wWBMToMEM2__oDataWriteAddress;
176
assign oDataBus          = (MST_I == 1'b1) ? wWBSToMEM2__oDataBus : wWBMToMEM2__oDataBus;
177
 
178
 
179
 
180
 
181
 
182
 wire [`DATA_ADDRESS_WIDTH-1:0] wMEMToWBM2_WBMToMEM_RAMWriteAddr;
183
 wire [`DATA_ADDRESS_WIDTH-1:0] w2WBMToMEM_MEMWriteAddress;
184
 
185
assign w2WBMToMEM_MEMWriteAddress = ( iAdr_O_Type == `ADR_IMM) ? iAdr_DataWriteBack : wMEMToWBM2_WBMToMEM_RAMWriteAddr;
186
 
187
wire w2MEMToWBM_BusOperationComplete;
188
assign w2MEMToWBM_BusOperationComplete = (iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE) ? ACK_I  :  wWBMToMEM2__Done;
189
 
190
 
191
wire [`DATA_ADDRESS_WIDTH-1:0] w2MEMToWBM_DataPointer;
192
assign w2MEMToWBM_DataPointer = (iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE) ? iDat_O_Pointer : iAdr_O_Pointer;
193
 
194
 
195
//------------------------------------------------------------------------------
196
MEM2WBMUnitB MEMToWBM
197
(
198
.Clock(                        Clock                                           ),
199
.Reset(                        Reset                                           ),
200
.iEnable(                      iEnable & (~iAdr_O_Type | iBusCyc_Type)         ),
201
.iMEMDataPointer(           w2MEMToWBM_DataPointer                          ),
202
.iMEMDataPointer2(           iAdr_O_Pointer                          ),
203
.iReadDataBus(                 iReadDataBus                                                                     ),   //3 Elements comming from DMEM
204
.iReadDataBus2(                iReadDataBus2                                   ),
205
.oReadDataElement(             wMEMToWBM2__ReadDataElement                     ),       //1 out of 3 elements we read
206
.oReadDataElement2(            wMEMToWBM2__ReadDataElement2                     ),      //1 out of 3 elements we read
207
.oDataReadAddress(              oDataReadAddress                                ),
208
.oDataReadAddress2(              oDataReadAddress2                             ),
209
.oDataWriteEnable(              wAddrerssSelector2_oDataWriteEnable             ),   //Always zero
210
.oDataAvailable(              wMEMToWBM_2__Enable                             ),    //Data from MEM available
211
.iRequestNextElement(          w2MEMToWBM_BusOperationComplete                 ),
212
.iDataInitialStorageAddress(    iAdr_DataWriteBack                              ), ////########
213
.oDataWriteAddress(             wMEMToWBM2_WBMToMEM_RAMWriteAddr        ), ////########
214
.oDone(                        wMEMToWBM_2__Done                               )
215
);
216
//------------------------------------------------------------------------------
217
 
218
 
219
 
220
 
221
 
222
wire [`DATA_ADDRESS_WIDTH-1:0] wTemp1;
223
 assign wWBMToMEM2__oDataWriteAddress = (iAdr_O_Type == `ADR_IMM) ? iAdr_DataWriteBack : wTemp1;
224
 
225
 
226
 
227
wire [`WIDTH-1:0] wADR_O_InitialAddress;
228
assign wADR_O_InitialAddress = (iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE) ? wMEMToWBM2__ReadDataElement2 : wMEMToWBM_2__Address;
229
wire wIncrement_Address_O;
230
assign wIncrement_Address_O = iEnable & ACK_I;
231
 
232
 
233
 
234
wire                 wMEMToWBM2__Done;
235
wire                 wMEMToWBM2__Trigger;
236
wire[`WB_WIDTH-1:0]  wMEMToWBM_2_Data;
237
wire                 w2MEMToWBM__Trigger;
238
wire                 wWBM2_MEMToWBM_DataWriteDone;
239
 
240
 
241
wire w2WBM_iEnable;
242
 
243
assign w2WBM_iEnable = (iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE) ? wMEMToWBM_2__Enable : iEnable;
244
 
245
//------------------------------------------------------------------------------
246
wire wSTB_O;
247
 
248
//If the address is a pointer, we need 1 cycle to read the data back from MEM
249
//before we can the set the value into WBM
250
wire wAddress_Set_Delayed;
251
FFD_POSEDGE_SYNCRONOUS_RESET # (1) FFD32_SetDelay
252
(
253
        .Clock(         Clock ),
254
        .Reset(         Reset ),
255
        .Enable( 1'b1 ),
256
        .D( iAdr_O_Set ),
257
        .Q( wAddress_Set_Delayed )
258
 
259
);
260
 
261
//If the Addr is IMM then just set it whenever iAdr_O_Set is set, but if we have a pointer, then use
262
//wAddress_Set_Delayed at the beginning and then wWBMToMEM2__Done
263
wire wWBM_iAddress_Set = (iAdr_O_Type == `ADR_POINTER) ? (wAddress_Set_Delayed | wWBMToMEM2__Done) :    iAdr_O_Set;
264
 
265
assign STB_O = wSTB_O & ~oDone;
266
 
267
        WishBoneMasterUnit WBM
268
        (
269
                .CLK_I(         Clock ),
270
                .RST_I(         Reset ),
271
                .DAT_I(         DAT_I ),
272
                .DAT_O(  DAT_O ),
273
                .ACK_I(         ACK_I  ),
274
                .ADR_O(         ADR_O ),
275
                .WE_O(  WE_O ),
276
                .STB_O( wSTB_O ),
277
                .CYC_O( CYC_O   ),
278
                .TGC_O( TGC_O   ),
279
                .GNT_I(  GNT_I ),
280
 
281
                .iEnable(                       w2WBM_iEnable       ),
282
                .iBusCyc_Type(    iBusCyc_Type                     ),
283
                .iAddress_Set(  wWBM_iAddress_Set  ),
284
                .iAddress(            wADR_O_InitialAddress            ),
285
                .oDataReady(            wWBM_2_WBMToMEM_DataAvailable    ),
286
                .iData(           wMEMToWBM2__ReadDataElement      ),
287
                .oData(                                 wWBM_2_WBMToMEM_Data                       )
288
        );
289
 
290
//------------------------------------------------------------------------------
291
WishBoneSlaveUnit WBS
292
(
293
 
294
                .CLK_I(         Clock  ),
295
                .RST_I(         Reset  ),
296
                .STB_I(  STB_I  ),
297
           .WE_I(   WE_I   ),
298
                .DAT_I(  DAT_I  ),
299
           .ADR_I(  ADR_I  ),
300
                .TGA_I(  TGA_I  ),
301
                .ACK_O(  ACK_O  ),
302
                .CYC_I(  CYC_I  ),
303
                .MST_I(  MST_I ),
304
 
305
                .oDataBus(               wWBSToMEM2__oDataBus                    ),
306
                .oInstructionBus(        oInstructionBus                         ),
307
                .oDataWriteAddress(      wWBSToMEM2__oDataWriteAddress           ),
308
                .oDataWriteEnable(       wWBSToMEM2__oDataWriteEnable            ),
309
                .oInstructionWriteAddress(      oInstructionWriteAddress         ),
310
                .oInstructionWriteEnable(       oInstructionWriteEnable          )
311
 
312
 
313
 
314
);
315
//------------------------------------------------------------------------------
316
 
317
 
318
endmodule
319
//--------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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