3.3.8 · D4Combinational Circuits

Exercises — Decoders (2 - 4, 3 - 8)

3,351 words15 min readBack to topic

Everything here builds on the parent note Decoders (2:4, 3:8). If a term feels unfamiliar, that note defines it from zero.

Reminder of the machinery we will reuse (every symbol earned before use):

One picture to carry the whole page. Before any exercise, look at how a binary address turns into one hot line. The arrows under each bit show its weight (what that bit is worth); you add only the weights above a , and the resulting number is the single output that lights up (shown in coral).

Figure — Decoders (2 - 4, 3 - 8)

Level 1 — Recognition

Goal: can you read a decoder and state which line fires?

L1-Q1. A 2:4 decoder receives . Which output is high, and what are the other three?

L1-Q2. A 3:8 decoder receives . Which single output is high?

L1-Q3. True or false: for a working 2:4 decoder it is possible for both and to be at the same time. Justify in one sentence.

Recall Solutions — Level 1

Use the weight picture at the top of the page (s02) as your worksheet — write the weights under the bits, then add only the columns showing a .

L1-Q1. Compute the decimal value of the address: . So the hot line is , and . Check with the minterm formula: . ✓

L1-Q2. Value . So ; every other output is . Check: , and . ✓

L1-Q3. False. By definition the outputs are mutually-exclusive minterms — each is for exactly one distinct address, and one address cannot be two things at once. So exactly one output is hot, never two together. (Once we meet the enable pin in Level 2 we'll see there is also a "chip off" state where zero outputs are hot — but still never two.)


Level 2 — Application

Goal: use the formulas and the enable input correctly.

L2-Q1. Write the full Boolean expression for of a 3:8 decoder in true/complement form.

L2-Q2. A 2:4 decoder has an active-high enable . Its outputs are . If and , what is ? What if with the same address?

L2-Q3. A commercial 74138-style chip has active-low outputs: the selected line goes to , all others stay . (The real 74138 also has three enable pins that must all be in their active state to switch the chip on; assume here the chip is enabled so we can focus on the outputs.) For address , write out all eight output values .

Recall Solutions — Level 2

L2-Q1. in binary is , i.e. . The picture below shows the rule that turns those bit values into the expression: a bit that is enters the AND in true form; a bit that is enters complemented (barred). Read the three cells left to right.

Figure — Decoders (2 - 4, 3 - 8)

A minterm ANDs all inputs, using true form where the bit is and complement form where the bit is : Sanity: this equals only when , which is exactly . ✓

L2-Q2. .

  • With : . In fact every output is — the chip is asleep. See figure s04: the enable pin acts as a master switch AND-ed into every output, so when it's the whole output bus goes low regardless of the address.
  • With : , and it's the only hot line (address ).
Figure — Decoders (2 - 4, 3 - 8)

L2-Q3. Address , so line is "selected". Active-low means selected , unselected . The schematic below shows why the pattern is a single in a field of s: each active-low output has an inverting bubble, so the one minterm that is internally comes out as , while the seven internal s come out as . (A real 74138 reaches this "enabled" state only when all three of its enable pins are held in their active states; we assume that here.)

The single zero marks the chosen output.


Level 3 — Analysis

Goal: reason about a function across all its input rows.

L3-Q1. A 3:8 decoder drives an OR gate. The OR is fed by outputs , , and . Write the function this circuit computes, as a sum of minterms and as a decimal set.

L3-Q2. For that same , fill in the truth-table column: for each of the 8 input rows, is or ? State how many rows give and why.

L3-Q3. A 2:4 decoder with active-high enable is used as a router. Data bit is wired to the enable pin; the address selects the destination. If and address , what does each output read? If and address ?

Recall Solutions — Level 3

L3-Q1. OR-ing decoder lines is literally OR-ing minterms (this is SOP). Recall the shorthand defined at the top: it just names which lines to feed the OR. As a decimal set: .

L3-Q2. on exactly the rows and everywhere else:

dec
0 000 1
1 001 0
2 010 0
3 011 1
4 100 0
5 101 0
6 110 1
7 111 0

Three rows give — one per minterm ORed in, because each decoder line is hot for exactly one address, and those addresses () are distinct.

L3-Q3. With enable-as-data (a demultiplexer): each output is . Address selects line .

  • : , the rest . The data "1" is delivered to output 2.
  • : , and every other output is too — the data "0" is delivered to output 2 (all lines read 0, but the selected one is faithfully carrying ). Either way, output 2 mirrors and the others stay silent. That is routing.

Level 4 — Synthesis

Goal: build/design circuits, not just read them.

L4-Q1. Implement using one 3:8 decoder plus a single OR gate. Give the wiring (which variable to which input) and the OR-gate connections.

L4-Q2. Build a 3:8 decoder from two 2:4 decoders that each have an active-high enable. Specify: what feeds the address inputs of each, and what drives each enable, so that the top handles lines and the bottom handles . Prove no two decoders can be on simultaneously.

L4-Q3. You only have decoders with active-low outputs (selected line ). You still want the SOP function . What single gate do you place after the two selected lines to recover on inputs 1 and 4? (Hint: think about what NAND does to two active-low signals.)

Recall Solutions — Level 4

L4-Q1. Wire the most significant function variable to the most significant decoder input: , , . The decoder now outputs all eight minterms. OR together exactly the ones in the set. The figure shows the decoder box with only the three listed lines () tapped into one OR gate — the physical meaning of :

Check the minterms: (since ), (), (). The 3-input OR gives . ✓

L4-Q2. (The hierarchical decoder trick from the parent note.) The figure below carries the whole argument — read it alongside these three wiring rules, and use the callout box in it to see the mutual-exclusion proof at a glance:

  • Feed (the two low bits) to the address inputs of both 2:4 decoders (mint arrows).

  • Top decoder: enable (through the NOT gate). Its outputs become .

  • Bottom decoder: enable (direct). Its outputs become .

Proof of mutual exclusion (the white box in the figure): and . Their AND is for every value of (a bit and its complement are never both ). So the two enables are never together — exactly one decoder is awake, and it fires exactly one of its four lines. One-hot over all eight is preserved. ∎

L4-Q3. With active-low outputs, the selected line reads . For input , line ; for input , line ; otherwise both are . A NAND gate outputs whenever any input is :

  • Input 1: . ✓
  • Input 4: . ✓
  • Any other input: both are . ✓ Why NAND is exactly right here (the De Morgan reason). Let the active-high meaning of each line be = "input is 1" and = "input is 4". Active-low wiring means the physical wire carries the complement: and . We want (fire on input 1 OR input 4). Now apply De Morgan's law (, read backwards): which is exactly a NAND of the two physical (active-low) wires. So NAND-of-active-low is OR-of-active-high — that is why one NAND replaces the OR when your outputs are active-low.

Level 5 — Mastery

Goal: prove, generalise, and handle degenerate cases.

Recall from the top of the page: is the number of address inputs, and an decoder therefore has one-hot outputs. Keep that meaning of in mind for all three problems below.

L5-Q1. Prove that for an enabled decoder (i.e. a decoder with address inputs), the OR of all outputs equals for every input. What does this tell you about the outputs as a set?

L5-Q2. How many 2:4 decoders (each with one active-high enable) do you need to build a 4:16 decoder, and what drives the enables? Generalise: to build an -input decoder from -input decoders, how many do you need and what selects among them?

L5-Q3. Degenerate case. Consider a "-input decoder", , so (one output, zero address bits). What does it do? Then consider a -input decoder (, a decoder). Write its two output equations and say what familiar gate each output is.

Recall Solutions — Level 5

L5-Q1. Each output is the minterm . The sum (OR) of all minterms of variables is the constant — this is a standard identity: every possible input row is covered by exactly one minterm, so for any input, precisely one and the OR is . Formally, . What it tells us: the outputs are exhaustive and mutually exclusive — they partition all input space. Exactly one is hot at all times (when enabled). This is the mathematical statement of "one-hot".

L5-Q2. A 4:16 has outputs; a 2:4 supplies outputs, so you need lower decoders for the outputs, plus one extra 2:4 acting as the selector that decodes the two high address bits into four enable signals. So 5 decoders total (4 workers + 1 chooser).

  • Low bits go to all four worker decoders.
  • Selector decodes ; its four one-hot outputs become the four enables — exactly one worker awake at a time.

Generalisation: to go from -input to -input you double the outputs, so you need two -input decoders, with the single new top bit selecting between them: enable one with , the other with . (This is the recursive doubling behind memory address decoding.)

L5-Q3.

  • : no address bits, output. Nothing to choose — the single output is always the selected one. With an enable it becomes : it just passes the enable through. A decoder with zero address bits is a plain wire/enable.
  • decoder (), one input , two outputs: is an inverter (NOT gate) of ; is just itself (a wire/buffer). So the smallest real decoder is "a bit and its complement" — the atom every larger decoder is built from.

Connections

  • Minterms and Maxterms — every exercise here rests on "output = minterm".
  • Sum of Products (SOP) — L3/L4 turn decoders into any SOP with one gate.
  • Demultiplexers — L3-Q3 and the enable-as-data idea.
  • Multiplexers — the complementary block; contrast with routing.
  • Encoders — the inverse; useful sanity check on direction.
  • Memory Address Decoding — L5 expansion is exactly how RAM rows/chips are selected.
  • 7-Segment Display Driver — a downstream user of decoded outputs.

Solution Map

L1 read the address

L2 apply formulas and enable

L3 analyse across all rows

L4 build circuits

L5 prove and generalise

hierarchical decoder