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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [icarus_version/] [rtl/] [Unit_EXE.v] - Diff between revs 174 and 175

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 174 Rev 175
`timescale 1ns / 1ps
`timescale 1ns / 1ps
`include "aDefinitions.v"
`include "aDefinitions.v"
`ifdef VERILATOR
`ifdef VERILATOR
`include "Module_InstructionEntryPoint.v"
`include "Module_InstructionEntryPoint.v"
`include "Module_InstructionFetch.v"
`include "Module_InstructionFetch.v"
`include "Module_InstructionDecode.v"
`include "Module_InstructionDecode.v"
`include "Module_VectorALU.v"
`include "Module_VectorALU.v"
`include "Module_ExecutionFSM.v"
`include "Module_ExecutionFSM.v"
`endif
`endif
/**********************************************************************************
/**********************************************************************************
Theia, Ray Cast Programable graphic Processing Unit.
Theia, Ray Cast Programable graphic Processing Unit.
Copyright (C) 2010  Diego Valverde (diego.valverde.g@gmail.com)
Copyright (C) 2010  Diego Valverde (diego.valverde.g@gmail.com)
 
 
This program is free software; you can redistribute it and/or
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
of the License, or (at your option) any later version.
 
 
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
GNU General Public License for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 
***********************************************************************************/
***********************************************************************************/
 
 
//---------------------------------------------------------------------
//---------------------------------------------------------------------
module ExecutionUnit
module ExecutionUnit
(
(
 
 
input wire                             Clock,
input wire                             Clock,
input wire                             Reset,
input wire                             Reset,
input wire [`ROM_ADDRESS_WIDTH-1:0]         iInitialCodeAddress,
input wire [`ROM_ADDRESS_WIDTH-1:0]    iInitialCodeAddress,
input wire [`INSTRUCTION_WIDTH-1:0]      iInstruction1,
input wire [`INSTRUCTION_WIDTH-1:0]    iInstruction1,
input wire [`INSTRUCTION_WIDTH-1:0]      iInstruction2,
input wire [`INSTRUCTION_WIDTH-1:0]      iInstruction2,
 
 
 
 
input wire [`DATA_ROW_WIDTH-1:0]                 iDataRead0,
input wire [`DATA_ROW_WIDTH-1:0]                 iDataRead0,
input wire [`DATA_ROW_WIDTH-1:0]       iDataRead1,
input wire [`DATA_ROW_WIDTH-1:0]       iDataRead1,
input wire                             iTrigger,
input wire                             iTrigger,
 
 
 
 
output wire [`ROM_ADDRESS_WIDTH-1:0]     oInstructionPointer1,
output wire [`ROM_ADDRESS_WIDTH-1:0]     oInstructionPointer1,
output wire [`ROM_ADDRESS_WIDTH-1:0]     oInstructionPointer2,
output wire [`ROM_ADDRESS_WIDTH-1:0]   oInstructionPointer2,
output wire [`DATA_ADDRESS_WIDTH-1:0]    oDataReadAddress0,
output wire [`DATA_ADDRESS_WIDTH-1:0]  oDataReadAddress0,
output wire [`DATA_ADDRESS_WIDTH-1:0]  oDataReadAddress1,
output wire [`DATA_ADDRESS_WIDTH-1:0]  oDataReadAddress1,
output wire                                                                     oDataWriteEnable,
output wire                            oDataWriteEnable,
output wire [`DATA_ADDRESS_WIDTH-1:0]    oDataWriteAddress,
output wire [`DATA_ADDRESS_WIDTH-1:0]  oDataWriteAddress,
output wire [`DATA_ROW_WIDTH-1:0]                oDataBus,
output wire [`DATA_ROW_WIDTH-1:0]      oDataBus,
output wire                            oReturnCode,
output wire                            oReturnCode,
 
 
 
 
output wire [`DATA_ROW_WIDTH-1:0]    oOMEMWriteAddress,
output wire [`DATA_ROW_WIDTH-1:0]    oOMEMWriteAddress,
output wire [`DATA_ROW_WIDTH-1:0]    oOMEMWriteData,
output wire [`DATA_ROW_WIDTH-1:0]      oOMEMWriteData,
output wire                                 oOMEMWriteEnable,
output wire                            oOMEMWriteEnable,
output wire [`DATA_ROW_WIDTH-1:0]    oTMEMReadAddress,
output wire [`DATA_ROW_WIDTH-1:0]      oTMEMReadAddress,
input wire [`DATA_ROW_WIDTH-1:0]     iTMEMReadData,
input wire [`DATA_ROW_WIDTH-1:0]       iTMEMReadData,
input wire                           iTMEMDataAvailable,
input wire                             iTMEMDataAvailable,
output wire                          oTMEMDataRequest,
output wire                            oTMEMDataRequest,
 
 
`ifdef DEBUG
`ifdef DEBUG
input wire [`MAX_CORES-1:0]            iDebug_CoreID,
input wire [`MAX_CORES-1:0]            iDebug_CoreID,
`endif
`endif
output wire                            oDone
output wire                            oDone
 
 
 
 
 
 
 
 
);
);
 
 
 
 
`ifdef DEBUG
`ifdef DEBUG
        wire [`ROM_ADDRESS_WIDTH-1:0] wDEBUG_IDU2_EXE_InstructionPointer;
 wire [`ROM_ADDRESS_WIDTH-1:0]    wDEBUG_IDU2_EXE_InstructionPointer;
`endif
`endif
 
 
wire                                                                            wEXE2__uCodeDone;
wire                                                                            wEXE2__uCodeDone;
wire                                                                            wEXE2_IFU__EXEBusy;
wire                              wEXE2_IFU__EXEBusy;
wire [`DATA_ADDRESS_WIDTH-1:0]   wEXE2_IDU_DataFordward_LastDestination;
wire [`DATA_ADDRESS_WIDTH-1:0]    wEXE2_IDU_DataFordward_LastDestination;
wire                                                                            wALU2_EXE__BranchTaken;
wire                              wALU2_EXE__BranchTaken;
wire                                                                            wALU2_IFU_BranchNotTaken;
wire                                                                            wALU2_IFU_BranchNotTaken;
wire [`INSTRUCTION_WIDTH-1:0]    CurrentInstruction;
wire [`INSTRUCTION_WIDTH-1:0]     wCurrentInstruction;
//wire                                                                          wIDU2_IFU__IDUBusy;
 
 
 
/* verilator lint_off UNOPTFLAT*/
/* verilator lint_off UNOPTFLAT*/
wire [`INSTRUCTION_OP_LENGTH-1:0]                                wOperation /* verilator isolate_assignments*/;
wire [`INSTRUCTION_OP_LENGTH-1:0] wOperation;
/* verilator lint_on UNOPTFLAT*/
/* verilator lint_on UNOPTFLAT*/
 
 
wire [`DATA_ROW_WIDTH-1:0] wSource0,wSource1;
wire [`DATA_ROW_WIDTH-1:0] wSource0,wSource1;
wire [`DATA_ADDRESS_WIDTH-1:0] wDestination;
wire [`DATA_ADDRESS_WIDTH-1:0]    wDestination;
wire wInstructionAvailable;
wire wInstructionAvailable;
 
 
//ALU wires
//ALU wires
wire [`INSTRUCTION_OP_LENGTH-1:0]                ALU2Operation;
wire [`INSTRUCTION_OP_LENGTH-1:0]   ALU2Operation;
wire [`WIDTH-1:0]                                        ALU2ChannelA;
wire [`WIDTH-1:0]      ALU2ChannelA;
wire [`WIDTH-1:0]                                        ALU2ChannelB;
wire [`WIDTH-1:0]      ALU2ChannelB;
wire [`WIDTH-1:0]                                        ALU2ChannelC;
wire [`WIDTH-1:0]      ALU2ChannelC;
wire [`WIDTH-1:0]                                        ALU2ChannelD;
wire [`WIDTH-1:0]      ALU2ChannelD;
wire [`WIDTH-1:0]                                        ALU2ChannelE;
wire [`WIDTH-1:0]      ALU2ChannelE;
wire [`WIDTH-1:0]                                        ALU2ChannelF;
wire [`WIDTH-1:0]      ALU2ChannelF;
wire [`WIDTH-1:0]                                        ALU2ResultA;
wire [`WIDTH-1:0]      ALU2ResultA;
wire [`WIDTH-1:0]                                        ALU2ResultB;
wire [`WIDTH-1:0]      ALU2ResultB;
wire [`WIDTH-1:0]                                        ALU2ResultC;
wire [`WIDTH-1:0]      ALU2ResultC;
wire                                                                            wEXE2_ALU__TriggerALU;
wire          wEXE2_ALU__TriggerALU;
wire                                                                            ALU2OutputReady;
wire          ALU2OutputReady;
wire                                                                            w2FIU__BranchTaken;
wire           w2FIU__BranchTaken;
wire    [`ROM_ADDRESS_WIDTH-1:0] JumpIp;
wire [`ROM_ADDRESS_WIDTH-1:0] JumpIp;
wire  [`ROM_ADDRESS_WIDTH-1:0]   wIDU2_IFU_ReturnAddress;
wire  [`ROM_ADDRESS_WIDTH-1:0]   wIDU2_IFU_ReturnAddress;
wire                             wALU2_IFU_ReturnFromSub;
wire                             wALU2_IFU_ReturnFromSub;
 
 
//wire wIDU2_IFU__InputsLatched;        
//wire wIDU2_IFU__InputsLatched; 
 
 
wire wEPU_Busy,wTriggerIFU;
wire wEPU_Busy,wTriggerIFU;
wire [`ROM_ADDRESS_WIDTH-1:0] wEPU_IP,wIFU_IP,wCodeEntryPoint;
wire [`ROM_ADDRESS_WIDTH-1:0] wEPU_IP,wIFU_IP,wCodeEntryPoint;
 
 
assign oInstructionPointer1 = (wEPU_Busy) ? wEPU_IP : wIFU_IP;
assign oInstructionPointer1 = (wEPU_Busy) ? wEPU_IP : wIFU_IP;
 
 
 
 
InstructionEntryPoint EPU
InstructionEntryPoint EPU
(
(
.Clock( Clock ),
.Clock( Clock ),
.Reset( Reset ),
.Reset( Reset ),
.iTrigger( iTrigger ),
.iTrigger( iTrigger ),
.iInitialCodeAddress( iInitialCodeAddress ),
.iInitialCodeAddress( iInitialCodeAddress ),
.iIMemInput(iInstruction1),
.iIMemInput(iInstruction1),
 
 
.oEPU_Busy(wEPU_Busy),
.oEPU_Busy(wEPU_Busy),
.oEntryPoint( wCodeEntryPoint ),
.oEntryPoint( wCodeEntryPoint ),
.oTriggerIFU( wTriggerIFU ),
.oTriggerIFU( wTriggerIFU ),
.oInstructionAddr( wEPU_IP )
.oInstructionAddr( wEPU_IP )
 
 
);
);
 
 
InstructionFetch IFU
InstructionFetch IFU
(
(
.Clock( Clock                                  ),
.Clock( Clock                                  ),
.Reset( Reset                                  ),
.Reset( Reset                                  ),
.iTrigger(              wTriggerIFU            ),
.iTrigger(              wTriggerIFU            ),
.iInstruction1(         iInstruction1          ),
.iInstruction1(         iInstruction1          ),
.iInstruction2(         iInstruction2          ),
.iInstruction2(         iInstruction2          ),
.iInitialCodeAddress(   wCodeEntryPoint        ),
.iInitialCodeAddress(   wCodeEntryPoint        ),
.iBranchTaken(          w2FIU__BranchTaken     ),
.iBranchTaken(          w2FIU__BranchTaken     ),
.iSubroutineReturn(     wALU2_IFU_ReturnFromSub ),
.iSubroutineReturn(     wALU2_IFU_ReturnFromSub ),
//.iReturnAddress(        wIDU2_IFU_ReturnAddress ),
//.iReturnAddress(        wIDU2_IFU_ReturnAddress ),
.oCurrentInstruction(   CurrentInstruction      ),
.oCurrentInstruction(   wCurrentInstruction      ),
.oInstructionAvalable(  wInstructionAvailable   ),
.oInstructionAvalable(  wInstructionAvailable   ),
.oIP(                   wIFU_IP                 ),
.oIP(                   wIFU_IP                 ),
.oIP2(                  oInstructionPointer2    ),
.oIP2(                  oInstructionPointer2    ),
.iEXEDone(              ALU2OutputReady         ),
.iEXEDone(              ALU2OutputReady         ),
.oMicroCodeReturnValue( oReturnCode             ),
.oMicroCodeReturnValue( oReturnCode             ),
.oExecutionDone(        oDone                   )
.oExecutionDone(        oDone                   )
);
);
 
 
////---------------------------------------------------------
////---------------------------------------------------------
wire wIDU2_EXE_DataReady;
wire wIDU2_EXE_DataReady;
wire wEXE2_IDU_ExeLatchedValues;
wire wEXE2_IDU_ExeLatchedValues;
 
 
InstructionDecode IDU
InstructionDecode IDU
(
(
        .Clock( Clock ),
 .Clock( Clock ),
        .Reset( Reset ),
        .Reset( Reset ),
        .iEncodedInstruction( CurrentInstruction ),
 .iEncodedInstruction( wCurrentInstruction ),
        .iInstructionAvailable( wInstructionAvailable ),
        .iInstructionAvailable( wInstructionAvailable ),
        //.iIP( oInstructionPointer1 ),
 //.iIP( oInstructionPointer1 ),
        //.oReturnAddress( wIDU2_IFU_ReturnAddress ),
 //.oReturnAddress( wIDU2_IFU_ReturnAddress ),
 
 
        .oRamAddress0( oDataReadAddress0 ),
 .oRamAddress0( oDataReadAddress0 ),
        .oRamAddress1( oDataReadAddress1 ),
 .oRamAddress1( oDataReadAddress1 ),
        .iRamValue0( iDataRead0 ),
 .iRamValue0( iDataRead0 ),
        .iRamValue1( iDataRead1 ),
 .iRamValue1( iDataRead1 ),
 
 
        .iLastDestination( wEXE2_IDU_DataFordward_LastDestination ),
 .iLastDestination( wEXE2_IDU_DataFordward_LastDestination ),
        .iDataForward( {ALU2ResultA,ALU2ResultB,ALU2ResultC} ),
 .iDataForward( {ALU2ResultA,ALU2ResultB,ALU2ResultC} ),
 
 
        //Outputs going to the ALU-FSM
 //Outputs going to the ALU-FSM
        .oOperation( wOperation ),
 .oOperation( wOperation ),
        .oDestination( wDestination ),
 .oDestination( wDestination ),
        .oSource0( wSource0 ),
 .oSource0( wSource0 ),
        .oSource1( wSource1  ),
 .oSource1( wSource1  ),
 
 
        `ifdef DEBUG
 `ifdef DEBUG
        .iDebug_CurrentIP( oInstructionPointer1 ),
 .iDebug_CurrentIP( oInstructionPointer1 ),
        .oDebug_CurrentIP( wDEBUG_IDU2_EXE_InstructionPointer ),
 .oDebug_CurrentIP( wDEBUG_IDU2_EXE_InstructionPointer ),
        `endif
 `endif
 
 
        .oDataReadyForExe( wIDU2_EXE_DataReady )
 .oDataReadyForExe( wIDU2_EXE_DataReady )
 
 
 
 
 
 
 
 
 
 
);
);
 
 
 
 
ExecutionFSM     EXE
ExecutionFSM  EXE
(
(
        .Clock( Clock ),
 .Clock( Clock ),
        .Reset( Reset | iTrigger ),  //New Sat Jun13
 .Reset( Reset | iTrigger ),  //New Sat Jun13
        .iDecodeDone( wIDU2_EXE_DataReady ),
 .iDecodeDone( wIDU2_EXE_DataReady ),
        .iOperation( wOperation ),
 .iOperation( wOperation ),
        .iDestination( wDestination ),
 .iDestination( wDestination ),
        .iSource0( wSource0 ),
 .iSource0( wSource0 ),
        .iSource1( wSource1 ) ,
 .iSource1( wSource1 ) ,
 
 
 
 
        `ifdef DEBUG
 `ifdef DEBUG
                .iDebug_CurrentIP( wDEBUG_IDU2_EXE_InstructionPointer ),
  .iDebug_CurrentIP( wDEBUG_IDU2_EXE_InstructionPointer ),
                .iDebug_CoreID( iDebug_CoreID ),
  .iDebug_CoreID( iDebug_CoreID ),
        `endif
 `endif
 
 
        //.iJumpResultFromALU( wALU2_EXE__BranchTaken ),
 //.iJumpResultFromALU( wALU2_EXE__BranchTaken ),
        .iBranchTaken( wALU2_EXE__BranchTaken ),
 .iBranchTaken( wALU2_EXE__BranchTaken ),
        .iBranchNotTaken( wALU2_IFU_BranchNotTaken ),
 .iBranchNotTaken( wALU2_IFU_BranchNotTaken ),
        .oJumpFlag( w2FIU__BranchTaken ),
 .oJumpFlag( w2FIU__BranchTaken ),
        .oJumpIp( JumpIp ),
 .oJumpIp( JumpIp ),
        .oRAMWriteEnable( oDataWriteEnable ),
 .oRAMWriteEnable( oDataWriteEnable ),
        .oRAMWriteAddress( oDataWriteAddress ),
 .oRAMWriteAddress( oDataWriteAddress ),
        .RAMBus( oDataBus ),
 .RAMBus( oDataBus ),
        .oBusy( wEXE2_IFU__EXEBusy ),
 .oBusy( wEXE2_IFU__EXEBusy ),
 
 
        .oExeLatchedValues( wEXE2_IDU_ExeLatchedValues ),
 .oExeLatchedValues( wEXE2_IDU_ExeLatchedValues ),
        .oLastDestination( wEXE2_IDU_DataFordward_LastDestination ),
 .oLastDestination( wEXE2_IDU_DataFordward_LastDestination ),
 
 
        //ALU ports and control signals
 //ALU ports and control signals
        .oTriggerALU( wEXE2_ALU__TriggerALU ),
 .oTriggerALU( wEXE2_ALU__TriggerALU ),
        .oALUOperation( ALU2Operation ),
 .oALUOperation( ALU2Operation ),
        .oALUChannelX1( ALU2ChannelA ),
 .oALUChannelX1( ALU2ChannelA ),
        .oALUChannelX2( ALU2ChannelB ),
 .oALUChannelX2( ALU2ChannelB ),
        .oALUChannelY1( ALU2ChannelC ),
 .oALUChannelY1( ALU2ChannelC ),
        .oALUChannelY2( ALU2ChannelD ),
 .oALUChannelY2( ALU2ChannelD ),
        .oALUChannelZ1( ALU2ChannelE ),
 .oALUChannelZ1( ALU2ChannelE ),
        .oALUChannelZ2( ALU2ChannelF ),
 .oALUChannelZ2( ALU2ChannelF ),
        .iALUResultX( ALU2ResultA ),
 .iALUResultX( ALU2ResultA ),
        .iALUResultY( ALU2ResultB ),
 .iALUResultY( ALU2ResultB ),
        .iALUResultZ( ALU2ResultC ),
 .iALUResultZ( ALU2ResultC ),
        .iALUOutputReady( ALU2OutputReady )
 .iALUOutputReady( ALU2OutputReady )
 
 
);
);
 
 
 
 
//--------------------------------------------------------
//--------------------------------------------------------
 
 
VectorALU ALU
VectorALU ALU
(
(
        .Clock(Clock),
 .Clock(Clock),
        .Reset(Reset),
 .Reset(Reset),
        .iOperation( ALU2Operation ),
 .iOperation( ALU2Operation ),
        .iChannel_Ax( ALU2ChannelA ),
 .iChannel_Ax( ALU2ChannelA ),
        .iChannel_Bx( ALU2ChannelB ),
 .iChannel_Bx( ALU2ChannelB ),
        .iChannel_Ay( ALU2ChannelC ),
 .iChannel_Ay( ALU2ChannelC ),
        .iChannel_By( ALU2ChannelD ),
 .iChannel_By( ALU2ChannelD ),
        .iChannel_Az( ALU2ChannelE ),
 .iChannel_Az( ALU2ChannelE ),
        .iChannel_Bz( ALU2ChannelF ),
 .iChannel_Bz( ALU2ChannelF ),
        .oResultA( ALU2ResultA ),
 .oResultA( ALU2ResultA ),
        .oResultB( ALU2ResultB ),
 .oResultB( ALU2ResultB ),
        .oResultC( ALU2ResultC ),
 .oResultC( ALU2ResultC ),
        .oBranchTaken( wALU2_EXE__BranchTaken ),
 .oBranchTaken( wALU2_EXE__BranchTaken ),
        .oBranchNotTaken( wALU2_IFU_BranchNotTaken ),
 .oBranchNotTaken( wALU2_IFU_BranchNotTaken ),
        .oReturnFromSub( wALU2_IFU_ReturnFromSub ),
 .oReturnFromSub( wALU2_IFU_ReturnFromSub ),
        .iInputReady( wEXE2_ALU__TriggerALU ),
 .iInputReady( wEXE2_ALU__TriggerALU ),
 
 
        //***********
 //***********
        .oOMEMWriteAddress(   oOMEMWriteAddress ),
 .oOMEMWriteAddress(   oOMEMWriteAddress ),
        .oOMEMWriteData(      oOMEMWriteData    ),
 .oOMEMWriteData(      oOMEMWriteData    ),
        .oOMEM_WriteEnable(   oOMEMWriteEnable ),
 .oOMEM_WriteEnable(   oOMEMWriteEnable ),
 
 
        .oTMEMReadAddress(     oTMEMReadAddress ),
 .oTMEMReadAddress(     oTMEMReadAddress ),
        .iTMEMReadData(        iTMEMReadData    ),
 .iTMEMReadData(        iTMEMReadData    ),
        .iTMEMDataAvailable(   iTMEMDataAvailable ),
 .iTMEMDataAvailable(   iTMEMDataAvailable ),
        .oTMEMDataRequest(     oTMEMDataRequest   ),
 .oTMEMDataRequest(     oTMEMDataRequest   ),
        //***********
 //***********
        .iCurrentIP( oInstructionPointer1 ),
 .iCurrentIP( oInstructionPointer1 ),
        .OutputReady( ALU2OutputReady )
 .OutputReady( ALU2OutputReady )
 
 
);
);
 
 
 
 
 
 
endmodule
endmodule
//---------------------------------------------------------------------
//---------------------------------------------------------------------
 
 

powered by: WebSVN 2.1.0

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