Section 2 · 10 min read
Combinational circuits
Adders, carry lookahead, subtractors, comparators, multiplexers, decoders, encoders, code converters, NAND/NOR realizations and hazards, with timing and gate-count problems in GATE style.
On this page
What a combinational circuit is
A combinational circuit has outputs that depend only on the current inputs. There is no memory and no feedback loop. Every such circuit is a set of Boolean functions, so the K-map tools from the previous topic apply directly. GATE questions here fall into four groups:
- Identify the function a given circuit computes (multiplexer or decoder with gates around it).
- Count components (how many 2-to-1 multiplexers, how many NAND gates).
- Timing (delay of ripple-carry versus carry-lookahead adders).
- Adder and subtractor behaviour, including flags.
Adders
Half adder and full adder
A half adder adds two bits: , .
A full adder adds , and carry-in :
is the majority function. The second form shows a full adder is two half adders plus an OR gate: the first half adder gives and , the second adds .
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
Ripple-carry adder (RCA)
An -bit RCA chains full adders; stage waits for the carry from stage . If one stage produces its carry after its carry-in is ready and its sum after its carry-in is ready, then with all operands applied at time 0:
The delay grows linearly with . Be careful about whether the question wants the last sum bit, the final carry, or both.
Carry-lookahead adder (CLA)
Define per bit a generate and a propagate signal:
Expanding the recurrence removes the chain:
With unlimited fan-in, every carry is a two-level AND-OR expression. The usual gate-delay count is: and in 1 delay, all carries 2 delays later, sums () 1 delay after that, so 4 gate delays regardless of . In practice fan-in is limited, so wide adders use 4-bit CLA blocks that either ripple carries between blocks or use a second level of lookahead.
is sometimes defined as instead of XOR. The carry equation still works with OR, but then the sum needs separately.
Subtraction
In 2's complement, . An adder-subtractor feeds each through an XOR gate with a control and connects to . adds; subtracts.
For unsigned subtraction with this circuit, final carry means no borrow (), and means a borrow occurred. Signed overflow is .
Comparators
A 1-bit equality test is XNOR. For -bit numbers, when every is 1. For magnitude, scan from the MSB:
Counting fact: for two -bit unsigned numbers, the number of input pairs with is .
Multiplexers
A -to-1 multiplexer (MUX) has select lines and outputs the data input whose index equals the select value. A 4-to-1 MUX with selects :
Implementing functions with a MUX
- A -to-1 MUX implements any -variable function: put the variables on the selects and the truth-table column on the data inputs (0s and 1s).
- A -to-1 MUX implements any -variable function if the last variable and its complement are available: for each select value, the data input is one of , , , .
- A single 2-to-1 MUX with constants can build NOT, AND and OR, so the 2-to-1 MUX is functionally complete. Without complemented inputs, it cannot build XOR in one unit.
MUX trees
To build an -to-1 MUX from -to-1 MUXes, divide repeatedly: at the first level, then , and so on down to 1. For 2-to-1 MUXes, an -to-1 tree needs units.
Demultiplexers
A 1-to- demultiplexer sends one input to the output selected by lines. It is a decoder whose enable is the data input.
Decoders and encoders
An -to- decoder activates exactly one output: output is minterm . Any function in sum-of-minterms form is a decoder plus an OR gate on the needed outputs (or a NOR or NAND on the others, for active-low parts).
Building larger decoders: a -to- decoder with enables can be expanded into an -to- decoder using a tree. For 6-to-64 from 3-to-8 units: one decoder takes the top 3 bits and enables one of 8 decoders that take the bottom 3 bits, total 9.
An encoder does the reverse: inputs, one of which is active, produce an -bit index. A priority encoder handles several active inputs by reporting the highest-priority one and adds a valid bit that is 0 when no input is active.
Code converters and parity
- Binary to Gray: , . In one line, .
- Gray to binary: , . Each binary bit is the XOR of all Gray bits from the MSB down to that position.
- BCD to excess-3: add . Excess-3 is self-complementing: the 9's complement of a digit is its bitwise inverse.
- Parity of bits needs two-input XOR gates (a chain or a tree; a tree has depth ).
NAND and NOR realizations
NAND and NOR are each universal. Useful minimum gate counts with two-input gates and only uncomplemented inputs:
| Function | Two-input NAND gates | Two-input NOR gates |
|---|---|---|
| NOT | 1 | 1 |
| AND | 2 | 3 |
| OR | 3 | 2 |
| XOR | 4 | 5 |
| XNOR | 5 | 4 |
| Half adder (sum and carry) | 5 | 5 |
A two-level AND-OR circuit becomes a two-level NAND-NAND circuit directly (same structure, every gate replaced by NAND). Likewise OR-AND becomes NOR-NOR.
Hazards
A static-1 hazard is a momentary 0 on an output that should stay 1 when one input changes. In a K-map it shows up as two adjacent 1-cells that are covered by different product terms with no single term covering both. The fix is to add the consensus term that bridges the two groups. Static-0 hazards are the dual for POS circuits. Hazards matter for asynchronous circuits; synchronous designs sample after the outputs settle.
Worked examples
Worked example 1: Function from a 4-to-1 MUX
Implement with a 4-to-1 MUX, using (MSB) and as selects.
Solution. For each , look at the two minterms that differ only in .
| Minterms | for , | Data input | |
|---|---|---|---|
| 00 | 0, 1 | 1, 0 | |
| 01 | 2, 3 | 1, 1 | |
| 10 | 4, 5 | 0, 1 | |
| 11 | 6, 7 | 0, 0 |
So , , , . Reverse problems (given the data inputs, find ) use the same table read backwards.
Worked example 2: RCA delay
A 16-bit RCA uses full adders with carry delay 2 ns and sum delay 3 ns (each measured from carry-in valid). When are all outputs valid?
Solution. Carry into stage 15 is valid at ns. Then is valid at 33 ns and at 32 ns. All outputs: 33 ns. Using the formula, .
Worked example 3: Block CLA timing
A 32-bit adder uses eight 4-bit CLA blocks, with the carry rippling from block to block. Within a block, and take 1 gate delay, each carry takes 2 gate delays after the block's , and carry-in are ready, and each sum takes 1 gate delay after its carry. Find the delay until all sums are valid.
Solution.
- All , are ready at time 1.
- Block 0 carry-out (): .
- Each later block adds 2 to its carry-out: block produces its carry-out at .
- Block 7 receives from block 6 at .
- Block 7 internal carries (and ) are ready at .
- Sums to are ready at .
All sums are valid after 18 gate delays. A plain 32-bit RCA with 2 gate delays per carry would take about 64.
Worked example 4: Half adder from NAND gates
What is the minimum number of two-input NAND gates for a half adder?
Solution. XOR needs 4 NAND gates: , , , . The carry is the complement of , which one more NAND (used as an inverter) produces. Total 5. Sharing between the sum and the carry is what keeps it at 5 instead of 6.
Worked example 5: Finding and fixing a hazard
. Find the hazard and fix it.
Solution. With , . When changes, one term turns off and the other turns on; if the inverter producing is slow, both terms can be 0 briefly, and glitches. The consensus term of and is . The hazard-free form is , which is logically the same function.
Common traps
- Confusing which select line is the MSB. Swapping and permutes the data inputs.
- Counting MUX trees as without recursing. For 64-to-1 from 4-to-1 the answer is .
- Forgetting the last sum delay in RCA problems, or adding it to the final carry instead of taking the maximum.
- Using as signed overflow. Signed overflow is .
- Treating the carry-out of as a borrow. A carry of 1 means no borrow.
- Assuming a 2-to-1 MUX cannot implement NOT. With and it can.
- In decoder-based designs, using active-high logic on an active-low decoder.
Quick revision
- Full adder: , .
- RCA delay: . CLA: about 4 gate delays with unlimited fan-in.
- , , .
- Subtract with ; signed overflow .
- -to-1 MUX plus the last variable and its complement gives any -variable function.
- -to-1 from 2-to-1 MUXes: units.
- Decoder output = minterm ; decoder plus OR gives any SOP.
- XOR: 4 NAND or 5 NOR. Half adder: 5 NAND.
- Gray: . Parity of bits: XOR gates.
- Static-1 hazard fix: add the consensus term.