Combinational circuits: decoder, mux, full adder, PLA
Decoder, multiplexer, full adder and the ripple-carry adder, and building any function with a PLA. Everything you need for short-answer and tracing questions.
On the previous page you saw gates. On this page you will learn four building blocks made from them that are found in every processor: the decoder, the multiplexer, the full adder and the PLA. All of them are combinational circuits: the output depends only on the current inputs, and nothing is remembered. Circuits that remember (latch, register) are the topic of week 4.
On the midterm these structures bring short-answer questions: “if the input is 101, which output is 1?”, “how many selects does a 32-to-1 mux need?”, “the output of a full adder for 1+1+0?”, “write the carries of a 4-bit adder”. You will see all of them in the LC-3 too: register selection is done with a decoder, the ALU input with a mux, and addition with an adder.
Decoder
A decoder with inputs has outputs. It reads the input as a binary number and sets the output with that number to 1 and all the rest to 0.
2-to-4 decoder
A1 A0 | D0 D1 D2 D3
0 0 | 1 0 0 0
0 1 | 0 1 0 0
1 0 | 0 0 1 0
1 1 | 0 0 0 1
D0 = A1'A0' D1 = A1'A0 D2 = A1A0' D3 = A1A0
Each output is an AND gate and produces exactly one minterm. Therefore:
TIP · Decoder + OR = any function. If the minterm list of a function is , connect the D1, D2, D4, D7 outputs of a 3-to-8 decoder to an OR gate. Done.
Where is it used? To decode the opcode of an instruction (which instruction?), to decode an address in memory (which row?), to choose which register to write in a register file.
Multiplexer (mux)
A mux chooses one of data inputs and passes it to the output. select lines decide which one passes.
| Mux | Data inputs | Select lines |
|---|---|---|
| 2-to-1 | 2 | 1 |
| 4-to-1 | 4 | 2 |
| 8-to-1 | 8 | 3 |
| 32-to-1 | 32 | 5 |
The equation of a 2-to-1 mux:
A 4-to-1 mux is a 2-to-4 decoder with four AND gates and an OR gate: the decoder decodes the select, and the chosen AND gate passes its own data input.
4-to-1 mux, I0..I3 = 1, 0, 0, 1
S1 S0 = 11 → I3 → output 1
S1 S0 = 01 → I1 → output 0
Building a function with a mux
You can build a function of variables with a -to-1 mux. Connect the first variables to the select. Split the table into groups of two rows according to these variables. In each group F, in terms of the last variable (C), is one of these four things: 0, 1, C, C’.
Example: , select = AB.
| AB | rows | F | to input |
|---|---|---|---|
| 00 | m0 = 1, m1 = 0 | 1 when C = 0 | |
| 01 | m2 = 0, m3 = 1 | 1 when C = 1 | |
| 10 | m4 = 1, m5 = 1 | always 1 | |
| 11 | m6 = 0, m7 = 0 | always 0 |
Adders
Half adder
It adds two bits: , . It cannot take an incoming carry, so it is useful only at the rightmost bit.
Full adder
It adds three bits: A, B and the coming from the right. It has two outputs: the right bit of the sum, S, and the going to the left.
| A | B | Cin | Cout | S |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 0 | 0 | 1 |
| 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 | 1 |
| 1 | 0 | 1 | 1 | 0 |
| 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 1 |
Do not memorize the table, just add the three bits: 1+1+1 = 3 = 11 → Cout = 1, S = 1. The equations:
S is 1 when the number of 1s is odd (odd parity). Cout is 1 when at least two inputs are 1 (majority).
Ripple-carry adder
To add two -bit numbers, full adders are placed side by side. The of each is connected to the of the one on its left. The of the rightmost is 0. The carry moves from right to left, “rippling” along.
Worked example: 0111 + 0101
carry in: 1 1 1 0
0 1 1 1 (7)
+ 0 1 0 1 (5)
---------
1 1 0 0 (12), Cout = 0
bit0: 1+1+0 = 10 → S=0, c=1
bit1: 1+0+1 = 10 → S=0, c=1
bit2: 1+1+1 = 11 → S=1, c=1
bit3: 0+0+1 = 01 → S=1, c=0
This adder is the same circuit for unsigned and 2’s complement. In 2’s complement, because 0111 + 0101 = 1100 (two positives → negative), there is overflow; this is the hardware counterpart of the rule from week 2. For subtraction, every bit of B is NOTed and the rightmost is made 1: .
PLA (programmable logic array)
A PLA is a ready-made piece of hardware for the idea “build every function as SOP”. It has two layers:
- AND array: produces product terms from the inputs and their complements.
- OR array: connects the desired terms to the OR gate of each output.
The connections are “programmed”: which AND gate goes to which OR is chosen. A term can be shared by several outputs.
Example: , . The distinct minterms needed are 0, 3, 5, 6. 4 gates are enough in the AND array; the gate of m3 is connected to both OR gates.
A full PLA with 3 inputs produces at most 8 distinct minterms. With inputs, .
Combinational versus sequential
| Combinational | Sequential | |
|---|---|---|
| What does the output depend on? | only the current input | the input and the past (state) |
| Memory | none | yes |
| Examples | decoder, mux, adder, PLA | latch, flip-flop, register, FSM |
| Week | 3 | 4 |
Common mistakes
| Wrong idea | The truth |
|---|---|
| More than one output of a decoder can be 1 | Exactly one output is always 1 |
| A 3-to-8 decoder has 3 outputs | 3 inputs, 8 outputs |
| A 32-to-1 mux needs 32 selects | , so 5 selects |
| The mux select and the data input are the same thing | The select chooses, the data passes |
| Full adder 1+1+1: S=0, Cout=1 | 3 = 11 → S=1, Cout=1 |
| Cout = A⊕B⊕Cin | That is the formula of S; Cout is majority |
| A separate adder is needed for 2’s complement | The same circuit, only the overflow interpretation differs |
| In a PLA each output produces its own terms | Terms are shared |
Test yourself
Exam-style questions. Solve them on paper first, then reveal the answer.
A 3-to-8 decoder has input A2A1A0 = 110. Which output is 1?
Show answer
A decoder reads the input as a binary number and sets the output with that number to 1. 110 = 6 → D6 = 1, the other seven outputs are 0.
How many outputs does a decoder with 5 inputs have, and how many of them are 1 at the same time?
Show answer
A decoder with inputs has outputs: . Each input combination selects exactly one output.
Write the Boolean expression of output D2 of a 2-to-4 decoder with inputs A1 (MSB) and A0.
Show answer
D2 is 1 when the inputs are 10. The minterm of this single row: A1 = 1 → A1, A0 = 0 → A0'. So D2 = A1·A0'. Every decoder output is a minterm.
How many select lines does an 8-to-1 multiplexer need?
Show answer
To choose one of data inputs, select lines are needed. → 3.
An 8-to-1 mux has data inputs I0..I7 = 0, 1, 1, 0, 1, 0, 0, 1 and select S2S1S0 = 101. What is the output?
Show answer
101 = 5 → the output is I5. Count from zero in the list: I0=0, I1=1, I2=1, I3=0, I4=1, I5=0. The output is 0.
Write the output equation of a 2-to-1 multiplexer with data inputs A, B and select S (S = 0 selects A).
Show answer
When S = 0, the term S'A passes A and the term SB is 0. When S = 1, the opposite. If you see this expression in a circuit-reading question, say 'this is a mux'.
Give S and Cout of a full adder for A = 1, B = 0, Cin = 1.
Show answer
1 + 0 + 1 = 2 = 10 (binary). The right bit is S = 0, the left bit is Cout = 1. With the formulas: S = 1⊕0⊕1 = 0, Cout = AB + ACin + BCin = 0 + 1 + 0 = 1.
Write the sum S and carry-out of a full adder as Boolean expressions of A, B and Cin.
Show answer
S is 1 when an odd number of the inputs are 1: Σm(1,2,4,7) = A⊕B⊕Cin. Cout is 1 when at least two inputs are 1: Σm(3,5,6,7) = AB + ACin + BCin (majority).
A 4-bit ripple-carry adder computes 1011 + 0110 with C0 = 0. Give the 4-bit sum, the final carry-out, and the carry into each bit (bit 3 to bit 0).
Show answer
From the right: bit0: 1+0+0 = 1, c=0. bit1: 1+1+0 = 10 → 0, c=1. bit2: 0+1+1 = 10 → 0, c=1. bit3: 1+0+1 = 10 → 0, c=1.
The sum is 0001, with a 1 out. The carries into the bits (bit3..bit0) are 1 1 0 0. Check: 11 + 6 = 17 = 1 0001.
Using a 3-to-8 decoder and one OR gate, which decoder outputs must be ORed to implement F(A,B,C) = A ⊕ B ⊕ C?
Show answer
A⊕B⊕C is 1 on the rows with an odd number of 1s: 001, 010, 100, 111 → m1, m2, m4, m7. The decoder produces each minterm on a separate output; ORing these four outputs is enough.
Implement F(A,B,C) = Σm(1, 2, 6, 7) with a 4-to-1 mux whose select lines are A (MSB) and B. What goes on inputs I0, I1, I2, I3?
Show answer
Split the table into AB pairs and write F in terms of C in each pair.
AB = 00: m0 = 0, m1 = 1 → F = C. AB = 01: m2 = 1, m3 = 0 → F = C'. AB = 10: m4 = 0, m5 = 0 → F = 0. AB = 11: m6 = 1, m7 = 1 → F = 1.
A PLA implements F1 = Σm(0, 3) and F2 = Σm(3, 5, 6) of inputs A, B, C using minterms. How many AND gates are needed in the AND array?
Show answer
In a PLA the AND array produces the terms and the OR array connects them to the outputs. A term can be shared among several outputs. The distinct minterms needed: {0, 3, 5, 6}, that is 4 AND gates. m3 is connected to both F1 and F2.
Verification: The decoder, mux, full adder and ripple-carry adder were simulated with node; the functions built with a mux and a decoder were compared with the target table on all input combinations (verify/SEN2201/03.mjs).