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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [icarus_version/] [rtl/] [Unit_EXE.v] - Blame information for rev 174

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_InstructionEntryPoint.v"
5
`include "Module_InstructionFetch.v"
6
`include "Module_InstructionDecode.v"
7
`include "Module_VectorALU.v"
8
`include "Module_ExecutionFSM.v"
9
`endif
10 158 diegovalve
/**********************************************************************************
11
Theia, Ray Cast Programable graphic Processing Unit.
12
Copyright (C) 2010  Diego Valverde (diego.valverde.g@gmail.com)
13
 
14
This program is free software; you can redistribute it and/or
15
modify it under the terms of the GNU General Public License
16
as published by the Free Software Foundation; either version 2
17
of the License, or (at your option) any later version.
18
 
19
This program is distributed in the hope that it will be useful,
20
but WITHOUT ANY WARRANTY; without even the implied warranty of
21
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
GNU General Public License for more details.
23
 
24
You should have received a copy of the GNU General Public License
25
along with this program; if not, write to the Free Software
26
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
27
 
28
***********************************************************************************/
29
 
30
//---------------------------------------------------------------------
31
module ExecutionUnit
32
(
33
 
34
input wire                             Clock,
35
input wire                             Reset,
36
input wire [`ROM_ADDRESS_WIDTH-1:0]         iInitialCodeAddress,
37
input wire [`INSTRUCTION_WIDTH-1:0]      iInstruction1,
38
input wire [`INSTRUCTION_WIDTH-1:0]      iInstruction2,
39
 
40
 
41
input wire [`DATA_ROW_WIDTH-1:0]                 iDataRead0,
42
input wire [`DATA_ROW_WIDTH-1:0]       iDataRead1,
43
input wire                             iTrigger,
44
 
45
 
46
output wire [`ROM_ADDRESS_WIDTH-1:0]     oInstructionPointer1,
47
output wire [`ROM_ADDRESS_WIDTH-1:0]     oInstructionPointer2,
48
output wire [`DATA_ADDRESS_WIDTH-1:0]    oDataReadAddress0,
49
output wire [`DATA_ADDRESS_WIDTH-1:0]  oDataReadAddress1,
50
output wire                                                                     oDataWriteEnable,
51
output wire [`DATA_ADDRESS_WIDTH-1:0]    oDataWriteAddress,
52
output wire [`DATA_ROW_WIDTH-1:0]                oDataBus,
53
output wire                            oReturnCode,
54
 
55
 
56
output wire [`DATA_ROW_WIDTH-1:0]    oOMEMWriteAddress,
57
output wire [`DATA_ROW_WIDTH-1:0]    oOMEMWriteData,
58
output wire                                 oOMEMWriteEnable,
59
output wire [`DATA_ROW_WIDTH-1:0]    oTMEMReadAddress,
60
input wire [`DATA_ROW_WIDTH-1:0]     iTMEMReadData,
61
input wire                           iTMEMDataAvailable,
62
output wire                          oTMEMDataRequest,
63
 
64
`ifdef DEBUG
65
input wire [`MAX_CORES-1:0]            iDebug_CoreID,
66
`endif
67
output wire                            oDone
68
 
69
 
70
 
71
 
72
);
73
 
74
 
75
`ifdef DEBUG
76
        wire [`ROM_ADDRESS_WIDTH-1:0] wDEBUG_IDU2_EXE_InstructionPointer;
77
`endif
78
 
79
wire                                                                            wEXE2__uCodeDone;
80
wire                                                                            wEXE2_IFU__EXEBusy;
81
wire [`DATA_ADDRESS_WIDTH-1:0]   wEXE2_IDU_DataFordward_LastDestination;
82
wire                                                                            wALU2_EXE__BranchTaken;
83
wire                                                                            wALU2_IFU_BranchNotTaken;
84
wire [`INSTRUCTION_WIDTH-1:0]    CurrentInstruction;
85
//wire                                                                          wIDU2_IFU__IDUBusy;
86
 
87 174 diegovalve
/* verilator lint_off UNOPTFLAT*/
88
wire [`INSTRUCTION_OP_LENGTH-1:0]                                wOperation /* verilator isolate_assignments*/;
89
/* verilator lint_on UNOPTFLAT*/
90 158 diegovalve
 
91
wire [`DATA_ROW_WIDTH-1:0] wSource0,wSource1;
92
wire [`DATA_ADDRESS_WIDTH-1:0] wDestination;
93
wire wInstructionAvailable;
94
 
95
//ALU wires
96
wire [`INSTRUCTION_OP_LENGTH-1:0]                ALU2Operation;
97
wire [`WIDTH-1:0]                                        ALU2ChannelA;
98
wire [`WIDTH-1:0]                                        ALU2ChannelB;
99
wire [`WIDTH-1:0]                                        ALU2ChannelC;
100
wire [`WIDTH-1:0]                                        ALU2ChannelD;
101
wire [`WIDTH-1:0]                                        ALU2ChannelE;
102
wire [`WIDTH-1:0]                                        ALU2ChannelF;
103
wire [`WIDTH-1:0]                                        ALU2ResultA;
104
wire [`WIDTH-1:0]                                        ALU2ResultB;
105
wire [`WIDTH-1:0]                                        ALU2ResultC;
106
wire                                                                            wEXE2_ALU__TriggerALU;
107
wire                                                                            ALU2OutputReady;
108
wire                                                                            w2FIU__BranchTaken;
109
wire    [`ROM_ADDRESS_WIDTH-1:0] JumpIp;
110
wire  [`ROM_ADDRESS_WIDTH-1:0]   wIDU2_IFU_ReturnAddress;
111
wire                             wALU2_IFU_ReturnFromSub;
112
 
113
//wire wIDU2_IFU__InputsLatched;        
114
 
115
wire wEPU_Busy,wTriggerIFU;
116
wire [`ROM_ADDRESS_WIDTH-1:0] wEPU_IP,wIFU_IP,wCodeEntryPoint;
117
 
118
assign oInstructionPointer1 = (wEPU_Busy) ? wEPU_IP : wIFU_IP;
119
 
120
 
121
InstructionEntryPoint EPU
122
(
123
.Clock( Clock ),
124
.Reset( Reset ),
125
.iTrigger( iTrigger ),
126
.iInitialCodeAddress( iInitialCodeAddress ),
127
.iIMemInput(iInstruction1),
128
 
129
.oEPU_Busy(wEPU_Busy),
130
.oEntryPoint( wCodeEntryPoint ),
131
.oTriggerIFU( wTriggerIFU ),
132
.oInstructionAddr( wEPU_IP )
133
 
134
);
135
 
136
InstructionFetch IFU
137
(
138
.Clock( Clock                                  ),
139
.Reset( Reset                                  ),
140
.iTrigger(              wTriggerIFU            ),
141
.iInstruction1(         iInstruction1          ),
142
.iInstruction2(         iInstruction2          ),
143
.iInitialCodeAddress(   wCodeEntryPoint        ),
144
.iBranchTaken(          w2FIU__BranchTaken     ),
145
.iSubroutineReturn(     wALU2_IFU_ReturnFromSub ),
146
//.iReturnAddress(        wIDU2_IFU_ReturnAddress ),
147
.oCurrentInstruction(   CurrentInstruction      ),
148
.oInstructionAvalable(  wInstructionAvailable   ),
149
.oIP(                   wIFU_IP                 ),
150
.oIP2(                  oInstructionPointer2    ),
151
.iEXEDone(              ALU2OutputReady         ),
152
.oMicroCodeReturnValue( oReturnCode             ),
153
.oExecutionDone(        oDone                   )
154
);
155
 
156
////---------------------------------------------------------
157
wire wIDU2_EXE_DataReady;
158
wire wEXE2_IDU_ExeLatchedValues;
159
 
160
InstructionDecode IDU
161
(
162
        .Clock( Clock ),
163
        .Reset( Reset ),
164
        .iEncodedInstruction( CurrentInstruction ),
165
        .iInstructionAvailable( wInstructionAvailable ),
166
        //.iIP( oInstructionPointer1 ),
167
        //.oReturnAddress( wIDU2_IFU_ReturnAddress ),
168
 
169
        .oRamAddress0( oDataReadAddress0 ),
170
        .oRamAddress1( oDataReadAddress1 ),
171
        .iRamValue0( iDataRead0 ),
172
        .iRamValue1( iDataRead1 ),
173
 
174
        .iLastDestination( wEXE2_IDU_DataFordward_LastDestination ),
175
        .iDataForward( {ALU2ResultA,ALU2ResultB,ALU2ResultC} ),
176
 
177
        //Outputs going to the ALU-FSM
178
        .oOperation( wOperation ),
179
        .oDestination( wDestination ),
180
        .oSource0( wSource0 ),
181
        .oSource1( wSource1  ),
182
 
183
        `ifdef DEBUG
184
        .iDebug_CurrentIP( oInstructionPointer1 ),
185
        .oDebug_CurrentIP( wDEBUG_IDU2_EXE_InstructionPointer ),
186
        `endif
187
 
188
        .oDataReadyForExe( wIDU2_EXE_DataReady )
189
 
190
 
191
 
192
 
193
 
194
);
195
 
196
 
197
ExecutionFSM     EXE
198
(
199
        .Clock( Clock ),
200
        .Reset( Reset | iTrigger ),  //New Sat Jun13
201
        .iDecodeDone( wIDU2_EXE_DataReady ),
202
        .iOperation( wOperation ),
203
        .iDestination( wDestination ),
204
        .iSource0( wSource0 ),
205
        .iSource1( wSource1 ) ,
206
 
207
 
208
        `ifdef DEBUG
209
                .iDebug_CurrentIP( wDEBUG_IDU2_EXE_InstructionPointer ),
210
                .iDebug_CoreID( iDebug_CoreID ),
211
        `endif
212
 
213
        //.iJumpResultFromALU( wALU2_EXE__BranchTaken ),
214
        .iBranchTaken( wALU2_EXE__BranchTaken ),
215
        .iBranchNotTaken( wALU2_IFU_BranchNotTaken ),
216
        .oJumpFlag( w2FIU__BranchTaken ),
217
        .oJumpIp( JumpIp ),
218
        .oRAMWriteEnable( oDataWriteEnable ),
219
        .oRAMWriteAddress( oDataWriteAddress ),
220
        .RAMBus( oDataBus ),
221
        .oBusy( wEXE2_IFU__EXEBusy ),
222
 
223
        .oExeLatchedValues( wEXE2_IDU_ExeLatchedValues ),
224
        .oLastDestination( wEXE2_IDU_DataFordward_LastDestination ),
225
 
226
        //ALU ports and control signals
227
        .oTriggerALU( wEXE2_ALU__TriggerALU ),
228
        .oALUOperation( ALU2Operation ),
229
        .oALUChannelX1( ALU2ChannelA ),
230
        .oALUChannelX2( ALU2ChannelB ),
231
        .oALUChannelY1( ALU2ChannelC ),
232
        .oALUChannelY2( ALU2ChannelD ),
233
        .oALUChannelZ1( ALU2ChannelE ),
234
        .oALUChannelZ2( ALU2ChannelF ),
235
        .iALUResultX( ALU2ResultA ),
236
        .iALUResultY( ALU2ResultB ),
237
        .iALUResultZ( ALU2ResultC ),
238
        .iALUOutputReady( ALU2OutputReady )
239
 
240
);
241
 
242
 
243
//--------------------------------------------------------
244
 
245
VectorALU ALU
246
(
247
        .Clock(Clock),
248
        .Reset(Reset),
249
        .iOperation( ALU2Operation ),
250
        .iChannel_Ax( ALU2ChannelA ),
251
        .iChannel_Bx( ALU2ChannelB ),
252
        .iChannel_Ay( ALU2ChannelC ),
253
        .iChannel_By( ALU2ChannelD ),
254
        .iChannel_Az( ALU2ChannelE ),
255
        .iChannel_Bz( ALU2ChannelF ),
256
        .oResultA( ALU2ResultA ),
257
        .oResultB( ALU2ResultB ),
258
        .oResultC( ALU2ResultC ),
259
        .oBranchTaken( wALU2_EXE__BranchTaken ),
260
        .oBranchNotTaken( wALU2_IFU_BranchNotTaken ),
261
        .oReturnFromSub( wALU2_IFU_ReturnFromSub ),
262
        .iInputReady( wEXE2_ALU__TriggerALU ),
263
 
264
        //***********
265
        .oOMEMWriteAddress(   oOMEMWriteAddress ),
266
        .oOMEMWriteData(      oOMEMWriteData    ),
267
        .oOMEM_WriteEnable(   oOMEMWriteEnable ),
268
 
269
        .oTMEMReadAddress(     oTMEMReadAddress ),
270
        .iTMEMReadData(        iTMEMReadData    ),
271
        .iTMEMDataAvailable(   iTMEMDataAvailable ),
272
        .oTMEMDataRequest(     oTMEMDataRequest   ),
273
        //***********
274
        .iCurrentIP( oInstructionPointer1 ),
275
        .OutputReady( ALU2OutputReady )
276
 
277
);
278
 
279
 
280
 
281
endmodule
282 174 diegovalve
//---------------------------------------------------------------------

powered by: WebSVN 2.1.0

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