Section 2 · Revision

Digital Logic formula sheet

Laws, counts, circuit equations, timing rules and number formats for Digital Logic on one printable page.

Full notes Section test

Boolean algebra and minimization

Laws to apply on sight

Law Form
Absorption A+AB=AA + AB = A, A(A+B)=AA(A + B) = A
Redundant literal A+A‾B=A+BA + \overline{A}B = A + B, A(A‾+B)=ABA(\overline{A} + B) = AB
Distributive (OR over AND) (A+B)(A+C)=A+BC(A + B)(A + C) = A + BC
Consensus AB+A‾C+BC=AB+A‾CAB + \overline{A}C + BC = AB + \overline{A}C
Consensus (POS) (A+B)(A‾+C)(B+C)=(A+B)(A‾+C)(A + B)(\overline{A} + C)(B + C) = (A + B)(\overline{A} + C)
De Morgan AB‾=A‾+B‾\overline{AB} = \overline{A} + \overline{B}, A+B‾=A‾ B‾\overline{A + B} = \overline{A}\,\overline{B}
XOR A⊕B=A‾B+AB‾A \oplus B = \overline{A}B + A\overline{B}, A⊕1=A‾A \oplus 1 = \overline{A}, A⊕A=0A \oplus A = 0
XOR with AND A(B⊕C)=AB⊕ACA(B \oplus C) = AB \oplus AC, A⊕B⊕AB=A+BA \oplus B \oplus AB = A + B
Dual swap +↔⋅+ \leftrightarrow \cdot and 0↔10 \leftrightarrow 1, keep literals
  • Complement of FF: take the dual and complement every literal.
  • Dual of Σm(S)\Sigma m(S) over nn variables: minterms 2n−1−m2^n - 1 - m for every m∉Sm \notin S.

Standard counts (nn variables)

Quantity Count
Boolean functions 22n2^{2^n}
Self-dual functions 22n−12^{2^{n-1}}
Symmetric functions 2n+12^{n+1}
Functions with kk rows fixed 22n−k2^{2^n - k}
Neutral functions (equal 0s and 1s) (2n2n−1)\binom{2^n}{2^{n-1}}
Minterms covered by a kk-literal product 2n−k2^{n-k}
Minterms of XOR of nn variables 2n−12^{n-1}

K-map and tabular method

  • Adjacent cells differ in one bit. Gray order: 00, 01, 11, 10. Edges wrap.
  • Groups have 2k2^k cells; a group of 2k2^k drops kk variables.
  • Prime implicant (PI): group that cannot grow. Essential PI: the only PI covering some 1-cell.
  • Procedure: take all EPIs, then cover the rest with the fewest PIs. Don't cares may be used, never required.
  • Cyclic function: no EPI, several minimal covers (for example Σm(0,1,2,5,6,7)\Sigma m(0,1,2,5,6,7), 6 PIs, 2 minimal SOPs).
  • Quine-McCluskey: group minterms by number of 1s; merge terms in adjacent groups that differ in one bit and have dashes in the same places; tick merged terms; unticked terms are PIs; then build the PI chart.
  • PI chart reduction: row with one X marks an EPI; drop dominated rows; drop dominating columns.
  • POS: group the 0s, write the result as a product of sums.

Functional completeness (Post): a set is complete iff, for each of the 5 classes, some member lies outside it: 0-preserving, 1-preserving, self-dual, monotone, linear (XOR-based).

  • Complete alone: NAND, NOR, {→,0}\{\to, 0\}, {∨,¬}\{\lor, \lnot\}, {∧,¬}\{\land, \lnot\}.
  • Not complete: {∧,∨}\{\land, \lor\}, {⊕,¬}\{\oplus, \lnot\}, {→}\{\to\} alone.

Combinational circuits

Adders and subtractors

Block Outputs
Half adder S=A⊕BS = A \oplus B, C=ABC = AB
Full adder S=A⊕B⊕CS = A \oplus B \oplus C, Cout=AB+C(A⊕B)=AB+BC+CAC_{out} = AB + C(A \oplus B) = AB + BC + CA
Half subtractor D=A⊕BD = A \oplus B, borrow =A‾B= \overline{A}B
Full subtractor D=A⊕B⊕BinD = A \oplus B \oplus B_{in}, borrow =A‾B+A‾Bin+BBin= \overline{A}B + \overline{A}B_{in} + BB_{in}
Adder-subtractor Bi⊕MB_i \oplus M into each stage, C0=MC_0 = M
  • Ripple-carry, nn bits: carry ready after n⋅tcn \cdot t_c; last sum at (n−1)tc+ts(n-1)t_c + t_s.
  • Carry lookahead: Gi=AiBiG_i = A_iB_i, Pi=Ai⊕BiP_i = A_i \oplus B_i, Ci+1=Gi+PiCiC_{i+1} = G_i + P_iC_i, Si=Pi⊕CiS_i = P_i \oplus C_i.
  • C2=G1+P1G0+P1P0C0C_2 = G_1 + P_1G_0 + P_1P_0C_0; all carries in 2 gate levels after P/G, independent of nn (fan-in grows).
  • Blocks of CLA chained in ripple: time ≈\approx P/G time + (number of blocks) ×\times block carry delay + final sum delay.

Multiplexers and decoders

  • 2n2^n-to-1 mux: nn select lines. Realises any (n+1)(n+1)-variable function with one variable (and its complement) on the data lines.
  • Residue rule: for each select value, the data input is 00, 11, xx or x‾\overline{x}.
  • Mux tree from mm-to-1 units for NN inputs: N/mN/m in level 1, then divide by mm (round up) per level until 1. Example: 32-to-1 from 4-to-1 needs 8+2+1=118 + 2 + 1 = 11.
  • nn-to-2n2^n decoder: each output is one minterm. OR of chosen outputs gives Σm\Sigma m; NOR of the rest gives the same FF.
  • Active-low outputs: NAND of chosen lines gives Σm\Sigma m, AND gives ΠM\Pi M.
  • Bigger decoder: 6-to-64 from 3-to-8 with enable needs 8+1=98 + 1 = 9.
  • Priority encoder: highest-priority active input wins; valid bit VV = OR of inputs.

Codes, comparators, parity

Item Rule
Binary to Gray Gn−1=Bn−1G_{n-1} = B_{n-1}, Gi=Bi+1⊕BiG_i = B_{i+1} \oplus B_i
Gray to binary Bn−1=Gn−1B_{n-1} = G_{n-1}, Bi=Bi+1⊕GiB_i = B_{i+1} \oplus G_i
Equality (bit) Ai⊕Bi‾\overline{A_i \oplus B_i}, AND over all bits
A>BA > B (2-bit) A1B1‾+A1⊕B1‾ A0B0‾A_1\overline{B_1} + \overline{A_1 \oplus B_1}\,A_0\overline{B_0}
Parity of nn bits n−1n - 1 two-input XOR gates
2×22 \times 2 multiplier P0=A0B0P_0 = A_0B_0, P1=A1B0⊕A0B1P_1 = A_1B_0 \oplus A_0B_1, P2=A1B1A0B0‾P_2 = A_1B_1\overline{A_0B_0}, P3=A0A1B0B1P_3 = A_0A_1B_0B_1

Gate counts (2-input, uncomplemented inputs): XOR = 4 NAND or 5 NOR; XNOR = 5 NAND or 4 NOR; NOT = 1 NAND; AND = 2 NAND; OR = 3 NAND.

Hazards

  • Static-1 hazard in SOP: two adjacent 1-cells not inside a common product term.
  • Fix: add the consensus term of each such pair. Hazard-free SOP covers every adjacent pair of 1s.
  • Static-0 hazard is the POS dual. Two-level SOP has no static-0 hazard for single input changes.

Sequential circuits

Flip-flops

FF Characteristic Excitation (Q→Q+Q \to Q^+: 00, 01, 10, 11)
SR Q+=S+R‾QQ^+ = S + \overline{R}Q, SR=0SR = 0 0X0X, 1010, 0101, X0X0
JK Q+=JQ‾+K‾QQ^+ = J\overline{Q} + \overline{K}Q 0X0X, 1X1X, X1X1, X0X0
D Q+=DQ^+ = D 00, 11, 00, 11
T Q+=T⊕QQ^+ = T \oplus Q 00, 11, 11, 00
  • Conversions: D from SR: S=DS = D, R=D‾R = \overline{D}. T from JK: J=K=TJ = K = T. T from D: D=T⊕QD = T \oplus Q. D from JK: J=DJ = D, K=D‾K = \overline{D}.
  • NOR latch: S=R=1S = R = 1 is forbidden (Q=Q‾=0Q = \overline{Q} = 0); releasing both together races.
  • Latch is level-sensitive; flip-flop is edge-triggered. JK master-slave avoids race-around.

Counters

Counter States with nn FFs Notes
Binary (ripple or sync) 2n2^n mod-NN needs ⌈log⁡2N⌉\lceil \log_2 N \rceil FFs
Ring nn one 1 circulates; 2n−n2^n - n unused
Johnson 2n2n Qin=Qlast‾Q_{in} = \overline{Q_{last}}; 2n−2n2^n - 2n unused
LFSR (max length) 2n−12^n - 1 all-zero state locks
  • Ripple counter settle time n⋅tpdn \cdot t_{pd}, so fmax=1/(n⋅tpd)f_{max} = 1/(n \cdot t_{pd}). Sync counter: fmax=1/(tpd+tgate+tsu)f_{max} = 1/(t_{pd} + t_{gate} + t_{su}).
  • Ripple outputs pass through false states (011 to 100 shows 010, 000).
  • MSB of a mod-NN counter: frequency fclk/Nf_{clk}/N; a T flip-flop divides by 2.
  • Asynchronous clear at state NN: modulus NN. Synchronous clear decoded at state N−1N-1: modulus NN. Same decode used synchronously gives one more state.
  • Self-starting check: trace every unused state until it enters the main cycle.

Timing (δ\delta = capture clock arrives δ\delta later than launch)

Check Condition
Setup T≥tcq+tcomb,max+tsu−δT \ge t_{cq} + t_{comb,max} + t_{su} - \delta
Hold tcq+tcomb,min≥thold+δt_{cq} + t_{comb,min} \ge t_{hold} + \delta
  • Hold does not involve TT: fix it by adding delay to the short path, never by changing the clock.
  • fmax=1/Tminf_{max} = 1/T_{min}.

State machines

  • Moore: output from state; Mealy: from state and input. Moore often needs 1 more state.
  • Sequence detector for a pattern of length kk: usually kk Mealy states and k+1k + 1 Moore states.
  • Counting machines: tracking (count mod pp, count mod qq) needs pqpq states when the output depends on both.
  • State minimisation: split by output, then refine by next-state blocks until stable; states left in one block are equivalent.

Number representation and arithmetic

Integer ranges, nn bits

Format Range Zeros
Unsigned 00 to 2n−12^n - 1 1
Sign-magnitude −(2n−1−1)-(2^{n-1} - 1) to 2n−1−12^{n-1} - 1 2
1's complement −(2n−1−1)-(2^{n-1} - 1) to 2n−1−12^{n-1} - 1 2
2's complement −2n−1-2^{n-1} to 2n−1−12^{n-1} - 1 1
  • 2's complement value: −bn−12n−1+∑i<n−1bi2i-b_{n-1}2^{n-1} + \sum_{i<n-1} b_i 2^i. Negate: invert and add 1.
  • Sign extension copies the MSB. Arithmetic right shift rounds toward −∞-\infty.
  • Base conversion: group 3 bits for octal, 4 for hex. Fractions: multiply by the base, take integer parts.
  • Unknown base: expand both sides as polynomials in bb, solve, check every digit is less than bb.

Overflow (2's complement)

  • Addition: V=Cn⊕Cn−1=a b s‾+a‾ b‾ sV = C_n \oplus C_{n-1} = a\,b\,\overline{s} + \overline{a}\,\overline{b}\,s (sign bits).
  • Opposite-sign operands never overflow on addition.
  • Subtraction A−BA - B: overflow iff signs of AA and BB differ and the result sign differs from AA.
  • Unsigned overflow: Cn=1C_n = 1 on add; Cn=0C_n = 0 on subtract via A+B‾+1A + \overline{B} + 1.

Booth recoding

Radix-2 (bi,bi−1)(b_i, b_{i-1}) Action Radix-4 (b2i+1,b2i,b2i−1)(b_{2i+1}, b_{2i}, b_{2i-1}) Digit
00 / 11 none 000 / 111 00
10 −M-M 001 / 010 +1+1
01 +M+M 011 +2+2
100 −2-2
101 / 110 −1-1
  • Append b−1=0b_{-1} = 0. Radix-2 operations = number of bit changes in bn−1…b0b−1b_{n-1} \ldots b_0 b_{-1}. Radix-4 gives n/2n/2 digits.

Codes

Code Rule
BCD each decimal digit in 4 bits; nibbles 1010 to 1111 invalid
BCD add add binary per digit; if sum > 9 or carry out, add 0110
Excess-3 digit dd stored as d+3d + 3; self-complementing
Gray consecutive values differ in one bit

Fixed point: nn-bit 2's complement with ff fraction bits: value = integer /2f/ 2^f, step 2−f2^{-f}, range −2n−1−f-2^{n-1-f} to 2n−1−f−2−f2^{n-1-f} - 2^{-f}. Product of formats with f1f_1 and f2f_2 fraction bits has f1+f2f_1 + f_2 fraction bits.

IEEE 754: value (−1)s×1.f×2e−bias(-1)^s \times 1.f \times 2^{e - bias} for 1≤e≤emax−11 \le e \le e_{max} - 1.

Item Single Double
Sign / exponent / fraction bits 1 / 8 / 23 1 / 11 / 52
Bias 127 1023
Smallest normal 2−1262^{-126} 2−10222^{-1022}
Smallest subnormal 2−1492^{-149} 2−10742^{-1074}
Largest finite (2−2−23)×2127(2 - 2^{-23}) \times 2^{127} (2−2−52)×21023(2 - 2^{-52}) \times 2^{1023}
Gap above 1 (epsilon) 2−232^{-23} 2−522^{-52}
Values in [2k,2k+1)[2^k, 2^{k+1}) 2232^{23} 2522^{52}
Exponent field Fraction Meaning
all 0 0 ±0\pm 0 (+0 = -0 when compared)
all 0 nonzero subnormal 0.f×21−bias0.f \times 2^{1 - bias}
all 1 0 ±∞\pm\infty
all 1 nonzero NaN (NaN ≠\ne NaN)
  • Custom format with kk exponent bits and mm fraction bits: bias 2k−1−12^{k-1} - 1, largest (2−2−m)×2bias(2 - 2^{-m}) \times 2^{bias}, smallest subnormal 21−bias−m2^{1 - bias - m}.
  • Exactly representable: p/2qp/2^q with enough fraction bits (0.10.1, 0.20.2 never are). Integers up to 2242^{24} in single.
  • Encode: write ±1.f×2E\pm 1.f \times 2^E, store E+biasE + bias. Hex shortcuts: 1.0 is 3F800000, 2.0 is 40000000, +∞+\infty is 7F800000.
  • Round to nearest, ties to even; spacing at exponent EE is 2E−m2^{E - m}.