Package io.matita08.logic
package io.matita08.logic
CPU logic and execution engine package for the simulator.
This package implements the core execution logic of the CPU simulator, providing the fetch-decode-execute cycle, operation management, and instruction processing capabilities. It serves as the "brain" of the simulated processor.
Core Components:
Execution- Main execution engine implementing CPU cycleOperation- Operation wrapper with dynamic instruction loadingPhase- Execution phase enumeration (Fetch, Decode, Execute)Operations3Bit- 3-bit instruction set implementationOperations4Bit- 4-bit instruction set implementation
Execution Model:
- Step-by-Step Execution: Single-step and continuous execution modes
- Multi-Cycle Operations: Realistic timing with variable cycle counts
- Phase-Based Processing: Clear separation of fetch, decode, and execute phases
- Dynamic Instruction Loading: Reflection-based operation set loading
- Memory Integration: Seamless interaction with register and memory systems
Supported Instruction Sets:
- 3-Bit ISA: Basic instruction set with essential operations (LOAD, STO, ADD, etc.)
- 4-Bit ISA: Extended instruction set with additional operations (SUB, JMP, conditional jumps)
Fetch-Decode-Execute Cycle:
- Fetch Phase:
- Read instruction from memory at PC address
- Store instruction in IR register
- Increment PC to next instruction
- Decode Phase:
- Interpret instruction opcode
- Look up operation definition
- Prepare operands and timing
- Execute Phase:
- Perform operation-specific actions
- Update registers and memory
- Set appropriate CPU flags
Dynamic Operation Loading:
The execution engine uses Java reflection to dynamically load instruction set definitions, allowing for different CPU architectures without modifying the core execution logic. Operation classes must implement the expected interface with proper static methods and fields.
Integration with Other Packages:
- Data Package: Direct access to registers, memory, and CPU state
- GUI Package: Execution control through step buttons and state display
- Value Package: Arithmetic operations and data type handling
Educational Value:
The logic package demonstrates fundamental computer science concepts:
- How instructions are fetched from memory and decoded
- The role of the program counter in sequential execution
- Multi-cycle instruction timing and pipeline concepts
- Control unit coordination of CPU components
- Memory addressing modes and data access patterns
- Since:
- 1.0
-
ClassDescriptionCPU Execution Engine - Instruction Cycle Management.Represents a CPU operation/instruction in the simulator with dynamic loading capabilities.3-Bit CPU Instruction Set Implementation.4-Bit CPU Instruction Set Implementation.CPU Execution Phases - Instruction Cycle States.