2.sequential Circuits
2.sequential Circuits
2.sequential Circuits
Sequential circuits
Sequential circuits
equal open/closed
Circuits with feedback
X1 Z1
X2 Z2
switching
network
Xn Zn
Simplest circuits with feedback
"1"
"stored value"
"0"
S' Q
Q
S'
R' Q'
R'
Timing behavior
R Q
S Q'
R
S
Q
\Q
State behavior of R-S latch
Q Q'
1 1
Theoretical R-S latch behavior
SR=10
SR=00 SR=00
SR=01 SR=10
Q Q' SR=01 Q Q'
0 1 1 0
SR=01 SR=10
SR=11
State diagram
States: possible values Q Q'
SR=11 0 0 SR=11
Transitions: changes
based on inputs SR=00
SR=00 SR=11
SR=01 SR=10
Q Q'
SR=11 0 0 SR=11
SR=00 SR=00
R-S latch analysis
Break feedback path
R Q Q(t)
S Q(t+)
S Q' R
S R Q(t) Q(t+)
0 0 0 0 S
hold
0 0 1 1
0 0 X 1
0 1 0 0 reset
0 1 1 0 Q(t) 1 0 X 1
1 0 0 1 set
R
1 0 1 1
1 1 0 X not allowed characteristic equation
1 1 1 X Q(t+) = S + R Q(t)
Gated R-S latch
S'
R'
enable'
Q
Q'
Clocks
period
Clocks(Cont.)
R' R
Q stable changing stable changing stable
R' and S'
clock'
Q' clock
S' S
Cascading latches
S S Q S Q
clock
Master-Slave structure
Break flow by alternating clocks (like an air-lock)
Use positive clock to latch inputs into one R-S latch
Use negative clock to change outputs with another R-S latch
View pair as one basic unit
master-slave flip-flop
twice as much logic
output changes a few gate delays after the falling edge of clock
but does not affect any cascaded flip-flops
S S Q S Q
P
clock
The 1s catching problem
D S Q S Q Q
P
clock
10 gates
Edge-triggered flip-flops
More efficient solution: only 6 gates
sensitive to inputs only near edge of clock signal
(not while high)
D D
holds D' when negative edge-triggered D
clock goes low flip-flop (D-FF)
0
4-5 gate delays
R
Q must respect setup and hold time
constraints to successfully
clock=1 capture input
Q
S
0
holds D when characteristic equation
clock goes low
D Q(t+1) = D
D
Edge-triggered flip-flops(Cont.)
Step-by-step analysis
D D D D
D D
R R
Q Q
Clk=0 Clk=0
S S
D D
D D new D D
new D old D
when clock goes high-to-low when clock is low
data is latched data is held
Edge-triggered flip-flops(Cont.)
0
1
0 1
0 The edge of the clock is used to
1
0
sample the "D" input & send it to
"Q (positive edge triggering).
At all other times the output Q
is independent of the input D
(just stores previously sampled
value).
The input must be stable for a
short time before the clock
edge.
Edge-triggered flip-flops(Cont.)
Positive edge-triggered
Inputs sampled on rising edge; outputs change after
rising edge
Negative edge-triggered flip-flops
Inputs sampled on falling edge; outputs change after
falling edge
100
D
CLK
Qpos
positive edge-triggered FF
Qpos'
Qneg
negative edge-triggered FF
Qneg'
Comparison of latches and flip-flops
D Q
CLK D
positive
edge-triggered
flip-flop CLK
Qedge
D Q
G Qlatch
CLK
transparent
(level-sensitive)
latch behavior is the same unless input changes
while the clock is high
Comparison of latches and flip-flops(Cont.)
The problem
Correct behavior assumes next state of all storage
elements determined by all storage elements at the same
time
This is difficult in high-performance systems because time
for clock to arrive at flip-flop is comparable to delays
through logic
Effect of skew on cascaded flip-flops:
100
In
CLK1 is a delayed
Q0 version of CLK0
Q1
CLK0
CLK1
original state: IN = 0, Q0 = 1, Q1 = 1
due to skew, next state becomes: Q0 = 0, Q1 = 0, and not Q0 = 0, Q1 = 1
Meta-stability and asynchronous inputs
logic 0
logic 0 logic 1
asynchronous D Q synchronized
D Q
input input
Clk
synchronous system
Handling asynchronous inputs
Clock Clock
Q1 D Q Q1
D Q
Clock Clock
Handling asynchronous inputs(Cont.)
In
In is asynchronous and
fans out to D0 and D1
Q0
one FF catches the
signal, one does not
Q1
inconsistent state may
be reached!
CLK
Flip-Flop features
Reset (set state to 0) R
Synchronous: Dnew = R' Dold (when next clock edge arrives)
Asynchronous: doesn't wait for clock, quick but dangerous
Preset or set (set state to 1) S (or sometimes P)
Synchronous: Dnew = Dold + S (when next clock edge arrives)
Asynchronous: doesn't wait for clock, quick but dangerous
Both reset and preset
Dnew = R' Dold + S (set-dominant)
Dnew = R' Dold + R'S (reset-dominant)
Selective input capability (input enable/load) LD or EN
Multiplexer at input: Dnew = LD' Q + LD Dold
Load may/may not override reset/set (usually R/S have priority)
Complementary outputs Q and Q'
Registers
D Q
D Q
clk
enable enable
clk
Registers with clock gating
Load signal is used to enable the clock signal to pass through if 1 and
prevent the clock signal from passing through if 0.
Example: For Positive Edge-Triggered or Negative Pulse Master-Slave Flip-
flop:
Clock
Load
Gated Clock to FF
What logic is needed for gating? Gated Clock = Clock + Load
What is the problem? Clock Skew of gated clocks with respect to clock or
each other
Register with selective/parallel load(Cont.)
1 0
load
clock R31 R0
Shift register
IN D Q D Q D Q D Q
CLK
Shift register with parallel load
Operation:
cycle 1: load x, output x0
cycle i: output xi
Each stage:
XI
Q(I-1) if (shift==0 )
Q(I)
load FF from xi
else from previous stage.
Shift/load
clk
Shift register with parallel load(Cont.)
shift=1
shift=0
4-bit version:
X3 X2 X1 X0
Shift/load
clk
??
??
x3 ??
x3
x2 x3
??
x2
x1 x1
x2
x3
x0
Shift registers with parallel load(Cont.)
X3 X2 X1 X0
Shift/load
clk
Parallel-to-serial converter
Also, works as Serial-to-parallel converter, if q values are connected out.
Also get used as controllers (ala ring counters)
Universal shift register
Holds 4 values
Serial or parallel inputs
Serial or parallel outputs
Permits shift left or right
Shift in
new values from left or right
output
clear sets the register contents
and output to 0
left_in right_out
left_out Universal right_in s1 and s0 determine the shift function
clear
s0 shift register clock s0 s1 function
s1 0 0 hold state
0 1 shift right
1 0 shift left
1 1 load new input
input
Universal shift register(Cont.)
Design of universal shift register
Nth cell
to N-1th to N+1th
cell Q cell
D
CLK
parallel inputs
serial transmission
Register file
Asel
Bsel
Din
R0
Dsel
R1
Multiplexor
decoder
multiplexor
1 R2
Bout
Aout
R31
ld
Frequency divider
DFF DFF
D Q D Q CLK
Q Q CLK_3
CLK_3
CLK
Pattern recognizer
OUT
IN D Q D Q D Q D Q
CLK
Counters
Counters are sequential circuits which "count" through a specific state sequence.
They can count up, count down, or count through other fixed sequences.
Examples:
binary counter: 000, 001, 010, 011, 100, 101, 110, 111, 000, 001,
gray code counter:
000, 010, 110, 100, 101, 111, 011, 001, 000, 010, 110,
one-hot counter: 0001, 0010, 0100, 1000, 0001, 0010,
BCD counter: 0000, 0001, 0010, , 1001, 0000, 0001
pseudo-random sequence generators: 10, 01, 00, 11, 10, 01, 00, ...
16MHz 64
Delays, Timing
Protocols
of A, A complements
The clock input for flip- D B
flop B is the complemented
output of flip-flop A R
When flip A changes Reset
from 1 to 0, there is a
positive edge on the
CP
clock input of B
causing B to
complement A
B
0 1 2 3 0 1
Ripple counter(Cont.)
C
Discouraged
Know it exists
Dont use it
Synchronous counters
To eliminate the "ripple" effects, use a common clock
for each flip-flop and a combinational circuit to
generate the next state.
For binary counters (most common case) incrementer
circuit would work,
register
Synchronous counters(Cont.)
D Q D Q D Q D Q c b a c+ b + a+
0 0 0 0 0 1
CLK 0 0 1 0 1 0
0 1 0 0 1 1
0 1 1 1 0 0
1 0 0 1 0 1
1 0 1 1 1 0
"1" 1 1 0 1 1 1
1 1 1 0 0 0
Synchronous counters(Cont.)
D Q 0
1
D Q 1
D Q 2
D Q 3
Carry
Output CO
Clock
counters with enable to count
Count
Count Enable D Q 0
D Q 1
Count Action
D Q 2
D Q 3
Carry
Output CO
Clock
Counter with parallel load
Load
Count
D 0 D Q 0
EN
(2) RCO goes high
D
C RCO
B
(3) High order 4-bits A QD
QC
are incremented LOAD QB
CLK QA
CLR
(1) Low order 4-bits = 1111
Offset counters
c b a c + b + a+
0 0 0 1 1 1
0 0 1 0 0 0
0 1 0 0 0 1
0 1 1 0 1 0
1 0 0 0 1 1
1 0 1 1 0 0
1 1 0 1 0 1
1 Down-count
1 1 1 1 0
Other counters
IN D Q D Q D Q D Q
CLK
IN D Q D Q D Q D Q
CLK
Sequential logic implementation
Sequential circuits
Primitive sequential elements
Combinational logic
Models for representing sequential circuits
Finite-state machines (Moore and Mealy)
Representation of memory (states)
Changes in state (transitions)
Basic sequential circuits Inputs Outputs
Shift registers Combinational
Counters Storage logic
Design procedure Elements
State diagrams
State transition table Next
Next state functions State State
Abstraction of state elements
Storage Elements
Forms of sequential logic
Clock
Synchronous circuit
Combinational
Logic
clk
time
Synchronous circuit(Cont.)
clock input
option feedback
output
Combinational Logic Blocks (CL)
Acyclic clock
no internal state (no feedback) distributed to all flip-flops
output only a function of inputs ALL CYCLES GO THROUGH A REG!
Registers (reg)
collections of flip-flops
Finite state machine representations
ERR
closed
0
0 1 0
0
001 011
0
Counters are simple finite state machines
Counters
Proceed thru well-defined state sequence in response to
enable
Many types of counters: binary, BCD, Gray-code
3-bit up-counter: 000, 001, 010, 011, 100, 101, 110, 111, 000,
...
3-bit down-counter: 111, 110, 101, 100, 011, 010, 001, 000,
111, ...
001 010 011
D Q D Q D Q
CLK
"1"
FSM design procedure
Start with counters
Simple because output is just state
Simple because no choice of next state based on input
State diagram to state transition table
Tabular form of state diagram
Like a truth-table
State encoding
Decide on representation of states
For counters it is simple: just its value
Implementation
Flip-flop for each state bit
Combinational logic based on encoding
FSM design procedure: State diagram to
encoded state transition table
Tabular form of state diagram
Like a truth-table (specify output for all input
combinations)
Encoding of states: easy for counters just use
value current state next state
0 000 001 1
001 010 011 1 001 010 2
2 010 011 3
3 011 100 4
000 100
4 100 101 5
3-bit up-counter
5 101 110 6
6 110 111 7
7 111 000 0
111 110 101
Implementation
D flip-flop for each state bit
Combinational logic based on encoding
notation to show
function represent
C3 C2 C1 N3 N2 N1 input to D-FF
0 0 0 0 0 1
0 0 1 0 1 0 N1 := C1'
0 1 0 0 1 1 N2 := C1C2' + C1'C2
0 1 1 1 0 0 := C1 xor C2
N3 := C1C2C3' + C1'C3 + C2'C3
1 0 0 1 0 1 := C1C2C3' + (C1' + C2')C3
1 0 1 1 1 0 := (C1C2) xor C3
1 1 0 1 1 1
1 1 1 0 0 0
N3 C3 N2 C3 N1 C3
0 0 1 1 0 1 1 0 1 1 1 1
C1 0 1 0 1 C1 1 0 0 1 C1 0 0 0 0
C2 C2 C2
Another example
Shift register
Input determines next state
100 1 110
In C1 C2 C3 N1 N2 N3 1
0 0 0 0 0 0 0 0 1
1 1
0 0 0 1 0 0 0
0 0 1 0 0 0 1 0 000 1 010 101 0 111 1
0 0 1 1 0 0 1
0 0 1 0
0 1 0 0 0 1 0 0
001 011
0 1 0 1 0 1 0 0
0 1 1 0 0 1 1
0 1 1 1 0 1 1
1 0 0 0 1 0 0 N1 := In
1 0 0 1 1 0 0 N2 := C1
1 0 1 0 1 0 1 N3 := C2
1 0 1 1 1 0 1 OUT1 OUT2 OUT3
1 1 0 0 1 1 0
1 1 0 1 1 1 0
1 1 1 0 1 1 1 IN D Q D Q D Q
1 1 1 1 1 1 1
CLK
More complex counter example
Complex counter
Repeats five states in sequence
Not a binary number representation
Step 1: derive the state transition diagram
Count sequence: 000, 010, 011, 101, 110
Step 2: derive the state transition table from the
state transition diagram
Present State Next State
000 110 C B A C+ B+ A+
0 0 0 0 1 0
0 0 1
0 1 0 0 1 1
010 101 0 1 1 1 0 1
1 0 0
1 0 1 1 1 0
011 1 1 0 0 0 0
1 1 1
note the don't care conditions that arise from the unused state codes
More complex counter example(Cont.)
A X 1 X 1 A X 0 X 1 A X 1 X 0
B B B
C+ := A
B+ := B' + A'C'
A+ := BC'
Self-Starting counters(Cont.)
A 1 1 1 1 A 1 0 0 1 A 0 1 0 0
B B B
011 011
State machine model
Current State
State machine model(Cont.)
output Outputs
logic
Inputs
next state Next State
logic
States: S1, S2, ..., Sk
Inputs: I1, I2, ..., Im Current State
State
Clock 0 1 2 3 4 5
Example: ant brain
Sensors: L and R antennae, 1 if in
touching wall
Actuators: F - forward step, TL/TR - turn
left/right slightly
Goal: find way out of maze
Strategy: keep the wall on the right
Example: ant brain(Cont.)
Ant behavior
L R L R R
R
L R
B C
R
(TR, F) (TR, F)
R
Example: ant brain(Cont.)
Synthesizing the ant brain circuit
Encode states using a set of state variables
Arbitrary choice - may affect cost, speed
Use transition truth table
Define next state function for each state variable
Define output function for each output
Implement next state and output functions using
combinational logic
2-level logic
Multi-level logic
Next state and output functions can be optimized
together
Example: ant brain(Cont.)
Transition truth table
L R L R R
R
L R
state L R next state outputs B C
LOST 0 0 LOST F (TR, F) (TR, F) R
LOST 1 E/G F R
LOST 1 E/G F
A 0 0 B TL, F
A 0 1 A TL, F
A 1 E/G TL, F
B 0 C TR, F
B 1 A TR, F
... ... ... ... ...
Example: ant brain(Cont.)
Synthesis
output F
TR
logic
TL
L next state Next State
R logic
X+ Y+ Z+
Current State
X Y Z
Example: ant brain(Cont.)
Dont cares in FSM synthesis
What happens to the "unused" states (101, 110, 111)?
Exploited as don't cares to minimize the logic
If states can't happen, then don't care what the functions
do
if states do happen, we may be in trouble
L R
L+R L R
000 L+R 001 L 010
(F) (TL) (TL, F)
101
L R R
R
L R
011 100
110 (TR, F) (TR, F) R
R
111
Ant is in deep trouble
if it gets in this state
Example: ant brain(Cont.)
State minimization
Fewer states may mean fewer state variables
High-level synthesis may generate many
redundant states
Two state are equivalent if they are impossible to
distinguish from the outputs of the FSM, i. e., for
any input sequence the outputs are the same
L R L R R
R
L R
B C
R
(TR, F) (TR, F)
R
Example: ant brain(Cont.)
New improved brain
Merge equivalent B and C states
Behavior is exactly the same as the 5-state
brain
We now need only 2 state variables rather
than 3 L+R L R
L R L R R
L R
B/C
R
(TR, F)
Example: ant brain(Cont.)
New brain implementation
L R / TL, F
L / TL
A
react right away to leaving the wall
L R / TR, F
Specifying outputs for a Moore machine
Output is only function of state
Specify in state bubble in state diagram
Example: sequence detector for 01 or 10
current next
reset input state state output
0
1 A
1 0 0 A B 0
B/0 D/1
0 1 A C 0
0 0 0 B B 0
0
reset 0 1 B D 0
A/0 1 0
0 0 C E 0
1 0 1 C C 0
1
0 0 D E 1
C/0 E/1 0 1 D C 1
0
0 0 E B 1
1 0 1 E D 1
Specifying outputs for a Mealy machine
1/0
Comparison of Mealy and Moore
machines
Mealy machines tend to have less states
Different outputs on arcs (n^2) rather than states (n)
Moore machines are safer to use
Outputs change at clock edge (always one cycle later)
In Mealy machines, input change can cause output change
as soon as logic is done a big problem when two
machines are interconnected asynchronous feedback
Mealy machines react faster to inputs
React in same cycle don't need to wait for clock
In Moore machines, more logic may be necessary to
decode state into outputs more gate delays after
logic for
inputs inputs outputs
combinational outputs
logic for
next state logic for combinational
R outputs logic for R
outputs
next state
A
D Q out
B
D Q
clock
Q
Mealy and Moore examples(Cont.)
A
D Q
B
D Q
Q
clock
out
A
D Q D Q
Q Q
B
D Q D Q
Q Q
clock
Registered Mealy machine(Really Moore)
output Outputs
Inputs logic
next state
logic
Current State
Example: vending machine
N
Vending Open
Coin Machine Release
Sensor FSM Mechanism
D
Clock
Example: vending machine(Cont.)
Inputs: N, D, reset N D N D
Output: open chute S4 S5 S6
S3
Assumptions: [open] [open] [open]
Mapping to logic
D1 Q1 D0
0 1 1 0
Q1 Open Q1
0 0 1 0
0 0 1 1
1 0 1 1 0 0 1 0
0 1 1 1 N N N
X X X X X X X X
D X X X X D D
0 1 1 1 0 0 1 0
1 1 1 1
Q0 Q0 Q0
D1 = Q1 + D + Q0 N
D0 = Q0 N + Q0 N + Q1 N + Q1 D
OPEN = Q1 Q0
Example: vending machine(Cont.)
One-hot encoding
present state inputs next state output
Q3 Q2 Q1 Q0 D N D3 D2 D1 D0 open
0 0 0 1 0 0 0 0 0 1 0 D0 = Q0 D N
0 1 0 0 1 0 0
1 0 0 1 0 0 0
1 1 - - - - - D1 = Q0 N + Q1 D N
0 0 1 0 0 0 0 0 1 0 0
0 1 0 1 0 0 0 D2 = Q0 D + Q1 N + Q2 D N
1 0 1 0 0 0 0
1 1 - - - - -
0 1 0 0 0 0 0 1 0 0 0 D3 = Q1 D + Q2 D + Q2 N + Q3
0 1 1 0 0 0 0
1 0 1 0 0 0 0 OPEN = Q3
1 1 - - - - -
1 0 0 0 - - 1 0 0 0 1
Example: vending machine(Cont.)
0
N D 0 N D/0
[0]
N N/0
D 5 D/0
N D 5 N D/0
[0]
N N/0
10
D N D D/1 10 N D/0
[0]
N+D N+D/1
15
Reset 15 Reset/1
[1]
Example: traffic light controller
A busy highway is intersected by a little used farmroad
Detectors C sense the presence of cars waiting on the farmroad
with no car on farmroad, light remain green in highway direction
if vehicle on farmroad, highway lights go from Green to Yellow to Red, allowing
the farmroad lights to become green
these stay green only as long as a farmroad car is detected but never longer
than a set interval
when these are met, farm lights transition from Green to Yellow to Red,
allowing highway to return to green
even if farmroad vehicles are waiting, highway gets at least a set interval as
green
Assume you have an interval timer that generates:
a short time pulse (TS) and
a long time pulse (TL),
in response to a set (ST) signal.
TS is to be used for timing yellow lights and TL for green lights
Example: traffic light controller(Cont.)
car sensors
highway
Example: traffic light controller(Cont.)
S0
TLC / ST TS / ST
S0: HG
S1: HY TS' S1 S3 TS'
S2: FG
S3: FY TS / ST TL+C' / ST
S2
(TL+C')'
Example: traffic light controller(Cont.)
SA1: HG = 00 HY = 01 FG = 11 FY = 10
SA2: HG = 00 HY = 10 FG = 01 FY = 11
SA3: HG = 0001 HY = 0010 FG = 0100 FY = 1000 (one-hot)
Example: traffic light controller(Cont.)
State minimization
Fewer states require fewer state bits
Fewer bits require fewer logic equations
Encodings: state, inputs, outputs
State encoding with fewer bits has fewer equations to
implement
However, each may be more complex
State encoding with more bits (e.g., one-hot) has simpler
equations
Complexity directly related to complexity of state diagram
Input/output encoding may or may not be under designer
control
State minimization
Algorithmic approach
Goal identify and combine states that have equivalent behavior
Equivalent states:
Same output
For all input combinations, states transition to same or equivalent
states
Algorithm sketch
1. Place all states in one set
2. Initially partition set based on output behavior
3. Successively partition resulting subsets based on next state
transitions
4. Repeat (3) until no further partitioning is required
states left in the same set are equivalent
Polynomial time procedure
State minimization(Cont.)
State minimization example
Reset S0 S1 S2 0 0
0 S1 S3 S4 0 0
1 S2 S5 S6 0 0
00 S3 S0 S0 0 0
01 S4 S0 S0 1 0
10 S5 S0 S0 0 0
11 S6 S0 S0 1 0
S0
0/0 1/0
S1 S2
0/0 1/0 0/0 1/0
S3 S4 S5 S6
1/0 1/0 1/0 1/0
0/0 0/1 0/0 0/1
State minimization(Cont.)
Method of successive partitions
Input Next State Output
Sequence Present State X=0 X=1 X=0 X=1
Reset S0 S1 S2 0 0
0 S1 S3 S4 0 0
1 S2 S5 S6 0 0
00 S3 S0 S0 0 0
01 S4 S0 S0 1 0
10 S5 S0 S0 0 0
11 S6 S0 S0 1 0
( S0 S1 S2 S3 S4 S5 S6 )
S1 is equivalent to S2
( S0 S1 S2 S3 S5 ) ( S4 S6 )
S3 is equivalent to S5
( S0 S3 S5 ) ( S1 S2 ) ( S4 S6 ) S4 is equivalent to S6
( S0 ) ( S3 S5 ) ( S1 S2 ) ( S4 S6 )
State minimization(Cont.)
Minimized FSM
S0
X/0
S1
0/0 1/0
S3 S4
X/0 0/1 1/0
State minimization(Cont.)
More complex state minimization
00 10
S0 00 S1
[1] [0]
01 present next state output
10 11 state 00 01 10 11
11
00 01 S0 S0 S1 S2 S3 1
00 01 S1 S0 S3 S1 S4 0
S2 S3 S2 S1 S3 S2 S4 1
[1] 01 [0] S3 S1 S0 S4 S5 0
10
10 11 11 S4 S0 S1 S2 S5 1
01
S5 S1 S4 S0 S5 0
10 10
00 S4 11 S5 00
[1] [0]
symbolic state
01 transition table
11
State minimization(Cont.)
Minimized FSM
Implication chart method
Cross out incompatible states based on outputs
Then cross out more cells if indexed chart entries are
already crossed out
S1 present next state output
state 00 01 10 11
S0-S1
S0' S0' S1 S2 S3' 1
S1-S3 S1 S0' S3' S1 S3' 0
S2
S2-S2 S2 S1 S3' S2 S0' 1
S3-S4 S3' S1 S0' S0' S3' 0
S0-S1
S3 S3-S0
S1-S4
S4-S5 minimized state table
S0-S0 S1-S0 (S0==S4) (S3==S5)
S4 S1-S1 S3-S1
S2-S2 S2-S2
S3-S5 S4-S5
S0-S1 S1-S1
S5 S3-S4 S0-S4
S1-S0 S4-S0
S4-S5 S5-S5
S0 S1 S2 S3 S4
State minimization(Cont.)
Minimizing incompletely specified FSMs
Equivalence of states is transitive when machine is fully specified
But its not transitive when don't cares are present
e.g., state output
S0 0 S1 is compatible with both S0 and S2
S1 1 but S0 and S2 are incompatible
S2 1
X 0 0 0 0 0
0 0 1 0 0
00 X
0 1 1 0 0
[0]
1 0 0 0 1
01 1 0 1 1 1
X X [1] 1 1 1 1 1
1 0 0 0
11 X
[0]
Q1+ = X (Q1 xor Q0)
X
Q0+ = X Q1 Q0
Another implementation of edge detector
00
X [0] X
X
10 01
[0] [1]
X
X 11 X
[0]
X
State assignment
1 0
S2 S5
[0] [0]
0 0
S3 S6 0 or 1
[1] [0]
Finite string pattern recognizer(Cont.)
S3 S6 0 or 1
...010 [1] ...100 [0]
Finite string pattern recognizer(Cont.)
Review of process
Understanding problem
Write down sample inputs and outputs to understand specification
Derive a state diagram
Write down sequences of states and transitions for sequences to be
recognized
Minimize number of states
Add missing transitions; reuse states as much as possible
State assignment or encoding
Encode states with unique patterns
Simulate realization
Verify I/O behavior of your state diagram to ensure it matches
specification
Complex counter
reset S0 0 S1 0 S2 0 S3 0 S4 0 S5 0 S6 0 S7
[000] [001] [010] [011] [100] [101] [110] [111]
1
1 1 1
1
1 1 1
Traffic light controller as two
communicating FSMs
Without separate timer
TS'
S0 would require 7 states
S1 would require 3 states S1 S1a
S2 would require 7 states TS/ST
S1b
S3 would require 3 states
S1 and S3 have simple transformation S1c
S0 and S2 would require many more arcs /ST
C could change in any of seven states
By factoring out timer
Greatly reduce number of states traffic light
4 instead of 20 controller
Counter only requires seven or eight states ST
12 total instead of 20 TS TL
timer
Communicating finite state machines
One machine's output is another machine's
input
X
CLK
FSM 1 FSM 2
Y FSM1 A A B
status control
info and state signal
inputs outputs
data-path
"puppet"
Digital combinational lock
clock
open/closed
Digital Combinational Lock(Cont.)
Digital combination lock state diagram
States: 5 states
Represent point in execution of machine
Each state has outputs
Transitions: 6 from state to state, 5 self transitions, 1
global
Changes of state occur when clock says its ok
Based on value of inputs
Inputs: reset, new, results of comparisons ERR
closed
Output: open/closed
C1!=value
C2!=value C3!=value
& new
& new & new
S1 S2 S3 OPEN
reset closed closed closed open
C1=value C2=value C3=value
& new & new & new
C1 C2 C3 new reset
4 4 4 mux
multiplexer
control
4 controller
value comparator clock
4 equal
open/closed
Digital combinational lock(Cont.)
State table for combination lock
Finite-State machine
Refine state diagram to take internal structure into
account
State table ready for encoding
next
reset new equal state state mux open/closed
1 S1 C1 closed
0 0 S1 S1 C1 closed
0 1 0 S1 ERR closed
0 1 1 S1 S2 C2 closed
...
0 1 1 S3 OPEN open
...
Digital combinational lock(Cont.)
Encodings for combination lock
Encode state table
State can be: S1, S2, S3, OPEN, or ERR
Needs at least 3 bits to encode: 000, 001, 010, 011, 100
And as many as 5: 00001, 00010, 00100, 01000, 10000
Choose 4 bits: 0001, 0010, 0100, 1000, 0000
new reset
Output mux can be: C1, C2, or C3 mux
Needs 2 to 3 bits to encode control
Choose 3 bits: 001, 010, 100 controller
clock
Output open/closed can be: open or closed equal
Needs 1 or 2 bits to encode
open/closed
Choose 1 bit: 1, 0
next
reset new equal state state mux open/closed
1 0001 001 0 mux is identical to last 3 bits of state
0 0 0001 0001 001 0 open/closed is identical to first bit of state
0 1 0 0001 0000 0 therefore, we do not even need to implement
0 1 1 0001 0010 010 0 FFs to hold state, just use outputs
...
0 1 1 0100 1000 1
Design register with set/reset
S R
D Q
Implementation Symbol
To avoid 1s catching
behavior, one solution
used is to use an J Q
edge-triggered D as
the core of the flip-flop
K
J D Q
K
T flip-flop
Behavior
Has a single input T
For T = 0, no change to state
For T = 1, changes to opposite state
Same as a J-K flip-flop with J = K = T
As a master-slave, has same 1s catching behavior as J-K
flip-flop
Cannot be initialized to a known state using the T input
Reset (asynchronous or synchronous) essential
T flip-flop(Cont.)
Implementation Symbol
To avoid 1s catching
behavior, one solution T Q
used is to use an
edge-triggered D as
the core of the flip-flop
D Q
T
Basic flip-flop descriptors
Used in analysis
Characteristic table - defines the next state of
the flip-flop in terms of flip-flop inputs and
current state
Characteristic equation - defines the next state
of the flip-flop as a Boolean function of the
flip-flop inputs and the current state
Used in design
Excitation table - defines the flip-flop input
variable values as function of the current state
and next state
D flip-flop descriptors
Characteristic Table
D Q(t + 1) Operation
0 0 Reset
1 1 Set
Characteristic Equation
Q(t+1) = D
Excitation Table
Q(t +1) D Operation
0 0 Reset
1 1 Set
T flip-flop descriptors
Characteristic Table
T Q(t + 1) Operation
0 Q ( t) No change
1 Q ( t) Complement
Characteristic Equation
Q(t+1) = T Q
Excitation Table
Q(t +1) T Operation
Q ( t) 0 No change
Q ( t) 1 Complement
S-R flip-flop descriptors
Characteristic Table S R Q(t + 1) Operation
0 0 Q ( t) No change
0 1 0 Reset
1 0 1 Set
1 1 ? Undefined
Characteristic Equation
Q(t+1) = S + R Q, S.R = 0
Excitation Table
Q(t) Q(t+ 1) S R Operation
0 0 0 X No change
0 1 1 0 Set
1 0 0 1 Reset
1 1 X 0 No change
J-K flip-flop descriptors
Characteristic Table J K Q(t + 1) Operation
0 0 Q ( t) No change
0 1 0 Reset
1 0 1 Set
1 1 Q ( t) Complement
Characteristic Equation
Q(t+1) = J Q + K Q
Excitation Table
Q(t) Q(t + 1) J K Operation
0 0 0 X No change
0 1 1 X Set
1 0 X 1 Reset
1 1 X 0 No Change
Flip-flop behavior
Use the characteristic tables to find the output waveforms for the flip-
flops shown:
Clock
D,T
D Q
T Q
Flip-flop behavior(Cont.)
Use the characteristic tables to find the output waveforms for the flip-
flops shown:
Clock
S,J
R,K
S QSR ?
J QJK
K
Implement D Flip-flop by T Flip-flop
Q Q 0 1
D 0 1 T
0 0 1
0 0 0
1 1 1 1 0
1
T = D Q + D Q
D
D
Q
T
Q
Implement JK Flip-flop by D Flip-flop
Q
0 1 Q 0 1
JK JK D Q+
00 0 1 00 0 1
01 0 0 01 0 0 0 0
11 1 0 11 1 0 1 1
10 1 1 10 1 1
D = J Q + K Q
J
Q
D
K Q
Implement JK Flip-flop by T Flip-flop
Q Q+
Q 0 1
0 1 JK Q+
JK JK
T Q+
00 0 1 00 0 0 00 Q
01 0 0 01 0 1 Q
01 0 0
11 1 0 11 1 1 10 1 1 Q
10 1 1 10 1 0 11 Q
T = J Q + K Q
J
Q
T
K Q
Implement T Flip-flop by JK Flip-flop
Q
T 0 1 J K
Q Q+
0 0 1 00 0 X
1 1 0 01 1 X
10 X 1
11 X 0
Q Q
T 0 1 T 0 1
0 X 0 X 0
0
1 1 X 1 X 1
J=T K=T
Sequential circuit analysis
thanks
digital design