Dr. Ameria Eldosoky Discrete mathematics
Basic Logic Gates
Basic Logic Gates and Basic Digital Design NOT, AND, and OR Gates NAND and NOR Gates DeMorgan’s Theorem Exclusive-OR (XOR) Gate Multiple-input Gates
Introduction to Basic Logic Gates Hardware consists of a few simple building blocks These are called logic gates AND, OR, NOT, … NAND, NOR, XOR, … Logic gates are built using transistors NOT gate can be implemented by a single transistor AND gate requires 3 transistors Transistors are the fundamental devices Pentium consists of 3 million transistors Compaq Alpha consists of 9 million transistors Now we can build chips with more than 100 million transistors
Basic Gates Simple gates AND OR NOT Functionality can be expressed by a truth table A truth table lists output for each possible input combination
AND Gate AND X Y Z 0 0 0 0 1 0 1 0 0 1 1 1 X Z Y Z = X + Y
OR Gate OR X Y Z 0 0 0 0 1 1 1 0 1 1 1 1 X Z Y Z = X | Y
NOT X ~X ~~X = X X ~X ~~X 0 1 0 1 0 1
NOT Gate -- Inverter X Y 1 1
Additional useful gates NAND NOR XOR NAND = AND + NOT NOR = OR + NOT XOR implements exclusive-OR function NAND and NOR gates require only 2 transistors AND and OR need 3 transistors!
NAND Gate NAND X Y Z 0 0 1 0 1 1 X 1 0 1 1 1 0 Z Y Z = ~(X & Y) 0 0 1 0 1 1 1 0 1 1 1 0 X Z Y Z = ~(X & Y) nand(Z,X,Y)
NAND Gate NOT-AND X Y W Z 0 0 0 1 0 1 0 1 X 1 0 0 1 1 1 1 0 W Z Y 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 X W Z Y W = X & Y Z = ~W = ~(X & Y)
NOR Gate NOR X Y Z 0 0 1 0 1 0 X 1 0 0 Z 1 1 0 Y Z = ~(X | Y) 0 0 1 0 1 0 1 0 0 1 1 0 X Z Y Z = ~(X | Y) nor(Z,X,Y)
NOR Gate NOT-OR X Y W Z 0 0 0 1 0 1 1 0 1 0 1 0 1 1 1 0 X W Z Y 0 0 0 1 0 1 1 0 1 0 1 0 1 1 1 0 X W Z Y W = X | Y Z = ~W = ~(X | Y)
NAND Gate X X Z Z = Y Y Z = ~(X & Y) Z = ~X | ~Y X Y W Z 0 0 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 X Y ~X ~Y Z 0 0 1 1 1 0 1 1 0 1 1 0 0 1 1 1 1 0 0 0
De Morgan’s Theorem-1 ~(X & Y) = ~X | ~Y Change & to | and | to & NOT all variables Change & to | and | to & NOT the result
NOR Gate X X Z Z Y Y Z = ~(X | Y) Z = ~X & ~Y X Y Z X Y ~X ~Y Z 0 0 1 0 0 1 0 1 0 1 0 0 1 1 0 X Y ~X ~Y Z 0 0 1 1 1 0 1 1 0 0 1 0 0 1 0 1 1 0 0 0
De Morgan’s Theorem-2 ~(X | Y) = ~X & ~Y Change & to | and | to & NOT all variables Change & to | and | to & NOT the result
De Morgan’s Theorem NOT all variables Change & to | and | to & NOT the result -------------------------------------------- ~X | ~Y = ~(~~X & ~~Y) = ~(X & Y) ~(X & Y) = ~~(~X | ~Y) = ~X | ~Y ~X & !Y = ~(~~X | ~~Y) = ~(X | Y) ~(X | Y) = ~~(~X & ~Y) = ~X & ~Y
Exclusive-OR Gate XOR X Y Z X Z 0 0 0 Y 0 1 1 1 0 1 1 1 0 Z = X ^ Y 0 0 0 Y 0 1 1 Z = X ^ Y xor(Z,X,Y) 1 0 1 1 1 0
Exclusive-NOR Gate XNOR X Y Z X Z 0 0 1 Y 0 1 0 1 0 0 1 1 1 Z = X ~^ Y 0 0 1 Y 0 1 0 Z = ~(X ^ Y) Z = X ~^ Y xnor(Z,X,Y) 1 0 0 1 1 1