Digital Logic Guide
Digital Logic Fundamentals: Gates, Boolean Algebra, K-Maps, and Logic Levels
Use this guide to connect ideal logic equations with practical electronics decisions: gate behavior, expression simplification, state, timing, fixed-width representation, and voltage-level compatibility.
- Reading Time
- 19 min
- Difficulty
- Beginner to Intermediate
- Last Updated
- September 12, 2026
Introduction
Digital logic calculators are useful because they make discrete behavior explicit. They can enumerate a truth table, evaluate a Boolean expression, simplify a small K-map, check a flip-flop transition, estimate counter size, or compare logic-level voltage margins. The engineering challenge is knowing which model you are using and where that model stops.
This guide explains the shared vocabulary behind ECParts Digital Logic calculators. It covers logic states, gates, truth tables, Boolean algebra, K-map grouping, sequential logic, counters, frequency dividers, timing margins, and logic-level compatibility. It also calls out the boundary between digital logic and generic number conversion so the Hex Decimal Binary Converter remains the right tool for pure base conversion.
Logic States and Voltage Reality
Boolean logic uses two abstract states: 0 and 1. Real circuits represent those states with voltage ranges, not perfect numbers. A CMOS input might treat low voltages as logic 0, high voltages as logic 1, and a middle region as undefined. A valid design must satisfy both the logical function and the electrical thresholds.
This distinction matters when a 3.3 V device drives a 5 V input, when an open-drain bus uses a pull-up rail, or when noisy signals cross between boards. The Logic Level Compatibility Calculator checks those voltage margins; a truth table alone cannot.
Formula reference
Logic-Level Noise Margin
NMH = VOH,min - VIH,minNML = VIL,max - VOL,maxVariable definitions
- NMH
- high-level noise margin
- NML
- low-level noise margin
- VOH,min
- minimum guaranteed output-high voltage from the driver
- VOL,max
- maximum guaranteed output-low voltage from the driver
- VIH,min
- minimum input voltage accepted as high by the receiver
- VIL,max
- maximum input voltage accepted as low by the receiver
Logic Gates and Truth Tables
Gates define ideal Boolean behavior. A truth table lists every input combination and output, which makes it a good first check before wiring logic or writing HDL. The output is functional behavior only; propagation delay, loading, fanout, power, and signal integrity must still be checked from device data.
| Gate | Expression | Ideal Behavior | Typical Engineering Use |
|---|---|---|---|
| AND | Y = A . B | 1 only when all inputs are 1. | Enable logic, validity checks, qualified control signals |
| OR | Y = A + B | 1 when at least one input is 1. | Fault flags, interrupt combines, request aggregation |
| NOT | Y = A' | Inverts the input state. | Active-low conversion, polarity correction |
| NAND | Y = (A . B)' | Inverse of AND. | Universal-gate implementation, memory and control logic |
| NOR | Y = (A + B)' | Inverse of OR. | Universal-gate implementation, reset or inhibit logic |
| XOR | Y = A XOR B | 1 when two inputs differ. | Parity, adders, change detection |
| XNOR | Y = (A XOR B)' | 1 when two inputs are the same. | Equality checks, phase comparison |
Use the Logic Gate Truth Table Calculator when you need a quick truth table for standard gates or want to compare OR, XOR, NAND, NOR, and XNOR behavior.
Boolean Algebra and Expressions
Boolean algebra lets engineers write logic compactly, check equivalence, and simplify circuits. In ECParts notation, AND may be written as a dot, OR as plus, and inversion as an apostrophe. Calculator syntax can differ, so always follow the symbols shown by the tool you are using.
Operator precedence matters. NOT normally binds before AND, AND before XOR, and XOR before OR in the ECParts Boolean calculator. Parentheses are cheap documentation: use them when moving logic between a calculator, schematic, HDL, or firmware expression.
| Identity Type | Example | Engineering Interpretation |
|---|---|---|
| Identity | A + 0 = A; A . 1 = A | Unused neutral terms can be removed. |
| Null | A + 1 = 1; A . 0 = 0 | A forced state overrides the variable. |
| Complement | A + A' = 1; A . A' = 0 | A signal and its inverse form a complete contradiction pair. |
| Idempotent | A + A = A; A . A = A | Repeated identical terms do not add behavior. |
| Absorption | A + A . B = A | A broader term absorbs a narrower gated term. |
| De Morgan | (A . B)' = A' + B'; (A + B)' = A' . B' | Inversions can move across AND and OR when the operator changes. |
Formula reference
Truth-Table Size and Expression Evaluation
Rows = 2^nEvaluate expression for every input combinationVariable definitions
- n
- number of independent Boolean inputs
- Rows
- number of rows in the truth table
- Expression
- a deterministic combination of variables and logic operators
K-Maps and Small Logic Simplification
A Karnaugh map is a visual simplification method for small Boolean functions. It arranges truth-table cells in Gray-code order so adjacent cells differ by only one variable. Groups of 1, 2, 4, 8, or 16 cells can remove variables that change inside the group.
K-maps are excellent for two to four variables, but they are not a full logic synthesis tool. A minimized SOP expression may reduce gate count while still being worse for hazards, timing, routing, or FPGA resource mapping. Use K-map results as a compact Boolean model, then check the implementation context.
Binary Words, Masks, and Representation Boundary
Digital systems store values in fixed-width words. A bit pattern can represent an unsigned number, a signed two's-complement number, a field of flags, an address, an instruction, or a coded state. The same bits can mean different things depending on width and interpretation.
This guide only covers representation where it affects digital logic design: overflow, masks, shifts, sign extension, and Gray code adjacency. Pure base conversion belongs to converter tools, while fixed-width arithmetic and bitwise design checks belong to the Digital Logic calculators.
Formula reference
Fixed-Width Digital Context
Unsigned range for n bits: 0 to 2^n - 1Two's-complement range for n bits: -2^(n-1) to 2^(n-1) - 1Mask test: result = value AND maskVariable definitions
- n
- number of bits in the word
- Overflow
- result cannot be represented in the selected width
- Mask
- bit pattern used to select, clear, set, toggle, or test fields
- Gray code
- adjacent code values differ by one bit
Sequential Logic, Counters, and Dividers
Sequential logic adds memory. A flip-flop stores one bit of state, and the next state depends on the present state plus current inputs. Counters and frequency dividers are built from state transitions, so their behavior cannot be fully described by a combinational truth table alone.
| Model | Meaning | Where It Applies |
|---|---|---|
| Combinational logic | Output depends only on present inputs. | Gates, decoders, multiplexers, adders, comparators |
| Sequential logic | Output depends on present inputs and stored state. | Flip-flops, registers, counters, state machines |
| Truth table | Enumerates every valid input combination. | Checking logic functions and calculator results |
| Characteristic table | Maps current state and inputs to next state. | Flip-flop behavior and sequential design |
| Excitation table | Finds inputs needed for a desired transition. | Counter and state-machine synthesis |
| Timing budget | Checks whether data arrives and remains stable around a clock edge. | Synchronous registers and clocked systems |
Formula reference
Counters and Clock Dividers
States from n flip-flops = 2^nRequired flip-flops = ceil(log2(modulus))Unused states = 2^n - modulusfout = fin / NT = 1 / fVariable definitions
- modulus
- number of intended counter states
- N
- divider ratio
- fin
- input clock frequency
- fout
- output clock frequency
- T
- clock period
Timing Margins
Functional logic can be correct and still fail in hardware if the clock is too fast or the data path is too short. Setup analysis asks whether data arrives early enough before the capture clock edge. Hold analysis asks whether data remains stable long enough after the edge. The two checks use different delay corners.
A slower clock often improves setup margin, but it does not automatically repair a hold violation. Hold failures are minimum-delay problems near the same active edge and may require routing, buffering, clocking, or constraint changes.
Formula reference
Simplified Synchronous Timing
Trequired = Tcq,max + Tlogic,max + Tsetup + Tuncertainty - TskewMsetup = Tclock - TrequiredMhold = Tcq,min + Tlogic,min - Thold - Tskew - Tuncertainty,holdfmax = 1 / TrequiredVariable definitions
- Tclock
- clock period
- Tcq
- clock-to-Q delay
- Tlogic
- combinational logic and routing delay
- Tsetup
- required setup time
- Thold
- required hold time
- Tskew
- capture clock arrival minus launch clock arrival in ECParts timing convention
- Tuncertainty
- margin reserve for clock uncertainty or modeling error
Practical Design Workflow
Use calculators in the same order an engineer reviews a logic problem: function first, representation second, state and timing third, and electrical compatibility before connecting real devices.
| Step | Check | Purpose |
|---|---|---|
| 1 | Define logic states | Know which signals are active-high, active-low, synchronous, asynchronous, or open-drain. |
| 2 | Write behavior first | Use words, equations, or a truth table before choosing gates or HDL operators. |
| 3 | Simplify where useful | Use Boolean algebra or K-maps to reduce small logic without hiding design intent. |
| 4 | Check representation | Confirm bit width, signed interpretation, overflow behavior, and mask boundaries. |
| 5 | Separate state from combinational logic | Identify flip-flops, counters, divider stages, and next-state equations. |
| 6 | Verify timing | Check setup, hold, clock-to-Q, combinational delay, skew, and uncertainty. |
| 7 | Verify voltage compatibility | Compare VOH, VOL, VIH, VIL, noise margins, and input absolute limits. |
| 8 | Document assumptions | State whether the result is ideal Boolean behavior, numeric representation, or hardware timing. |
Worked Examples
NAND truth-table check
For A=1 and B=1, AND is 1, so NAND is 0. For any other two-input combination, AND is 0, so NAND is 1.
Boolean absorption
A + A . B simplifies to A. If A is 1, the result is already 1. If A is 0, both A and A . B are 0.
Two-variable K-map grouping
A function with minterms 1 and 3 in A,B ordering is true whenever B=1, so the simplified SOP is B.
XOR is not OR
For A=1 and B=1, OR is 1, but XOR is 0 because the two inputs are not different.
4-bit overflow context
Unsigned 1111 + 0001 produces a carry out and wraps the 4-bit result to 0000. The carry is part of the fixed-width interpretation.
Counter sizing
A modulo-10 counter needs ceil(log2(10)) = 4 flip-flops. Four flip-flops provide 16 states, so 6 states are unused.
Clock divider
A 48 MHz input divided by 48 produces 1 MHz. The output period is 1 microsecond using T = 1 / f.
Logic-level margin
If VOH,min = 2.9 V and VIH,min = 2.0 V, the high-level noise margin is 0.9 V. If VOL,max = 0.4 V and VIL,max = 0.8 V, the low-level noise margin is 0.4 V.
Common Mistakes
- Treating Boolean 0 and 1 as exact analog voltage values instead of logic states with threshold ranges.
- Confusing OR and XOR when both inputs are high.
- Ignoring operator precedence in Boolean expressions copied into code, HDL, or documentation.
- Using binary counting order where a K-map requires Gray-code adjacency.
- Treating don't-care terms as required output-1 minterms.
- Assuming the simplest Boolean expression always produces the safest or fastest hardware.
- Forgetting that bit width controls overflow, sign extension, masks, and wraparound.
- Mixing signed two's-complement interpretation with unsigned arithmetic without documenting it.
- Using a divided clock without considering timing constraints and clock-domain handling.
- Assuming slower clock frequency fixes both setup and hold problems.
- Connecting logic families without checking VOH, VOL, VIH, VIL, input tolerance, and pull-up behavior.
- Using ideal truth tables as a replacement for datasheet timing, loading, fanout, or signal-integrity checks.
Related Calculators
Related Engineering Guides
Support reference
FAQ
What is digital logic?
Digital logic is the use of discrete logic states, usually represented as 0 and 1, to describe switching behavior in gates, registers, counters, processors, programmable logic, and embedded interfaces.
What is the difference between a truth table and a Boolean expression?
A truth table lists every input combination and output. A Boolean expression is a compact equation that produces the same behavior. Calculators can help move between the two forms, but the designer still needs to check intent and hardware limits.
Why is XOR different from OR?
OR is true when either input is true, including the case where both are true. Two-input XOR is true only when the inputs are different, so XOR is false when both inputs are 1.
What does a Karnaugh map do?
A Karnaugh map arranges truth-table cells in Gray-code order so adjacent cells differ by one variable. Grouping adjacent 1 cells can reduce a small Boolean function into a simpler SOP expression.
What are don't-care terms?
Don't-care terms are input combinations where either output is acceptable for the application. They may be used to form larger K-map groups, but they should not be confused with required output-1 cases.
What is the difference between combinational and sequential logic?
Combinational logic depends only on present inputs. Sequential logic also depends on stored state, usually held in flip-flops or registers and updated on a clock edge.
Why does bit width matter in digital design?
Bit width determines representable range, overflow behavior, masks, sign extension, and wraparound. A value that is valid in 16 bits may overflow or change meaning in 8 bits.
Is Gray code the same as binary?
No. Gray code is an ordering where adjacent values differ by one bit. It is useful in encoders and state transitions, but it is not ordinary weighted binary arithmetic.
How many flip-flops are needed for a modulo-N counter?
The minimum count is ceil(log2(N)). That number of flip-flops provides 2^n states, and any states beyond the intended modulus must be handled by reset or state logic.
What are setup and hold margins?
Setup margin checks whether data arrives early enough before the capture clock edge. Hold margin checks whether data remains stable long enough after the edge. They use different delay corners.
How do I check logic-level compatibility?
Compare the driver output limits with the receiver input thresholds. High margin is VOH,min - VIH,min, and low margin is VIL,max - VOL,max. Also check absolute input voltage limits and pull-up requirements.
Does this replace the Hex Decimal Binary Converter?
No. This guide explains how representation affects digital logic design. Base conversion, ASCII inspection, and general number-format conversion remain converter-page responsibilities.
Summary
Digital logic design starts with ideal states and gates, then moves through expressions, simplification, bit width, sequential state, clock timing, and voltage-level compatibility. Each layer answers a different engineering question.
Use ECParts calculators to check those layers explicitly, but do not collapse them into one model. A correct truth table does not prove voltage margin, a simplified expression does not prove timing, and a converted bit pattern does not define intent unless width and interpretation are documented.
