Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • RTL Foundations57
    • Digital Logic for RTL Engineers
      • Algebra Before Gates
      • The Identity Toolkit
      • De Morgan Rules
      • Truth Tables as a Debug Anchor
      • K-Map Intuition
      • Implementation Trade-offs
      • Digital Logic Summary
      • Worked Examples and Waveforms
      • Corner Cases and Stress Tests
    • Number Systems for RTL Engineers
    • Verilog Fundamentals
    • Verilog Operators and Types
    • SystemVerilog for RTL
    • Simulation and Testbenches
  • Combinational Design58
  • Sequential Design61
  • FSM & Control66
  • Timing & Clocking64
  • Reset & CDC58
  • Memory & Buses94
  • Advanced RTL60
  • Senior & Interview175
  • Glossary and Notation
Loading lesson

‹Digital Logic for RTL Engineers
  1. Topics
  2. RTL Design
  3. RTL Foundations
  4. Digital Logic for RTL Engineers
  5. De Morgan Rules

Part 1 · Foundations · Beginner

De Morgan Rules

Convert between AND/OR and NAND/NOR forms, build any gate from NAND, and handle active-low signals without sign errors.

On this page

    Why this matters

    Standard-cell libraries favour NAND and NOR, and interfaces are full of active-low signals. A misplaced inversion bubble is a classic wrong-polarity bug that simulates plausibly.

    After this lesson you can: apply De Morgan's laws to convert between AND/OR and NAND/NOR forms and to read active-low conditions correctly.

    The two rules

    Negating a group flips the operator and negates each member:

    Rule

    Equation

    Plain English

    First law

    (a · b)′ = a′ + b′

    NAND is the same as OR of the inverted inputs.

    Second law

    (a + b)′ = a′ · b′

    NOR is the same as AND of the inverted inputs.

    The pattern is called bubble pushing: moving an inversion bubble from an output to the inputs (or the reverse) while switching AND to OR. It extends to any number of inputs.

    Bubble pushing: moving the inversion bubble from the output to both inputs swaps AND for OR; the bottom row is the three-NAND OR built in the next section

    Read each row left to right: the orange circles are the inversions, and both sides of the equals sign compute the same y for every input.

    • Top row: the bubble leaves the NAND output, lands on both inputs, and the AND body becomes an OR.

    • Middle row: the same move on a NOR turns the OR body into an AND.

    • Bottom row: a NAND with its inputs tied is an inverter, so na and nb are a′ and b′; the last NAND is the top-row OR with inverted inputs, so y = a | b with three gates.

    Everything from NAND

    NAND is universal: any Boolean function can be built from NAND alone. Tying both inputs together turns a NAND into an inverter, and the rest follows from De Morgan.

    Standard-cell libraries are rich in NAND and NOR gates, so mapping converts AND/OR equations into these forms with De Morgan.

    and_from_nand.v
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    module and_from_nand (input wire a, b, output wire y);
      wire n1;
      nand g1 (n1, a, b);      // ~(a & b)
      nand g2 (y,  n1, n1);    // inverter: ~~(a & b) = a & b
    endmodule
    
    module or_from_nand (input wire a, b, output wire y);
      wire na, nb;
      nand g1 (na, a, a);      // inverter: ~a
      nand g2 (nb, b, b);      // inverter: ~b
      nand g3 (y,  na, nb);    // ~(~a & ~b) = a | b   (De Morgan)
    endmodule

    Function

    NAND2 gates needed

    How

    NOT

    1

    Tie both inputs together.

    AND

    2

    NAND followed by an inverter.

    OR

    3

    Invert both inputs, then NAND.

    Active-low signals

    In the gate primitives above, terminals are output first: nand g3(y, na, nb) means y = ~(na & nb). Push a bubble through an AND gate by changing it to OR and inverting both inputs: (a·b)′ = a′+b′. Pushing through OR gives the dual rule. Do not invert the output twice when moving between the two forms.

    A signal named en_n is asserted when it is 0. Active-low signals appear in almost every interface.

    Suppose a block is selected only when two active-low enables are both asserted. The condition “both asserted” is ~en_a_n & ~en_b_n, and De Morgan turns that into a single NOR:

    select_two_enables.v
    1
    2
    3
    4
    5
    6
    7
    8
    module select_two_enables (
      input  wire en_a_n,    // active low
      input  wire en_b_n,    // active low
      output wire sel        // active high
    );
      // sel = (~en_a_n) & (~en_b_n) = ~(en_a_n | en_b_n)
      assign sel = ~(en_a_n | en_b_n);
    endmodule

    Common pitfall

    In Verilog ! is a logical NOT that returns one bit, and ~ is a bitwise NOT that works per bit. De Morgan applies per bit, so use ~ on vectors. !bus is true only when the whole vector is zero, which is almost never what the bitwise equation meant.

    Tip

    Name active-low signals with a _n suffix and convert them to active-high names at the boundary of a block. It keeps the bubbles in one place instead of scattered through the equations.

    Check yourself Express a | b using only NAND2 gates. How many gates does it need?

    Three: invert a (NAND with both inputs tied), invert b the same way, then NAND the two results. By De Morgan, ~(~a & ~b) = a | b.

    Check yourself A chip select is asserted when cs0_n is low OR cs1_n is low. Write the active-high select.

    sel = ~cs0_n | ~cs1_n, which De Morgan rewrites as ~(cs0_n & cs1_n): a single NAND of the active-low signals.

    Remember

    • Negating a group flips the operator and negates each member: (a·b)' = a' + b'.

    • NAND alone builds any function: tie its inputs for NOT, then use De Morgan for the rest.

    • Use ~ on vectors; ! tests the whole vector and is rarely what you mean.

    Rule of thumb: convert active-low names to active-high at the block boundary, so the bubbles stay in one place.

    Keep going

    • Interview: run a mock interview on this topic

    Related topics

    • The identity toolkit

    • Verilog operators and types

    Previous

    3 / 694

    Next: Truth Tables as a Debug Anchor

    Up next

    Up nextTruth Tables as a Debug Anchor

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Algebra Before Gates
    • K-Map Intuition
    • Implementation Trade-offs