Browserbasierter Simulator für digitale Logikschaltungen zum Lernen, Testen und Validieren digitaler Schaltungen mit Timing-Analyse, Race-Condition-Erkennung, FSM-Workflows sowie Verilog-/VHDL-Export.
Ein mit KI entwickeltes Tool zur Unterstützung von Studierenden beim Einstieg in die Digitaltechnik – Unterstützung für Praktika, Übungsaufgaben und Prüfungsvorbereitung
Entwickelt mit React, TypeScript und Vite.
- Simulation kombinatorischer und sequentieller Schaltungen
- Timing-Analyse und Race-Condition-Erkennung
- FSM-Workflows und Zustandsmodellierung
- Verilog-/VHDL-Export
- KI-gestützter Chat über die aktuell geöffnete Schaltung (lokaler Broker, eigener API-Key)
- Fokus auf Lehre, Übungsaufgaben und Prüfungsvorbereitung
Dieses Projekt wurde maßgeblich mit KI entwickelt und wird fachlich sowie funktional iterativ getestet und weiterentwickelt.
Gate-Delay-Modus vollständig implementiert und gehärtet: zuverlässige Race-Condition-Erkennung mit 5 Schweregradklassen, TTL-Leitungsmarkierung und Timing-Diagramm-Integration.
📖 Vollständige Bedienungsanleitung: BEDIENUNGSANLEITUNG.md
🤖 KI-Anbindung & Sicherheit: API_ANBINDUNG.md
- Discrete-Event-Scheduler mit konfigurierbarer Propagationsverzögerung pro Gatter
- Race-Condition-Erkennung mit 5 Schweregrad-Klassen (kritisch, Glitch, Timing, Warnung, Schleife)
- TTL-Leitungsmarkierung — kurzlebige Glitches bleiben 400 ms farblich sichtbar
- Race-Panel mit Klick-to-Focus auf betroffene Netze
- Vollständige Rückkopplungsunterstützung
| Werkzeug | Kombinatorisch | Sequenziell / Rückkopplung |
|---|---|---|
| Wahrheitstabelle | ✅ Alle Eingangskombinationen, Zwischenwerte | – |
| Zustandsübergangstabelle | – | ✅ Bei Rückkopplungen oder sequenziellen Zustandsbausteinen; Einzel-Tick Q(t) → Q(t+1) |
| Timing-Diagramm | ✅ | ✅ |
| Race-Condition-Panel | ✅ Statische Hazards / rekonfluente Glitches | ✅ Klick-to-Focus auf betroffene Netze |
| Format | Hinweise |
|---|---|
| JSON | Vollständiger Schaltkreis (Speichern / Laden) |
| Verilog | Synthesefähiges HDL |
| VHDL | Synthesefähiges HDL |
HDL-Export:
- Zentrales Identifier-Sanitizing: Alle Gate-Namen werden IEEE-konform bereinigt (Sonderzeichen, Keyword-Kollisionen, führende Ziffern)
- Nicht verbundene Pins werden zu expliziten Modulports mit
nc_-Präfix - 3-Pass-Architektur (Verilog): korrekte
output reg/output wire-Typisierung für alle Gates - Vollständige toVerilog/toVHDL-Emitter für: MUX2, MUX4, Schmitt-Trigger, ALU4 (explizites Bit-Mapping), CMP1, CMP4 (mit Cascade-Eingängen im
else-Zweig)
- Grafischer FSM-Editor mit Drag-and-Drop-Zuständen und Übergängen
- Bedingungsausdruck-Parser für Übergangsbeschriftungen
- Synthese vom FSM-Graphen zur Logikschaltung auf dem Canvas
| Gatter | Varianten |
|---|---|
| AND, OR, NOT, NAND, NOR, XOR, XNOR | 2–8 Eingänge |
| Buffer, Schmitt-Trigger, Tri-State-Buffer | – |
| Komplementäre Ausgangspaare | – |
- Multiplexer (2:1 / 4:1 / 8:1) und Demultiplexer
- Komparator (1-Bit / 4-Bit) – CMP4 mit Cascade-Eingängen (LTin / EQin / GTin): Mehrere CMP4 lassen sich zur Wortbreitenvergrößerung verketten; bei A=B werden die Cascade-Eingänge direkt auf die Ausgänge durchgeleitet
- Bus-Splitter / Bus-Kombinator
| Op2 | Op1 | Op0 | Operation | Ergebnis | COUT |
|---|---|---|---|---|---|
| 0 | 0 | 0 | ADD | A + B + CIN | Übertrag Bit 4 |
| 0 | 0 | 1 | SUB | A − B − CIN | Borrow-Ausgang |
| 0 | 1 | 0 | AND | A & B | 0 |
| 0 | 1 | 1 | OR | A | B | 0 |
| 1 | 0 | 0 | XOR | A ^ B | 0 |
| 1 | 0 | 1 | NOT A | ~A | 0 |
| 1 | 1 | 0 | SHL | A << 1 | A[3] |
| 1 | 1 | 1 | SHR | A >> 1 | A[0] |
Flag ZERO = 1 wenn S[3:0] = 0. Rechtsklick auf ALU4 → ❓ Hilfe (Op-Codes) für Kurzreferenz.
- D-, T-, SR-, JK-Flip-Flops (synchrones & asynchrones Löschen / Preset)
- Master-Slave-Flip-Flop
- 4-Bit Schieberegister (SHIFT4) – SIPO mit 4 Bit-LED-Anzeigen für Q0–Q3 im Gatter-Body
- 4-Bit Parallelregister (REG4) – mit EN-Eingang und 4 Bit-LED-Anzeigen
- 8-Bit Parallelregister (REG8)
- Binärzähler mit integrierter 7-Segment-Anzeige
- RAM (synchrones Lesen/Schreiben), ROM mit eingebautem Hex-Editor
| Komponente | Beschreibung |
|---|---|
| Eingabeschalter | HIGH / LOW umschalten |
| Taster | Kurzzeitiger HIGH-Impuls |
| Taktgenerator | Einstellbare Frequenz |
| Konstant HIGH / LOW | Feste Spannungsquelle |
| Ausgangs-LED | Konfigurierbare Farbe |
| 7-Segment-Anzeige | BCD-Eingang |
| Dot-Matrix-Anzeige | Bitmap-Anzeige |
| ADC | 8-Bit-Analogschieberegler |
| Schrittmotor | Visuelle Schrittzähler-Anzeige |
| Textnotiz | Canvas-Annotation |
- 74xx-Serien-ICs (u. a. 74HC595 mit funktionalem /OE-Pin)
- Custom IC – Kombinatorische Teilschaltung als in der Palette verfügbare, wiederverwendbare Komponente kapseln
git clone https://github.com/p-keminer/logic-simulator-studio.git
cd logic-simulator-studio
npm install
npm run devÖffne http://localhost:5173 im Browser.
node launcher.mjs # oder: npm run launchÖffnet automatisch eine Web-Oberfläche auf http://localhost:4321 mit Buttons zum Starten von App (Port 5173) und KI-Broker (Port 8787). Alternativ Doppelklick auf Start Launcher.bat (Windows), Start Launcher.command (macOS) oder start-launcher.sh (Linux).
Der KI-Broker ist ein optionaler lokaler Backend-Prozess. Er wird nur benötigt wenn du die KI-Chat-Funktion im Broker-Modal der App nutzen möchtest. Der Simulator selbst läuft vollständig clientseitig ohne den Broker.
Der Ordner validation/ enthält die Verifikations-, Regressions- und Reifegrad-Artefakte des Projekts. Für die normale Nutzung des Simulators ist er nicht erforderlich, für Entwicklung und Qualitätssicherung aber die zentrale Referenz.
Wichtigste Inhalte:
validation/README.md: kanonischer Einstiegspunkt mit Lesereihenfolgefocused-nine-*: aktuelle Hochrisiko-Suite mit Core-/UI-Berichten und Rohdatengolden-corpus-v1.*plusgenerated-circuits-golden/undgenerated-exports-golden/: erster Basis-Regressionskorpusgenerated-circuits-focused/,generated-exports-focused/,generated-ui-focused/: reproduzierbare Fokus-Artefaktecontracts/,gate-contract-schema.json,gate-inventory.json: maschinenlesbare Spezifikations- und Inventardatenmaturity-gap-dashboard.md,maturity-priority-list.json,industry-lite-roadmap.md,verification-matrix.md: Reifegrad, Prioritäten und Prüfstrategiearchive/: historische Altstände, nicht die aktuelle Quelle der Wahrheit
Praktische Nutzung:
- Für den aktuellen QA-Stand immer zuerst
validation/README.mdlesen. - Markdown-Dateien sind für Menschen gedacht, JSON-Dateien für Automatisierung und Weiterverarbeitung.
- Die
generated-*-Ordner sind Nachweise und Reproduktionsmaterial, keine Laufzeit-Abhängigkeiten der App.
| Schicht | Technologie |
|---|---|
| UI-Framework | React 19 |
| Sprache | TypeScript 5.9 (strict) |
| Bundler | Vite 7 |
| Styling | Tailwind CSS 4 |
| Linting | ESLint 9 + typescript-eslint |
| Zustandsverwaltung | React Context + useReducer |
| Persistenz | sessionStorage (Auto-Save, sitzungsgebunden) + JSON-Export |
| KI-Broker (optional) | Fastify 5, Node.js 20+, TypeScript, Zod |
Der Simulator selbst läuft vollständig clientseitig. Der KI-Broker ist ein optionaler lokaler Prozess für die KI-Chat-Funktion – kein zentraler Server, kein Cloud-Backend.
| Taste | Aktion |
|---|---|
Delete / Backspace |
Ausgewählte Elemente löschen |
| Pfeiltasten | Ausgewählte Gatter verschieben (Shift: 5× Schritt) |
Strg+C |
Ausgewählte Gatter kopieren (inkl. interner Kabel) |
Strg+V |
Zwischenablage einfügen (+24 px versetzt) |
Escape |
Kabelzeichnen abbrechen / Menüs schließen |
R |
Ausgewählte Gatter drehen |
W |
Verdrahtungsmodus ein/aus |
X |
Snap-to-Port-Modus ein/aus (gelber Rahmen) |
| Mausrad | Canvas zoomen |
Alt + Ziehen |
Viewport verschieben (Pan) |
| Mitteltaste + Ziehen | Viewport verschieben (Pan) |
| Ziehen auf leerem Canvas | Lasso-Auswahl → Pfeiltasten zum Verschieben |
| Rechtsklick auf Gatter | Kontextmenü (Kopieren, Drehen, Umbenennen, Farbe, Löschen, …) |
| Rechtsklick auf Kabel | Kontextmenü (Farbe, Knotenpunkt, Löschen) |
| Rechtsklick auf Wegpunkt | Kontextmenü (Wegpunkt entfernen, In Knotenpunkt umwandeln) |
| Rechtsklick auf Canvas | Einfügen an Mausposition (wenn Zwischenablage gefüllt) |
Browser-based simulator for digital logic circuits for learning, testing, and validating digital circuits, with timing analysis, race-condition detection, FSM workflows, and Verilog/VHDL export.
A tool developed with AI to support students getting started with digital logic – for lab work, practice exercises, and exam preparation.
Built with React, TypeScript, and Vite.
- Simulation of combinational and sequential circuits
- Timing analysis and race-condition detection
- FSM workflows and state modelling
- Verilog/VHDL export
- AI-assisted chat about the currently open circuit (local broker, user-supplied API key)
- Support for lab work, practice exercises, and exam preparation
This project was developed primarily with AI and is being iteratively tested and refined from both a technical and functional perspective.
Gate-delay mode fully implemented and hardened: reliable race-condition detection with 5 severity levels, TTL wire marking, and timing-diagram integration.
📖 Full user manual: BEDIENUNGSANLEITUNG.md
🤖 AI Integration & Security: API_ANBINDUNG.md
- Discrete-event scheduler with configurable per-gate propagation delay
- Race-condition detection with 5 severity levels (critical, glitch, timing, warning, loop)
- TTL wire marking — short-lived glitches remain colour-highlighted for 400 ms
- Race panel with click-to-focus on affected nets
- Full feedback-loop support
| Tool | Combinatorial | Sequential / Feedback |
|---|---|---|
| Truth Table | ✅ All input combinations, intermediate values | – |
| State Transition Table | – | ✅ With feedback loops or sequential state elements; single-tick Q(t) → Q(t+1) |
| Timing Diagram | ✅ | ✅ |
| Race Condition Panel | ✅ Static hazards / reconvergent glitches | ✅ Click-to-focus on affected nets |
| Format | Notes |
|---|---|
| JSON | Full circuit round-trip (save / load) |
| Verilog | Synthesisable HDL |
| VHDL | Synthesisable HDL |
HDL Export:
- Central identifier sanitizing: all gate names are made IEEE-compliant (special characters, keyword collisions, leading digits)
- Unconnected pins become explicit module ports with
nc_prefi - 3-pass architecture (Verilog): correct
output reg/output wiretyping for all gates - Full toVerilog/toVHDL emitters for: MUX2, MUX4, Schmitt Trigger, ALU4 (explicit bit mapping), CMP1, CMP4 (cascade inputs propagated in the
elsebranch)
- Condition expression parser for transition labels
- Synthesis from FSM graph to logic circuit on the canvas
| Gates | Variants |
|---|---|
| AND, OR, NOT, NAND, NOR, XOR, XNOR | 2–8 inputs |
| Buffer, Schmitt Trigger, Tri-State Buffer | – |
| Complementary output pairs | – |
- Multiplexer (2:1 / 4:1 / 8:1) and Demultiplexer
- Comparator (1-bit / 4-bit) – CMP4 with cascade inputs (LTin / EQin / GTin): multiple CMP4s can be chained for wider word comparisons; when A=B the cascade inputs are passed straight through to the outputs
- Bus Splitter / Bus Combiner
| Op2 | Op1 | Op0 | Operation | Result | COUT |
|---|---|---|---|---|---|
| 0 | 0 | 0 | ADD | A + B + CIN | Carry out bit 4 |
| 0 | 0 | 1 | SUB | A − B − CIN | Borrow bit |
| 0 | 1 | 0 | AND | A & B | 0 |
| 0 | 1 | 1 | OR | A | B | 0 |
| 1 | 0 | 0 | XOR | A ^ B | 0 |
| 1 | 0 | 1 | NOT A | ~A | 0 |
| 1 | 1 | 0 | SHL | A << 1 | A[3] (shifted-out MSB) |
| 1 | 1 | 1 | SHR | A >> 1 | A[0] (shifted-out LSB) |
Flags: ZERO = 1 when result S[3:0] = 0. Right-click any ALU4 instance → ❓ Help (Op-Codes).
- D, T, SR, JK Flip-Flops (synchronous & asynchronous clear / preset)
- Master-Slave Flip-Flop
- 4-bit Shift Register (SHIFT4) – SIPO with 4 in-gate bit-LED indicators for Q0–Q3
- 4-bit Parallel Register (REG4) – with EN input and 4 in-gate bit-LED indicators
- 8-bit Parallel Register (REG8)
- Binary counter with integrated 7-segment display
- RAM (synchronous read/write), ROM with built-in hex editor
| Component | Description |
|---|---|
| Input Switch | Toggle HIGH / LOW |
| Push Button | Momentary HIGH pulse |
| Clock Generator | Adjustable frequency |
| Constant HIGH / LOW | Fixed voltage source |
| Output LED | Configurable colour |
| 7-Segment Display | BCD input |
| Dot-Matrix Display | Bitmap display |
| ADC | 8-bit analogue slider |
| Stepper Motor | Visual step-count display |
| Text Note | Canvas annotation |
- 74xx series ICs (including 74HC595 with functional /OE pin)
- Custom IC – encapsulate a combinational sub-circuit as a reusable palette component (flip-flops / latches inside a Custom IC are not correctly simulated)
git clone https://github.com/p-keminer/logic-simulator-studio.git
cd logic-simulator-studio
npm install
npm run devOpen http://localhost:5173 in your browser.
node launcher.mjs # or: npm run launchAutomatically opens a web UI at http://localhost:4321 with buttons to start the App (port 5173) and AI Broker (port 8787). Alternatively double-click Start Launcher.bat (Windows), Start Launcher.command (macOS), or start-launcher.sh (Linux).
The AI Broker is an optional local backend process only needed for the AI chat feature in the broker modal. The simulator itself runs fully client-side without it.
The validation/ folder contains the project's verification, regression, and maturity-tracking artefacts. It is not required for normal simulator usage, but it is the main reference area for development and QA.
Most important contents:
validation/README.md: canonical entry point and reading orderfocused-nine-*: current high-risk suite with core/UI reports and raw datagolden-corpus-v1.*plusgenerated-circuits-golden/andgenerated-exports-golden/: first baseline regression corpusgenerated-circuits-focused/,generated-exports-focused/,generated-ui-focused/: reproducible focused-suite artefactscontracts/,gate-contract-schema.json,gate-inventory.json: machine-readable specification and inventory datamaturity-gap-dashboard.md,maturity-priority-list.json,industry-lite-roadmap.md,verification-matrix.md: maturity tracking, priorities, and validation strategyarchive/: historical snapshots that are no longer the active source of truth
Practical usage:
- Read
validation/README.mdfirst for the current QA status. - Markdown files are for humans; JSON files are for automation and downstream tooling.
- The
generated-*directories are evidence and reproduction material, not runtime dependencies of the app.
| Layer | Technology |
|---|---|
| UI Framework | React 19 |
| Language | TypeScript 5.9 (strict) |
| Bundler | Vite 7 |
| Styling | Tailwind CSS 4 |
| Linting | ESLint 9 + typescript-eslint |
| State management | React Context + useReducer |
| Persistence | sessionStorage (auto-save, session-scoped) + JSON export |
| AI Broker (optional) | Fastify 5, Node.js 20+, TypeScript, Zod |
The simulator runs fully client-side. The AI Broker is an optional local process for the AI chat feature — no central server, no cloud backend.
| Key | Action |
|---|---|
Delete / Backspace |
Delete selected elements |
| Arrow keys | Move selected gates (Shift: 5× step) |
Ctrl+C |
Copy selected gates (and internal wires) |
Ctrl+V |
Paste clipboard (+24 px offset) |
Escape |
Cancel wire drawing / close menus |
R |
Rotate selected gate(s) |
W |
Toggle wire-draw mode |
X |
Toggle snap-to-port mode (yellow outline) |
| Mouse wheel | Zoom canvas |
Alt + drag |
Pan viewport |
| Middle-button drag | Pan viewport |
| Drag on empty canvas | Lasso selection → use arrow keys to move |
| Right-click gate | Context menu (copy, rotate, label, colour, delete, …) |
| Right-click wire | Context menu (colour, junction, delete) |
| Right-click waypoint | Context menu (remove waypoint, convert to junction) |
| Right-click empty canvas | Paste at cursor (if clipboard non-empty) |
The requestAnimationFrame loop in CircuitContext.tsx:
syncBuffer– Copies user-controlled inputs (switches, buttons) from React state into theSimBuffer- Settle phase – After structural changes,
runUntilStablepropagates signals with clocks frozen (max 64 ticks) EventScheduler.advance()– Processes all pending events up to the target time; downstream gates are re-evaluated and new events are enqueued attriggerTime + gate.propagationDelaySIMULATION_APPLYdispatch – Only when any signal actually changed, preventing unnecessary re-renders
The main simulation uses the EventScheduler (discrete-event model). The double-buffer model (separate read / write buffers per tick) is still used internally for the settle phase (runUntilStable) and for the State Transition Table algorithm (runOneTick), where it guarantees structurally correct evaluation of cyclic topologies.
topologicalSortidentifies which gates are in cycles (feedback gates = state holders)- For every combination of (external inputs × current state Q_t), a fresh
SimBufferis seeded - Exactly one
runOneTick– the mathematical definition of Q(t+1) in the double-buffer model - Stable rows (Q_t = Q_t+1) are highlighted
committedOutputsholds the last stable value for every gate output- A priority queue stores
(time, netId, value, sourceGateId)events sorted by time - Each
advance()call processes all events withtime ≤ targetTime, re-evaluates downstream gates, and enqueues new events attriggerTime + gate.propagationDelay - Race detection with 5 severity classes:
critical(value_conflict) >timing(setup_hold_risk) >glitch(reconvergent_glitch) >warning(multi_source) >loop(loop_overflow) - TTL wire-marking:
raceMarkRefmap keeps severity colours visible for 400 ms per net — short-lived glitches remain readable - Per-batch timing snapshots:
onBatchCommitcallback fires once peradvance()batch, producing one timing-diagram step per gate-delay level (e.g. 20 NOT gates in series = 20 staircase steps) - INPUT_SWITCH fix:
seed()acceptsliveCustomStateFor— overridescommittedCustomStatesfor switch gates before the eval pass so toggling a switch generates a properly timed event instead of a silent no-op - Memory safety: events are only generated when the computed value differs from the committed value; settled circuits produce zero new events
Single source of truth for all identifier sanitizing. Rules (applied in order):
- Replace chars outside
[A-Za-z0-9_]with_ - Strip leading underscores
- Empty result → fallback
x - Leading digit → prefix
m_(modules) orn_(signals/ports) - Reserved keyword collision → prefix
n_
Gates that implement their own toVerilog/toVHDL and handle all output signals internally can set verilogSkipUnconnectedOutputs: true / vhdlSkipUnconnectedOutputs: true in their GateDefinition. This suppresses the automatic fallback wire/signal declaration for unconnected outputs. Without the flag, the fallback is always emitted — ensuring gates like SR_LATCH, D_FF, REG8, and ALU4 never produce undeclared-wire compile errors under `default_nettype none. Currently opt-in: MUX2, MUX4, SCHMITT.
Pull requests are welcome. For major changes please open an issue first.
