C713 of 57
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

C7 · Lesson 13 · Combinational logic

Building functions from gates

A combinational circuit's outputs depend only on its present inputs: no memory. Adders, multiplexers, decoders and comparators are all combinational, and together they make up the "arithmetic and logic unit" at the heart of a processor. Designing one means getting from a truth table to a small set of gates, and the classic tool for that is the Karnaugh map, which turns algebraic simplification into spotting rectangles.

Play

  • A 2-bit adder: two full-adder stages, where the carry out of the low bit feeds the high bit. Flip the switches to set A (A1 A0) and B (B1 B0).
  • Check a few sums against the truth table. Which output is the carry out of the whole adder?
  • Follow the carry from the low stage. When does it make a difference to the high bits?

Predict

A function of three inputs is 1 exactly when C is 1, whatever A and B are. How many of its 8 truth-table rows are 1?

Name it

Designing combinational logic

From a truth table to a sum of products. Each row where the output is 1 is a minterm: an AND of all inputs, each plain or inverted. OR them together and you have the function. It's correct, but rarely small.

Karnaugh maps. Arrange the truth table in a grid whose rows and columns are in Gray-code order (00, 01, 11, 10), so neighboring cells differ in one input, including wrapping around the edges. Then:

  1. group the 1s into rectangles whose sides are powers of 2, as large as possible, overlapping if useful;
  2. each rectangle is one AND term, keeping only the inputs that stay the same across it;
  3. OR the terms.

A group of 2 drops one input, a group of 4 drops two.

Building blocks:

  • Multiplexer (mux): selects one of 2n inputs by an n-bit select. A 2:1 mux is Y=S¯A+SB.
  • Decoder: n inputs, 2n outputs, exactly one active: used to pick a memory chip or a register.
  • Half adder: S=A⊕B, C=AB. Full adder: S=A⊕B⊕Cin, Cout=AB+Cin(A⊕B).
  • Ripple-carry adder: n full adders in a chain, each carry feeding the next; simple but slow (lesson 19).

Worked example

A full adder gets A = 1, B = 1 and carry-in 0. What are its sum and carry?

Show the solution
  1. Sum. S=A⊕B⊕Cin=1⊕1⊕0=0
  2. Carry. Cout=AB+Cin(A⊕B)=1+0=1
  3. Check. 1 + 1 = 10 in binary.

Answer the sum is 0 and the carry is 1.

Worked example

Minimize ∑m(1,3,5,7) for inputs A, B, C.

Show the solution
  1. Find the block. Every odd row is a 1, and the four cells form a block in which A and B both vary.
  2. Read the term. Only C stays the same across the block, so the function is just C.

Answer f=C.

Worked example

Design a majority function of three inputs: 1 when at least two are 1. How many two-input NAND gates does it take?

Show the solution
  1. Find the rows. The output is 1 in rows 3, 5, 6 and 7.
  2. Minimize. Each 1 pairs with another to give M=AB+AC+BC the full adder's carry.
  3. First level of NANDs. Three NAND2 gates make AB¯, AC¯ and BC¯.
  4. Combine the three. A NAND of all three gives M, which needs a three-input NAND, or two more NAND2 gates and an inverter: 3+3=6 gates using only two-input NANDs.
  5. Where it's used. Majority voting is how triple-redundant systems outvote one failed copy.

Answer M=AB+AC+BC, which takes 6 two-input NAND gates.

Check

A function of A, B and C is 1 for rows 1, 3, 5 and 7 (counting from 0 with A as the top bit). Write it as simply as possible.

Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.

Check

A 2:1 multiplexer outputs A when S = 0 and B when S = 1. Write its output.

Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.

Check

Simplify ABC¯+ABC+A¯BC.

Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.

Check

How many outputs does a 4-input decoder have?

Check

Add 011 and 001 in binary. Give a 4-bit result.

Check

Write the three-input majority function.

Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.

Check

Write a function that's 1 when A = B and C = D, using XOR, AND and NOT.

Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.

Explain why

Why do neighboring cells in a Karnaugh map differ in only one input, and why does that matter?

Practice

Keep practicing

5 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.