Logic Gates, Gate Delay and Universal Gates
In questa pagina 5
A digital circuit is made of logic gates: each performs a logic operation on binary inputs and produces a binary output. They are built with transistors (CMOS Gates and Technology ParametersIn CMOS integrated circuits MOSFETs are modelled as switches: nMOS closed when the gate is 1, pMOS closed when the gate is 0. A static gate has a pull-up network (only pMOS, to Vdd) and a dual pull-down network (only nMOS, to ground): one is ON and the other OFF. NAND has series nMOS and parallel pMOS, NOR the opposite; an n-input gate has 2n transistors. Real-gate parameters: fan-in, fan-out, noise margin, propagation delay, power dissipation and cost.CMOS Gates and Technology Parameters →); at the logic level they are treated as functions. This note contrasts the ideal gate (instantaneous, perfect levels) with the real one (delay, finite fan-out, noise margins).
The three basic gates
Every logic function is described by a truth table listing the output for all input combinations; with inputs it has rows.
AND (): iff all inputs are 1. OR (): iff at least one input is 1. NOT (): inverter.
AND has precedence over OR: ; parentheses are advisable.
| AND | OR | NAND | NOR | XOR | XNOR | ||
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
Derived gates
- NAND NOT(AND): ; 0 only if all inputs are 1.
- NOR NOT(OR): ; 1 only if all inputs are 0.
- XOR (exclusive OR, ): 1 if the inputs are different.
- XNOR: complement of XOR; 1 if the inputs are equal.
In symbols a bubble at an output or input denotes negation. Gates may have more inputs: a 3-input AND is 1 only for (1 row of 8); a 6-input OR is 0 only for (1 row of 64). A multi-input XOR is 1 if the number of 1 inputs is odd (odd-parity function); its complement is 1 if the number of 1s is even. E.g. .
XOR properties: , , , ; commutative and associative. So complements a bit and leaves it unchanged: binary subtraction uses XORs for this (Binary Adders and SubtractorsHalf adder: S = X xor Y, C = XY. Full adder with carry in Z: S = X xor Y xor Z, C = XY + XZ + YZ = G + PZ with P = X xor Y, G = XY; two half adders and an OR. The n-bit ripple carry adder chains n full adders, so delay grows linearly with n. Adder-subtractor: XOR of each B bit with a control S, which is also the carry in, computes A+B or A+not B+1 = A-B. The 2-bit multiplier uses 4 ANDs and 2 half adders.Binary Adders and Subtractors →).
In VHDL the predefined operators are and, or, not, nand, nor, xor, xnor; parentheses are mandatory when mixing different operators (and and or have the same precedence).
Timing diagram and gate delay
A timing diagram has time on the axis and a binary signal on the axis. An ideal gate has zero delay.
A real gate has a propagation delay (gate delay): the time from a change of at least one input to the change reaching the output. It depends on technology, supply voltage, temperature and load (fan-out). In general the delay for an output () differs from that for () and depends on which input switches; for simplicity is often assumed.
Example. AND with . between and ; between and . The ideal output is 1 between and ; with the delay it rises at and falls at : same shape, shifted by .
| time (ns) | 0 | 10 | 20 | 22 | 40 | 42 | 60 |
|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | 1 | 0 | 0 | 0 | |
| 0 | 0 | 1 | 1 | 1 | 1 | 0 | |
| (ideal) | 0 | 0 | 1 | 1 | 0 | 0 | 0 |
| () | 0 | 0 | 0 | 1 | 1 | 0 | 0 |
(Each column is the value after the event at that instant.) In sequential circuits gate delays set the maximum operating frequency.
Universal gates
A set of gates is universal (complete) if every Boolean function can be built with it. is by definition; NAND alone is universal, and NOR alone too.
With NAND (an inverter is a NAND with tied inputs): NOT (1 NAND); AND (2 NAND); OR (3 NAND).
With NOR, dually: NOT = NOR with tied inputs; OR (2 NOR); AND (3 NOR).
XOR with four NAND: , , , .
| 0 | 0 | 1 | 1 | 1 | 0 |
| 0 | 1 | 1 | 1 | 0 | 1 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 0 |
. In CMOS NAND and NOR are more compact and faster than AND and OR, so circuits are usually built from NAND and NOR only (Combinational Design - Hierarchy and NAND-NOR MappingA combinational circuit has outputs depending only on the present inputs (no memory, no feedback); a sequential one also depends on history (state, memory, feedback). Design flow: specification, truth table, minimum-cost function, logic diagram, verification. With many inputs the hierarchical approach splits the system into reusable blocks (regularity). Basic blocks: one-variable functions, vectors, enabling. Technology mapping in CMOS: SOP to NAND-NAND, POS to NOR-NOR.Combinational Design - Hierarchy and NAND-NOR Mapping →).
Common mistakes
- Confusing XOR (1 if different) with OR (1 also when both are 1).
- Saying NAND cannot make a NOT: tie its inputs together.
- Reading the 3-input XOR as "exactly one 1" instead of odd parity.
- Ignoring the delay in a real timing diagram.
Versione ripasso
- Basic gates: AND (1 iff all inputs 1); OR (1 iff at least one 1); NOT . Truth table: rows.
- Derived: NAND (0 only if all 1); NOR (1 only if all 0); XOR (1 if different); XNOR (1 if equal). For : NAND 0, NOR 0, XOR 0, XNOR 1.
- Multi-input: 3-input AND is 1 only for ; 6-input OR is 0 only for . XOR = odd-parity function; XNOR = even parity. .
- XOR properties: , , , .
- Ideal vs real: ideal gate has zero delay; real gate has (with in general). AND with ns, in , in : ideal output 1 in , real in .
- Universal gates: NAND alone and NOR alone. NAND: NOT ; AND NAND+inverter; OR (3 NAND). NOR dually: OR in 2 NOR, AND in 3 NOR.
- XOR from 4 NAND: , , , .
- VHDL:
and or not nand nor xor xnor; parentheses needed when mixingand/or. - Mistakes: XOR vs OR; NAND "cannot invert"; XOR3 as "exactly one 1"; delay ignored.