A digital logic circuit simulator built in C++ with Qt. Drag logic gates and input/output sources onto a canvas, wire them together, and watch signal state propagate through the circuit in real time.
A practice project intended as a learning platform for young students (future engineers), to learn the basics of electronics and logic gates through hands-on, visual experimentation rather than abstract theory.
- Interactive circuit canvas: drag components from a palette, drop them onto the scene, and connect ports by clicking between them
- Live simulation: component states update and propagate through the circuit automatically whenever a connection or input changes
- Supported components:
- Inputs: VCC, GND, push button
- Logic gates: AND, OR, NOT
- Outputs: LED, buzzer
The simulation core is fully decoupled from the UI Core/Circuit contains no Qt dependencies at all, so the logic can be reasoned about (and tested) independently of how it's rendered.
Core/Circuit/
├── Components/ Component, Port, and concrete component types
│ (gates, inputs, outputs), built via ComponentsFactory
└── Managers/ CircuitManager — owns all components, evaluates
circuit state, notifies observers on change
UI/
├── Controllers/ SceneEditor (canvas interaction), MainGuiContainer
├── disp/ Qt widgets, views, and .ui forms
└── Models/ Component metadata for the palette
Common/
└── Observable/IObserver Generic observer pattern used to notify the UI
when circuit state changes
Key design decisions:
- Factory pattern (
ComponentsFactory) creates the correct component subclass from anElementTypeenum, keeping construction logic in one place. - Observer pattern (
Observable/IObserver) letsSceneEditorreact to circuit state changes withoutCircuitManagerknowing anything about the UI. - Circuit evaluation repeatedly recomputes component outputs until the circuit reaches a stable state (a fixed-point iteration), so it correctly handles circuits where signal changes cascade through multiple components in one update.
- CMake 3.16+
- Qt 6 (or Qt 5) with the Widgets and Multimedia components
- A C++17-compatible compiler
mkdir build && cd build
cmake ..
cmake --build .Or open CMakeLists.txt directly in Qt Creator and build from there.
| Path | Contents |
|---|---|
Core/Circuit/Components/ |
Component base class, ports, and all concrete component types |
Core/Circuit/Managers/ |
CircuitManager — the simulation engine |
Common/ |
Shared interfaces (Observable, IObserver) |
UI/Controllers/ |
Scene interaction and window composition |
UI/disp/ |
Qt widgets and .ui form files |
UI/disp/Widgets/CircuitElement/ |
Visual representation of each component type on the canvas |
Resources/ |
Icons and images used by the UI |
- Unit tests for
CircuitManagerand component evaluation logic - Additional logic gates (NAND, NOR, XOR, XNOR)
- Save/load circuits to file
