Salta al contenuto
Note per Studenti Logic Gates, Gate Delay and Universal Gates Report

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 nn inputs it has 2n2^n rows.

AND (Z=X⋅Y=XYZ=X\cdot Y=XY): Z=1Z=1 iff all inputs are 1. OR (Z=X+YZ=X+Y): Z=1Z=1 iff at least one input is 1. NOT (Z=X‾Z=\overline X): inverter.

AND has precedence over OR: A+BC=A+(B⋅C)A+BC=A+(B\cdot C); parentheses are advisable.

XX YY 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): Z=XY‾Z=\overline{XY}; 0 only if all inputs are 1.
  • NOR == NOT(OR): Z=X+Y‾Z=\overline{X+Y}; 1 only if all inputs are 0.
  • XOR (exclusive OR, Z=X⊕YZ=X\oplus Y): 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 111111 (1 row of 8); a 6-input OR is 0 only for 000000000000 (1 row of 64). A multi-input XOR A⊕B⊕CA\oplus B\oplus C 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. 1⊕0⊕1=01\oplus0\oplus1=0.

XOR properties: X⊕0=XX\oplus0=X, X⊕1=X‾X\oplus1=\overline X, X⊕X=0X\oplus X=0, X⊕X‾=1X\oplus\overline X=1; commutative and associative. So X⊕1X\oplus1 complements a bit and X⊕0X\oplus0 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 xx axis and a binary signal on the yy axis. An ideal gate has zero delay.

A real gate has a propagation delay tGt_G (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 0→10\to1 (tpLHt_{pLH}) differs from that for 1→01\to0 (tpHLt_{pHL}) and depends on which input switches; for simplicity tpLH=tpHL=tGt_{pLH}=t_{pHL}=t_G is often assumed.

Example. AND with tG=2 nst_G=2\,\mathrm{ns}. A=1A=1 between 1010 and 40 ns40\,\mathrm{ns}; B=1B=1 between 2020 and 60 ns60\,\mathrm{ns}. The ideal output is 1 between 2020 and 40 ns40\,\mathrm{ns}; with the delay it rises at 22 ns22\,\mathrm{ns} and falls at 42 ns42\,\mathrm{ns}: same shape, shifted by tGt_G.

time (ns) 0 10 20 22 40 42 60
AA 0 1 1 1 0 0 0
BB 0 0 1 1 1 1 0
YY (ideal) 0 0 1 1 0 0 0
YY (tG=2t_G=2) 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. {AND,OR,NOT}\{AND,OR,NOT\} is by definition; NAND alone is universal, and NOR alone too.

With NAND (an inverter is a NAND with tied inputs): NOT X‾=X⋅X‾\overline X=\overline{X\cdot X} (1 NAND); AND XY=XY‾‾XY=\overline{\overline{XY}} (2 NAND); OR X+Y=X‾⋅Y‾‾X+Y=\overline{\overline X\cdot\overline Y} (3 NAND).

With NOR, dually: NOT = NOR with tied inputs; OR =X+Y‾‾=\overline{\overline{X+Y}} (2 NOR); AND XY=X‾+Y‾‾XY=\overline{\overline X+\overline Y} (3 NOR).

XOR with four NAND: n1=ab‾n_1=\overline{ab}, n2=a n1‾n_2=\overline{a\,n_1}, n3=b n1‾n_3=\overline{b\,n_1}, y=n2n3‾y=\overline{n_2n_3}.

aa bb n1n_1 n2n_2 n3n_3 yy
0 0 1 1 1 0
0 1 1 1 0 1
1 0 1 0 1 1
1 1 0 1 1 0

y=a⊕by=a\oplus b. 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 XYXY (1 iff all inputs 1); OR X+YX+Y (1 iff at least one 1); NOT X‾\overline X. Truth table: 2n2^n rows.
  • Derived: NAND XY‾\overline{XY} (0 only if all 1); NOR X+Y‾\overline{X+Y} (1 only if all 0); XOR (1 if different); XNOR (1 if equal). For X=Y=1X=Y=1: NAND 0, NOR 0, XOR 0, XNOR 1.
  • Multi-input: 3-input AND is 1 only for 111111; 6-input OR is 0 only for 000000000000. XOR = odd-parity function; XNOR = even parity. 1⊕0⊕1=01\oplus0\oplus1=0.
  • XOR properties: X⊕0=XX\oplus0=X, X⊕1=X‾X\oplus1=\overline X, X⊕X=0X\oplus X=0, X⊕X‾=1X\oplus\overline X=1.
  • Ideal vs real: ideal gate has zero delay; real gate has tGt_G (with tpLH≠tpHLt_{pLH}\ne t_{pHL} in general). AND with tG=2t_G=2 ns, A=1A=1 in [10,40][10,40], B=1B=1 in [20,60][20,60]: ideal output 1 in [20,40][20,40], real in [22,42][22,42].
  • Universal gates: NAND alone and NOR alone. NAND: NOT =XX‾=\overline{XX}; AND == NAND+inverter; OR =X‾ Y‾‾=\overline{\overline X\,\overline Y} (3 NAND). NOR dually: OR in 2 NOR, AND in 3 NOR.
  • XOR from 4 NAND: n1=ab‾n_1=\overline{ab}, n2=a n1‾n_2=\overline{a\,n_1}, n3=b n1‾n_3=\overline{b\,n_1}, y=n2n3‾y=\overline{n_2n_3}.
  • VHDL: and or not nand nor xor xnor; parentheses needed when mixing and/or.
  • Mistakes: XOR vs OR; NAND "cannot invert"; XOR3 as "exactly one 1"; delay ignored.

Teoria collegata