1-IntroductionSequentialCircuits (1) (1)
1-IntroductionSequentialCircuits (1) (1)
Grading :
2 Midterm exams, Lab, Final Exam
3
Schedule
❖ Latches
❖ Flip-Flops
❖ Combinational Circuit
Outputs = F(Inputs)
Combinational
Function of Inputs only Inputs Outputs
Circuit
NO internal memory
❖ Sequential Circuit
Outputs is a function of Inputs and internal Memory
There is an internal memory that stores the state of the circuit
Time is very important: memory changes with time
Introduction to Sequential Circuits
A Sequential circuit consists of:
Next State also depends on the Inputs and the Present State
Examples of sequential devices
• Many real-life devices are sequential in nature:
– Combination locks open if you enter numbers in the right order.
– Elevators move up or down and open or close depending on the buttons
that are pressed on different floors and in the elevator itself.
– Traffic lights may switch from red to green
• Most importantly for us, computers are sequential! For example, key presses
and mouse clicks mean different things depending on which program is running
and the state of that program.
7
Two Types of Sequential Circuits
1. Synchronous Sequential Circuit
Uses a clock signal as an additional input
Asynchronous
Inputs Outputs
Combinational
Circuit
Memory
Elements
Synchronous
Inputs Outputs
Combinational
Circuit
Flip-flops
Clock
9
Synchronous Sequential Circuits
Inputs Outputs
Combinational
Logic
Present Next
State Memory State
Elements
Clock
❖ Synchronous sequential circuits use a clock signal
❖ The clock signal is an input to the memory elements
❖ The clock determines when the memory should be updated
❖ The present state = output value of memory (stored)
❖ The next state = input value to memory (not stored yet)
The Clock
Positive Negative
Clock cycle Clock cycle Pulse Pulse
Time
Time
❖ Latches
❖ Flip-Flops
15
The basic idea of storage
• How can a circuit “remember” anything, when it’s just a bunch of gates that
produce outputs according to the inputs?
• The basic idea is to make a loop, so the circuit outputs are also inputs.
• Here is one initial attempt, shown with two equivalent layouts:
16
A really confusing circuit
• Let’s use NOR gates instead of inverters. The SR latch below has two inputs S
and R, which will let us control the outputs Q and Q’.
• Here Q and Q’ feed back into the circuit. They’re not only outputs, they’re
also inputs!
• To figure out how Q and Q’ change, we have to look at not only the inputs S
and R, but also the current values of Q and Q’:
Qnext = (R + Q’current)’
Q’next = (S + Qcurrent)’
• Let’s see how different input values for S and R affect this thing.
17
Storing a value: SR = 00
• What if S = 0 and R = 0?
• The equations on the right reduce to:
18
Setting the latch: SR = 10
• What if S = 1 and R = 0?
• Since S = 1, Q’next is 0, regardless of Qcurrent:
Q’next = (1 + Qcurrent)’ = 0
19
Latch delays
• Timing diagrams are especially useful in
understanding how sequential circuits work.
• Here is a diagram which shows an example of
how our latch outputs change with inputs SR=10.
Q’
20
Resetting the latch: SR = 01
• What if S = 0 and R = 1?
• Since R = 1, Qnext is 0, regardless of Qcurrent:
Qnext = (1 + Q’current)’ = 0
21
SR latches are memories!
• This little table shows that our latch S R Q
provides everything we need in a 0 0 No change
memory: we can set it, reset it, and 0 1 0 (reset)
remember the current value. 1 0 1 (set)
22
SR latches are sequential!
• Notice that for inputs SR = 00, the S R Q
next value of Q could be either 0 or 1, 0 0 No change
depending on the current value of Q.
0 1 0 (reset)
• So the same inputs can yield different 1 0 1 (set)
outputs, depending on whether the
latch was previously set or reset.
• This is very different from the
combinational circuits that we’ve seen
so far, where the same inputs always
yield the same outputs.
Inputs Current Next
S R Q Q’ Q Q’
0 0 0 1 0 1
0 0 1 0 1 0
0 1 0 1 0 1
0 1 1 0 0 1
1 0 0 1 1 0
1 0 1 0 1 0
23
What about SR = 11?
• Both Qnext and Q’next will become 0.
• This contradicts the assumption that Q and Qnext = (R + Q’current)’
Q’ are always complements. Q’next = (S + Qcurrent)’
• Another problem is what happens if we then
make S = 0 and R = 0 together. 0 0
Qnext = (0 + 0)’ = 1
Q’next = (0 + 0)’ = 1
0 0
• But these new values go back into the NOR
gates, and in the next step we get:
Qnext = (0 + 1)’ = 0
Q’next = (0 + 1)’ = 0
0 1
• The circuit enters an infinite loop, where Q
and Q’ cycle between 0 and 1 forever.
• This is actually the worst case, but the
1
moral is don’t ever set SR=11! 0
24
S’R’ latch
• There are several varieties of latches.
• You can use NAND instead of NOR gates to get a S’R’ latch.
S’ R’ Q
1 1 No change
1 0 0 (reset)
0 1 1 (set)
0 0 Avoid!
• This is just like an SR latch, but with inverted inputs, as you can see from the
table.
• You can derive this table by writing equations for the outputs in terms of the
inputs and the current state, just as we did for the SR latch.
25
An SR latch with a control input
• Here is an SR latch with a control input C.
C S R S’ R’ Q
0 x x 1 1 No change
1 0 0 1 1 No change
1 0 1 1 0 0 (reset)
1 1 0 0 1 1 (set)
1 1 1 0 0 Avoid!
26
Summary S-R Latch
• SR Latch
S R Q0 Q Q’
0 0 0 0 1 Q = Q0
R 0 0
Q
S Q
0 1
Initial Value
27
Summary S-R Latch
• SR Latch
S R Q0 Q Q’
0 0 0 0 1 Q = Q0
0 0 1 1 0 Q = Q0
R 0 1
Q
S Q
0 0
28
Summary S-R Latch
• SR Latch
S R Q0 Q Q’
0 0 0 0 1
Q = Q0
0 0 1 1 0
0 1 0 0 1 Q=0
R 1 0
Q
S Q
0 1
29
Summary S-R Latch
• SR Latch
S R Q0 Q Q’
0 0 0 0 1
Q = Q0
0 0 1 1 0
0 1 0 0 1 Q=0
R 1 1
Q
0 1 1 0 1 Q=0
S Q
0 0
30
Summary S-R Latch
• SR Latch
S R Q0 Q Q’
0 0 0 0 1
Q = Q0
0 0 1 1 0
0 1 0 0 1
R 0
Q=0
0 0 1 1 0 1
Q 1 0 0 1 0 Q=1
S Q
1 1
31
Summary S-R Latch
• SR Latch
S R Q0 Q Q’
0 0 0 0 1
Q = Q0
0 0 1 1 0
0 1 0 0 1
R 0
Q=0
1 0 1 1 0 1
Q 1 0 0 1 0 Q=1
1 0 1 1 0 Q=1
S Q
1 0
32
Summary S-R Latch
• SR Latch
S R Q0 Q Q’
0 0 0 0 1
Q = Q0
0 0 1 1 0
0 1 0 0 1
R 1
Q=0
0 0 1 1 0 1
Q 1 0 0 1 0
Q=1
1 0 1 1 0
1 1 0 0 0 Q = Q’
S Q
1 10
33
Summary S-R Latch
• SR Latch
S R Q0 Q Q’
0 0 0 0 1
Q = Q0
0 0 1 1 0
0 1 0 0 1
R 1
Q=0
10 0 1 1 0 1
Q 1 0 0 1 0
Q=1
1 0 1 1 0
1 1 0 0 0 Q = Q’
1 1 1 0 0 Q = Q’
S Q
1 0
34
Summary S-R Latch
• SR Latch
S R Q
R Q Q0 No change
0 0
0 1 0 Reset
1 0 1 Set
S Q 1 1 Q=Q’=0 Invalid
S S R Q
Q
0 0 Q=Q’=1 Invalid
0 1 1 Set
1 0 0 Reset
R Q
1 1 Q0 No change
35
Summary S-R Latch
• SR Latch
S R Q
R Q Q0 No change
0 0
0 1 0 Reset
1 0 1 Set
S Q 1 1 Q=Q’=0 Invalid
S S’ R’ Q
Q Invalid
0 0 Q=Q’=1
0 1 1 Set
Q 1 0 0 Reset
R Q0 No change
1 1
36
Summary S-R Latch
R R S S
Q Q
C C
S Q R Q
S R
C S R Q
0 x x Q0 No change
1 0 0 Q0 No change
1 0 1 0 Reset
1 1 0 1 Set
1 1 1 Q=Q’ Invalid 37
SR Latch Operation
Set Operation Store Operation
R (Reset) 0 1 R (Reset) 0 1
Q Q
0 Q 0 Q
S (Set) 1 S (Set) 0
R (Reset) 1 0 R (Reset) 0 0
Q Q
1 Q 1 Q
S (Set) 0 S (Set) 0
SR Latch Invalid Operation
Invalid Operation Race Condition
0 Q Q
S (Set) 1 S (Set) 1→0
0→1
S 1 0 0 0 1 1 0 0 0 1
R 0 0 1 0 0 1 0 1 0 0
Q 1 1 0 0 1 0 0 0 1
Q 0 0 1 1 0 0 1 1 0
Time
Gated SR Latch (with Nor)
with Clock Enable
R (Reset) CR
Q
C (Clock)
CS Q
S (Set)
❖ No undefined state
❖ Inverter can be removed Q
❖ When 𝐶 = 1, 𝑅 = 𝑆ҧ = 𝐷
ഥ C R
Timing of a D-Latch with Clock Enable
D S
Q
D-Latch with
Clock Input
Q
C R
Q
Time
Graphic Symbols for Latches
𝑆 𝑄 𝑆ҧ 𝑄 𝐷 𝑄
𝑆𝑅 𝑆𝑅 𝐷
𝐶 𝐶
𝐿𝑎𝑡𝑐ℎ 𝐿𝑎𝑡𝑐ℎ 𝐿𝑎𝑡𝑐ℎ
𝑅 𝑄 𝑅ത 𝑄 𝐶 𝑄
Indicates that logic-0 is used (not logic-1) to set (or reset) the
latch (as in the NAND latch implementation)
Problem with Latches
❖ A latch is level-sensitive (sensitive to the level of the clock)
❖ Latches
❖ Flip-Flops
Time
Edge-Triggered D Flip-Flop
❖ Built using two latches in a master-slave configuration
❖ A master latch (D-type) receives external inputs
❖ A slave latch (SR-type) receives inputs from the master latch
❖ Only one latch is enabled at any given time
When Clk=0, the master is enabled and the D input is latched (slave disabled)
When Clk=1, the slave is enabled to generate the outputs (master is disabled)
𝑄𝑚
Outputs
Master Slave
𝑄𝑚 change when
Clk
Clk changes
from 0 to 1
Negative Edge-Triggered D Flip-Flop
❖ Similar to positive edge-triggered flip-flop
❖ The first inverter at the Master C input is removed
❖ Only one latch is enabled at any given time
When Clk=1, the master is enabled and the D input is latched (slave disabled)
When Clk=0, the slave is enabled to generate the outputs (master is disabled)
𝑄𝑚
Outputs
Master Slave change when
𝑄𝑚
Clk Clk changes
from 1 to 0
D Flip-Flop Timing Diagram
❖ The diagram shows the timing of a positive-edge D Flip-Flop
❖ Notice the slight delay in the output Q after the rising edge
Clk
Qm
Time
Graphic Symbols for Flip-Flops
𝐷𝑎𝑡𝑎 𝐷 𝑄 𝐷𝑎𝑡𝑎 𝐷 𝑄
Flip Flip
Flop Flop
𝐶𝑙𝑘 𝑄 𝐶𝑙𝑘 𝑄
Master Slave
𝑄1
𝑆 𝑆 𝑄
SR Latch
SR Latch
𝐽
𝐶𝑙𝑘 𝐶 𝐶
𝐾 𝑄1
𝑅 𝑅 𝑄
T Flip-Flop
❖ The T (Toggle) flip-flop has inputs: T and Clk
❖ Next state is defined in terms of the current state and the inputs
❖ Hold Time (Th): Time duration for which the data input must
not be changed after the clock transition occurs.
Rising
Edge Clock
Ts Th