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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_1.2/] [rtl/] [IO/] [Unit_IO.v] - Blame information for rev 92

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

Line No. Rev Author Line
1 31 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 82 diegovalve
 input wire                            iEnable,
30 31 diegovalve
 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 82 diegovalve
 inout wire [`WIDTH-1:0]               oData,
52
 output wire                           oBusy,
53 31 diegovalve
 output wire                           oDone,
54
 //Theia specific interfaces
55
 input wire MST_I,
56
 //Wish Bone Interfaces
57
output wire [31:0]   DAT_O,
58
input wire [31:0]    DAT_I,
59
input wire           ACK_I,
60
output wire          ACK_O,
61
output wire [31:0]   ADR_O,
62
output wire [31:0]   ADR_I,
63
output wire          WE_O,
64
input wire           WE_I,
65
output wire          STB_O,
66
input wire           STB_I,
67
output wire          CYC_O,
68
input wire           CYC_I,
69
input wire  [1:0]    TGA_I,
70 76 diegovalve
output wire     [1:0]    TGC_O,
71
input wire           GNT_I
72 31 diegovalve
);
73
 
74
 
75
wire [`WIDTH-1:0]          wMEMToWBM2__ReadDataElement;
76
wire [`WIDTH-1:0]          wMEMToWBM2__ReadDataElement2;
77
wire                       wMEMToWBM_2__Enable;
78
wire                       wWBMToMEM2__Done;
79
wire                       wWBM_2_WBMToMEM_DataAvailable;
80
wire [`WIDTH-1:0]          wWBM_2_WBMToMEM_Data;
81
wire [`WIDTH-1:0]          wWBS_2__WBMToMEM_Frame;
82
wire                       wWBMToMEM_2_WBM_Enable;
83
wire [`WIDTH-1:0]          wWBMToMEM_2_WBM_Address;
84
wire                       wWBMToMEM2__oDataWriteEnable;
85
wire                       wAddrerssSelector2_oDataWriteEnable;
86
wire [`DATA_ROW_WIDTH-1:0] wWBMToMEM2__oDataBus;
87
wire [`DATA_ROW_WIDTH-1:0] wWBSToMEM2__oDataBus;
88
wire                       wAddressSelector_2__SetAddress;
89
wire [`WIDTH-1:0]          wMEMToWBM_2__Address;
90
wire                       wMEMToWBM_2__Done;
91
wire                       w2WBMToMEM__Enable;
92
wire                       w2WBMToMEM__SetAddress;
93
wire                       wWBS_2__WBSToMEM_FrameAvailable;
94
wire[`WIDTH-1:0]           wWBS_2__WBMToMEM_Address;
95
wire                       wWBSToMEM2__oDataWriteEnable;
96
wire[`DATA_ADDRESS_WIDTH-1:0] wWBSToMEM2__oDataWriteAddress;
97
wire[`DATA_ADDRESS_WIDTH-1:0] wWBMToMEM2__oDataWriteAddress;
98 82 diegovalve
 
99
 
100
assign oBusy = CYC_O;
101 31 diegovalve
wire wReadOperation;
102
assign wReadOperation = (iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE) ? 0 : 1;
103
 
104
 
105
assign wMEMToWBM_2__Address    = ( iAdr_O_Type == `ADR_IMM ) ? iAdr_O_Imm  : wMEMToWBM2__ReadDataElement;
106
assign w2WBMToMEM__Enable    = ( iAdr_O_Type == `ADR_IMM ) ? iEnable       : wMEMToWBM_2__Enable;
107
//assign oDone                  = ( (iAdr_O_Type == `ADR_IMM) && !(iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE) ) 
108
//? wWBMToMEM2__Done : wMEMToWBM_2__Done;
109
 
110
//TODO: WHEN ADR_POINTER Then Done is not until we got the 3 values from X,Y,Z in iAdr_O_Pointer
111
assign oDone = (iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE || iAdr_O_Type == `ADR_POINTER ) ? wMEMToWBM_2__Done : wWBMToMEM2__Done;
112
 
113
assign oDataWriteEnable  = (MST_I == 1'b1) ? wWBSToMEM2__oDataWriteEnable : (wWBMToMEM2__oDataWriteEnable);// ^ wAddrerssSelector2_oDataWriteEnable);
114
assign oDataWriteAddress = (MST_I == 1'b1) ? wWBSToMEM2__oDataWriteAddress : wWBMToMEM2__oDataWriteAddress;
115
assign oDataBus          = (MST_I == 1'b1) ? wWBSToMEM2__oDataBus : wWBMToMEM2__oDataBus;
116
 
117
 
118
 
119
 
120
 
121
 wire [`DATA_ADDRESS_WIDTH-1:0] wMEMToWBM2_WBMToMEM_RAMWriteAddr;
122
 wire [`DATA_ADDRESS_WIDTH-1:0] w2WBMToMEM_MEMWriteAddress;
123
 
124
assign w2WBMToMEM_MEMWriteAddress = ( iAdr_O_Type == `ADR_IMM) ? iAdr_DataWriteBack : wMEMToWBM2_WBMToMEM_RAMWriteAddr;
125
 
126
wire w2MEMToWBM_BusOperationComplete;
127
assign w2MEMToWBM_BusOperationComplete = (iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE) ? ACK_I  :  wWBMToMEM2__Done;
128
 
129
 
130
wire [`DATA_ADDRESS_WIDTH-1:0] w2MEMToWBM_DataPointer;
131
assign w2MEMToWBM_DataPointer = (iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE) ? iDat_O_Pointer : iAdr_O_Pointer;
132
//------------------------------------------------------------------------------
133
MEM2WBMUnitB MEMToWBM
134
(
135
.Clock(                        Clock                                           ),
136
.Reset(                        Reset                                           ),
137
.iEnable(                      iEnable & (~iAdr_O_Type | iBusCyc_Type)         ),
138
.iMEMDataPointer(           w2MEMToWBM_DataPointer                          ),
139
.iMEMDataPointer2(           iAdr_O_Pointer                          ),
140
.iReadDataBus(                 iReadDataBus                                                                     ),   //3 Elements comming from DMEM
141
.iReadDataBus2(                iReadDataBus2                                   ),
142
.oReadDataElement(             wMEMToWBM2__ReadDataElement                     ),       //1 out of 3 elements we read
143
.oReadDataElement2(            wMEMToWBM2__ReadDataElement2                     ),      //1 out of 3 elements we read
144
.oDataReadAddress(              oDataReadAddress                                ),
145
.oDataReadAddress2(              oDataReadAddress2                             ),
146
.oDataWriteEnable(              wAddrerssSelector2_oDataWriteEnable             ),   //Always zero
147
.oDataAvailable(              wMEMToWBM_2__Enable                             ),    //Data from MEM available
148
.iRequestNextElement(          w2MEMToWBM_BusOperationComplete                 ),
149
.iDataInitialStorageAddress(    iAdr_DataWriteBack                              ), ////########
150
.oDataWriteAddress(             wMEMToWBM2_WBMToMEM_RAMWriteAddr        ), ////########
151
.oDone(                        wMEMToWBM_2__Done                               )
152
);
153
//------------------------------------------------------------------------------
154
wire [`DATA_ADDRESS_WIDTH-1:0] wTemp1;
155
 assign wWBMToMEM2__oDataWriteAddress = (iAdr_O_Type == `ADR_IMM) ? iAdr_DataWriteBack : wTemp1;
156
WBM2MEMUnit WBMToMEM
157
(
158
.Clock(                 Clock                                     ),
159
.Reset(                 Reset                                     ),
160
.iEnable(              w2WBMToMEM__Enable & (wReadOperation | MST_I)  ), //Don't write stuff to MEM unless is Read bus cycle
161
 
162
.iStore(                iStore | ~iAdr_O_Type                     ),
163
.iWriteBack_Set( iWriteBack_Set ),
164
.iAdr_DataWriteBack(w2WBMToMEM_MEMWriteAddress              ),
165
//.iAdr_DataWriteBack(      iAdr_DataWriteBack ),
166
.iWBMDataAvailable(     wWBM_2_WBMToMEM_DataAvailable             ),
167
.iWBMData(              wWBM_2_WBMToMEM_Data                      ),
168
 
169
.oDataBus(               wWBMToMEM2__oDataBus                     ),
170
.oData(                 oData                                     ),
171
.oEnableWBM(           wWBMToMEM_2_WBM_Enable                   ),
172
.oDataWriteAddress(      wTemp1            ),///*******************!!!!!!!!!!!!!!
173
.oDataWriteEnable(       wWBMToMEM2__oDataWriteEnable             ),
174
.oDone(                 wWBMToMEM2__Done                          )
175
);
176
 
177
 
178
 
179
wire [`WIDTH-1:0] wADR_O_InitialAddress;
180
assign wADR_O_InitialAddress = (iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE) ? wMEMToWBM2__ReadDataElement2 : wMEMToWBM_2__Address;
181
wire wIncrement_Address_O;
182
assign wIncrement_Address_O = iEnable & ACK_I;
183
 
184
 
185
 
186
wire                 wMEMToWBM2__Done;
187
wire                 wMEMToWBM2__Trigger;
188
wire[`WB_WIDTH-1:0]  wMEMToWBM_2_Data;
189
wire                 w2MEMToWBM__Trigger;
190
wire                 wWBM2_MEMToWBM_DataWriteDone;
191
 
192
 
193
wire w2WBM_iEnable;
194 76 diegovalve
 
195 31 diegovalve
assign w2WBM_iEnable = (iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE) ? wMEMToWBM_2__Enable : iEnable;
196 76 diegovalve
 
197 31 diegovalve
//------------------------------------------------------------------------------
198
wire wSTB_O;
199
 
200
//If the address is a pointer, we need 1 cycle to read the data back from MEM
201
//before we can the set the value into WBM
202
wire wAddress_Set_Delayed;
203
FFD_POSEDGE_SYNCRONOUS_RESET # (1) FFD32_SetDelay
204
(
205
        .Clock(         Clock ),
206
        .Reset(         Reset ),
207
        .Enable( 1'b1 ),
208
        .D( iAdr_O_Set ),
209
        .Q( wAddress_Set_Delayed )
210
 
211
);
212
 
213
//If the Addr is IMM then just set it whenever iAdr_O_Set is set, but if we have a pointer, then use
214
//wAddress_Set_Delayed at the beginning and then wWBMToMEM2__Done
215
wire wWBM_iAddress_Set = (iAdr_O_Type == `ADR_POINTER) ? (wAddress_Set_Delayed | wWBMToMEM2__Done) :    iAdr_O_Set;
216
 
217
assign STB_O = wSTB_O & ~oDone;
218
 
219
        WishBoneMasterUnit WBM
220
        (
221
                .CLK_I(         Clock ),
222
                .RST_I(         Reset ),
223
                .DAT_I(         DAT_I ),
224
                .DAT_O(  DAT_O ),
225 76 diegovalve
                .ACK_I(         ACK_I  ),
226 31 diegovalve
                .ADR_O(         ADR_O ),
227
                .WE_O(  WE_O ),
228
                .STB_O( wSTB_O ),
229
                .CYC_O( CYC_O   ),
230 76 diegovalve
                .TGC_O( TGC_O   ),
231
                .GNT_I(  GNT_I ),
232 31 diegovalve
 
233 76 diegovalve
                .iEnable(                       w2WBM_iEnable       ),
234 31 diegovalve
                .iBusCyc_Type(    iBusCyc_Type                     ),
235 76 diegovalve
                .iAddress_Set(  wWBM_iAddress_Set  ),
236 31 diegovalve
                .iAddress(            wADR_O_InitialAddress            ),
237
                .oDataReady(            wWBM_2_WBMToMEM_DataAvailable    ),
238
                .iData(           wMEMToWBM2__ReadDataElement      ),
239
                .oData(                                 wWBM_2_WBMToMEM_Data                       )
240
        );
241
//------------------------------------------------------------------------------
242
WishBoneSlaveUnit WBS
243
(
244
 
245
                .CLK_I(         Clock  ),
246
                .RST_I(         Reset  ),
247
                .STB_I(  STB_I  ),
248
           .WE_I(   WE_I   ),
249
                .DAT_I(  DAT_I  ),
250
           .ADR_I(  ADR_I  ),
251
                .TGA_I(  TGA_I  ),
252
                .ACK_O(  ACK_O  ),
253
                .CYC_I(  CYC_I  ),
254
                .MST_I(  MST_I ),
255
 
256
                .oDataBus(               wWBSToMEM2__oDataBus                    ),
257
                .oInstructionBus(        oInstructionBus                         ),
258
                .oDataWriteAddress(      wWBSToMEM2__oDataWriteAddress           ),
259
                .oDataWriteEnable(       wWBSToMEM2__oDataWriteEnable            ),
260
                .oInstructionWriteAddress(      oInstructionWriteAddress         ),
261
                .oInstructionWriteEnable(       oInstructionWriteEnable          )
262
 
263
 
264
 
265
);
266
//------------------------------------------------------------------------------
267
 
268
 
269
endmodule
270
//--------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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