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

AboutRoadmapCareersInternshipsFAQContactPrivacyTerms
Skip to lesson

Course contents

  • RTL Foundations36
    • 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
    • Number Systems for RTL Engineers
    • Verilog Fundamentals
    • Verilog Operators and Types
    • SystemVerilog for RTL
    • Simulation and Testbenches
  • Combinational Design25
  • Sequential Design27
  • FSM & Control27
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
  • Advanced RTL28
  • Senior & Interview76
  • 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. Algebra Before Gates
On this page

    Part 1 of 9, lesson 1 of 36Part 1 of 9/Foundations/Lesson 1 of 36Beginner

    Algebra Before Gates

    From truth table to sum-of-products equation, and the cost of logic in literals and levels.

    Start from gates and you end up with a design nobody can explain or test. Start from the equation and the cost is visible at once: the three-input majority function has 12 literals as a raw sum of products and 6 once simplified.

    After this lesson you can: turn a truth table into a sum-of-products equation and estimate its cost in literals and levels.

    Start from the equation

    A logic gate network is a Boolean equation drawn as hardware. Write the equation first, and the gates, the cost estimate, and the test all follow.

    Starting from gates usually ends with a design that cannot be explained.

    The basic operators

    Function

    Symbol in equations

    Verilog bitwise

    Output is 1 when…

    NOT

    a′ or ¬a

    ~a

    a is 0

    AND

    a·b

    a & b

    both inputs are 1

    OR

    a+b

    a | b

    at least one input is 1

    XOR

    a⊕b

    a ^ b

    the inputs differ

    NAND

    (a·b)′

    ~(a & b)

    not both inputs are 1

    NOR

    (a+b)′

    ~(a | b)

    both inputs are 0

    XNOR

    (a⊕b)′

    ~(a ^ b)

    the inputs are equal

    In equations, “+” means OR and “·” (or juxtaposition) means AND. In Verilog + is arithmetic addition.

    Mixing the two up is a classic confusion when moving from a textbook to code.

    The Verilog bitwise operators &, |, ^, and ~ map one-to-one onto AND, OR, XOR, and NOT.

    Sum of products: spec to equation

    The most direct way from truth table to equation is sum of products (SOP). For every row where the output is 1, write an AND term (a minterm) true only for that row, then OR the terms.

    Take a 3-input majority function. The output is 1 when at least two of three inputs are 1.

    a

    b

    c

    y

    minterm

    0

    0

    0

    0

    0

    0

    1

    0

    0

    1

    0

    0

    0

    1

    1

    1

    a′·b·c

    1

    0

    0

    0

    1

    0

    1

    1

    a·b′·c

    1

    1

    0

    1

    a·b·c′

    1

    1

    1

    1

    a·b·c

    Four minterms give the raw SOP y = a′bc + ab′c + abc′ + abc. A little algebra (next lesson) collapses it to y = ab + bc + ac, which reads “any two of the three”.

    majority3.v
    1
    2
    3
    4
    5
    6
    7
    module majority3 (
      input  wire a, b, c,
      output wire y
    );
      // y = ab + bc + ac : true when at least two inputs are 1
      assign y = (a & b) | (b & c) | (a & c);
    endmodule
    The majority function as a two-level AND-OR network: three 2-input ANDs feeding a 3-input OR.

    Cost: literals and levels

    Two numbers describe a first-order implementation cost, long before a tool runs:

    • Literals — the total count of variable appearances (ab + bc + ac has 6). More literals generally means more transistors, so more area.

    • Levels — the longest chain of gates from an input to the output. More levels means more delay.

    The raw SOP above has 12 literals; the simplified form has 6. Both are two levels deep: same function, half the literal count. That comparison assumes true and complemented inputs are both available and ignores fan-in limits. Mapped gate cost depends on the library.

    XOR is the classic example of why equations beat intuition. a⊕b written out as a·b′ + a′·b costs four literals and needs both complements, so two inverters when only the true inputs are available, while a library XOR cell can do it in one compact gate. Write a ^ b and let the tool pick the cell.

    Check yourself How many minterms does the 3-input majority function have, and what does that equal in a 4-input majority-of-at-least-3?

    Three-input majority has 4 minterms (011, 101, 110, 111). For “at least 3 of 4” there are C(4,3) + C(4,4) = 4 + 1 = 5 minterms.

    • One minterm per output-1 row, ORed together, is the most direct route from table to equation.

    • Literals approximate area and levels approximate delay, long before a tool runs.

    • In equations + means OR; in Verilog + is addition. Use | for OR.

    Rule of thumb: write the equation first, then draw the gates.

    • Interview: run a mock interview on this topic

    Related topics

    • The identity toolkit — simplifying the equation

    • Truth tables as a debug anchor

    Previous

    1 / 350

    Next: The Identity Toolkit

    Up next

    Up nextThe Identity Toolkit

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • De Morgan Rules
    • Truth Tables as a Debug Anchor
    • K-Map Intuition