Logic 1
Logic 1
Number of Lectures: 10
Crank Angle
λ Sensor
Throttle Injectors
Logic 0: 0 V Æ 0.8 V
Logic 1: 2.0 V Æ 5.0 V
1 1 0 1 0
Natural Natural
Decimal binary Decimal binary
0 0000 8 1000
1 0001 9 1001
2 0010 10 1010
3 0011 11 1011
4 0100 12 1100
5 0101 13 1101
6 0110 14 1110
7 0111 15 1111
2. Complement (0 Æ 1, 1 Æ 0)
3. Add 1
Example: -5
Natural binary 000101 5
Complement 111010
Add 1 111011 -5
10110011
Hamming distance = 2
10011011
8 0 0 1 1 1
4 1 0 0 0 0
2 1 1 1 1 0
1 1 1 1 0 0
Indicated position: 7 3 11 10 8
Gray Gray
Decimal code Decimal code
0 0000 8 1100
1 0001 9 1101
2 0011 10 1111
3 0010 11 1110
4 0110 12 1010
5 0111 13 1011
6 0101 14 1001
7 0100 15 1000
Position = 1101 = 9
This bit is called the parity bit and is chosen to make the
total number of 1s even (even parity) or odd (odd parity)
1 bit 2 bits
Even Even
Decimal Parity Decimal Parity
0 00000 8 11000
1 10001 9 01001
2 10010 10 01010
3 00011 11 11011
4 10100 12 01100
5 00101 13 11101
6 00110 14 11110
7 10111 15 01111
Odd Odd
Decimal Parity Decimal Parity
0 10000 8 01000
1 00001 9 11001
2 00010 10 11010
3 10011 11 01011
4 00100 12 11100
5 10101 13 01101
6 10110 14 01110
7 00111 15 11111
1 bit 3 bits
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 28
Error-Correcting Codes
Error-correcting code with minimum Hamming distance of 5:
1 bit 5 bits
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 29
Error-Correcting Codes
NOT A or A or A′ A A
0 1
1 0
A OR B or A+B A B A+B
0 0 0
0 1 1
1 0 1
1 1 1
A ⊕ B ≡ A.B + A.B
A.B ≡ B.A
Commutative laws:
A+B ≡ B+ A
A+0 ≡ A A.0 ≡ 0
A + 1≡ 1 A.1 ≡ A
A+ A≡ A A.A ≡ A
A+ A≡1 A.A ≡ 0
A B A+B A+B A B A. B
0 0 0 1 1 1 1
0 1 1 0 1 0 0
1 0 1 0 0 1 0
1 1 1 0 0 0 0
F = ( A + B).( A + B + D ).( A + B + C )
F = A.B.C F = A+ B+C
F = A.B.(C + D )
A A
B A+ B+C B A+ B+C
C C
OR NOR
Through-hole
Surface-
mount
A.(B + C + B.C )
B + C + B.C
1-variable K-Map:
A=0 1
F = A
A=1 0
3-variable K-map:
C=0 C=1
B=0 0 1
A=0
F = C.( A + B) 0 0
B=1
0 1
A=1
B=0 0 1
4-variable K-map:
C=0 C=1
D=0 D=1 D=0
B=0 0 0 0 0
A=0
F = A + B.C.D 0 0 1 0
B=1
1 1 1 1
A=1
B=0 1 1 1 1
1 1 0 0 0 0 0 0 1 0 0 1
0 0 0 0 1 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 1 0 0 1
F = B .C F = A .B .D F = B .D
C=0 C=1
D=0 D=1 D=0
B=0 1 1 1 1 Groups of 16: none
A=0 Groups of 8: A
1 1 1 1
B=1 Groups of 4: none
1 0 0 0
A=1 Groups of 2: B .C .D
B=0 0 0 0 0 Groups of 1: none
A
A
B F
C
B.C.D
D
C=0 C=1
D=0 D=1 D=0
B=0 1 1 1 1
A=0
1 1 1 1
B=1
1 0 0 0
A=1
B=0 0 0 0 0
F = ( A + B).( A + D ).( A + C )
A A+B
B A+C
C F
D A+D
A B C D F A B C D F
0 0 0 0 0 1 0 0 0 0
0 0 0 1 0 1 0 0 1 0
0 0 1 0 0 1 0 1 0 X
0 0 1 1 1 1 0 1 1 X
0 1 0 0 1 1 1 0 0 1
0 1 0 1 1 1 1 0 1 1
0 1 1 0 1 1 1 1 0 1
0 1 1 1 X 1 1 1 1 1
B B
F
C
D C.D
B B+C
C
F
D B+D
1
( A.1) = A
NOT A
AND A
( A.B) = A.B
B
A
OR ( A.B) = A + B
B
0
( A + 0) = A
NOT A
A
AND ( A + B) = A.B
B
A
OR ( A + B) = A + B
B
F = ( A .B ).(C .D .E ). ...
C
B.C.D
D
R=0 R=1
Q=0 X 0 Unused Sunday
P=0
1 1 Monday Tuesday
Q=1
1 0 Friday Saturday
P=1
Q=0 1 1 Wednesday Thursday
P P
P.Q
F
Q P.Q
Q
R
A A.B.C
C B.C.D
D A.B.D
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 75
Implementation in NOR
1. Obtain the function in simplest product-of-sums form:
F = ( A + B).(B + C + D ). ...
F = ( A + B).(B + C + D ). ...
3. Use DeMorgan’s theorem on lower inversion:
F = ( A + B) + (B + C + D ) + ...
4. The function can now be implemented using only NOR
gates
A ( A + B)
(A + C)
B
F
C
D ( A + D)
P
(P + Q )
P F
Q Q
(P + Q + R )
R
R
B=A
C=A+B
Static hazard:
Dynamic hazard:
Output gate
Input gates
Input gate 1
Input gate 2
Output
No Hazard
Input gate 1
Input gate 2
Output
No Hazard
Input gate 1
Input gate 2
Output
ABCD ABCD
0101 0111
Q1 = ( A.C ) 0 1
Q 2 = (B.C.D ) 1 0
Q3 = ( A.B.C ) 1 1
ABCD ABCD
0101 0111
Q1 = ( A.C ) 0 1
Q 2 = (B.C.D ) 1 0
Q3 = ( A.B.C ) 1 1
Q 4 = ( A.B.D ) 0 0
B
C
F
C=0 C=1
D=0 D=1 D=0
B=0 1 1 0 0
A=0
1 1 0 0
B=1
1 1 1 1
A=1
B=0 0 1 1 0
F = A.C + A.B.D
A static hazard may occur if the inputs change from A=1,
B=0, C=1, D=0 to A=0, B=0, C=1, D=0
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 97
Example of a Static Hazard
F = ( A.C ) + ( A.B.D )
F = ( A + C ).( A + B + D )
= ( A + C ).( A + B + D )
= ( A + C ) + ( A + B + D)
= Q1 + Q 2
ABCD ABCD
1010 0010
Q1 = ( A + C ) 0 1
Q2 = ( A + B + D) 1 0
ABCD ABCD
1010 0010
Q1 = ( A + C ) 0 1
Q2 = ( A + B + D) 1 0
Q 3 = (B + C + D ) 1 1
Static hazard has been eliminated
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 100
Design Example
Implement the function: F = A.C + B.C + A.B.C
in hazard-free form using NOR gates
C=0 C=1
B=0 1 0
A=0
1 0
B=1
1 1
A=1
B=0 0 0
C=0 C=1
B=0 1 0
A=0
1 0
B=1
1 1
A=1
B=0 0 0
F
B
D =C
E = A.C
F = B.D = B.C
G = E + F = A.C + B.C
H = D.G = C.( A.C + B.C ) = B.C
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 104
Dynamic Hazards
D =C
Let A=1 E = A.C
B=1 F = B.D = B.C
G = E + F = A.C + B.C
H = D.G = C.( A.C + B.C ) = B.C
C
D
E
F
G
H
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 105
Exclusive-OR Gates
A
B A⊕B
Identities:
A⊕B ≡ B⊕ A
( A ⊕ B) ⊕ C ≡ A ⊕ ( B ⊕ C )
A
B A⊕B⊕C
C
A
B A⊕B⊕C⊕D
C
D
a a
b b
c c
d d
e e
f f
g g
common common
For any input combination one, and only one, output line is
set to logical 1
A Y0
For example, a B Y1
3-to-8 line decoder C Y2
Y3
Y4
74HCT138 Y5
Y6
Y7
C B A Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
0 0 0 1 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0 0
0 1 0 0 0 1 0 0 0 0 0
0 1 1 0 0 0 1 0 0 0 0
1 0 0 0 0 0 0 1 0 0 0
1 0 1 0 0 0 0 0 1 0 0
1 1 0 0 0 0 0 0 0 1 0
1 1 1 0 0 0 0 0 0 0 1
Y0 A
For example, an Y1 B
8-to-3 line encoder Y2 C
Y3
Y4
74HCT148 Y5
Y6
Y7
Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 C B A
0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0
X 1 0 0 0 0 0 0 0 0 1
X X 1 0 0 0 0 0 0 1 0
X X X 1 0 0 0 0 0 1 1
X X X X 1 0 0 0 1 0 0
X X X X X 1 0 0 1 0 1
X X X X X X 1 0 1 1 0
X X X X X X X 1 1 1 1
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 117
Multiplexers
A multiplexer (MUX) is a combinational logic device that
selects binary information from one of several input lines
Data inputs D0 W
D1
D2
For example, an D3
8-to-1 line MUX D4
D5
D6
74HCT152 D7
C B A
Select inputs
C B A W
0 0 0 D0
0 0 1 D1
0 1 0 D2
0 1 1 D3
1 0 0 D4
1 0 1 D5
1 1 0 D6
1 1 1 D7
Program-
mable AND
matrix
Outputs: W X Y Z
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 121
HDL Definition File
Name EX1;
Partno EX0000;
Date 6/10/98;
Rev 01;
Designer J.B.Grimbleby;
Company University of Reading;
Assembly None;
Location None;
Device p16l8;
Boolean Operator Symbols:
/* input pins */
PIN 1 = A; ! Æ NOT
PIN 2 =
PIN 3 =
B;
C;
& Æ AND
PIN 4 = D; # Æ OR
/* output pins */
PIN 19 = F;
/* equations */
F = !A & (B # C # !B & !C) # A & B & !(C # D);
Symbol Table:
Pin Variable Pterms Max Min
Pol Name Ext Pin Type Used Pterms Level
--- -------- --- --- ---- ------ ------ -----
A 1 V - - -
B 2 V - - -
C 3 V - - -
D 4 V - - -
F 19 V 3 7 1
A=B
B=A
R
Q = (R + P )
P = (S + Q)
S
R = 0, S = 0 : Q = (0 + P ) = P P = (0 + Q) = Q
R = 1, S = 0 : Q = (1 + P ) = 1 = 0 P = (0 + Q) = 0 = 1
R = 0, S = 1: P = (1 + Q) = 1 = 0 Q = (0 + P ) = 0 = 1
S R Q
0 0 Q-
1 0 1
0 1 0
1 1 X
S
Q = (S.P )
P = (R.Q)
R
R = 1, S = 1: Q = (1.P ) = P P = (1.Q) = Q
R = 1, S = 0 : Q = (0.P ) = 0 = 1 P = (1.Q) = 1 = 0
R = 0, S = 1: P = (0.Q) = 0 = 1 Q = (1.P ) = 1 = 0
S R Q
1 1 Q-
0 1 1
1 0 0
0 0 X
Q
Assume break S
before make
R
R
S
Q
le R
Q
S
D
D Q le Q
Q 0 Q-
1 D
le
Note that the control terminal is level-sensitive: as long as
le=1 the latch remains transparent (the output Q follows the
input D)
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 133
Edge-Triggered Flip-Flops
Level-sensitive flip-flops are not suitable for use in clocked
sequential systems such as counters
D Q
Q
clk
The output Q changes only on a 0-to-1 transition of clk:
Q+ = D −
where Q+ is the output value after the transition and D- is the
data input value immediately before the transition
Synchronous systems:
The clocks of all flip-flops are connected together to a
common source
Asynchronous systems:
The clocks of the flip-flops are derived from different
sources (usually the outputs of other flip-flops)
D Q Output
Q
Input
Input
Q
D =Q
D Q Q1 D Q Q2 D Q Q3
Q Q Q
Input
Input
Q1
Q2
Q3
Input
Q1
Q2
Q3
Delays in flip-flops
Q1: 1 0 0 0
Q2: 1 1 0 0
Q3: 0 0 0 1
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 139
Synchronous Counters
In synchronous counters the clock terminals of all the flip-
flops are connected to the input
Q1 Q2
D2
D Q D Q
Q Q
Input
Input
Q1
Q2
D2
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 140
Synchronous Counters
Synchronous counters can easily be made to count in any
modulo: Q1 Q2
D2
D Q D Q
Q Q
Input
Input
Q1
Q2
D2
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 141
Shift Registers
Q1 Q2 Q3 Q4
Input D Q D Q D Q D Q
Q Q Q Q
Clock
Clock
Input
Q1
Q2
Q3
Q4
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 142
Serial-to-Parallel Conversion
Serial data can be clocked into the shift register until the
complete data word is stored
D Q D Q D Q
Q Q Q
Input
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 144
Johnson-Code Counters
Input
Q1
Q2
Q3
Q3
D Q D Q D Q D Q
Q Q Q Q
Input
Input
Q1
Q2
Q3
Q4
D1
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 146
Design of Synchronous Counters
Counter is required to count modulo-m: then n flip-flops will
be required where 2n ≥ m
Q1 Q2 Q3
Q1 D Q Q1 D Q Q1 D Q
Q2 Q2 Q2
Q3 Q Q3 Q Q3 Q
Input
B=0 B=1
A=0 1 1 X X
A=1 0 0 1 0
B=0 B=1 B=0 B=1
A=0 1 X A=0 1 X
A=1 0 1 A=1 0 0
DA DB
Thus: DA = A + B DB = A
A B
D Q D Q
Q Q
Input
State A B C
1 0 1 0
2 1 0 0
3 0 0 1
4 0 1 1
5 1 1 0
1 0 1 0 etc.
DA = A.B DB = C + A.B DC = B
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 154
Design Example
DA = A.B DB = C + A.B DC = B
Unwanted states:
DA = A.B DB = C . ( A.B) DC = B
DA = A.B DB = C . ( A.B) DC = B
D Q D Q D Q C
Q A Q Q
Input
State A B C
1 0 1 0
2 1 0 0
3 0 0 1
4 0 1 1
5 1 1 0
1 0 1 0 etc.
C=0 C=1
B=0 X 0 X 1 X 1
A=0
1 1 0 1 0 0
B=1
0 X 1 X 0 X
A=1
B=0 0 X 0 X 1 X
DA = A + B DB = A.B + A.C DC = B
Duality:
DA = A.B DB = ( A + B).( A + C ) DC = B
DA = A.B DB = ( A + B).( A + C ) DC = B
Unwanted states:
DA = A + B DB = ( A + B) + ( A + C ) DC = B
DA = A + B DB = ( A + B) + ( A + C ) DC = B
A B
D Q D Q D Q C
Q Q Q
Input
J Q
K Q
clk
The output Q changes only on a 0-to-1 transition of clk
1 J Q Output
K Q
Input
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 162
Edge-Triggered JK Flip-Flops
Asynchronous natural binary counter:
Q1 Q2 Q3
1 1 1
J Q J Q J Q
K Q K Q K Q
Input
Input
Q1
Q2
Q3
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 163
Edge-Triggered JK Flip-Flops
Shift register:
Q1 Q2 Q3 Q4
Input J Q J Q J Q J Q
K Q K Q K Q K Q
Clock
OFF: IB = 0 IC = 0
ON: IB » IC/β VBE = 0.6V VCE < 0.2V
C=0 C=1
B=0 1 0 F = A.B.C
A=0
0 0
B=1 = A+B+C
0 0
A=1 NOR gate
B=0 0 0
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 170
Complementary Metal-Oxide
Semiconductor (CMOS) Logic
CMOS was introduced after TTL and is the technology used
in nearly all LSI devices
Q2 (p-channel)
VIN VOUT
Q1 (n-channel)
VIN Q1 Q2 VOUT
0.0 Æ 1.5V OFF ON 5.0V
3.5 Æ 5.0V ON OFF 0.0V
B Q4
F
Q2 Q1
A B Q1 Q2 Q3 Q4 F
lo lo OFF OFF ON ON hi
lo hi OFF ON ON OFF lo
hi lo ON OFF OFF ON lo
hi hi ON ON OFF OFF lo
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 175
CMOS NAND Gate
VDD = 5.0V
Q3 Q4
F
A Q1
B Q2
A B Q1 Q2 Q3 Q4 F
lo lo OFF OFF ON ON hi
lo hi OFF ON ON OFF hi
hi lo ON OFF OFF ON hi
hi hi ON ON OFF OFF lo
J. B. Grimbleby School of Systems Engineering: Electronic Engineering Slide 176
Emitter-Coupled Logic (ECL)
© J. B. Grimbleby, February 07