Digital Logic Simulator

Digital Logic Simulator

Connect binary logic gates and D flip-flops to see how a circuit responds to a discrete input sequence. Gates evaluate in dependency order; each flip-flop samples its D input at a rising primary-input clock edge, and all Q outputs update simultaneously. The displayed outputs are recomputed after that edge. This is an ideal 0/1 teaching model, without propagation delay, unknown levels, analog voltages or hardware timing guarantees.

1. Wire the circuit

Node IDs are unique signal names. Gate pins and D may use primary inputs, gate outputs or stored Q. CLK uses a primary input only. Limits: 8 inputs, 24 gates, 8 flip-flops and 12 outputs.

Primary inputs

CLKENABLE

Logic gates

A gate needs two connected pins except NOT and BUF, which use one. Connecting gates into a cycle is an error; feedback through a flip-flop Q is allowed.

Gate NEXT

D flip-flops

A primary CLK is sampled once per tick. D is read before a rising edge; Q changes together after it. CLK starts low before tick 0.

D flip-flop Q

Named outputs

OUT

2. Input sequence and clock

Set every input bit at each discrete tick. Only 0→1 on a flip-flop's CLK input triggers a capture. Repeated 1 does not. Maximum 64 ticks.

Input bits per tick
TickCLKENABLEAction
0
1
2
3
4
5
6

4. Restore a circuit

Open or paste a strict JSON circuit file up to 100 kB. Duplicate keys, bad wires and impossible cycles are rejected without replacing the working circuit.

Edit the example circuit and run its input sequence.

Comments & questions

Digital Logic Simulator

Connect binary logic gates and D flip-flops to see how a circuit responds to a discrete input sequence. Gates evaluate in dependency order; each flip-flop samples its D input at a rising primary-input clock edge, and all Q outputs update simultaneously. The displayed outputs are recomputed after that edge. This is an ideal 0/1 teaching model, without propagation delay, unknown levels, analog voltages or hardware timing guarantees.

Key features

  • Eight real binary gate functions: AND, OR, XOR, NAND, NOR, XNOR, NOT and buffer
  • Gate dependency sorting with missing pin, unknown wire and combinational loop rejection
  • Rising-edge D flip-flops that sample pre-edge D and update Q simultaneously
  • Editable primary-input 0/1 sequence of up to 64 ticks, with initial clock level assumed low
  • Per-tick trace table and downloadable SVG waveform with input, gate, Q and output lanes
  • Strict, bounded local JSON circuit import, export and deterministic round-trip

How to use

  1. Start from the ENABLE/XOR flip-flop example or add primary inputs, gates, flip-flops and outputs.
  2. Choose each gate type and connect its input pins to a primary input, another gate or a flip-flop Q. Connect every D pin; choose a primary input for each CLK pin.
  3. Set 0 or 1 for every primary input at every tick, adding or removing ticks as needed. The clock begins conceptually at 0 before tick 0.
  4. Run the circuit. Inspect the pre-edge D sample, rising-edge markers, after-edge Q state and resulting outputs in the trace table and waveform.
  5. Download the SVG waveform and full circuit JSON. Paste or open a saved JSON file to restore the gates, wires, initial state and sequence.

Use cases

  • Check all four rows of a basic gate truth table
  • Teach why a D flip-flop updates only on a 0→1 clock transition
  • Explore safe feedback through stored Q versus an invalid combinational cycle
  • Share a small reproducible 0/1 circuit and input sequence as JSON

Frequently asked questions

When does a D flip-flop update?

At a tick whose primary-input CLK is 1 after being 0 on the previous tick. Each D value is computed with the previous Q state before the edge; all triggered Q outputs update together. Clock is assumed low before the first tick, so a high first sample is a rising edge.

Why is a gate loop rejected but Q feedback allowed?

Gate-to-gate cycles have no defined stable value in this zero-delay binary model, so they fail before simulation. A path through a D flip-flop Q is broken by stored state and can be evaluated one tick at a time.

Can a flip-flop clock come from another gate?

No. For an unambiguous discrete sample model, each CLK pin must connect directly to a primary input. Derived or asynchronous clocks, propagation delays, setup/hold times and metastability are outside this tool.

What happens if a pin is blank or a wire refers to a removed node?

The circuit fails validation with a pin or wire error. It never silently treats an unconnected signal as zero. Duplicate IDs, extra/missing sequence bits and combinational cycles also fail.

Is the circuit suitable for physical electronics design?

No. Logic is strictly two-state 0/1, one discrete row per tick. There are no X/Z values, voltage thresholds, fan-out, delays, glitches or electrical safety checks.

Are my circuit files uploaded?

No. Validation, simulation, waveform generation and JSON downloads run locally in this browser tab.

Privacy

Circuit wiring and sequence stay in this browser tab. A JSON or SVG file is downloaded only when you request it; no circuit data is submitted to a server API.

Related Tools

State Machine TesterNumber Base ConverterBinary Protocol DesignerWasm Module InspectorHreflang Matrix CheckerAST Query PlaygroundContainer Build GraphDependency Graph ExplorerSemver Range LabCron Schedule AuditorPatch Review WorkbenchSource Map ExplorerLocalization Catalog AuditorStructured Data ReviewerHTTP Archive AnalyzerWebhook Signature LabProtobuf Schema WorkbenchGraphQL Schema LabAvro Schema EvolutionLocal SQL WorkbenchSchema Form BuilderMesh Repair WorkbenchPipe Network LabRobot Arm Kinematics LabThermal Network LabBeam Response LabGear Train DesignerTolerance Stackup LabSensor Calibration FitPCB Stackup PlannerDigital Filter DesignerNetwork Reachability MapSun Shadow MapGPS Error SimulatorAnalog Circuit LabMechanism Linkage LabAnalysis Mesh GeneratorOpenAPI Contract InspectorDatabase Migration PlannerDimensional Equation CheckerTruss Force LabBoolean Minimization LabControl Response LabQueueing Simulation LabGeofence Event SimulatorCoordinate Reference LabSurvey Traverse LabRaster Classification LabChoropleth Design LabMap Print ComposerRaster Reprojection LabElevation Contour MakerTerrain Viewshed LabWatershed DelineatorMap Tile PackagerText File Encoding WorkbenchFilesystem Portability AuditorSBOM License ExplorerFile Signature Auditornpm Lockfile Conflict ResolverSource Secret AuditorOffline Web Package BuilderCertificate Chain InspectorTorrent Metainfo InspectorChunked File PackagerEncrypted File VaultDuplicate File FinderArchive WorkbenchDesign Token ManagerSpacing Token DesignerResponsive Type SystemPackaging Dieline DesignerSVG Icon Sprite PackerFlex Layout PlaygroundCSS Grid PlaygroundRegex Equivalence LabMarkdown Repository AuditorLog Template MinerResponsive Layout AuditorEmail Template PreviewInternal Link GraphPetri Net SimulatorGit History VisualizerCurl Request WorkbenchHex File EditorBinary Patch WorkbenchFile Signature WorkbenchAPI Mock SandboxSchema Column MapperEvent Log SessionizerER Diagram DesignerTime Series Gap AuditorStratified Data SplitterData Lineage DesignerDecision Tree LabData Anonymization WorkbenchData Expectation RunnerJSON Schema ValidatorBasket Pattern AnalyzerRobots Policy TesterSEO HTML AuditorAccessibility Structure AuditorSyndication Feed WorkbenchIndexNow Payload BuilderCrawl Log AnalyzerCSP Policy WorkbenchSearch Performance AnalyzerCSV Formula Risk AuditorCORS Response SimulatorCache Header LabCookie Policy InspectorWeb Vitals Trace LabSitemap Health AuditorBatch File RenamerFile Manifest VerifierFolder Space MapFolder Difference ReviewerRoute Order OptimizerGeoJSON Map EditorPolygon Overlay LabCartographic Label PlacerSpatial Table JoinGeoJSON Topology AuditorGPX Track AnalyzerTrack Privacy RedactorCSV Table JoinCSV Pivot WorkbenchScientific Data ProfilerTabular Cleaning WorkbenchRecord ReconciliationData Dictionary BuilderCanonical Graph AuditorRedirect Plan TesterHTTP response and ping reference testBrowser and System InformationJSON ↔ YAML ConverterXML ↔ JSON ConverterHTML FormatterJavaScript MinifierMock Data Generator.gitignore GeneratorLicense GeneratorUser-Agent ParserPassword Strength CheckerCode to ImageXML FormatterHTTP Status Code LookupMIME Type LookupJS & SQL String EscapeCSS Box Shadow GeneratorCSS Gradient GeneratorIndent ConverterUnicode Escape ConverterUnicode InspectorJSON Structure DiffMarkdown Table GeneratorBase64 EncoderJSON FormatterURL EncoderSQL FormatterCron Expression GeneratorRegex TesterUUID GeneratorHash GeneratorTimestamp ConverterJWT DecoderHTML Entity ConverterMarkdown PreviewCSS MinifierMeta Tag GeneratorJSON ↔ CSVCase ConverterImage to Base64
Explore all Dev Tools tools →Image/Media →Text/Convert →Life/Fun →