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 214

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

powered by: WebSVN 2.1.0

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