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 196

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 175 diegovalve
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
input wire [`DATA_ROW_WIDTH-1:0]       iDataRead0,
40
input wire [`DATA_ROW_WIDTH-1:0]       iDataRead1,
41 158 diegovalve
input wire                             iTrigger,
42 175 diegovalve
output wire [`ROM_ADDRESS_WIDTH-1:0]   oInstructionPointer1,
43
output wire [`ROM_ADDRESS_WIDTH-1:0]   oInstructionPointer2,
44
output wire [`DATA_ADDRESS_WIDTH-1:0]  oDataReadAddress0,
45 158 diegovalve
output wire [`DATA_ADDRESS_WIDTH-1:0]  oDataReadAddress1,
46 175 diegovalve
output wire                            oDataWriteEnable,
47
output wire [`DATA_ADDRESS_WIDTH-1:0]  oDataWriteAddress,
48
output wire [`DATA_ROW_WIDTH-1:0]      oDataBus,
49 158 diegovalve
output wire                            oReturnCode,
50 175 diegovalve
output wire [`DATA_ROW_WIDTH-1:0]      oOMEMWriteAddress,
51
output wire [`DATA_ROW_WIDTH-1:0]      oOMEMWriteData,
52
output wire                            oOMEMWriteEnable,
53
output wire [`DATA_ROW_WIDTH-1:0]      oTMEMReadAddress,
54
input wire [`DATA_ROW_WIDTH-1:0]       iTMEMReadData,
55
input wire                             iTMEMDataAvailable,
56
output wire                            oTMEMDataRequest,
57 158 diegovalve
 
58
`ifdef DEBUG
59
input wire [`MAX_CORES-1:0]            iDebug_CoreID,
60
`endif
61
output wire                            oDone
62
 
63
 
64
 
65
 
66
);
67
 
68
 
69
`ifdef DEBUG
70 175 diegovalve
 wire [`ROM_ADDRESS_WIDTH-1:0]    wDEBUG_IDU2_EXE_InstructionPointer;
71 158 diegovalve
`endif
72 175 diegovalve
wire                              wEXE2__uCodeDone;
73
wire                              wEXE2_IFU__EXEBusy;
74
wire [`DATA_ADDRESS_WIDTH-1:0]    wEXE2_IDU_DataFordward_LastDestination;
75
wire                              wALU2_EXE__BranchTaken;
76
wire                              wALU2_IFU_BranchNotTaken;
77
wire [`INSTRUCTION_WIDTH-1:0]     wCurrentInstruction;
78
/* verilator lint_off UNOPTFLAT */
79
wire [`INSTRUCTION_OP_LENGTH-1:0] wOperation;
80
/* verilator lint_on UNOPTFLAT */
81
wire [`DATA_ROW_WIDTH-1:0]        wSource0,wSource1;
82
wire [`DATA_ADDRESS_WIDTH-1:0]    wDestination;
83 158 diegovalve
wire wInstructionAvailable;
84
 
85
//ALU wires
86 175 diegovalve
wire [`INSTRUCTION_OP_LENGTH-1:0]   ALU2Operation;
87
wire [`WIDTH-1:0]      ALU2ChannelA;
88
wire [`WIDTH-1:0]      ALU2ChannelB;
89
wire [`WIDTH-1:0]      ALU2ChannelC;
90
wire [`WIDTH-1:0]      ALU2ChannelD;
91
wire [`WIDTH-1:0]      ALU2ChannelE;
92
wire [`WIDTH-1:0]      ALU2ChannelF;
93
wire [`WIDTH-1:0]      ALU2ResultA;
94
wire [`WIDTH-1:0]      ALU2ResultB;
95
wire [`WIDTH-1:0]      ALU2ResultC;
96
wire          wEXE2_ALU__TriggerALU;
97
wire          ALU2OutputReady;
98
wire           w2FIU__BranchTaken;
99
wire [`ROM_ADDRESS_WIDTH-1:0] JumpIp;
100 158 diegovalve
wire  [`ROM_ADDRESS_WIDTH-1:0]   wIDU2_IFU_ReturnAddress;
101
wire                             wALU2_IFU_ReturnFromSub;
102
 
103 175 diegovalve
//wire wIDU2_IFU__InputsLatched; 
104 158 diegovalve
 
105
wire wEPU_Busy,wTriggerIFU;
106
wire [`ROM_ADDRESS_WIDTH-1:0] wEPU_IP,wIFU_IP,wCodeEntryPoint;
107
 
108
assign oInstructionPointer1 = (wEPU_Busy) ? wEPU_IP : wIFU_IP;
109
 
110
 
111
InstructionEntryPoint EPU
112
(
113
.Clock( Clock ),
114
.Reset( Reset ),
115
.iTrigger( iTrigger ),
116
.iInitialCodeAddress( iInitialCodeAddress ),
117
.iIMemInput(iInstruction1),
118
 
119
.oEPU_Busy(wEPU_Busy),
120
.oEntryPoint( wCodeEntryPoint ),
121
.oTriggerIFU( wTriggerIFU ),
122
.oInstructionAddr( wEPU_IP )
123
 
124
);
125
 
126
InstructionFetch IFU
127
(
128
.Clock( Clock                                  ),
129
.Reset( Reset                                  ),
130
.iTrigger(              wTriggerIFU            ),
131 175 diegovalve
.iInstruction1(         iInstruction1          ),
132 158 diegovalve
.iInstruction2(         iInstruction2          ),
133
.iInitialCodeAddress(   wCodeEntryPoint        ),
134
.iBranchTaken(          w2FIU__BranchTaken     ),
135
.iSubroutineReturn(     wALU2_IFU_ReturnFromSub ),
136
//.iReturnAddress(        wIDU2_IFU_ReturnAddress ),
137 175 diegovalve
.oCurrentInstruction(   wCurrentInstruction      ),
138 158 diegovalve
.oInstructionAvalable(  wInstructionAvailable   ),
139
.oIP(                   wIFU_IP                 ),
140
.oIP2(                  oInstructionPointer2    ),
141
.iEXEDone(              ALU2OutputReady         ),
142 175 diegovalve
.oMicroCodeReturnValue( oReturnCode             ),
143 158 diegovalve
.oExecutionDone(        oDone                   )
144
);
145
 
146
////---------------------------------------------------------
147
wire wIDU2_EXE_DataReady;
148
wire wEXE2_IDU_ExeLatchedValues;
149
 
150
InstructionDecode IDU
151
(
152 175 diegovalve
 .Clock( Clock ),
153
 .Reset( Reset ),
154
 .iEncodedInstruction( wCurrentInstruction ),
155
 .iInstructionAvailable( wInstructionAvailable ),
156
 //.iIP( oInstructionPointer1 ),
157
 //.oReturnAddress( wIDU2_IFU_ReturnAddress ),
158
 
159
 .oRamAddress0( oDataReadAddress0 ),
160
 .oRamAddress1( oDataReadAddress1 ),
161
 .iRamValue0( iDataRead0 ),
162
 .iRamValue1( iDataRead1 ),
163
 
164
 .iLastDestination( wEXE2_IDU_DataFordward_LastDestination ),
165
 .iDataForward( {ALU2ResultA,ALU2ResultB,ALU2ResultC} ),
166
 
167
 //Outputs going to the ALU-FSM
168
 .oOperation( wOperation ),
169
 .oDestination( wDestination ),
170
 .oSource0( wSource0 ),
171
 .oSource1( wSource1  ),
172
 
173
 `ifdef DEBUG
174
 .iDebug_CurrentIP( oInstructionPointer1 ),
175
 .oDebug_CurrentIP( wDEBUG_IDU2_EXE_InstructionPointer ),
176
 `endif
177
 
178
 .oDataReadyForExe( wIDU2_EXE_DataReady )
179
 
180
 
181
 
182
 
183
 
184 158 diegovalve
);
185
 
186
 
187 175 diegovalve
ExecutionFSM  EXE
188 158 diegovalve
(
189 175 diegovalve
 .Clock( Clock ),
190
 .Reset( Reset | iTrigger ),  //New Sat Jun13
191
 .iDecodeDone( wIDU2_EXE_DataReady ),
192
 .iOperation( wOperation ),
193
 .iDestination( wDestination ),
194
 .iSource0( wSource0 ),
195
 .iSource1( wSource1 ) ,
196 158 diegovalve
 
197 175 diegovalve
 
198
 `ifdef DEBUG
199
  .iDebug_CurrentIP( wDEBUG_IDU2_EXE_InstructionPointer ),
200
  .iDebug_CoreID( iDebug_CoreID ),
201
 `endif
202
 
203
 //.iJumpResultFromALU( wALU2_EXE__BranchTaken ),
204
 .iBranchTaken( wALU2_EXE__BranchTaken ),
205
 .iBranchNotTaken( wALU2_IFU_BranchNotTaken ),
206
 .oJumpFlag( w2FIU__BranchTaken ),
207
 .oJumpIp( JumpIp ),
208
 .oRAMWriteEnable( oDataWriteEnable ),
209
 .oRAMWriteAddress( oDataWriteAddress ),
210
 .RAMBus( oDataBus ),
211
 .oBusy( wEXE2_IFU__EXEBusy ),
212 158 diegovalve
 
213 175 diegovalve
 .oExeLatchedValues( wEXE2_IDU_ExeLatchedValues ),
214
 .oLastDestination( wEXE2_IDU_DataFordward_LastDestination ),
215 158 diegovalve
 
216 175 diegovalve
 //ALU ports and control signals
217
 .oTriggerALU( wEXE2_ALU__TriggerALU ),
218
 .oALUOperation( ALU2Operation ),
219
 .oALUChannelX1( ALU2ChannelA ),
220
 .oALUChannelX2( ALU2ChannelB ),
221
 .oALUChannelY1( ALU2ChannelC ),
222
 .oALUChannelY2( ALU2ChannelD ),
223
 .oALUChannelZ1( ALU2ChannelE ),
224
 .oALUChannelZ2( ALU2ChannelF ),
225
 .iALUResultX( ALU2ResultA ),
226
 .iALUResultY( ALU2ResultB ),
227
 .iALUResultZ( ALU2ResultC ),
228
 .iALUOutputReady( ALU2OutputReady )
229 158 diegovalve
 
230
);
231
 
232
 
233
//--------------------------------------------------------
234
 
235
VectorALU ALU
236
(
237 175 diegovalve
 .Clock(Clock),
238
 .Reset(Reset),
239
 .iOperation( ALU2Operation ),
240
 .iChannel_Ax( ALU2ChannelA ),
241
 .iChannel_Bx( ALU2ChannelB ),
242
 .iChannel_Ay( ALU2ChannelC ),
243
 .iChannel_By( ALU2ChannelD ),
244
 .iChannel_Az( ALU2ChannelE ),
245
 .iChannel_Bz( ALU2ChannelF ),
246
 .oResultA( ALU2ResultA ),
247
 .oResultB( ALU2ResultB ),
248
 .oResultC( ALU2ResultC ),
249
 .oBranchTaken( wALU2_EXE__BranchTaken ),
250
 .oBranchNotTaken( wALU2_IFU_BranchNotTaken ),
251
 .oReturnFromSub( wALU2_IFU_ReturnFromSub ),
252
 .iInputReady( wEXE2_ALU__TriggerALU ),
253
 
254
 //***********
255
 .oOMEMWriteAddress(   oOMEMWriteAddress ),
256
 .oOMEMWriteData(      oOMEMWriteData    ),
257
 .oOMEM_WriteEnable(   oOMEMWriteEnable ),
258
 
259
 .oTMEMReadAddress(     oTMEMReadAddress ),
260
 .iTMEMReadData(        iTMEMReadData    ),
261
 .iTMEMDataAvailable(   iTMEMDataAvailable ),
262
 .oTMEMDataRequest(     oTMEMDataRequest   ),
263
 //***********
264
 .iCurrentIP( oInstructionPointer1 ),
265
 .OutputReady( ALU2OutputReady )
266
 
267 158 diegovalve
);
268 175 diegovalve
 
269 158 diegovalve
 
270
 
271
endmodule
272 174 diegovalve
//---------------------------------------------------------------------

powered by: WebSVN 2.1.0

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