CPU Simulator is a desktop Java application for step-by-step simulation of a simple CPU instruction flow.
The project models a basic processor with registers and memory, provides a graphical interface for building and executing command sequences, and persists commands in SQLite. It was built as a practice project to explore CPU simulation concepts, desktop UI development, architectural separation with MVP, and synchronization between application state and visualization.
- step-by-step execution of a command sequence
- GUI for adding and managing commands
- visualization of register values
- visualization of memory state
- execution progress highlighting
- command usage statistics
- SQLite-based command persistence between launches
- MVP-based project structure
Current implementation supports the following commands:
INIT <value> <address>— writes a value to memoryLD <address> <register>— loads a value from memory into a registerST <register> <address>— stores a register value into memoryADD <register> <register | value>— adds either another register value or an immediate numberMUL <register> <register | value>— multiplies either by another register value or an immediate number
Registers used in the simulator:
ABCD
- Java 23
- Maven
- Java Swing
- SQLite JDBC
The application follows the MVP (Model–View–Presenter) pattern:
- Model — CPU logic, RAM, command validation, program state, SQLite persistence
- View — Swing-based GUI components for command list, output, memory, registers, and statistics
- Presenter — interaction layer between UI and business logic
This separation makes the project easier to maintain, extend, and reason about.
src/main/java
├── cpus # application entry point
├── model # CPU, RAM, commands, validation, persistence
├── presenter # presenter layer
├── view # Swing UI
└── util # auxiliary event utilities