Logic Gates
Logic Gates
Transistors as Switches
¡ VBB voltage controls whether the transistor
conducts in a common base configuration.
A B C
0 0 0
0 1 0
1 0 0
1 1 1
OR
¡ Current flows if either switch is closed
¤ Logic notation A + B = C
A B C
0 0 0
0 1 1
1 0 1
1 1 1
Properties of AND and OR
¡ Commutation
¤A+B=B+A
¤AB=BA
Same as
Same as
Properties of AND and OR
¡ Associative Property
¤ A + (B + C) = (A + B) + C
¤ A (B C) = (A B) C
Properties of AND and OR
¡ Distributive Property
¤ A + B C = (A + B) (A + C)
¤ A+BC
A B C Q
0 0 0 0
0 0 1 0
0 1 0 0
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 1
Distributive Property
¡ (A + B) (A + C)
A B C Q
0 0 0 0
0 0 1 0
0 1 0 0
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 1
Binary Addition
A B S C(arry)
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
A Q
0 1
Logic: QA
1 0
Exclusive OR (XOR)
A B AB AB
Accumulating our results: Binary addition is the
result of XOR plus AND
Half Adder
Called a half adder because we haven’t allowed for any carry bit
on input. In elementary addition of numbers, we always need to
allow for a carry from one column to the next.
18
25
3 (plus a carry)
4
Full Adder
INPUTS OUTPUTS
A B CIN COUT S
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
Full Adder Circuit
Chaining the Full Adder
Possible to use the same
scheme for subtraction by
noting that
A – B = A + (-B)
Binary Counting
Use 1 for ON
Use 0 for OFF
= 00101011
Binary Counter
Counting in Binary
1 1 11 1011 21 10101
2 10 12 1100 22 10110
3 11 13 1101 23 10111
4 100 14 1110 24 11000
5 101 15 1111 25 11001
6 110 16 10000 26 11010
7 111 17 10001 27 11011
8 1000 18 10010 28 11100
9 1001 19 10011 29 11101
10 1010 20 10100 30 11110
NAND (NOT AND)
A B Q
Q AB 0 0 1
0 1 1
1 0 1
1 1 0
NOR (NOT OR)
A B Q
QAB 0 0 1
0 1 0
1 0 0
1 1 0
Exclusive NOR
A B Q
Q AB
0 0 1
0 1 0
Equality Detector
1 0 0
1 1 1
Summary
Summary for all 2-input gates
0 0 0 1 0 1 0 1
0 1 0 1 1 0 1 0
1 0 0 1 1 0 1 0
1 1 1 0 1 0 0 1
Number Systems
¡ Decimal (base 10) {0 1 2 3 4 5 6 7 8 9}
¤ Place value gives a logarithmic representation
of the number
¤ Ex. 4378 means
۞ 4 X 103 = 4000
۞ 3 X 102 = 300
۞ 7 X 101 = 70
۞ 8 X 100 = 8
¤ The place also gives the exponent of the base
Example
¡ 432,600
4 3 2 6 0 0
105 100
104 101
103 102
Powers of ten:
100 = 1 102 = 100 104 = 10000
101 = 10 103 = 1000 105 = 100000
Binary (base 2) {0 1}
Binary Decimal
0 0
1 1
10 2
11 3
100 4
101 5
110 6
111 7
1000 8
1001 9
1010 10
Example
1 1 0 1 1 0 0 1
27 20
26 21
25 22
24 23
Decimal Equivalent
¡ 1101 1001 Notice how powers of two
1 X 27 = 128 stand out:
+ 1 X 26 = 64 20 = 1
+ 0 X 25 = 0
21 = 10
+ 1 X 24 = 16
+ 1 X 23 = 8 22 = 100
+ 0 X 22 = 0 23 = 1000
+ 0 X 21 = 0
+ 1 X 20 = 1
217
Decimal to Binary Conversion
¡ Ex. 575
¤ Find the largest power of two less than the number
۞ 29 = 512
¤ Subtract that power of two from the number
۞ 575 – 512 = 63
¤ Repeat steps 1 and 2 for the new result until you reach zero.
۞ 25 = 32 63 – 32 = 31
۞ 24 = 16 31 – 16 = 15
۞ 23 = 8 15 – 8 = 7
۞ 22 = 4 7–4=3
۞ 21 = 2 3–2=1
۞ 20 = 1 1–1=0
¤ Construct the number
۞ 1000111111
Another Example
¡ 144
¤ 27 = 128 144 – 128 = 16
¤ 24 = 16 16 – 16 = 0
¡ Result 10010000
Hexadecimal (base 16)
¡ {0 1 2 3 4 5 6 7 8 9 A B C D E F}
¡ Assignments Dec Hex Dec Hex
0 0 8 8
1 1 9 9
2 2 10 A
3 3 11 B
4 4 12 C
5 5 13 D
6 6 14 E
7 7 15 F
Example
3B6E
163 160
162 161
3 X 163 = 12288
11 X 162 = 2816
6 X 161 = 96
15214
14 X 160 = 14
Hexadecimal is Convenient for
Binary Conversion
Binary Hex Binary Hex
0 0 1001 29
1 1 1010 A
10 2 1011 B
11 3 1100 C
100 4 1101 D
101 5 1110 E
110 6 1111 F
111 7 1 0000 10
1000 8 Nibble
Binary to Hex Conversion
¡ Group binary number by fours (nibbles)
¤ 1101 1001 0110
¡ Convert each nibble into hex equivalent
¤ 1101 1001 0110
D 9 6
Decimal to Hex Conversion
¡ Ex. 284
¤ 162 = 256 284 – 256 = 28
¤ 161 = 16 28 - 16 = 12 (Hex C)
¤ Result 1 1 C
Another Example with an Extension
¡ 1054
¤ 162 = 256
۞But we have several multiples of 256 in 1054
– 1054/256 = 4.12 take integer part
– This eliminates 4*256 = 1024
۞ 1054 – 1024 = 30
¤ 161 = 16 30 – 16 = 14 (Hex E)
¤ Result 4 1 E