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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [tags/] [Beta_0.2/] [rtl/] [EXE/] [Module_ExecutionFSM.v] - Diff between revs 82 and 86

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

Rev 82 Rev 86
`timescale 1ns / 1ps
`timescale 1ns / 1ps
`include "aDefinitions.v"
`include "aDefinitions.v"
/**********************************************************************************
/**********************************************************************************
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.
 
 
***********************************************************************************/
***********************************************************************************/
`define EXEU_AFTER_RESET                                                        0
`define EXEU_AFTER_RESET                                                        0
`define EXEU_INITIAL_STATE                                              1
`define EXEU_INITIAL_STATE                                              1
`define EXEU_WAIT_FOR_DECODE                                            2
`define EXEU_WAIT_FOR_DECODE                                            2
`define EXEU_FETCH_DECODED_INST                                 3
`define EXEU_FETCH_DECODED_INST                                 3
`define EXEU_WAIT_FOR_ALU_EXECUTION                             4
`define EXEU_WAIT_FOR_ALU_EXECUTION                             4
`define EXEU_WRITE_BACK_TO_RAM                                  5
`define EXEU_WRITE_BACK_TO_RAM                                  5
`define EXEU_HANDLE_JUMP                                                        7
`define EXEU_HANDLE_JUMP                                                        7
 
 
 
 
 
 
module ExecutionFSM
module ExecutionFSM
(
(
input wire                                                              Clock,
input wire                                                              Clock,
input wire                                                              Reset,
input wire                                                              Reset,
 
 
input   wire                                                                            iDecodeDone,
input   wire                                                                            iDecodeDone,
input wire[`INSTRUCTION_OP_LENGTH-1:0]   iOperation,
input wire[`INSTRUCTION_OP_LENGTH-1:0]   iOperation,
input wire[`DATA_ROW_WIDTH-1:0]                          iSource0,iSource1,
input wire[`DATA_ROW_WIDTH-1:0]                          iSource0,iSource1,
input wire[`DATA_ADDRESS_WIDTH-1:0]              iDestination,
input wire[`DATA_ADDRESS_WIDTH-1:0]              iDestination,
inout wire[`DATA_ROW_WIDTH-1:0]                          RAMBus,
inout wire[`DATA_ROW_WIDTH-1:0]                          RAMBus,
//output        reg                                                                     ReadyForNextInstruction,
//output        reg                                                                     ReadyForNextInstruction,
output wire                                                                     oJumpFlag                       ,
output wire                                                                     oJumpFlag                       ,
output  wire [`ROM_ADDRESS_WIDTH-1:0]    oJumpIp                                 ,
output  wire [`ROM_ADDRESS_WIDTH-1:0]    oJumpIp                                 ,
output  wire                                                                    oRAMWriteEnable         ,
output  wire                                                                    oRAMWriteEnable         ,
output  wire [`DATA_ADDRESS_WIDTH-1:0]   oRAMWriteAddress        ,
output  wire [`DATA_ADDRESS_WIDTH-1:0]   oRAMWriteAddress        ,
output  wire                                                                    oExeLatchedValues,
output  wire                                                                    oExeLatchedValues,
output  reg                                                                             oBusy ,
output  reg                                                                             oBusy ,
 
 
//ALU ports and control signals
//ALU ports and control signals
output  wire [`INSTRUCTION_OP_LENGTH-1:0]                                oALUOperation,
output  wire [`INSTRUCTION_OP_LENGTH-1:0]                                oALUOperation,
output  wire [`WIDTH-1:0]                                                                        oALUChannelX1,
output  wire [`WIDTH-1:0]                                                                        oALUChannelX1,
output  wire [`WIDTH-1:0]                                                                        oALUChannelY1,
output  wire [`WIDTH-1:0]                                                                        oALUChannelY1,
output  wire [`WIDTH-1:0]                                                                        oALUChannelZ1,
output  wire [`WIDTH-1:0]                                                                        oALUChannelZ1,
output  wire [`WIDTH-1:0]                                                                        oALUChannelX2,
output  wire [`WIDTH-1:0]                                                                        oALUChannelX2,
output  wire [`WIDTH-1:0]                                                                        oALUChannelY2,
output  wire [`WIDTH-1:0]                                                                        oALUChannelY2,
output  wire [`WIDTH-1:0]                                                                        oALUChannelZ2,
output  wire [`WIDTH-1:0]                                                                        oALUChannelZ2,
output  wire                                                                                                    oTriggerALU,
output  wire                                                                                                    oTriggerALU,
 
 
input  wire   [`WIDTH-1:0]                                                                       iALUResultX,
input  wire   [`WIDTH-1:0]                                                                       iALUResultX,
input  wire       [`WIDTH-1:0]                                                                   iALUResultY,
input  wire       [`WIDTH-1:0]                                                                   iALUResultY,
input wire        [`WIDTH-1:0]                                                                   iALUResultZ,
input wire        [`WIDTH-1:0]                                                                   iALUResultZ,
input wire                                                                                                              iALUOutputReady,
input wire                                                                                                              iALUOutputReady,
input   wire                                                                                                            iBranchTaken,
input   wire                                                                                                            iBranchTaken,
input wire                                                                                                              iBranchNotTaken,
input wire                                                                                                              iBranchNotTaken,
 
 
`ifdef DEBUG
`ifdef DEBUG
        input wire[`ROM_ADDRESS_WIDTH-1:0]  iDebug_CurrentIP,
        input wire[`ROM_ADDRESS_WIDTH-1:0]  iDebug_CurrentIP,
        input wire [`MAX_CORES-1:0]         iDebug_CoreID,
        input wire [`MAX_CORES-1:0]         iDebug_CoreID,
`endif
`endif
//Data forward Signals
//Data forward Signals
output wire [`DATA_ADDRESS_WIDTH-1:0] oLastDestination
output wire [`DATA_ADDRESS_WIDTH-1:0] oLastDestination
 
 
 
 
);
);
 
 
wire wLatchNow;
wire wLatchNow;
reg rInputLatchesEnabled;
reg rInputLatchesEnabled;
 
 
//If ALU says jump, just pass along
//If ALU says jump, just pass along
assign oJumpFlag = iBranchTaken;
assign oJumpFlag = iBranchTaken;
//JumpIP is the instruction destination (= oRAMWriteAddress)
//JumpIP is the instruction destination (= oRAMWriteAddress)
assign oJumpIp = oRAMWriteAddress;
assign oJumpIp = oRAMWriteAddress;
 
 
assign wLatchNow = iDecodeDone & rInputLatchesEnabled;
assign wLatchNow = iDecodeDone & rInputLatchesEnabled;
assign oExeLatchedValues = wLatchNow;
assign oExeLatchedValues = wLatchNow;
assign oTriggerALU = wLatchNow;
assign oTriggerALU = wLatchNow;
 
 
wire wOperationIsJump;
wire wOperationIsJump;
assign wOperationIsJump = iBranchTaken || iBranchNotTaken;
assign wOperationIsJump = iBranchTaken || iBranchNotTaken;
 
 
//Don't allow me to write back back if the operation is a NOP
//Don't allow me to write back back if the operation is a NOP
`ifdef DEBUG
`ifdef DEBUG
        assign oRAMWriteEnable = iALUOutputReady && !wOperationIsJump &&
        assign oRAMWriteEnable = iALUOutputReady && !wOperationIsJump &&
                (oALUOperation != `NOP) && oALUOperation != `DEBUG_PRINT;
                (oALUOperation != `NOP) && oALUOperation != `DEBUG_PRINT;
`else
`else
        assign oRAMWriteEnable = iALUOutputReady && !wOperationIsJump && oALUOperation != `NOP;
        assign oRAMWriteEnable = iALUOutputReady && !wOperationIsJump && oALUOperation != `NOP;
`endif
`endif
 
 
 
 
assign RAMBus = ( oRAMWriteEnable ) ? {iALUResultX,iALUResultY,iALUResultZ} : `DATA_ROW_WIDTH'bz;
assign RAMBus = ( oRAMWriteEnable ) ? {iALUResultX,iALUResultY,iALUResultZ} : `DATA_ROW_WIDTH'bz;
 
 
assign oALUChannelX1 = iSource1[95:64];
assign oALUChannelX1 = iSource1[95:64];
assign oALUChannelY1 = iSource1[63:32];
assign oALUChannelY1 = iSource1[63:32];
assign oALUChannelZ1 = iSource1[31:0];
assign oALUChannelZ1 = iSource1[31:0];
 
 
assign oALUChannelX2 = iSource0[95:64];
assign oALUChannelX2 = iSource0[95:64];
assign oALUChannelY2 = iSource0[63:32];
assign oALUChannelY2 = iSource0[63:32];
assign oALUChannelZ2 = iSource0[31:0];
assign oALUChannelZ2 = iSource0[31:0];
 
 
/*
/*
FF32_POSEDGE_SYNCRONOUS_RESET SourceX1
FF32_POSEDGE_SYNCRONOUS_RESET SourceX1
(
(
        .Clock( wLatchNow ),
        .Clock( wLatchNow ),
        .Clear( Reset ),
        .Clear( Reset ),
        .D( iSource1[95:64] ),
        .D( iSource1[95:64] ),
        .Q( oALUChannelX1 )
        .Q( oALUChannelX1 )
);
);
 
 
FF32_POSEDGE_SYNCRONOUS_RESET SourceY1
FF32_POSEDGE_SYNCRONOUS_RESET SourceY1
(
(
        .Clock( wLatchNow ),
        .Clock( wLatchNow ),
        .Clear( Reset ),
        .Clear( Reset ),
        .D( iSource1[63:32] ),
        .D( iSource1[63:32] ),
        .Q( oALUChannelY1 )
        .Q( oALUChannelY1 )
);
);
 
 
FF32_POSEDGE_SYNCRONOUS_RESET SourceZ1
FF32_POSEDGE_SYNCRONOUS_RESET SourceZ1
(
(
        .Clock( wLatchNow ),
        .Clock( wLatchNow ),
        .Clear( Reset ),
        .Clear( Reset ),
        .D( iSource1[31:0] ),
        .D( iSource1[31:0] ),
        .Q( oALUChannelZ1 )
        .Q( oALUChannelZ1 )
);
);
*/
*/
/*
/*
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceX1
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceX1
(
(
        .Clock( Clock ),//wLatchNow ),
        .Clock( Clock ),//wLatchNow ),
        .Reset( Reset),
        .Reset( Reset),
        .Enable( wLatchNow ),//1'b1 ),
        .Enable( wLatchNow ),//1'b1 ),
        .D( iSource1[95:64] ),
        .D( iSource1[95:64] ),
        .Q(oALUChannelX1)
        .Q(oALUChannelX1)
);
);
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceY1
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceY1
(
(
        .Clock( Clock ),//wLatchNow ),
        .Clock( Clock ),//wLatchNow ),
        .Reset( Reset),
        .Reset( Reset),
        .Enable( wLatchNow ),//1'b1 ),
        .Enable( wLatchNow ),//1'b1 ),
        .D( iSource1[63:32] ),
        .D( iSource1[63:32] ),
        .Q(oALUChannelY1)
        .Q(oALUChannelY1)
);
);
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceZ1
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceZ1
(
(
        .Clock( Clock ),//wLatchNow ),
        .Clock( Clock ),//wLatchNow ),
        .Reset( Reset),
        .Reset( Reset),
        .Enable( wLatchNow ),//1'b1 ),
        .Enable( wLatchNow ),//1'b1 ),
        .D( iSource1[31:0] ),
        .D( iSource1[31:0] ),
        .Q(oALUChannelZ1)
        .Q(oALUChannelZ1)
);
);
*/
*/
/*
/*
FF32_POSEDGE_SYNCRONOUS_RESET SourceX2
FF32_POSEDGE_SYNCRONOUS_RESET SourceX2
(
(
        .Clock( wLatchNow ),
        .Clock( wLatchNow ),
        .Clear( Reset ),
        .Clear( Reset ),
        .D( iSource0[95:64] ),
        .D( iSource0[95:64] ),
        .Q( oALUChannelX2 )
        .Q( oALUChannelX2 )
);
);
 
 
FF32_POSEDGE_SYNCRONOUS_RESET SourceY2
FF32_POSEDGE_SYNCRONOUS_RESET SourceY2
(
(
        .Clock( wLatchNow ),
        .Clock( wLatchNow ),
        .Clear( Reset ),
        .Clear( Reset ),
        .D( iSource0[63:32] ),
        .D( iSource0[63:32] ),
        .Q( oALUChannelY2 )
        .Q( oALUChannelY2 )
);
);
 
 
FF32_POSEDGE_SYNCRONOUS_RESET SourceZ2
FF32_POSEDGE_SYNCRONOUS_RESET SourceZ2
(
(
        .Clock( wLatchNow ),
        .Clock( wLatchNow ),
        .Clear( Reset ),
        .Clear( Reset ),
        .D( iSource0[31:0] ),
        .D( iSource0[31:0] ),
        .Q( oALUChannelZ2 )
        .Q( oALUChannelZ2 )
);
);
*/
*/
/*
/*
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceX2
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceX2
(
(
        .Clock( Clock ),//wLatchNow ),
        .Clock( Clock ),//wLatchNow ),
        .Reset( Reset),
        .Reset( Reset),
        .Enable( wLatchNow ),//1'b1 ),
        .Enable( wLatchNow ),//1'b1 ),
        .D( iSource0[95:64] ),
        .D( iSource0[95:64] ),
        .Q(oALUChannelX2)
        .Q(oALUChannelX2)
);
);
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceY2
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceY2
(
(
        .Clock( Clock ),//wLatchNow ),
        .Clock( Clock ),//wLatchNow ),
        .Reset( Reset),
        .Reset( Reset),
        .Enable( wLatchNow ),//1'b1 ),
        .Enable( wLatchNow ),//1'b1 ),
        .D( iSource0[63:32] ),
        .D( iSource0[63:32] ),
        .Q(oALUChannelY2)
        .Q(oALUChannelY2)
);
);
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceZ2
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceZ2
(
(
        .Clock( Clock ),//wLatchNow ),
        .Clock( Clock ),//wLatchNow ),
        .Reset( Reset),
        .Reset( Reset),
        .Enable( wLatchNow ),//1'b1 ),
        .Enable( wLatchNow ),//1'b1 ),
        .D( iSource0[31:0] ),
        .D( iSource0[31:0] ),
        .Q(oALUChannelZ2)
        .Q(oALUChannelZ2)
);
);
*/
*/
//Finally one more latch to store 
//Finally one more latch to store 
//the iOperation and the destination
//the iOperation and the destination
 
 
 
 
assign oALUOperation = iOperation;
assign oALUOperation = iOperation;
//assign oRAMWriteAddress = iDestination;
//assign oRAMWriteAddress = iDestination;
/*
/*
FF_OPCODE_POSEDGE_SYNCRONOUS_RESET FFOperation
FF_OPCODE_POSEDGE_SYNCRONOUS_RESET FFOperation
(
(
        .Clock( wLatchNow ),
        .Clock( wLatchNow ),
        .Clear( Reset ),
        .Clear( Reset ),
        .D( iOperation  ),
        .D( iOperation  ),
        .Q( oALUOperation )
        .Q( oALUOperation )
 
 
);
);
 
 
 
 
FF16_POSEDGE_SYNCRONOUS_RESET PSRegDestination
FF16_POSEDGE_SYNCRONOUS_RESET PSRegDestination
(
(
        .Clock( wLatchNow  ),
        .Clock( wLatchNow  ),
        .Clear( Reset ),
        .Clear( Reset ),
        .D( iDestination  ),
        .D( iDestination  ),
        .Q( oRAMWriteAddress )
        .Q( oRAMWriteAddress )
 
 
);
);
*/
*/
/*
/*
FFD_POSEDGE_SYNCRONOUS_RESET # ( `INSTRUCTION_OP_LENGTH ) FFOperation
FFD_POSEDGE_SYNCRONOUS_RESET # ( `INSTRUCTION_OP_LENGTH ) FFOperation
(
(
        .Clock( Clock ),//wLatchNow ),
        .Clock( Clock ),//wLatchNow ),
        .Reset( Reset),
        .Reset( Reset),
        .Enable( wLatchNow ),//1'b1 ),
        .Enable( wLatchNow ),//1'b1 ),
        .D( iOperation ),
        .D( iOperation ),
        .Q(oALUOperation)
        .Q(oALUOperation)
);
);
*/
*/
FFD_POSEDGE_SYNCRONOUS_RESET # ( `DATA_ADDRESS_WIDTH ) PSRegDestination
FFD_POSEDGE_SYNCRONOUS_RESET # ( `DATA_ADDRESS_WIDTH ) PSRegDestination
(
(
        .Clock( Clock ),//wLatchNow ),
        .Clock( Clock ),//wLatchNow ),
        .Reset( Reset),
        .Reset( Reset),
        .Enable( wLatchNow ),//1'b1 ),
        .Enable( wLatchNow ),//1'b1 ),
        .D( iDestination ),
        .D( iDestination ),
        .Q(oRAMWriteAddress)
        .Q(oRAMWriteAddress)
);
);
 
 
//Data forwarding
//Data forwarding
assign oLastDestination = oRAMWriteAddress;
assign oLastDestination = oRAMWriteAddress;
 
 
reg [7:0] CurrentState;
reg [7:0] CurrentState;
reg [7:0] NextState;
reg [7:0] NextState;
 
 
 
 
//------------------------------------------------
//------------------------------------------------
  always @(posedge Clock or posedge Reset)
  always @(posedge Clock or posedge Reset)
  begin
  begin
 
 
 
 
 
 
    if (Reset)
    if (Reset)
                CurrentState <= `EXEU_AFTER_RESET;
                CurrentState <= `EXEU_AFTER_RESET;
    else
    else
                CurrentState <= NextState;
                CurrentState <= NextState;
 
 
  end
  end
//------------------------------------------------
//------------------------------------------------
 
 
 
 
always @( * )
always @( * )
   begin
   begin
        case (CurrentState)
        case (CurrentState)
                  //------------------------------------------
                  //------------------------------------------
                  `EXEU_AFTER_RESET:
                  `EXEU_AFTER_RESET:
                  begin
                  begin
                                //ReadyForNextInstruction <= 1;
                                //ReadyForNextInstruction <= 1;
                                oBusy                                                   <= 0;
                                oBusy                                                   <= 0;
                                rInputLatchesEnabled            <=      1;
                                rInputLatchesEnabled            <=      1;
 
 
 
 
                                NextState       <= `EXEU_WAIT_FOR_DECODE;
                                NextState       <= `EXEU_WAIT_FOR_DECODE;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  /**
                  /**
                        At the same time iDecodeDone goes to 1, our Flops
                        At the same time iDecodeDone goes to 1, our Flops
                        will store the value, so next clock cycle we can
                        will store the value, so next clock cycle we can
                        tell IDU to go ahead and decode the next instruction
                        tell IDU to go ahead and decode the next instruction
                        in the pipeline.
                        in the pipeline.
                  */
                  */
                  `EXEU_WAIT_FOR_DECODE:
                  `EXEU_WAIT_FOR_DECODE:
                  begin
                  begin
 
 
 
 
                                //ReadyForNextInstruction <= 1;
                                //ReadyForNextInstruction <= 1;
                                oBusy                                                   <= 0;
                                oBusy                                                   <= 0;
                                rInputLatchesEnabled            <=      1;
                                rInputLatchesEnabled            <=      1;
 
 
 
 
                        if ( iDecodeDone )      //This same thing triggers the ALU
                        if ( iDecodeDone )      //This same thing triggers the ALU
                                NextState       <= `EXEU_WAIT_FOR_ALU_EXECUTION;
                                NextState       <= `EXEU_WAIT_FOR_ALU_EXECUTION;
                        else
                        else
                                NextState       <= `EXEU_WAIT_FOR_DECODE;
                                NextState       <= `EXEU_WAIT_FOR_DECODE;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  /*
                  /*
                  If the instruction is aritmetic then pass the parameters
                  If the instruction is aritmetic then pass the parameters
                  the ALU, else if it store iOperation then...
                  the ALU, else if it store iOperation then...
                  */
                  */
                  `EXEU_WAIT_FOR_ALU_EXECUTION:
                  `EXEU_WAIT_FOR_ALU_EXECUTION:
                  begin
                  begin
 
 
                                //ReadyForNextInstruction <= 0;                                         //*
                                //ReadyForNextInstruction <= 0;                                         //*
                                oBusy                                                   <= 1;
                                oBusy                                                   <= 1;
                                rInputLatchesEnabled            <=      0;               //NO INTERRUPTIONS WHILE WE WAIT!!
                                rInputLatchesEnabled            <=      0;               //NO INTERRUPTIONS WHILE WE WAIT!!
 
 
 
 
 
 
                                if ( iALUOutputReady )  /////This same thing enables writing th results to RAM
                                if ( iALUOutputReady )  /////This same thing enables writing th results to RAM
                                        NextState <= `EXEU_WAIT_FOR_DECODE;
                                        NextState <= `EXEU_WAIT_FOR_DECODE;
                                else
                                else
                                        NextState <= `EXEU_WAIT_FOR_ALU_EXECUTION;
                                        NextState <= `EXEU_WAIT_FOR_ALU_EXECUTION;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
                  `EXEU_WRITE_BACK_TO_RAM:
                  `EXEU_WRITE_BACK_TO_RAM:
                  begin
                  begin
 
 
                                //ReadyForNextInstruction <= 0;                                         
                                //ReadyForNextInstruction <= 0;                                         
                                oBusy                                                   <= 1;
                                oBusy                                                   <= 1;
                                rInputLatchesEnabled            <=      1;
                                rInputLatchesEnabled            <=      1;
 
 
                        if ( iDecodeDone )
                        if ( iDecodeDone )
                                NextState <= `EXEU_WAIT_FOR_ALU_EXECUTION;
                                NextState <= `EXEU_WAIT_FOR_ALU_EXECUTION;
                        else
                        else
                                NextState <= `EXEU_WAIT_FOR_DECODE;
                                NextState <= `EXEU_WAIT_FOR_DECODE;
 
 
                  end
                  end
 
 
                  //------------------------------------------
                  //------------------------------------------
                  default:
                  default:
                  begin
                  begin
 
 
                                //ReadyForNextInstruction <= 1;
                                //ReadyForNextInstruction <= 1;
                                oBusy                                                   <= 0;
                                oBusy                                                   <= 0;
                                rInputLatchesEnabled            <=      1;
                                rInputLatchesEnabled            <=      1;
 
 
                                NextState <= `EXEU_AFTER_RESET;
                                NextState <= `EXEU_AFTER_RESET;
                  end
                  end
                  //------------------------------------------
                  //------------------------------------------
        endcase
        endcase
end
end
 
 
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
`ifdef DUMP_CODE
`ifdef DUMP_CODE
integer ucode_file;
integer ucode_file;
integer reg_log;
integer reg_log;
initial
initial
begin
begin
 
 
        $display("Opening ucode dump file....\n");
        $display("Opening ucode dump file....\n");
        ucode_file = $fopen("Code.log","w");
        ucode_file = $fopen("Code.log","w");
        $fwrite(ucode_file,"\n\n************ Theia UCODE DUMP *******\n\n\n\n");
        $fwrite(ucode_file,"\n\n************ Theia UCODE DUMP *******\n\n\n\n");
        $display("Opening Register lof file...\n");
        $display("Opening Register lof file...\n");
        reg_log = $fopen("Registers.log","w");
        reg_log = $fopen("Registers.log","w");
 
 
end
end
 
 
`endif //Ucode dump
`endif //Ucode dump
 
 
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
`ifdef DEBUG
`ifdef DEBUG
wire [`WIDTH-1:0] wALUChannelX1,wALUChannelY1,wALUChannelZ1;
wire [`WIDTH-1:0] wALUChannelX1,wALUChannelY1,wALUChannelZ1;
wire [`WIDTH-1:0] wALUChannelX2,wALUChannelY2,wALUChannelZ2;
wire [`WIDTH-1:0] wALUChannelX2,wALUChannelY2,wALUChannelZ2;
 
 
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceX1
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceX1
(
(
        .Clock( Clock ),
        .Clock( Clock ),
        .Reset( Reset),
        .Reset( Reset),
        .Enable( wLatchNow ),
        .Enable( wLatchNow ),
        .D( iSource1[95:64] ),
        .D( iSource1[95:64] ),
        .Q(wALUChannelX1)
        .Q(wALUChannelX1)
);
);
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceY1
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceY1
(
(
        .Clock( Clock ),
        .Clock( Clock ),
        .Reset( Reset),
        .Reset( Reset),
        .Enable( wLatchNow ),
        .Enable( wLatchNow ),
        .D( iSource1[63:32] ),
        .D( iSource1[63:32] ),
        .Q(wALUChannelY1)
        .Q(wALUChannelY1)
);
);
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceZ1
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceZ1
(
(
        .Clock( Clock ),
        .Clock( Clock ),
        .Reset( Reset),
        .Reset( Reset),
        .Enable( wLatchNow ),
        .Enable( wLatchNow ),
        .D( iSource1[31:0] ),
        .D( iSource1[31:0] ),
        .Q(wALUChannelZ1)
        .Q(wALUChannelZ1)
);
);
 
 
 
 
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceX2
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceX2
(
(
        .Clock( Clock ),
        .Clock( Clock ),
        .Reset( Reset),
        .Reset( Reset),
        .Enable( wLatchNow ),
        .Enable( wLatchNow ),
        .D( iSource0[95:64] ),
        .D( iSource0[95:64] ),
        .Q(wALUChannelX2)
        .Q(wALUChannelX2)
);
);
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceY2
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceY2
(
(
        .Clock( Clock ),
        .Clock( Clock ),
        .Reset( Reset),
        .Reset( Reset),
        .Enable( wLatchNow ),
        .Enable( wLatchNow ),
        .D( iSource0[63:32] ),
        .D( iSource0[63:32] ),
        .Q(wALUChannelY2)
        .Q(wALUChannelY2)
);
);
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceZ2
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) SourceZ2
(
(
        .Clock( Clock ),
        .Clock( Clock ),
        .Reset( Reset),
        .Reset( Reset),
        .Enable( wLatchNow ),
        .Enable( wLatchNow ),
        .D( iSource0[31:0] ),
        .D( iSource0[31:0] ),
        .Q(wALUChannelZ2)
        .Q(wALUChannelZ2)
);
);
 
 
 
 
        always @ (posedge iDecodeDone && iDebug_CoreID == `DEBUG_CORE)
        always @ (posedge iDecodeDone && iDebug_CoreID == `DEBUG_CORE)
        begin
        begin
                `LOGME"[CORE %d] IP:%d", iDebug_CoreID,iDebug_CurrentIP);
                `LOGME"[CORE %d] IP:%d", iDebug_CoreID,iDebug_CurrentIP);
        end
        end
 
 
        always @ (negedge  Clock && iDebug_CoreID == `DEBUG_CORE)
        always @ (negedge  Clock && iDebug_CoreID == `DEBUG_CORE)
        begin
        begin
        if ( iALUOutputReady )
        if ( iALUOutputReady )
        begin
        begin
 
 
 
 
                if (iBranchTaken)
                if (iBranchTaken)
                        `LOGME"<BT>");
                        `LOGME"<BT>");
 
 
                if (iBranchNotTaken     )
                if (iBranchNotTaken     )
                        `LOGME"<BNT>");
                        `LOGME"<BNT>");
 
 
                if (oRAMWriteEnable)
                if (oRAMWriteEnable)
                        `LOGME"<WE>");
                        `LOGME"<WE>");
 
 
                `LOGME "(%dns ",$time);
                `LOGME "(%dns ",$time);
                                        case ( oALUOperation )
                                        case ( oALUOperation )
                                        `RETURN: `LOGME"RETURN");
                                        `RETURN: `LOGME"RETURN");
                                        `ADD:   `LOGME"ADD");
                                        `ADD:   `LOGME"ADD");
                                        `SUB:           `LOGME"SUB");
                                        `SUB:           `LOGME"SUB");
                                        `DIV:           `LOGME"DIV");
                                        `DIV:           `LOGME"DIV");
                                        `MUL:   `LOGME"MUL");
                                        `MUL:   `LOGME"MUL");
                                        `MAG:           `LOGME"MAG");
                                        `MAG:           `LOGME"MAG");
                                        `JGX:           `LOGME"JGX");
                                        `JGX:           `LOGME"JGX");
                                        `JLX:           `LOGME"JLX");
                                        `JLX:           `LOGME"JLX");
                                        `JGEX:  `LOGME"JGEX");
                                        `JGEX:  `LOGME"JGEX");
                                        `JGEY:  `LOGME"JGEY");
                                        `JGEY:  `LOGME"JGEY");
                                        `JGEZ:  `LOGME"JGEZ");
                                        `JGEZ:  `LOGME"JGEZ");
                                        `JLEX:  `LOGME"JLEX");
                                        `JLEX:  `LOGME"JLEX");
                                        `JLEY:  `LOGME"JLEY");
                                        `JLEY:  `LOGME"JLEY");
                                        `JLEZ:  `LOGME"JLEZ");
                                        `JLEZ:  `LOGME"JLEZ");
                                        `JMP:           `LOGME"JMP");
                                        `JMP:           `LOGME"JMP");
                                        `ZERO:  `LOGME"ZERO");
                                        `ZERO:  `LOGME"ZERO");
                                        `JNEX:  `LOGME"JNEX");
                                        `JNEX:  `LOGME"JNEX");
                                        `JNEY:  `LOGME"JNEY");
                                        `JNEY:  `LOGME"JNEY");
                                        `JNEZ:  `LOGME"JNEZ");
                                        `JNEZ:  `LOGME"JNEZ");
                                        `JEQX:  `LOGME"JEQX");
                                        `JEQX:  `LOGME"JEQX");
                                        `JEQY:  `LOGME"JEQY");
                                        `JEQY:  `LOGME"JEQY");
                                        `JEQZ:  `LOGME"JEQZ");
                                        `JEQZ:  `LOGME"JEQZ");
                                        `CROSS: `LOGME"CROSS");
                                        `CROSS: `LOGME"CROSS");
                                        `DOT:           `LOGME"DOT");
                                        `DOT:           `LOGME"DOT");
                                        `SETX:  `LOGME"SETX");
                                        `SETX:  `LOGME"SETX");
                                        `SETY:  `LOGME"SETY");
                                        `SETY:  `LOGME"SETY");
                                        `SETZ:  `LOGME"SETZ");
                                        `SETZ:  `LOGME"SETZ");
                                        `NOP:   `LOGME"NOP");
                                        `NOP:   `LOGME"NOP");
                                        `COPY:  `LOGME"COPY");
                                        `COPY:  `LOGME"COPY");
                                        `INC:           `LOGME"INC");
                                        `INC:           `LOGME"INC");
                                        `DEC:           `LOGME"DEC");
                                        `DEC:           `LOGME"DEC");
                                        `MOD:           `LOGME"MOD");
                                        `MOD:           `LOGME"MOD");
                                        `FRAC:  `LOGME"FRAC");
                                        `FRAC:  `LOGME"FRAC");
                                        `NEG:    `LOGME"NEG");
                                        `NEG:    `LOGME"NEG");
                                        `SWIZZLE3D: `LOGME"SWIZZLE3D");
                                        `SWIZZLE3D: `LOGME"SWIZZLE3D");
                                        `MULP:          `LOGME"MULP");
                                        `MULP:          `LOGME"MULP");
                                        `XCHANGEX:      `LOGME"XCHANGEX");
                                        `XCHANGEX:      `LOGME"XCHANGEX");
                                        `IMUL:      `LOGME"IMUL");
                                        `IMUL:      `LOGME"IMUL");
                                        `UNSCALE:      `LOGME"UNSCALE");
                                        `UNSCALE:      `LOGME"UNSCALE");
                                        `INCX: `LOGME"INCX");
                                        `INCX: `LOGME"INCX");
                                        `INCY: `LOGME"INCY");
                                        `INCY: `LOGME"INCY");
                                        `INCZ: `LOGME"INCZ");
                                        `INCZ: `LOGME"INCZ");
                                        `DEBUG_PRINT:
                                        `DEBUG_PRINT:
                                        begin
                                        begin
                                                `LOGME"DEBUG_PRINT");
                                                `LOGME"DEBUG_PRINT");
 
 
                                        end
                                        end
                                        default:
                                        default:
                                        begin
                                        begin
                                                `LOGME"**********ERROR UNKNOWN OP*********");
                                                `LOGME"**********ERROR UNKNOWN OP*********");
                                                $display("%dns EXE: Error Unknown Instruction : %d", $time,oALUOperation);
                                                $display("%dns EXE: Error Unknown Instruction : %d", $time,oALUOperation);
                                        //      $stop();
                                        //      $stop();
                                        end
                                        end
                                        endcase
                                        endcase
 
 
                                        `LOGME"\t %h [ %h %h %h ][ %h %h %h ] = ",
                                        `LOGME"\t %h [ %h %h %h ][ %h %h %h ] = ",
                                        oRAMWriteAddress,
                                        oRAMWriteAddress,
                                        wALUChannelX1,wALUChannelY1,wALUChannelZ1,
                                        wALUChannelX1,wALUChannelY1,wALUChannelZ1,
                                        wALUChannelX2,wALUChannelY2,wALUChannelZ2
                                        wALUChannelX2,wALUChannelY2,wALUChannelZ2
 
 
                                        );
                                        );
 
 
                                        if (oALUOperation == `RETURN)
                                        if (oALUOperation == `RETURN)
                                                `LOGME"\n\n\n");
                                                `LOGME"\n\n\n");
 
 
                end
                end
        end //always
        end //always
 
 
        always @ ( negedge Clock && iDebug_CoreID == `DEBUG_CORE )
        always @ ( negedge Clock && iDebug_CoreID == `DEBUG_CORE )
        begin
        begin
        if ( iALUOutputReady )
        if ( iALUOutputReady )
                `LOGME" [ %h %h %h ])\n",iALUResultX,iALUResultY,iALUResultZ);
                `LOGME" [ %h %h %h ])\n",iALUResultX,iALUResultY,iALUResultZ);
        end //always
        end //always
`endif
`endif
 
 
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

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