Class ControlUnit

java.lang.Object
io.matita08.data.ControlUnit

public final class ControlUnit extends Object
CPU Control Unit State Management.

This class maintains the state of the CPU's control unit, tracking execution phases, instruction cycles, and current operations. It serves as the central coordinator for instruction execution flow.

State Components:

  • Execution Phases: Current and next phases (Fetch/Decode/Execute)
  • Cycle Management: Current cycle within instruction execution
  • Operation Tracking: Current instruction being executed
  • ALU Status: Current arithmetic/logic operation display

The control unit coordinates with the execution engine to manage the fetch-decode-execute cycle and handle multi-cycle instruction execution.

Since:
1.0
  • Field Details

    • current

      public static Phase current
      Current execution phase of the CPU.

      Represents the current state in the instruction cycle: Fetch, Decode, Execute, or None (inactive).

    • next

      public static Phase next
      Next execution phase to transition to.

      Set by the current phase to determine the next phase in the instruction execution cycle.

    • currentCycle

      public static int currentCycle
      Current cycle number within the current instruction execution.

      Counts down from the total cycles required for the current instruction. When it reaches 0, the instruction execution is complete.

    • totalCycles

      public static int totalCycles
      Total number of cycles required for the current instruction.

      Set during the decode phase based on the instruction being executed. Used for progress tracking and multi-cycle instruction coordination.

    • opcode

      public static Operation opcode
      Current operation being executed.

      Set during decode phase and used throughout execution. Contains the instruction's execution logic and metadata.

    • ALUOpcode

      public static String ALUOpcode
      String representation of current ALU operation for display.

      Used by the GUI to show which arithmetic/logic operation is currently being performed. Set by arithmetic instructions.