Module 3 · 12 min read · Free chapter
Logic gates, CMOS logic and combinational circuits
A static CMOS gate pairs an NMOS pull-down network with its dual PMOS pull-up, so it draws almost no static current. Dynamic power is αC_L V_DD² f. NAND and NOR are universal. A full adder gives S = A ⊕ B ⊕ C_in, carry lookahead speeds addition, and a 2ⁿ-to-1 multiplexer can implement any function of n variables.
Start from zero: circuits whose output depends only on now
A light switch on a staircase can be wired so that either switch turns the light on or off. The light depends only on the present positions of the two switches. A circuit like this, with no memory, is called combinational.
Combinational circuits are built from logic gates, each a small circuit that computes one Boolean operation. Today almost every gate is made in CMOS, using complementary pairs of n-channel and p-channel MOSFETs from the device chapters. The way those transistors are arranged sets the gate's speed, power and noise tolerance.
From gates we build larger blocks: adders that do arithmetic, multiplexers that select data, decoders that pick one line from many, and code converters. These blocks fill every processor, phone and controller.
This chapter covers gates, their CMOS implementation and the main combinational building blocks.
Why it matters. GATE EC asks a CMOS gate, an adder or a multiplexer function nearly every year, and JE papers test gate counts and truth tables.
Logic gates and universal gates
The basic gates are AND, OR and NOT. Combining them gives NAND (AND followed by NOT), NOR (OR followed by NOT), XOR and XNOR.
XOR gives 1 when its inputs differ, . With many inputs it gives 1 when an odd number of them are 1, so it is the parity function used in error detection. XNOR gives 1 when the inputs are equal, so it is an equality detector.
NAND and NOR are called universal gates, because any Boolean function can be built using only one of them. With NAND, tying both inputs together gives NOT, a NAND followed by NOT gives AND, and NANDs on inverted inputs give OR by De Morgan's theorem. NOR works the same way with the roles of AND and OR swapped.
Universality matters in practice. In CMOS, NAND and NOR are the natural gates and are smaller and faster than AND and OR, so designers build logic from them.
A two-level SOP expression maps directly to a NAND-NAND circuit, and a POS expression maps to NOR-NOR. You draw the AND-OR form, then replace every gate by NAND, and the bubbles cancel in pairs.
Worked example. An XOR needs four two-input NAND gates. With , the output is .
Why it matters. Questions ask the minimum number of NAND or NOR gates for a function, or the output of a gate network.
Static CMOS gates
The CMOS inverter has a PMOS from to the output and an NMOS from the output to ground, with both gates driven by the input. When the input is high, the NMOS is on and the PMOS off, so the output is pulled to 0. When the input is low, the reverse happens and the output is pulled to .
In either steady state one transistor is off, so no current flows from supply to ground. This is why CMOS uses almost no static power and why it replaced older logic families.
Every static CMOS gate has the same structure. A pull-down network of NMOS transistors connects the output to ground when the function should be 0. A pull-up network of PMOS transistors connects it to when the function should be 1. The two networks are duals: NMOS in series become PMOS in parallel, and the other way round.
A two-input NAND has two NMOS in series, since the output falls only when both inputs are 1, and two PMOS in parallel. A two-input NOR has two NMOS in parallel and two PMOS in series. Because holes are slower than electrons, series PMOS are slow, so NAND is usually preferred over NOR in CMOS.
CMOS gates are naturally inverting. An AND gate is a NAND followed by an inverter, so it needs six transistors against four for the NAND.
The inverter's voltage transfer curve is very steep. Its switching threshold is near when the PMOS is made wider by about , two to three times, to match the NMOS drive. The noise margins measure how much noise an input can take:
CMOS power is mostly dynamic, spent charging and discharging the load capacitance:
Here α is the fraction of clock cycles in which the node switches. Because power rises with , lowering the supply is the most effective way to save energy, which is why chip supplies fell from 5 V to below 1 V. Delay rises roughly as , so lower supplies also mean slower gates.
Worked example. A node with fF switches with α = 0.1 at 1 GHz and V. Then µW.
Why it matters. Drawing a CMOS gate for a given function and finding dynamic power are standard GATE questions.
Arithmetic circuits: adders and subtractors
A half adder adds two bits and gives a sum and a carry:
A full adder also takes a carry in from the previous column:
It can be built from two half adders and an OR gate. can also be written as the majority function .
An -bit ripple-carry adder chains full adders, each carry feeding the next. It is small, but the carry may have to travel through every stage, so the worst-case delay grows in proportion to . For a 64-bit adder this is far too slow.
The carry-lookahead adder removes the wait. For each bit it forms a generate term , which means this column makes a carry by itself, and a propagate term , which means it passes an incoming carry on. Then:
Expanding this gives every carry directly from the inputs and , in two gate levels. Wide adders use lookahead in groups and trees, giving delay that grows only as .
Subtraction uses the same adder. To find , invert every bit of B and set , which adds the 2's complement of B. An XOR on each B input, controlled by a single add-subtract line, gives an adder-subtractor.
Worked example. With and , ripple addition gives sum 0001 with a carry out of 1, that is . In 4 bits this shows as 0001 plus a carry.
Why it matters. Adder equations, delay comparisons and the adder-subtractor are frequent GATE questions.
Multiplexers, demultiplexers and decoders
A multiplexer (MUX) is a data selector. A -to-1 MUX has data inputs, select lines and one output, and the select code chooses which input reaches the output. For a 4-to-1 MUX:
Each term is a minterm of the select lines ANDed with one data input. So a MUX can implement any function: connect the variables to the select lines and put the truth-table output values, 0 or 1, on the data inputs. A -to-1 MUX can even implement any function of variables, by using the last variable, its complement, 0 or 1 as the data inputs.
A decoder does the opposite of selecting. An -to- decoder has inputs and outputs, and exactly one output is active for each input code. Each output is one minterm, so a decoder with an OR gate on the chosen outputs implements any function in sum-of-minterms form. Decoders also select memory chips and devices by address.
A demultiplexer (DEMUX) sends one data input to one of outputs chosen by the select lines. It is simply a decoder whose enable input carries the data.
MUXes and DEMUXes together let many signals share one wire by taking turns, which is time-division multiplexing, the basis of telephone exchanges and digital buses.
Worked example. Implement with a 4-to-1 MUX using A and B as selects. For AB = 00, F is 1 only at C = 1, so . For 01, F = 1 at C = 0, so . For 10, F = 0, so , and for 11, F = 1, so .
Why it matters. "What function does this MUX implement" is one of the most common GATE digital questions.
Encoders, comparators, hazards and logic families
An encoder does the reverse of a decoder: it outputs the binary code of whichever input is active. If several inputs can be active at once, a priority encoder outputs the code of the highest-priority one and a valid flag. Keyboards and interrupt controllers use priority encoders.
A magnitude comparator compares two binary numbers and gives three outputs, , and . Equality uses XNOR on each bit pair, and the greater-than test checks bits from the MSB down. Code converters, such as binary to Gray or BCD to seven-segment, are designed like any combinational circuit, from a truth table and K-maps.
Real gates have delay, and different paths have different delays. When one input changes, the output may briefly take the wrong value, a glitch.
If the output should stay at 1 but dips to 0, that is a static-1 hazard. On a K-map it occurs where two adjacent 1s are covered by different groups. Adding the consensus term, a group covering both, removes it. Hazards matter when the output drives a clock or an asynchronous input.
Several logic families have been used. TTL used bipolar transistors and a 5 V supply. ECL kept transistors out of saturation and was the fastest, but drew high power.
CMOS has the lowest static power and the widest noise margin, and dominates today. Families are compared by propagation delay, power and their product, the speed-power product, and by fan-out, the number of inputs one output can drive.
Why it matters. Hazard identification, priority encoder outputs and family comparisons appear in GATE, ESE and JE papers.
Descriptive lens: how this topic is asked in written papers
Written papers ask this topic in four ways:
- Draw a static CMOS gate for a given function, or the NAND-only form of a circuit.
- Explain why CMOS has low static power, why NAND is preferred to NOR, or why ripple-carry is slow.
- Design a full adder, a carry-lookahead stage, a comparator or a code converter from its truth table.
- Implement a function with a multiplexer or a decoder.
Practice questions (our own, not previous-year questions).
- Draw the transistor-level static CMOS circuit for and explain how the pull-up and pull-down networks are derived. (15 marks)
- Derive the carry-lookahead expressions for a 4-bit adder and compare its delay with a ripple-carry adder. (10 marks)
- Implement using an 8-to-1 multiplexer. (10 marks)
Answer plan for question 1.
- Note that F is inverted, so the pull-down network realises directly.
- Draw NMOS A in series with the parallel pair NMOS B and NMOS C, from output to ground.
- Form the dual pull-up: PMOS A in parallel with the series pair PMOS B and PMOS C, from to output.
- Check one input case each way, such as A = 1, B = 1 giving output 0, and A = 0 giving output 1.
- State the count, six transistors, and that only one network conducts in any steady state.
Quick revision
- NAND and NOR are universal, XOR is parity and XNOR is equality.
- SOP maps to NAND-NAND and POS maps to NOR-NOR.
- Static CMOS has an NMOS pull-down and its dual PMOS pull-up, with series in one meaning parallel in the other.
- CMOS NAND has series NMOS and is preferred to NOR, which has series PMOS.
- Noise margins are and , and dynamic power is .
- The full adder gives and .
- Ripple-carry delay goes as n, while lookahead uses and goes as log n.
- A -to-1 MUX implements any function of n, or n + 1, variables, and a decoder plus OR gives any function.
- A static hazard is removed by adding the consensus group.