Lecture 10&11
Lecture 10&11
Lecture 10&11
to Logic Design
Sequential Circuits
• Asst. Prof. Ahmet Can Erten
3
3
Latch
• Basic storage element
• A latch is a storage element that can store its
content forever.
• Latches are asynchronous circuits and do not
need a clock signal to operate.
• Hence they can not be used in synchronous
circuits directly.
• They are used to construct flip-flops.
4
4
Basic NOR SR-Latch
R
Q1
Q1next= (R + Q2present)’=R’ q2’
Q2next= (S + Q1present)’=S’ q1’
Q2
S
S R Q1 Q2
0 0 q1 q2 q1= q2’
0 1 0 1
1 0 1 0 Q1next=1= Q2next’
1 1 0 0 Forbidden
S = 1, R = 1 is forbidden as input pattern
https://electronics-course.com/sr-nor-latch
5
5
Time R S Q Q Comment
0 0 ? ? Stored state unknown S Q
0 1 1 0 “Set” Q to 1
0 0 1 0 Now Q “remembers” 1
1 0 0 1 “Reset” Q to 0 R Q’
0 0 0 1 Now Q “remembers” 0
1 1 0 0 Both go low SR-latch
0 0 ? ? Unstable!
https://www.youtube.com/watch?v=mo4Lq0DvJ68
https://everycircuit.com/circuit/4734276190601216/nor-sr-latch 6
6
Basic NAND SR-Latch (S’R’ Latch)
S
Q1
Q1next= (S Q2present)’=S’ + q2 ‘
Q2next= (R Q1present)’=R’+ q1‘
Q2
R
S R Q1 Q2
0 0 1 1 Forbidden
0 1 1 0
1 0 0 1
1 1 q1 q2 q1= q2’
S = 0, R = 0 is forbidden as input pattern
7
7
Time R S Q Q Comment
1 1 ? ? Stored state unknown
1 0 1 0 “Set” Q to 1
1 1 1 0 Now Q “remembers” 1
0 1 0 1 “Reset” Q to 0
1 1 0 1 Now Q “remembers” 0
0 0 1 1 Both go high
1 1 ? ? Unstable!
8
8
SR-Latch with Control Input
S
Q
C
Q= ((S C)’q’)’=SC + q
Q’= ((R C)’q)’=RC + q’
Q’
R
C S R Q Q’
0 X X q q’ No change
1 0 0 q q’ No change
1 0 1 0 1 Reset state
1 1 0 1 0 Set state
1 1 1 ? ? Undefined
9
9
Q’
R
Q(t) C S R Q(t+1) Comment • The table describes
0 0 X X 0 No change what happens after the
0 1 0 0 0 No change clock [at time (t+1)]
0 1 0 1 0 Clear Q based on:
0 1 1 0 1 Set Q – current inputs (S,R) and
0 1 1 1 ??? Indeterminate – current state Q(t).
1 1 0 0 1 No change
1 1 0 1 0 Clear Q
1 1 1 0 1 Set Q
1 1 1 1 ??? Indeterminate
10
10
Simulation of SR-Latch with Control
Input
D-Latch
• Because the undefined situation can cause stability
problems, SR latches are not used often.
• Solution: D-latch
D S
Q
R Q’
12
12
Simulation of D-Latch
D-Latch
C D Next state of Q
0 X No change
1 0 Q = 0; reset state
1 1 Q = 1; set state
S Q D Q
R Q’ C Q’
SR-latch D-latch
14
14
D Latch as a Storage Element
• When C = 1 D latch copies the input to the output.
• When C = 0 the information is kept unchanged.
• Latches are called level triggered.
– While C is in logic-1 level, the changes at the input cause
changes at the output.
• The states of the storage elements should change
synchronously.
• We need a storage element which changes the state
in a very short time spot.
• These storage elements are called edge triggered
and specially flip-flops.
15
15
clk’ Y=D
clk
clk
Q=Y=D
16
16
Rising Edge Triggered D Flip-Flop
Y
D D Q D Q Q
D latch D latch
(master) (slave)
clk’ C C
clk
clk
Y= D
clk’ Y does not change
Q=Y=D
clk
17
17
D Q
Falling edge triggered
D FF
D Flip-Flop
clk C
• Characteristic Equation
• Q(t+1) = D
19
19
JK Flip-Flop
J K Q(t+1) Next State
J Q
0 0 Q(t) No change
C
0 1 0 Reset
K 1 0 1 Set
1 1 Q’(t) Complement
Characteristic Table
• Characteristic Equation
Q(t+1) = JQ’(t) + K’Q(t)
20
20
T (Toggle) Flip-Flop
T Q(t+1) next state
0 Q(t) no change
T Q 1 Q’(t) Complement
C Characteristic Table
Characteristic Equation
• Q(t+1) = T Q(t) = TQ’(t) + T’Q(t)
T J Q
D Q
C T
C
K
21
21
• Aim:
– Finding the behaviour of the synchronous sequential
circuits
– “Behaviour”
• Inputs
• Outputs
• States of the flip-flops
– Finding the Boolean functions of the outputs and the
inputs of the flip-flops
– Output and state equations
• state table
• state diagram
22
22
Analysis of Synchronous Sequential
• Current State at Circuits
time t is stored in
an array of flip- Inputs Outputs
Combina-
flops. tional
• Next State at time Storage Logic
Elements
t+1 is a Boolean
Next
function of State
State
Current State and
Inputs. CLK
• Outputs at time t
are a Boolean
function of
Current State and
sometimes Inputs. 23
23
D2
D Q y2
C
y2 ’
z
clk 24
24
State and Output Equations
• D1 = ( y1 y2 ) x = Y1
• D 2 = x y 2’ = Y 2
• z = y 1 y2 x
Y1
D Q y1
x C
y1’
Y2
D Q y2
C
y2 ’
z
clk
25
25
00 0/0 11
0 0 0 0 0 0
0 0 1 0 1 0
0 1 0 0 0 0
0 1 1 1 0 0
1/0 0/0 0/0 1/0 1 0 0 0 0 0
1 0 1 1 1 0
1 1 0 0 0 0
1 1 1 0 0 1
01 10
1/0
27
27
J2
J
D Q y2
clk C
C
1 K
K2
31
31
State Diagram
0/0 1/1
Current Input Next Output
State State
00 0/0 11 y1 y2 x Y1 Y2 z
0 0 0 0 0 0
0 0 1 0 1 0
1/0 0/0 0/0 1/0
0 1 0 0 0 0
0 1 1 1 0 0
1 0 0 0 0 0
1 0 1 1 1 0
01 10 1 1 0 0 0 0
1 1 1 0 0 1
1/0
32
32
Analysis with T Flip-Flops
• Method is the same T1 = xy0
• Example T0 = x
T1
x T Q y1
C
T0
T
D Q y0
clk C
C
reset
33
33
• Characteristic equation
Y0 = T0 y0
Y1 = T1 y1
• Flip-flop Input equations
T1 = x y0
T0 = x
• State equations
Y0 = x y0
Y1 = x y0 y1
34
34
State Table & Diagram
• Y 0 = x y0
0 0
• Y1 = x y0 y1
Present Next 1
State 00/00 01/01
State Input Output
y1 y0 x Y1 Y0 y1 y0
0 0 0 0 0 0 0 1
1
0 0 1 0 1 0 0
0 1 0 0 1 0 1
0 1 1 1 0 0 1
1 0 0 1 0 1 0 11/11 10/10
1
1 0 1 1 1 1 0
1 1 0 1 1 1 1 0
0
1 1 1 0 0 1 1
35
35
Chapter 1 36
36
Moore and Mealy Example Tables
• Moore Model state table maps state to
outputs Present Next State Output
State x=0 x=1
0 0 1 0
1 0 2 0
2 0 2 1
• Mealy Model state table maps inputs and
state to outputs Present Next State Output
State x=0 x=1 x=0 x=1
0 0 1 0 0
1 0 1 0 1
Chapter 1 37
37
reset
Mealy Machine
• External inputs, x and y, are asynchronous
• Thus, outputs may have momentary (incorrect) values
• Inputs must be synchronized with clocks
• Outputs must be sampled only during clock edges.
38
38
Example: Moore Machines
y1
x T Q
z
C
T
D Q
y2
clk C
C
reset
39
39
State Diagrams
Label form:
• On circle with output included:
state/output
Moore type output depends only on state
• On directed arc with the output included:
input/output
Mealy type output depends on state and
input
40
Example State Diagrams for Moore and Mealy
Machines
• State Diagram for Mealy Model
x=1/z=0
x=0/z=0
0 1
x=0/z=0 x=1/z=1
x=0
• State Diagram for Moore Model
0/0
x=0
x=1 x=1
x=0
1/0 2/1
x=1 41
41
Design Process
1. Verbal description of desired operation
2. Draw the state diagram
3. Reduce the number of states if necessary and
possible: s = number of states
4. Determine the number of flip-flops: n log 2 s
5. State assignment: 00 0 ,00
n bits
1,00
n bits
10 ,
n bits
6. Obtaine the encoded state table
7. Choose the type of the flip-flops
8. Derive the simplified flip-flop input equations
9. Derive the simplified output equations
10.Draw the logic diagram
42
42
Example: Design of a Synchronous
Sequential Circuit
• Verbal description
– 1st Step: we want a circuit that detects three or
more consecutive 1’s in a string of bits.
• Input: string of bits of any length
• Output:
– “1” if the circuit detects such a pattern in the string
– “0” otherwise
43
43
1
Initial/0 “1“/0
0 0 1
0
“111”/1 “11”/0
1
1
44
44
Synthesis with D Flip-Flops 1/5
• 3rd Step: State 0
reduction 01
00 1
– Not possible
Initial/0 “1”/0
• 4th Step: Number of
0
flip-flops 0 1
0
– 4 states “111”/1 “11”/0
– ? flip-flop 1
11 10
• 5thStep: State
assignment 1
45
45
46
46
Synthesis with D Flip-Flops 3/5
• 7th Step: Choose the type of the flip-flops
– D type flip-flops
• 8th Step: : Derive the simplified flip-flop input
equations
– Boolean expressions for D1 and D2
y2x y2x
y1 00 01 11 10 y1 00 01 11 10
0 0 0 1 0 0 0 1 0 0
1 0 1 1 0 1 0 1 1 0
z = y1 y2
48
48
Synthesis with D Flip-Flops 5/5
• 10th Step: Draw the logic diagram
D1 = y1x + y2x D2 = y1x + y2’x z = y1y2
x D1 y1
D Q
C
R
z
D2 y2
D Q
C
R
clock reset
49
49
Number of states= 6
•6 shifting lights
•= lojik-1
•O= lojik-0
50
50
State Diagram & Table
Y = Jy’ + K’y
000 D0 D1 D2 010
001 J K Y
0 0 y
100 0 1 0
101 D5 D4 D3 011 1 0 1
1 1 Q’
51
53
0
1
y0
0
y2 y1
z1=y2y1y0+y2y1y0+y2y1y0+k(y2y1y0+y2y1y0)
54
54
Implementation of Output Equations
0
y0
0
0
y2 y 1
z0=y2y1y0+k(y2y1y0+y2y1y0)
55
55
Logic Diagram
J2 = y1y0’ K2 = y0 J1 = y2’y0 K1 = y0 J0 = 1 K1 =1
J Q J
D Q 1 J
D Q
C C
C C
C
K Q K 1 K
clk
Q
56
56