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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_1.1/] [rtl/] [CONTROL/] [Unit_Control.v] - Diff between revs 18 and 58

Only display areas with differences | Details | Blame | View Log

Rev 18 Rev 58
/**********************************************************************************
/**********************************************************************************
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.
 
 
***********************************************************************************/
***********************************************************************************/
/**********************************************************************************
/**********************************************************************************
Description:
Description:
 
 
This is the main Finite State Machine.
This is the main Finite State Machine.
 
 
**********************************************************************************/
**********************************************************************************/
 
 
`timescale 1ns / 1ps
`timescale 1ns / 1ps
`include "aDefinitions.v"
`include "aDefinitions.v"
 
 
`define CU_AFTER_RESET_STATE 0
`define CU_AFTER_RESET_STATE 0
`define CU_WAIT_FOR_INITIAL_CONFIGURATION 1
`define CU_WAIT_FOR_INITIAL_CONFIGURATION 1
`define CU_TRIGGER_CONFIGURATION_DATA_READ 2
`define CU_TRIGGER_CONFIGURATION_DATA_READ 2
`define CU_WAIT_FOR_CONFIG_DATA_READ    3
`define CU_WAIT_FOR_CONFIG_DATA_READ    3
`define CU_ACK_CONFIG_DATA_READ 4
`define CU_ACK_CONFIG_DATA_READ 4
`define CU_PRECALCULATE_CONSTANTS 5
`define CU_PRECALCULATE_CONSTANTS 5
`define CU_WAIT_FOR_CONSTANT 6
`define CU_WAIT_FOR_CONSTANT 6
`define CU_ACK_PRECALCULATE_CONSTANTS 7
`define CU_ACK_PRECALCULATE_CONSTANTS 7
`define CU_WAIT_FOR_TASK 8
`define CU_WAIT_FOR_TASK 8
`define CU_READ_TASK_DATA 9
`define CU_READ_TASK_DATA 9
`define CU_WAIT_TASK_DATA_READ 10
`define CU_WAIT_TASK_DATA_READ 10
`define CU_ACK_TASK_DATA_READ 11
`define CU_ACK_TASK_DATA_READ 11
`define CU_TRIGGER_RGU 12
`define CU_TRIGGER_RGU 12
`define CU_WAIT_FOR_RGU 13
`define CU_WAIT_FOR_RGU 13
`define CU_ACK_RGU 14
`define CU_ACK_RGU 14
`define CU_TRIGGER_GEO 15
`define CU_TRIGGER_GEO 15
`define CU_WAIT_FOR_GEO_SYNC 16
`define CU_WAIT_FOR_GEO_SYNC 16
//`define CU_CHECK_AABBIU_REQUEST 17
//`define CU_CHECK_AABBIU_REQUEST 17
`define CU_TRIGGER_TCC 17
`define CU_TRIGGER_TCC 17
//`define CU_CHECK_BIU_REQUEST 18
//`define CU_CHECK_BIU_REQUEST 18
`define CU_TRIGGER_TFF 18
`define CU_TRIGGER_TFF 18
//`define CU_CHECK_GEO_DONE 19
//`define CU_CHECK_GEO_DONE 19
`define CU_WAIT_FOR_TFF 19
`define CU_WAIT_FOR_TFF 19
`define CU_TRIGGER_AABBIU 20
`define CU_TRIGGER_AABBIU 20
`define CU_WAIT_FOR_AABBIU 21
`define CU_WAIT_FOR_AABBIU 21
`define CU_TRIGGER_BIU 22
`define CU_TRIGGER_BIU 22
`define CU_WAIT_FOR_BIU 23
`define CU_WAIT_FOR_BIU 23
`define CU_ACK_UCODE 24
`define CU_ACK_UCODE 24
`define CU_TRIGGER_PSU 25
`define CU_TRIGGER_PSU 25
`define CU_WAIT_FOR_PSU 26
`define CU_WAIT_FOR_PSU 26
`define CU_ACK_PSU 27
`define CU_ACK_PSU 27
`define CU_TRIGGER_PCU 28
`define CU_TRIGGER_PCU 28
`define CU_WAIT_FOR_PCU 29
`define CU_WAIT_FOR_PCU 29
`define CU_ACK_PCU 30
`define CU_ACK_PCU 30
`define CU_CHECK_HIT 31
`define CU_CHECK_HIT 31
`define CU_CLEAR_REGISTERS 32
`define CU_CLEAR_REGISTERS 32
`define CU_WAIT_CLEAR_REGISTERS 33
`define CU_WAIT_CLEAR_REGISTERS 33
`define CU_ACK_CLEAR_REGISTERS  34
`define CU_ACK_CLEAR_REGISTERS  34
`define CU_TRIGGER_PSU_WITH_TEXTURE 35
`define CU_TRIGGER_PSU_WITH_TEXTURE 35
`define WAIT_FOR_TCC 36
`define WAIT_FOR_TCC 36
`define CU_TRIGGER_NPU 37
`define CU_TRIGGER_NPU 37
`define CU_WAIT_NPU 38
`define CU_WAIT_NPU 38
`define CU_ACK_NPU 39
`define CU_ACK_NPU 39
`define CU_PERFORM_INTIAL_CONFIGURATION 40
`define CU_PERFORM_INTIAL_CONFIGURATION 40
`define CU_SET_PICTH 41
`define CU_SET_PICTH 41
 
 
//--------------------------------------------------------------
//--------------------------------------------------------------
module ControlUnit
module ControlUnit
(
(
 
 
input  wire                                  Clock,
input  wire                                  Clock,
input  wire                                  Reset,
input  wire                                  Reset,
input  wire[15:0]                            iControlRegister,
input  wire[15:0]                            iControlRegister,
input  wire                                  iExternalBus_DataReady,
input  wire                                  iExternalBus_DataReady,
input    wire                                  iBusUnitDone,
input    wire                                  iBusUnitDone,
output reg                                   oGFUEnable,
output reg                                   oGFUEnable,
input    wire                                  iTriggerAABBIURequest,
input    wire                                  iTriggerAABBIURequest,
input   wire                                   iTriggerBIURequest,
input   wire                                   iTriggerBIURequest,
input wire                                   iTriggertTCCRequest,
input wire                                   iTriggertTCCRequest,
output reg                                   oUCodeEnable,
output reg                                   oUCodeEnable,
output reg[`ROM_ADDRESS_WIDTH-1:0]           oUCodeInstructioPointer,
output reg[`ROM_ADDRESS_WIDTH-1:0]           oUCodeInstructioPointer,
input   wire                                   iUCodeDone,
input   wire                                   iUCodeDone,
input wire                                   iUCodeReturnValue,
input wire                                   iUCodeReturnValue,
input wire                                   iGFUDone,
input wire                                   iGFUDone,
input wire                                   iGEOSync,
input wire                                   iGEOSync,
output reg                                   oTriggerTFF,
output reg                                   oTriggerTFF,
input wire                                   iTFFDone,
input wire                                   iTFFDone,
input wire                                   MST_I,
input wire                                   MST_I,
output reg[2:0]                              oRamBusOwner,
output reg[2:0]                              oRamBusOwner,
input wire                                   iIODone,
input wire                                   iIODone,
output reg                                   oSetCurrentPitch,
output reg                                   oSetCurrentPitch,
//output reg                                   //oIncCurrentPitch,
//output reg                                   //oIncCurrentPitch,
//output wire[`WIDTH-1:0]                      oPitchInitialValue,
//output wire[`WIDTH-1:0]                      oPitchInitialValue,
output reg                                   oIOWritePixel
output reg                                   oIOWritePixel
 
 
);
);
 
 
//Internal State Machine varibles
//Internal State Machine varibles
reg     [5:0]    CurrentState;
reg     [5:0]    CurrentState;
reg     [5:0]    NextState;
reg     [5:0]    NextState;
integer ucode_file;
integer ucode_file;
reg rResetHitFlop,rHitFlopEnable;
reg rResetHitFlop,rHitFlopEnable;
wire wHit;
wire wHit;
 
 
`ifdef DUMP_CODE
`ifdef DUMP_CODE
        integer log;
        integer log;
 
 
        initial
        initial
        begin
        begin
 
 
        $display("Opening ucode dump file....\n");
        $display("Opening ucode dump file....\n");
        ucode_file = $fopen("CU.log","w");
        ucode_file = $fopen("CU.log","w");
        end
        end
 
 
`endif
`endif
 
 
 
 
wire[`ROM_ADDRESS_WIDTH-1:0] wAABBIUAddress;
wire[`ROM_ADDRESS_WIDTH-1:0] wAABBIUAddress;
assign wAABBIUAddress = (iControlRegister[`CR_USER_AABBIU] == 1'b1) ? `USER_AABBIU_UCODE_ADDRESS : `AABBIU_UCODE_ADDRESS;
assign wAABBIUAddress = (iControlRegister[`CR_USER_AABBIU] == 1'b1) ? `USER_AABBIU_UCODE_ADDRESS : `AABBIU_UCODE_ADDRESS;
 
 
 
 
//--------------------------------------------------------------
//--------------------------------------------------------------
FFToggleOnce_1Bit FFTO1
FFToggleOnce_1Bit FFTO1
(
(
        .Clock( Clock ),
        .Clock( Clock ),
        .Reset( rResetHitFlop ),
        .Reset( rResetHitFlop ),
        .Enable( rHitFlopEnable && iUCodeDone ),
        .Enable( rHitFlopEnable && iUCodeDone ),
        .S( iUCodeReturnValue ),
        .S( iUCodeReturnValue ),
        .Q( wHit )
        .Q( wHit )
);
);
//--------------------------------------------------------------
//--------------------------------------------------------------
 
 
`ifdef DEBUG
`ifdef DEBUG
        always @ ( wHit )
        always @ ( wHit )
        begin
        begin
                `LOGME "*** Triangle HIT ***\n");
                `LOGME "*** Triangle HIT ***\n");
        end
        end
`endif
`endif
 
 
//Next states logic and Reset sequence
//Next states logic and Reset sequence
always @(posedge Clock or posedge Reset)
always @(posedge Clock or posedge Reset)
  begin
  begin
 
 
    if (Reset)
    if (Reset)
                CurrentState <= `CU_AFTER_RESET_STATE;
                CurrentState <= `CU_AFTER_RESET_STATE;
    else
    else
                CurrentState <= NextState;
                CurrentState <= NextState;
 
 
  end
  end
 
 
//--------------------------------------------------------------
//--------------------------------------------------------------
always @ ( * )
always @ ( * )
begin
begin
        case (CurrentState)
        case (CurrentState)
        //-----------------------------------------
        //-----------------------------------------
        `CU_AFTER_RESET_STATE:
        `CU_AFTER_RESET_STATE:
        begin
        begin
 
 
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d CU_AFTER_RESET_STATE\n",$time);
                `LOGME"%d CU_AFTER_RESET_STATE\n",$time);
        `endif
        `endif
 
 
                oRamBusOwner                            <= 0;
                oRamBusOwner                            <= 0;
                oUCodeInstructioPointer <= `INITIAL_UCODE_ADDRESS;
                oUCodeInstructioPointer <= `INITIAL_UCODE_ADDRESS;
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oUCodeEnable                            <= 0;
                oUCodeEnable                            <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 1;
                rResetHitFlop                           <= 1;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
                oTriggerTFF             <= 0;
                oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 1;
                oSetCurrentPitch        <= 1;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                NextState                                       <= `CU_WAIT_FOR_INITIAL_CONFIGURATION;
                NextState                                       <= `CU_WAIT_FOR_INITIAL_CONFIGURATION;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
 
 
        `CU_WAIT_FOR_INITIAL_CONFIGURATION:
        `CU_WAIT_FOR_INITIAL_CONFIGURATION:
        begin
        begin
        $display("CU_WAIT_FOR_INITIAL_CONFIGURATION");
        $display("CU_WAIT_FOR_INITIAL_CONFIGURATION");
//              `ifdef DEBUG
//              `ifdef DEBUG
//                      `LOGME"%d Control: CU_WAIT_FOR_INITIAL_CONFIGURATION\n",$time);
//                      `LOGME"%d Control: CU_WAIT_FOR_INITIAL_CONFIGURATION\n",$time);
//              `endif
//              `endif
 
 
                oRamBusOwner                            <= 0;
                oRamBusOwner                            <= 0;
                oUCodeInstructioPointer <= 0;
                oUCodeInstructioPointer <= 0;
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oUCodeEnable                            <= 0;
                oUCodeEnable                            <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 1;
                rResetHitFlop                           <= 1;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;         
                //oIncCurrentPitch        <= 0;         
 
 
                if ( MST_I  )
                if ( MST_I  )
                        NextState <= `CU_PERFORM_INTIAL_CONFIGURATION;//`CU_WAIT_FOR_CONFIG_DATA_READ;
                        NextState <= `CU_PERFORM_INTIAL_CONFIGURATION;//`CU_WAIT_FOR_CONFIG_DATA_READ;
                else
                else
                        NextState <= `CU_WAIT_FOR_INITIAL_CONFIGURATION;
                        NextState <= `CU_WAIT_FOR_INITIAL_CONFIGURATION;
 
 
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_PERFORM_INTIAL_CONFIGURATION:
        `CU_PERFORM_INTIAL_CONFIGURATION:
        begin
        begin
        oRamBusOwner                            <= 0;
        oRamBusOwner                            <= 0;
                oUCodeInstructioPointer <= 0;
                oUCodeInstructioPointer <= 0;
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oUCodeEnable                            <= 0;
                oUCodeEnable                            <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 1;
                rResetHitFlop                           <= 1;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;         
                //oIncCurrentPitch        <= 0;         
 
 
                if ( MST_I  )
                if ( MST_I  )
                        NextState <= `CU_PERFORM_INTIAL_CONFIGURATION;//`CU_WAIT_FOR_CONFIG_DATA_READ;
                        NextState <= `CU_PERFORM_INTIAL_CONFIGURATION;//`CU_WAIT_FOR_CONFIG_DATA_READ;
                else
                else
                        NextState <= `CU_CLEAR_REGISTERS;
                        NextState <= `CU_CLEAR_REGISTERS;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_CLEAR_REGISTERS:
        `CU_CLEAR_REGISTERS:
        begin
        begin
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d CU_CLEAR_REGISTERS\n",$time);
                `LOGME"%d CU_CLEAR_REGISTERS\n",$time);
        `endif
        `endif
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= `INITIAL_UCODE_ADDRESS;
                oUCodeInstructioPointer <= `INITIAL_UCODE_ADDRESS;
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oUCodeEnable                            <= 1;   //*
                oUCodeEnable                            <= 1;   //*
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
                oTriggerTFF             <= 0;
                oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                NextState                                       <= `CU_WAIT_CLEAR_REGISTERS;
                NextState                                       <= `CU_WAIT_CLEAR_REGISTERS;
        end
        end
//-----------------------------------------     
//-----------------------------------------     
        `CU_WAIT_CLEAR_REGISTERS:
        `CU_WAIT_CLEAR_REGISTERS:
        begin
        begin
//      `ifdef DEBUG
//      `ifdef DEBUG
//              `LOGME"%d CU_WAIT_CLEAR_REGISTERS\n",$time);
//              `LOGME"%d CU_WAIT_CLEAR_REGISTERS\n",$time);
//      `endif  
//      `endif  
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= `INITIAL_UCODE_ADDRESS;
                oUCodeInstructioPointer <= `INITIAL_UCODE_ADDRESS;
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oUCodeEnable                            <= 0;
                oUCodeEnable                            <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                if ( iUCodeDone )
                if ( iUCodeDone )
                        NextState <= `CU_ACK_CLEAR_REGISTERS;
                        NextState <= `CU_ACK_CLEAR_REGISTERS;
                else
                else
                        NextState <= `CU_WAIT_CLEAR_REGISTERS;
                        NextState <= `CU_WAIT_CLEAR_REGISTERS;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_ACK_CLEAR_REGISTERS:
        `CU_ACK_CLEAR_REGISTERS:
        begin
        begin
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d CU_ACK_CLEAR_REGISTERS\n", $time);
                `LOGME"%d CU_ACK_CLEAR_REGISTERS\n", $time);
        `endif
        `endif
 
 
                oRamBusOwner                            <= 0;
                oRamBusOwner                            <= 0;
                oUCodeInstructioPointer <= 0;
                oUCodeInstructioPointer <= 0;
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oUCodeEnable                            <= 0; //*        
                oUCodeEnable                            <= 0; //*        
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                NextState <= `CU_WAIT_FOR_CONFIG_DATA_READ;
                NextState <= `CU_WAIT_FOR_CONFIG_DATA_READ;
        end
        end
 
 
 
 
 
 
        //-----------------------------------------
        //-----------------------------------------
        `CU_WAIT_FOR_CONFIG_DATA_READ:
        `CU_WAIT_FOR_CONFIG_DATA_READ:
        begin
        begin
        $display("CU_WAIT_FOR_CONFIG_DATA_READ");
        $display("CU_WAIT_FOR_CONFIG_DATA_READ");
//              `ifdef DEBUG
//              `ifdef DEBUG
//                      `LOGME"%d Control: CU_WAIT_FOR_CONFIG_DATA_READ\n",$time);
//                      `LOGME"%d Control: CU_WAIT_FOR_CONFIG_DATA_READ\n",$time);
//              `endif
//              `endif
 
 
                oRamBusOwner                            <= 0;//`REG_BUS_OWNED_BY_BCU;
                oRamBusOwner                            <= 0;//`REG_BUS_OWNED_BY_BCU;
                oUCodeInstructioPointer <= 0;
                oUCodeInstructioPointer <= 0;
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oUCodeEnable                            <= 0;
                oUCodeEnable                            <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                if ( MST_I == 0  )
                if ( MST_I == 0  )
                        NextState <= `CU_PRECALCULATE_CONSTANTS;
                        NextState <= `CU_PRECALCULATE_CONSTANTS;
                else
                else
                        NextState <= `CU_WAIT_FOR_CONFIG_DATA_READ;
                        NextState <= `CU_WAIT_FOR_CONFIG_DATA_READ;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_PRECALCULATE_CONSTANTS:
        `CU_PRECALCULATE_CONSTANTS:
        begin
        begin
        $display("CU_PRECALCULATE_CONSTANTS");
        $display("CU_PRECALCULATE_CONSTANTS");
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_PRECALCULATE_CONSTANTS\n", $time);
                `LOGME"%d Control: CU_PRECALCULATE_CONSTANTS\n", $time);
        `endif
        `endif
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= `CPPU_UCODE_ADDRESS;
                oUCodeInstructioPointer <= `CPPU_UCODE_ADDRESS;
                oGFUEnable                              <= 0;
                oGFUEnable                              <= 0;
                oUCodeEnable                            <= 1; //*       
                oUCodeEnable                            <= 1; //*       
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                NextState <= `CU_WAIT_FOR_CONSTANT;
                NextState <= `CU_WAIT_FOR_CONSTANT;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_WAIT_FOR_CONSTANT:
        `CU_WAIT_FOR_CONSTANT:
        begin
        begin
//      `ifdef DEBUG
//      `ifdef DEBUG
//              `LOGME"%d Control: CU_WAIT_FOR_CONSTANT\n", $time);
//              `LOGME"%d Control: CU_WAIT_FOR_CONSTANT\n", $time);
//      `endif
//      `endif
 
 
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= `CPPU_UCODE_ADDRESS;
                oUCodeInstructioPointer <= `CPPU_UCODE_ADDRESS;
                oGFUEnable                                 <= 0;
                oGFUEnable                                 <= 0;
                oUCodeEnable                            <= 0; //*        
                oUCodeEnable                            <= 0; //*        
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                if ( iUCodeDone )
                if ( iUCodeDone )
                        NextState <= `CU_ACK_PRECALCULATE_CONSTANTS;
                        NextState <= `CU_ACK_PRECALCULATE_CONSTANTS;
                else
                else
                        NextState <= `CU_WAIT_FOR_CONSTANT;
                        NextState <= `CU_WAIT_FOR_CONSTANT;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_ACK_PRECALCULATE_CONSTANTS:
        `CU_ACK_PRECALCULATE_CONSTANTS:
        begin
        begin
        $display("CU_ACK_PRECALCULATE_CONSTANTS");
        $display("CU_ACK_PRECALCULATE_CONSTANTS");
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_ACK_PRECALCULATE_CONSTANTS\n", $time);
                `LOGME"%d Control: CU_ACK_PRECALCULATE_CONSTANTS\n", $time);
        `endif
        `endif
 
 
 
 
                oRamBusOwner                            <= 0;//`REG_BUS_OWNED_BY_BCU;
                oRamBusOwner                            <= 0;//`REG_BUS_OWNED_BY_BCU;
                oUCodeInstructioPointer <= 0;
                oUCodeInstructioPointer <= 0;
                oGFUEnable                                 <= 0;
                oGFUEnable                                 <= 0;
                oUCodeEnable                            <= 0; //*        
                oUCodeEnable                            <= 0; //*        
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                NextState <= `CU_TRIGGER_RGU;//CU_WAIT_FOR_TASK;
                NextState <= `CU_TRIGGER_RGU;//CU_WAIT_FOR_TASK;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_TRIGGER_RGU:
        `CU_TRIGGER_RGU:
        begin
        begin
 
 
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_TRIGGER_RGU\n",$time);
                `LOGME"%d Control: CU_TRIGGER_RGU\n",$time);
        `endif
        `endif
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= `RGU_UCODE_ADDRESS;
                oUCodeInstructioPointer <= `RGU_UCODE_ADDRESS;
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oUCodeEnable                            <= 1;   //*
                oUCodeEnable                            <= 1;   //*
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                NextState <= `CU_WAIT_FOR_RGU;
                NextState <= `CU_WAIT_FOR_RGU;
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_WAIT_FOR_RGU:
        `CU_WAIT_FOR_RGU:
        begin
        begin
 
 
//      `ifdef DEBUG
//      `ifdef DEBUG
//              `LOGME"%d Control: CU_WAIT_FOR_RGU\n",$time);
//              `LOGME"%d Control: CU_WAIT_FOR_RGU\n",$time);
//      `endif
//      `endif
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= 0;
                oUCodeInstructioPointer <= 0;
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oUCodeEnable                            <= 0;
                oUCodeEnable                            <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                if ( iUCodeDone )
                if ( iUCodeDone )
                        NextState <= `CU_ACK_RGU;
                        NextState <= `CU_ACK_RGU;
                else
                else
                        NextState <= `CU_WAIT_FOR_RGU;
                        NextState <= `CU_WAIT_FOR_RGU;
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_ACK_RGU:
        `CU_ACK_RGU:
        begin
        begin
 
 
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_ACK_RGU\n",$time);
                `LOGME"%d Control: CU_ACK_RGU\n",$time);
        `endif
        `endif
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= 0;
                oUCodeInstructioPointer <= 0;
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oUCodeEnable                            <= 0; //*        
                oUCodeEnable                            <= 0; //*        
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                if ( iUCodeDone  == 0)
                if ( iUCodeDone  == 0)
                        NextState <= `CU_TRIGGER_GEO;
                        NextState <= `CU_TRIGGER_GEO;
                else
                else
                        NextState <= `CU_ACK_RGU;
                        NextState <= `CU_ACK_RGU;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_TRIGGER_GEO:
        `CU_TRIGGER_GEO:
        begin
        begin
 
 
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_TRIGGER_GEO\n",$time);
                `LOGME"%d Control: CU_TRIGGER_GEO\n",$time);
        `endif
        `endif
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oUCodeInstructioPointer <= 0;
                oUCodeInstructioPointer <= 0;
                oUCodeEnable                            <= 0;
                oUCodeEnable                            <= 0;
                oGFUEnable                                      <= 1;
                oGFUEnable                                      <= 1;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 1;   //*
                rResetHitFlop                           <= 1;   //*
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                NextState <= `CU_WAIT_FOR_GEO_SYNC;
                NextState <= `CU_WAIT_FOR_GEO_SYNC;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_WAIT_FOR_GEO_SYNC:
        `CU_WAIT_FOR_GEO_SYNC:
        begin
        begin
 
 
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_WAIT_FOR_GEO_SYNC\n",$time);
                `LOGME"%d Control: CU_WAIT_FOR_GEO_SYNC\n",$time);
        `endif
        `endif
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oUCodeInstructioPointer <= 0;
                oUCodeInstructioPointer <= 0;
                oUCodeEnable                            <= 0;
                oUCodeEnable                            <= 0;
                oGFUEnable                                      <= 0; //Change AUg 15
                oGFUEnable                                      <= 0; //Change AUg 15
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
        if (iGEOSync & iTriggerAABBIURequest )
        if (iGEOSync & iTriggerAABBIURequest )
                NextState <= `CU_TRIGGER_AABBIU;
                NextState <= `CU_TRIGGER_AABBIU;
        else if (iGEOSync & iTriggerBIURequest)
        else if (iGEOSync & iTriggerBIURequest)
                NextState <= `CU_TRIGGER_BIU;
                NextState <= `CU_TRIGGER_BIU;
        else if (iGEOSync & iTriggertTCCRequest )
        else if (iGEOSync & iTriggertTCCRequest )
      NextState <= `CU_TRIGGER_TCC;
      NextState <= `CU_TRIGGER_TCC;
   else if (iGEOSync & iGFUDone )
   else if (iGEOSync & iGFUDone )
      NextState <= `CU_CHECK_HIT;
      NextState <= `CU_CHECK_HIT;
   else
   else
      NextState <= `CU_WAIT_FOR_GEO_SYNC;
      NextState <= `CU_WAIT_FOR_GEO_SYNC;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_TRIGGER_TCC:
        `CU_TRIGGER_TCC:
        begin
        begin
        //$display("CU_TRIGGER_TCC");
        //$display("CU_TRIGGER_TCC");
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_TRIGGER_TCC\n",$time);
                `LOGME"%d Control: CU_TRIGGER_TCC\n",$time);
        `endif
        `endif
 
 
           oRamBusOwner                                 <= `REG_BUS_OWNED_BY_UCODE;
           oRamBusOwner                                 <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= `TCC_UCODE_ADDRESS;
                oUCodeInstructioPointer <= `TCC_UCODE_ADDRESS;
                oUCodeEnable                            <= 1;   //*
                oUCodeEnable                            <= 1;   //*
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
          NextState  <= `WAIT_FOR_TCC;
          NextState  <= `WAIT_FOR_TCC;
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `WAIT_FOR_TCC:
        `WAIT_FOR_TCC:
        begin
        begin
 
 
        //$display("WAIT_FOR_TCC");
        //$display("WAIT_FOR_TCC");
           oRamBusOwner                                 <= `REG_BUS_OWNED_BY_UCODE;
           oRamBusOwner                                 <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= `TCC_UCODE_ADDRESS;
                oUCodeInstructioPointer <= `TCC_UCODE_ADDRESS;
                oUCodeEnable                            <= 0;    //*
                oUCodeEnable                            <= 0;    //*
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
           if ( iUCodeDone )
           if ( iUCodeDone )
                        NextState <= `CU_ACK_UCODE;
                        NextState <= `CU_ACK_UCODE;
                else
                else
                        NextState <= `WAIT_FOR_TCC;
                        NextState <= `WAIT_FOR_TCC;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        /*
        /*
        Was there any hit at all?
        Was there any hit at all?
        At this point, all the triangles in the list
        At this point, all the triangles in the list
        have been traversed looking for a hit with our ray.
        have been traversed looking for a hit with our ray.
        There are 3 possibilities:
        There are 3 possibilities:
        1) The was not a single hit, then just paint a black
        1) The was not a single hit, then just paint a black
        pixel on the screen and send it via PCU.
        pixel on the screen and send it via PCU.
        2)There was a hit and Texturing is not enabled, then trigger the PSU with
        2)There was a hit and Texturing is not enabled, then trigger the PSU with
        no texturing
        no texturing
        2) There was a hit and Texturing is enabled, then fetch the texture
        2) There was a hit and Texturing is enabled, then fetch the texture
        values corresponding to the triangle that we hitted.
        values corresponding to the triangle that we hitted.
        */
        */
        `CU_CHECK_HIT:
        `CU_CHECK_HIT:
        begin
        begin
 
 
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_CHECK_HIT\n",$time);
                `LOGME"%d Control: CU_CHECK_HIT\n",$time);
        `endif
        `endif
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oUCodeInstructioPointer <= 0;
                oUCodeInstructioPointer <= 0;
                oUCodeEnable                            <= 0;
                oUCodeEnable                            <= 0;
                oGFUEnable                                      <= 0;    ///CHANGED Aug 15
                oGFUEnable                                      <= 0;    ///CHANGED Aug 15
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
           oTriggerTFF             <= 0;
           oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                if (wHit && !iControlRegister[`CR_EN_TEXTURE] )
                if (wHit && !iControlRegister[`CR_EN_TEXTURE] )
                        NextState <= `CU_TRIGGER_PSU;
                        NextState <= `CU_TRIGGER_PSU;
                else if (wHit && iControlRegister[`CR_EN_TEXTURE])
                else if (wHit && iControlRegister[`CR_EN_TEXTURE])
                        NextState <= `CU_TRIGGER_TFF;           //Fetch the texture values from external RAM
                        NextState <= `CU_TRIGGER_TFF;           //Fetch the texture values from external RAM
                else
                else
                        NextState <= `CU_TRIGGER_PCU;           //Make sure contents of the OUT_REG are ZERo!
                        NextState <= `CU_TRIGGER_PCU;           //Make sure contents of the OUT_REG are ZERo!
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        /*
        /*
        Get the texture values from external RAM.
        Get the texture values from external RAM.
        GFU already took care of calculating the correct
        GFU already took care of calculating the correct
        texture addresses for the 4 coordinates so now lets
        texture addresses for the 4 coordinates so now lets
        just ask for them.
        just ask for them.
        */
        */
        `CU_TRIGGER_TFF:
        `CU_TRIGGER_TFF:
        begin
        begin
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_TRIGGER_TFF\n",$time);
                `LOGME"%d Control: CU_TRIGGER_TFF\n",$time);
        `endif
        `endif
 
 
        //$display("CU_TRIGGER_TFF");
        //$display("CU_TRIGGER_TFF");
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oUCodeInstructioPointer <= 0;
                oUCodeInstructioPointer <= 0;
                oUCodeEnable                            <= 0;
                oUCodeEnable                            <= 0;
                oGFUEnable                                      <= 1;
                oGFUEnable                                      <= 1;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
                oTriggerTFF             <= 1;       //*
                oTriggerTFF             <= 1;       //*
           oSetCurrentPitch        <= 0;
           oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                NextState <= `CU_WAIT_FOR_TFF;
                NextState <= `CU_WAIT_FOR_TFF;
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_WAIT_FOR_TFF:
        `CU_WAIT_FOR_TFF:
        begin
        begin
 
 
           oRamBusOwner                                 <= `REG_BUS_OWNED_BY_GFU;
           oRamBusOwner                                 <= `REG_BUS_OWNED_BY_GFU;
                oUCodeInstructioPointer <= 0;
                oUCodeInstructioPointer <= 0;
                oUCodeEnable                            <= 0;
                oUCodeEnable                            <= 0;
                oGFUEnable                                      <= 0;     //Changed Aug 14
                oGFUEnable                                      <= 0;     //Changed Aug 14
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
                oTriggerTFF             <= 0;
                oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
        if (iTFFDone)
        if (iTFFDone)
                NextState <= `CU_TRIGGER_PSU_WITH_TEXTURE;
                NextState <= `CU_TRIGGER_PSU_WITH_TEXTURE;
        else
        else
                NextState <= `CU_WAIT_FOR_TFF;
                NextState <= `CU_WAIT_FOR_TFF;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_TRIGGER_PSU_WITH_TEXTURE:
        `CU_TRIGGER_PSU_WITH_TEXTURE:
        begin
        begin
 
 
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_TRIGGER_PSU_WITH_TEXTURE\n",$time);
                `LOGME"%d Control: CU_TRIGGER_PSU_WITH_TEXTURE\n",$time);
        `endif
        `endif
 
 
           oRamBusOwner                                 <= `REG_BUS_OWNED_BY_UCODE;
           oRamBusOwner                                 <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= `PSU_UCODE_ADRESS2;
                oUCodeInstructioPointer <= `PSU_UCODE_ADRESS2;
                oUCodeEnable                            <= 1;
                oUCodeEnable                            <= 1;
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
                oTriggerTFF             <= 0;
                oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
           //oIncCurrentPitch        <= 0;
           //oIncCurrentPitch        <= 0;
 
 
                NextState <= `CU_WAIT_FOR_PSU;
                NextState <= `CU_WAIT_FOR_PSU;
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_TRIGGER_AABBIU:
        `CU_TRIGGER_AABBIU:
        begin
        begin
 
 
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_TRIGGER_AABBIU\n",$time);
                `LOGME"%d Control: CU_TRIGGER_AABBIU\n",$time);
        `endif
        `endif
//      $stop();
//      $stop();
                oRamBusOwner                            <= wAABBIUAddress;//`REG_BUS_OWNED_BY_UCODE;
                oRamBusOwner                            <= wAABBIUAddress;//`REG_BUS_OWNED_BY_UCODE;
 
 
                oUCodeInstructioPointer <=`AABBIU_UCODE_ADDRESS;
                oUCodeInstructioPointer <=`AABBIU_UCODE_ADDRESS;
                oUCodeEnable                            <= 1;
                oUCodeEnable                            <= 1;
                oGFUEnable                                      <= 1;
                oGFUEnable                                      <= 1;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                NextState <= `CU_WAIT_FOR_AABBIU;
                NextState <= `CU_WAIT_FOR_AABBIU;
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_WAIT_FOR_AABBIU:
        `CU_WAIT_FOR_AABBIU:
        begin
        begin
 
 
 
 
//      `ifdef DEBUG
//      `ifdef DEBUG
//              `LOGME"%d Control: CU_WAIT_FOR_AABBIU\n",$time);
//              `LOGME"%d Control: CU_WAIT_FOR_AABBIU\n",$time);
//      `endif
//      `endif
 
 
 
 
//      $display("iUCodeDone",iUCodeDone);
//      $display("iUCodeDone",iUCodeDone);
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= `AABBIU_UCODE_ADDRESS;
                oUCodeInstructioPointer <= `AABBIU_UCODE_ADDRESS;
                oUCodeEnable                            <= 0;
                oUCodeEnable                            <= 0;
                oGFUEnable                                      <= 1;
                oGFUEnable                                      <= 1;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                if ( iUCodeDone )
                if ( iUCodeDone )
                begin
                begin
        //         $display("iUCodeDone\n",iUCodeDone);
        //         $display("iUCodeDone\n",iUCodeDone);
        //              $stop();
        //              $stop();
                        NextState <= `CU_ACK_UCODE;
                        NextState <= `CU_ACK_UCODE;
                end
                end
                else
                else
                        NextState <= `CU_WAIT_FOR_AABBIU;
                        NextState <= `CU_WAIT_FOR_AABBIU;
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_TRIGGER_BIU:
        `CU_TRIGGER_BIU:
        begin
        begin
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_TRIGGER_BIU\n",$time);
                `LOGME"%d Control: CU_TRIGGER_BIU\n",$time);
        `endif
        `endif
 
 
                        oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                        oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                        oUCodeInstructioPointer <= `BIU_UCODE_ADDRESS;
                        oUCodeInstructioPointer <= `BIU_UCODE_ADDRESS;
                        oUCodeEnable                            <= 1;
                        oUCodeEnable                            <= 1;
                        oGFUEnable                                      <= 1;
                        oGFUEnable                                      <= 1;
                        oIOWritePixel                           <= 0;
                        oIOWritePixel                           <= 0;
                        rResetHitFlop                           <= 0;//1;        
                        rResetHitFlop                           <= 0;//1;        
                        rHitFlopEnable                          <= 1;
                        rHitFlopEnable                          <= 1;
         oTriggerTFF             <= 0;
         oTriggerTFF             <= 0;
                        oSetCurrentPitch        <= 0;
                        oSetCurrentPitch        <= 0;
                        //oIncCurrentPitch        <= 0;
                        //oIncCurrentPitch        <= 0;
                //      $stop();
                //      $stop();
 
 
                        NextState <= `CU_WAIT_FOR_BIU;
                        NextState <= `CU_WAIT_FOR_BIU;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_WAIT_FOR_BIU:
        `CU_WAIT_FOR_BIU:
        begin
        begin
//      `ifdef DEBUG
//      `ifdef DEBUG
//              `LOGME"%d Control: CU_WAIT_FOR_BIU\n",$time);
//              `LOGME"%d Control: CU_WAIT_FOR_BIU\n",$time);
//      `endif
//      `endif
 
 
                        oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                        oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                        oUCodeInstructioPointer <= `BIU_UCODE_ADDRESS;
                        oUCodeInstructioPointer <= `BIU_UCODE_ADDRESS;
                        oUCodeEnable                            <= 0;
                        oUCodeEnable                            <= 0;
                        oGFUEnable                                      <= 1;
                        oGFUEnable                                      <= 1;
                        oIOWritePixel                           <= 0;
                        oIOWritePixel                           <= 0;
                        rResetHitFlop                           <= 0;
                        rResetHitFlop                           <= 0;
                        rHitFlopEnable                          <= 1;
                        rHitFlopEnable                          <= 1;
         oTriggerTFF             <= 0;
         oTriggerTFF             <= 0;
                        oSetCurrentPitch        <= 0;
                        oSetCurrentPitch        <= 0;
                        //oIncCurrentPitch        <= 0;
                        //oIncCurrentPitch        <= 0;
 
 
                if ( iUCodeDone )
                if ( iUCodeDone )
                        NextState <= `CU_ACK_UCODE;
                        NextState <= `CU_ACK_UCODE;
                else
                else
                        NextState <= `CU_WAIT_FOR_BIU;
                        NextState <= `CU_WAIT_FOR_BIU;
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        /*
        /*
                ACK UCODE by setting oUCodeEnable = 0
                ACK UCODE by setting oUCodeEnable = 0
        */
        */
        `CU_ACK_UCODE:
        `CU_ACK_UCODE:
        begin
        begin
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_ACK_UCODE\n",$time);
                `LOGME"%d Control: CU_ACK_UCODE\n",$time);
        `endif
        `endif
 
 
                        oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                        oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                        oUCodeInstructioPointer <= 0; //*
                        oUCodeInstructioPointer <= 0; //*
                        oUCodeEnable                            <= 0;    //*
                        oUCodeEnable                            <= 0;    //*
                        oGFUEnable                                      <= 0; //Changed Aug 15
                        oGFUEnable                                      <= 0; //Changed Aug 15
                        oIOWritePixel                           <= 0;
                        oIOWritePixel                           <= 0;
                        rResetHitFlop                           <= 0;
                        rResetHitFlop                           <= 0;
                        rHitFlopEnable                          <= 0;
                        rHitFlopEnable                          <= 0;
         oTriggerTFF             <= 0;
         oTriggerTFF             <= 0;
                        oSetCurrentPitch        <= 0;
                        oSetCurrentPitch        <= 0;
                        //oIncCurrentPitch        <= 0;
                        //oIncCurrentPitch        <= 0;
 
 
        //              $stop();
        //              $stop();
 
 
                        if ( iUCodeDone == 0 )
                        if ( iUCodeDone == 0 )
                                NextState <= `CU_WAIT_FOR_GEO_SYNC;
                                NextState <= `CU_WAIT_FOR_GEO_SYNC;
                        else
                        else
                                NextState <= `CU_ACK_UCODE;
                                NextState <= `CU_ACK_UCODE;
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        /*
        /*
        Here we no longer use GFU so set Enable to zero
        Here we no longer use GFU so set Enable to zero
        */
        */
        `CU_TRIGGER_PSU:
        `CU_TRIGGER_PSU:
        begin
        begin
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_TRIGGER_PSU\n",$time);
                `LOGME"%d Control: CU_TRIGGER_PSU\n",$time);
        `endif
        `endif
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= `PSU_UCODE_ADRESS;
                oUCodeInstructioPointer <= `PSU_UCODE_ADRESS;
                oUCodeEnable                            <= 1;
                oUCodeEnable                            <= 1;
                oGFUEnable                                      <= 0;//*
                oGFUEnable                                      <= 0;//*
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
                oTriggerTFF             <= 0;
                oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
 
 
                NextState <= `CU_WAIT_FOR_PSU;
                NextState <= `CU_WAIT_FOR_PSU;
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_WAIT_FOR_PSU:
        `CU_WAIT_FOR_PSU:
        begin
        begin
 
 
//      `ifdef DEBUG
//      `ifdef DEBUG
//              `LOGME"%d Control: CU_TRIGGER_PSU\n",$time);
//              `LOGME"%d Control: CU_TRIGGER_PSU\n",$time);
//      `endif
//      `endif
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= `PSU_UCODE_ADRESS;
                oUCodeInstructioPointer <= `PSU_UCODE_ADRESS;
                oUCodeEnable                            <= 0;
                oUCodeEnable                            <= 0;
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
                oTriggerTFF             <= 0;
                oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
 
 
                if ( iUCodeDone )
                if ( iUCodeDone )
                        NextState <= `CU_ACK_PSU;
                        NextState <= `CU_ACK_PSU;
                else
                else
                        NextState <= `CU_WAIT_FOR_PSU;
                        NextState <= `CU_WAIT_FOR_PSU;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_ACK_PSU:
        `CU_ACK_PSU:
        begin
        begin
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_ACK_PSU\n",$time);
                `LOGME"%d Control: CU_ACK_PSU\n",$time);
        `endif
        `endif
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= 0;    //*
                oUCodeInstructioPointer <= 0;    //*
                oUCodeEnable                            <= 0;    //*
                oUCodeEnable                            <= 0;    //*
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                if ( iUCodeDone  == 0)
                if ( iUCodeDone  == 0)
                        NextState <= `CU_TRIGGER_PCU;
                        NextState <= `CU_TRIGGER_PCU;
                else
                else
                        NextState <= `CU_ACK_PSU;
                        NextState <= `CU_ACK_PSU;
 
 
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        /*
        /*
                Trigger the Pixel Commit.
                Trigger the Pixel Commit.
        */
        */
        `CU_TRIGGER_PCU:
        `CU_TRIGGER_PCU:
        begin
        begin
 
 
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_TRIGGER_PCU\n",$time);
                `LOGME"%d Control: CU_TRIGGER_PCU\n",$time);
        `endif
        `endif
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oUCodeInstructioPointer <= 0;    //*
                oUCodeInstructioPointer <= 0;    //*
                oUCodeEnable                            <= 0;    //*
                oUCodeEnable                            <= 0;    //*
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oIOWritePixel                           <= 1; //*
                oIOWritePixel                           <= 1; //*
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
 
 
                NextState <= `CU_SET_PICTH;
                NextState <= `CU_SET_PICTH;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_SET_PICTH:
        `CU_SET_PICTH:
        begin
        begin
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oUCodeInstructioPointer <= 0;    //*
                oUCodeInstructioPointer <= 0;    //*
                oUCodeEnable                            <= 0;    //*
                oUCodeEnable                            <= 0;    //*
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oIOWritePixel                           <= 1; //*
                oIOWritePixel                           <= 1; //*
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 1; //*
                oSetCurrentPitch        <= 1; //*
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
 
 
                NextState <= `CU_WAIT_FOR_PCU;
                NextState <= `CU_WAIT_FOR_PCU;
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_WAIT_FOR_PCU:
        `CU_WAIT_FOR_PCU:
        begin
        begin
 
 
//      `ifdef DEBUG
//      `ifdef DEBUG
//              `LOGME"%d Control: CU_WAIT_FOR_PCU\n",$time);
//              `LOGME"%d Control: CU_WAIT_FOR_PCU\n",$time);
//      `endif
//      `endif
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oUCodeInstructioPointer <= 0;    //*
                oUCodeInstructioPointer <= 0;    //*
                oUCodeEnable                            <= 0;    //*
                oUCodeEnable                            <= 0;    //*
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oIOWritePixel                           <= 1;
                oIOWritePixel                           <= 1;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                if ( iIODone )
                if ( iIODone )
                        NextState <= `CU_ACK_PCU;
                        NextState <= `CU_ACK_PCU;
                else
                else
                        NextState <= `CU_WAIT_FOR_PCU;
                        NextState <= `CU_WAIT_FOR_PCU;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_ACK_PCU:
        `CU_ACK_PCU:
        begin
        begin
 
 
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_ACK_PCU\n",$time);
                `LOGME"%d Control: CU_ACK_PCU\n",$time);
        `endif
        `endif
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
                oUCodeInstructioPointer <= 0;    //*
                oUCodeInstructioPointer <= 0;    //*
                oUCodeEnable                            <= 0;    //*
                oUCodeEnable                            <= 0;    //*
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                NextState <= `CU_TRIGGER_NPU;
                NextState <= `CU_TRIGGER_NPU;
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_TRIGGER_NPU: //Next Pixel Unit
        `CU_TRIGGER_NPU: //Next Pixel Unit
        begin
        begin
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_TRIGGER_NPU\n",$time);
                `LOGME"%d Control: CU_TRIGGER_NPU\n",$time);
        `endif
        `endif
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= `NPG_UCODE_ADDRESS;  //*
                oUCodeInstructioPointer <= `NPG_UCODE_ADDRESS;  //*
                oUCodeEnable                            <= 1;   //*
                oUCodeEnable                            <= 1;   //*
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                NextState <= `CU_WAIT_NPU;
                NextState <= `CU_WAIT_NPU;
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_WAIT_NPU:
        `CU_WAIT_NPU:
        begin
        begin
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= `NPG_UCODE_ADDRESS;
                oUCodeInstructioPointer <= `NPG_UCODE_ADDRESS;
                oUCodeEnable                            <= 0;
                oUCodeEnable                            <= 0;
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
                oTriggerTFF             <= 0;
                oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                if ( iUCodeDone )
                if ( iUCodeDone )
                        NextState <= `CU_ACK_NPU;
                        NextState <= `CU_ACK_NPU;
                else
                else
                        NextState <= `CU_WAIT_NPU;
                        NextState <= `CU_WAIT_NPU;
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        `CU_ACK_NPU:
        `CU_ACK_NPU:
        begin
        begin
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: CU_ACK_PSU\n",$time);
                `LOGME"%d Control: CU_ACK_PSU\n",$time);
        `endif
        `endif
 
 
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
                oUCodeInstructioPointer <= 0;    //*
                oUCodeInstructioPointer <= 0;    //*
                oUCodeEnable                            <= 0;    //*
                oUCodeEnable                            <= 0;    //*
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                if ( iUCodeDone  == 0)
                if ( iUCodeDone  == 0)
                        NextState <= `CU_TRIGGER_RGU;
                        NextState <= `CU_TRIGGER_RGU;
                else
                else
                        NextState <= `CU_ACK_NPU;
                        NextState <= `CU_ACK_NPU;
 
 
 
 
        end
        end
        //-----------------------------------------
        //-----------------------------------------
        default:
        default:
        begin
        begin
 
 
        `ifdef DEBUG
        `ifdef DEBUG
                `LOGME"%d Control: ERRO Undefined State\n",$time);
                `LOGME"%d Control: ERRO Undefined State\n",$time);
        `endif
        `endif
 
 
                oRamBusOwner                            <= 0;
                oRamBusOwner                            <= 0;
                oUCodeInstructioPointer <= 0;
                oUCodeInstructioPointer <= 0;
                oUCodeEnable                            <= 0;
                oUCodeEnable                            <= 0;
                oGFUEnable                                      <= 0;
                oGFUEnable                                      <= 0;
                oIOWritePixel                           <= 0;
                oIOWritePixel                           <= 0;
                rResetHitFlop                           <= 0;
                rResetHitFlop                           <= 0;
                rHitFlopEnable                          <= 0;
                rHitFlopEnable                          <= 0;
      oTriggerTFF             <= 0;
      oTriggerTFF             <= 0;
                oSetCurrentPitch        <= 0;
                oSetCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
                //oIncCurrentPitch        <= 0;
 
 
                NextState <= `CU_AFTER_RESET_STATE;
                NextState <= `CU_AFTER_RESET_STATE;
        end
        end
        //-----------------------------------------
        //-----------------------------------------
 
 
        endcase
        endcase
 
 
end //always    
end //always    
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

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