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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [tags/] [latest_stable/] [rtl/] [GPU/] [CORES/] [IO/] [Unit_IO.v] - Blame information for rev 76

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

powered by: WebSVN 2.1.0

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