Escolar Documentos
Profissional Documentos
Cultura Documentos
Sequential circuits
Sequential circuits
Circuits with feedback
Outputs = f(inputs, past inputs, past outputs)
Basis for building "memory" into logic circuits
Door combination lock is an example of a sequential circuit
State is memory
State is an "output" and an "input" to combinational logic
Combination storage elements are also memory
new
value
C1
C2
C3
multiplexer
mux
control
equal
comb. logic
state
comparator
equal
reset
open/closed
clock
X1
X2
Xn
switching
network
Z1
Z2
Zn
"load"
"stored value"
Q'
R
S
S'
R'
S'
R'
Q'
Timing behavior
Reset
R
S
Q
\Q
Hold
Q'
Set
Reset
Set
100
Race
R
0
1
0
1
Q
hold
0
1
unstable
Q Q'
1 0
Q Q'
0 0
Q Q'
1 1
Q Q'
0 1
SR=01
SR=01
SR=10
Q Q'
1 0
SR=11
State diagram
States: possible values
Transitions: changes
based on inputs
SR=11
SR=01
possible oscillation
between states 00 and 11
Q Q'
0 0
SR=11
SR=00
SR=11
SR=00
SR=10
Q Q'
1 1
SR=00
SR=10
Q Q'
0 1
SR=01
SR=01
SR=10
Q Q'
1 0
SR=11
SR=11
SR=00
Q Q'
0 0
SR=11
SR=00
SR=00
SR=10
Q'
S
S
0
0
0
0
1
1
1
1
R
0
0
1
1
0
0
1
1
Q(t)
0
1
0
1
0
1
0
1
Q(t+)
0
hold
1
0 reset
0
1 set
1
X not allowed
X
Q(t)
Q(t+)
S
R
Q(t)
R
characteristic equation
Q(t+) = S + R Q(t)
Set
S'
R'
enable'
Q
Q'
R'
enable'
Q'
S'
100
Reset
Clocks
Used to keep time
Wait long enough for inputs (R' and S') to settle
Then allow to have effect on value stored
period
Clocks(Cont.)
Q
R' and S'
clock'
S'
Q'
clock
Cascading latches
Connect output of one latch to input of another
How to stop changes from racing through chain?
Need to control flow of data from one latch to the
next
Advance from one latch per clock period
Worry about logic between latches (arrows) that is
too fast
clock
Q'
Q'
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
master stage
clock
Q'
P'
Q'
Reset
slave stage
master stage
1s
catch
clock
Master
Outputs
Slave
Outputs
Q' P'
Q'
D flip-flop
Make S and R complements of each other
Eliminates 1s catching problem
Can't just hold previous value (must have new value ready
every clock period)
Value of D just before clock goes low is what is stored in
flip-flop
Can make R-S flip-flop by adding logic to make D = S + R' Q
slave stage
master stage
D
clock
Q'
P'
Q'
Q'
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
0
R
negative edge-triggered D
flip-flop (D-FF)
clock=1
S
0
holds D when
clock goes low
characteristic equation
Q(t+1) = D
Edge-triggered flip-flops(Cont.)
Step-by-step analysis
D
D
R
D
R
Clk=0
Clk=0
S
S
D
D
when clock goes high-to-low
data is latched
new D
new D old D
Edge-triggered flip-flops(Cont.)
0
1
0
1
0
1
0
Edge-triggered flip-flops(Cont.)
Positive edge-triggered
Inputs sampled on rising edge; outputs change after
rising edge
positive edge-triggered FF
negative edge-triggered FF
positive
edge-triggered
flip-flop
D
CLK
Qedge
D Q
G
Qlatch
CLK
transparent
(level-sensitive)
latch
unclocked
latch
always
level-sensitive
latch
clock high
(Tsu/Th around falling
edge of clock)
master-slave
flip-flop
clock high
(Tsu/Th around falling
edge of clock)
negative
clock hi-to-lo transition propagation delay from falling edge
edge-triggered (Tsu/Th around falling of clock
flip-flop
edge of clock)
Clock skew
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
Q0
Q1
CLK1 is a delayed
version of CLK0
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
Asynchronous circuits
Inputs, state, and outputs sampled or changed independently of
a common reference signal (glitches/hazards a major concern)
E.g., R-S latch
Synchronization failure
Occurs when FF input changes close to clock edge
FF may enter a meta-stable state neither a logic 0 nor 1
May stay in this state an indefinite amount of time
Is not likely in practice but has some probability
logic 1
logic 0
logic 1
logic 0
oscilloscope traces demonstrating
synchronizer failure and eventual
decay to steady state
synchronized
input
Q
Clk
synchronous system
D Q
Synchronizer
Q0
Async
Input D Q
D Q
Clock
Clock
D Q
Q1
Clock
Q0
D Q
Q1
Clock
In is asynchronous and
fans out to D0 and D1
one FF catches the
signal, one does not
inconsistent state may
be reached!
Flip-Flop features
Reset (set state to 0) R
(set-dominant)
(reset-dominant)
Registers
Collections of flip-flops with similar controls and
logic
Stored values somehow related (e.g., form binary
value)
Share clock, reset, and set lines
Similar logic at each stage
Examples
OUT1
Shift registers
"0"
Counters
OUT2
R S
D Q
OUT3
R S
D Q
R S
D Q
OUT4
R S
D Q
CLK
IN1
IN2
IN3
IN4
How do we modify our D flipflop so that it holds the value till we are
done with it?
En State Next
A very simple FSM
0
1
Q
D
clk
enable
enable
clk
Q
Q
Q
D
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
load
clock
R31
R0
Shift register
Holds samples of input
Store last 4 input values in sequence
4-bit shift register:
OUT1
IN
CLK
D Q
D Q
OUT2
D Q
OUT3
D Q
OUT4
Each stage:
XI
Q(I)
Shift/load
clk
Q(I-1)
if (shift==0 )
load FF from xi
else from previous stage.
4-bit version:
X3
IN
X2
X1
X0
Q(2)
Q(3)
Q(1)
Q(0)
Shift/load
clk
??
??
x3
??
x3
x2
x3
??
x2
x1
x1
x2
x3
x0
IN
X2
Q(3)
X1
Q(2)
X0
Q(1)
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)
Q(0)
left_in
left_out
clear
s0
s1
Universal
shift register
input
right_out
right_in
clock
s1
0
1
0
1
function
hold state
shift right
shift left
load new input
clear
1
0
0
0
0
s0
0
0
1
1
s1
0
1
0
1
new value
0
output
output value of FF to left (shift right)
output value of FF to right (shift left)
input
to N+1th
cell
Q
D
CLK
CLEAR
0 1 2 3 s0 and s1
control mux
Q[N-1]
(left)
Input[N]
Q[N+1]
(right)
Unversal
shift reagister
Universal
shift register
parallel inputs
serial transmission
Universal
shift register
Register file
Asel
Din
Bsel
R0
Dsel
R31
ld
multiplexor
R2
Multiplexor
decoder
R1
Bout
Aout
Frequency divider
Divide clock frequency by 4
CLK
DFF
Q
D
Q
DFF
Q
D
Q
CLK
CLK_4
CLK_4
DFF
Q
D
Q
CLK
CLK_3
CLK_3
CLK
Pattern recognizer
Combinational function of input samples
In this case, recognizing the pattern 1001 on the
single input signal
OUT
OUT1
IN
CLK
D Q
D Q
OUT2
D Q
OUT3
D Q
OUT4
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, ...
Two distinct types are in common usage:
Ripple Counters
Clock is connected to the flip-flop clock input on the LSB bit flip-flop
For all other bits, a flip-flop output is connected to the clock input, thus
circuit is not truly synchronous
Output change is delayed more for each bit toward the MSB.
Resurgent because of low power consumption
Synchronous Counters
Clock is directly connected to the flip-flop clock inputs
Logic is used to implement the desired state sequencing
Counters(Cont.)
64
Delays, Timing
Protocols
Ripple counter
How does it work?
When there is a positive
edge on the clock input
of A, A complements
The clock input for flipflop B is the complemented
output of flip-flop A
When flip A changes
from 1 to 0, there is a
positive edge on the
clock input of B
causing B to
complement
D
Clock
B
R
Reset
CP
B
0
Ripple counter(Cont.)
The arrows show the
CP
cause-effect relationA
ship from the prior
slide =>
B
The corresponding
0
1
0
1
2
3
sequence of states =>
(B,A) = (0,0),
(0,1), (1,0), (1,1), (0,0), (0,1),
Each additional bit, C, D, behaves like bit B, changing half as
frequently as the bit before it.
For 3 bits: (C,B,A) = (0,0,0), (0,0,1), (0,1,0), (0,1,1),
(1,0,0), (1,0,1), (1,1,0), (1,1,1), (0,0,0),
Ripple counter(Cont.)
These circuits are called ripple counters because each edge
sensitive transition (positive in the example) causes a change
in the next flip-flops state.
The changes ripple upward through the chain of flip-flops, i.
e., each transition occurs after a clock-to-output delay from
the stage before.
To see this effect in detail look at the waveforms on the next
slide.
Ripple counter(Cont.)
Starting with C = B = A = 1, equivalent to (C,B,A) = 7 base
10, the next clock increments the count to (C,B,A) = 0 base
10. In fine timing detail:
The clock to output delay
tPHL causes an increasing
delay from clock edge for
each stage transition.
Thus, the count ripples
from least to most
significant bit.
For n bits, total worst case
delay is n tPHL.
Discouraged
Know it exists
Dont use it
tPHL
CP
A
tPHL
tpHL
B
C
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.)
OUT1
D Q
CLK
"1"
OUT2
D Q
OUT3
D Q
OUT4
D Q
c
0
0
0
0
1
1
1
1
b
0
0
1
1
0
0
1
1
a
0
1
0
1
0
1
0
1
c+ b + a+
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
0 0 0
Synchronous counters(Cont.)
Carry
Output CO
Clock
Count Enable
Count
Action
Carry
Output CO
Clock
Count
Action
Load D
Carry
Output CO
Clock
EN
(2) RCO goes high
D
C
RCO
B
QD
A
QC
LOAD QB
QA
CLK
CLR
Offset counters
Starting offset counters use of
synchronous load
e.g., 0110, 0111, 1000, 1001, 1010,
1011, 1100, 1101, 1111, 0110, . . .
"1"
"0"
"1"
"1"
"0"
"0"
EN
RCO
QD
D
QC
C
QB
B
QA
A
LOAD
CLK
CLR
"1"
"0"
"0"
"0"
"0"
EN
D
C
B
A
LOAD
CLK
CLR
RCO
QD
QC
QB
QA
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
Sequences through a fixed set of patterns
In this case, 1000, 0100, 0010, 0001
If one of the patterns is its initial state (by loading or
set/reset)
OUT1
OUT2
OUT3
OUT4
IN
D Q
D Q
D Q
D Q
CLK
D Q
D Q
D Q
D Q
Design procedure
Storage
Elements
State diagrams
State transition table
Next state functions
Outputs
Inputs
Combinational
logic
State
Next
State
Combinational
Logic
State Inputs
Outputs
State Outputs
Storage Elements
Combinational
logic
Clock
Synchronous circuit
Combinational
Logic
clk
time
Synchronous circuit(Cont.)
clock
input
input
CL
reg
CL
reg
output
option feedback
output
Combinational Logic Blocks (CL)
Acyclic
no internal state (no feedback)
output only a function of inputs
Registers (reg)
collections of flip-flops
clock
distributed to all flip-flops
001
In = 0
Sequential logic
In = 1
100
111
In = 0
In = 1
110
closed
not equal
& new
S1
reset
closed
mux=C1
not new
not equal
& new
S3
S2
equal
& new
closed
mux=C2
not new
not equal
& new
equal
& new
closed
mux=C3
not new
OPEN
equal
& new
open
OUT1
000
001
0
0
D Q
101
0
OUT3
110
010
1
0
D Q
100
1
D Q
OUT2
111
0
1
011
000
010
011
100
3-bit up-counter
111
110
101
D Q
CLK
"1"
OUT2
D Q
OUT3
D Q
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
000
010
011
100
3-bit up-counter
111
110
101
0
1
2
3
4
5
6
7
000
001
010
011
100
101
110
111
001
010
011
100
101
110
111
000
1
2
3
4
5
6
7
0
Implementation
D flip-flop for each state bit
Combinational logic based on encoding
C3
0
0
0
0
1
1
1
1
C2
0
0
1
1
0
0
1
1
C1
0
1
0
1
0
1
0
1
N3
N3
0
0
0
1
1
1
1
0
C3
N2
0
1
1
0
0
1
1
0
notation to show
function represent
input to D-FF
N1
1
0
1
0
1
0
1
0
N1 := C1'
N2 := C1C2' + C1'C2
:= C1 xor C2
N3 := C1C2C3' + C1'C3 + C2'C3
:= C1C2C3' + (C1' + C2')C3
:= (C1C2) xor C3
N2
C3
N1
C3
C1 0
C1 1
C1 0
C2
C2
C2
Another example
Shift register
Input determines next state
In
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
C1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
C2
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
C3
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
N1
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
N2
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
N3
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
1
1
100
1
0
000
001
N1 := In
N2 := C1
N3 := C2
IN
CLK
010
D Q
111
1
011
OUT1
D Q
1
101
110
OUT2
D Q
OUT3
0
1
0
0
1
1
0
1
1
1
0
1
010
101
1
0
0
1
0
1
1
1
0
1
1
0
0
0
0
011
1
1
1
note the don't care conditions that arise from the unused state codes
000
110
B+
C
0
A+
C
1
C+ := A
B+ := B' + A'C'
A+ := BC'
C
0
Self-Starting counters(Cont.)
B
Present State Next State
C
B
A
C+ B+ A+
0
0
0
0
1
0
0
0
1
1
1
0
0
1
0
0
1
1
0
1
1
1
0
1
1
0
0
0
1
0
1
0
1
1
1
0
1
1
0
0
0
0
1
1
1
1
0
0
111
001
000
110
100
010
101
011
Self-Starting counters
Start-up states
Self-starting solution
111
001
000
110
implementation
on previous slide
000
100
001
110
100
010
101
011
010
101
011
Outputs
Function of current state and inputs (Mealy machine)
Function of current state only (Moore machine)
Inputs
output
logic
next state
logic
Current State
Outputs
Next State
Inputs
Outputs
next state
logic
Next State
Ant behavior
A: Following wall, touching
Go forward, turning
left slightly
C: Break in wall
Go forward, turning
right slightly
E: Wall in front
Turn left until...
LOST
(F)
L R
L+R
L R
L
E/G
(TL)
L R
A
(TL, F)
R
L R
B
(TR, F)
C
(TR, F)
L R
L+R
E/G
(TL)
L R
L R
A
(TL, F)
R
L R
state
LOST
LOST
LOST
A
A
A
B
B
...
L
0
1
0
0
1
...
R
0
1
0
1
0
1
...
next state
LOST
E/G
E/G
B
A
E/G
C
A
...
outputs
F
F
F
TL, F
TL, F
TL, F
TR, F
TR, F
...
B
(TR, F)
R
C
(TR, F)
Synthesis
5 states : at least 3 state variables
required (X, Y, Z)
State assignment (in this case, arbitrarily
chosen)
state
X,Y,Z
000
000
...
010
010
010
010
011
011
...
L R
0 0
0 1
... ...
0 0
0 1
1 0
1 1
0 0
0 1
... ...
next state
X', Y', Z'
000
001
...
011
010
001
001
100
010
...
outputs
F TR TL
1 0 0
1 0 0
...
1 0 1
1 0 1
1 0 1
1 0 1
1 1 0
1 1 0
...
it now remains
to synthesize
these 6 functions
LOST
E/G
A
B
C
000
001
010
011
100
inputs
L R
0 0
- 1
1 0 0
- 1
1 0 0
0 1
1 - 0
- 1
- 0
- 1
next state
X+,Y+,Z+
000
001
001
011
010
010
011
010
001
100
010
100
010
outputs
F TR TL
1 0 0
1 0 0
1 0 0
0 0 1
0 0 1
0 0 1
1 0 1
1 0 1
1 0 1
1 1 0
1 1 0
1 1 0
1 1 0
e.g.
TR = X + Y Z
X+ = X R + Y Z R = R TR
Circuit implementation
Outputs are a function of the current state only - Moore machine
F
TR
TL
output
logic
L
R
next state
logic
Current State
Next State
X+
Y+
Z+
000
(F)
101
L+R
L+R
001
(TL)
L R
L R
010
(TL, F)
L
R
L R
011
(TR, F)
110
111
R
100
(TR, F)
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
Two conditions for two states to be equivalent:
Output must be the same in both states
Must transition to equivalent states for all input
combinations
LOST
(F)
L R
L+R
L R
E/G
(TL)
L R
A
(TL, F)
R
L R
B
(TR, F)
C
(TR, F)
L+R
L R
E/G
(TL)
L R
A
(TL, F)
R
L R
B/C
(TR, F)
L R
inputs
L R
0 0
- 1
1 0 0
- 1
1 0 0
0 1
1 - 0
- 1
X+
X
0
0
0
0
1
0
0
0
1
1
1
1
Y+
1
1
0
0
R
L
X
0
1
1
1
1
0
0
0
X
1
1
1
1
0
0
0
0
1
1
1
1
Y
1
1
1
1
1
0
0
1
1
0
1
1
TR
R
L
X
0
0
0
0
0
0
0
0
1
1
1
1
Y
0
0
0
0
TL
R
L
X
0
0
0
0
1
1
1
1
0
0
0
0
Y
1
1
1
1
A
react right away to leaving the wall
L R / TR, F
B/0
D/1
0
reset
0
1
A/0
1
C/0
1
E/1
reset
1
0
0
0
0
0
0
0
0
0
0
input
0
1
0
1
0
1
0
1
0
1
current
state
A
A
B
B
C
C
D
D
E
E
next
state
A
B
C
B
D
E
C
E
C
B
D
output
0
0
0
0
0
0
1
1
1
1
B
0/0
reset/0
0/1
1/1
1/0
C
1/0
reset
1
0
0
0
0
0
0
input
0
1
0
1
0
1
current
state
A
A
B
B
C
C
next
state
A
B
C
B
C
B
C
output
0
0
0
0
1
1
0
inputs
combinational
logic for
next state
state feedback
inputs
logic for
outputs
outputs
logic for
outputs
combinational
logic for
next state
state feedback
outputs
clock
out
Q
Q
B
clock
Q
Q
out
out
A
Q
Q
Q
Q
clock
out
A
Q
B
Q
Q
clock
Q
Q
Q
Q
output
logic
next state
logic
Current State
Outputs
Coin
Sensor
Vending
Machine
FSM
Clock
Open
Release
Mechanism
Reset
3 nickels
nickel, dime
dime, nickel
two dimes
S0
N
Assumptions:
Assume N and D asserted
for one cycle
Each state has a self loop
for N = D = 0 (no coin)
S1
N
S3
N
S7
[open]
S2
D
S4
[open]
S5
[open]
D
S6
[open]
Reset
0
5
5
N
D
D
10
10
N+D
15
[open]
15
inputs
D
N
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1
next
state
0
5
10
5
10
15
10
15
15
15
output
open
0
0
0
0
0
0
0
0
0
next
D1
0
0
1
0
1
1
1
1
1
state
D0
0
1
0
1
0
1
0
1
1
output
open
0
0
0
0
0
0
0
0
0
Mapping to logic
D1
Q1
X X X X
1 1 1 1
Q0
Q1
Open
0 0 1 0
0 1 1 0
0 0 1 1
0 1 1 1
Q1
D0
1 0 1 1
X X X X
0 0 1 0
0 1 1 1
X X X X
0 0 1 0
Q0
Q0
D1 = Q1 + D + Q0 N
D0 = Q0 N + Q0 N + Q1 N + Q1 D
OPEN = Q1 Q0
One-hot encoding
present state
Q3 Q2 Q1 Q0
0 0 0 1
0 0
0 1
1 0
inputs
D N
0 0
0 1
1 0
1 1
0 0
0 1
1 0
1 1
0 0
0 1
1 0
1 1
- -
next state
D3 D2 D1
0 0 0
0 0 1
0 1 0
- - 0 0 1
0 1 0
1 0 0
- - 0 1 0
1 0 0
1 0 0
- - 1 0 0
output
D0 open
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
D0 = Q0 D N
D1 = Q0 N + Q1 D N
D2 = Q0 D + Q1 N + Q2 D N
D3 = Q1 D + Q2 D + Q2 N + Q3
OPEN = Q3
Moore machine
Reset
0
[0]
Mealy machine
outputs associated with
transitions
N D
N
D
5
[0]
10
[0]
N D
D/0
N D/0
10
N D/0
15
Reset/1
N/0
N D
N+D
15
[1]
N D/0
N/0
N
D
(N D + Reset)/0
Reset/0
D/1
N+D/1
Reset
highway
description
outputs
description
place FSM in initial state
HG, HY, HR assert green/yellow/red highway lights
detect vehicle on the farm road
FG, FY, FR
assert green/yellow/red highway lights
short time interval expired ST
start timing a short or long interval
long time interval expired
description
highway green (farm road red)
highway yellow (farm road red)
farm road green (highway red)
farm road yellow (highway red)
State diagram
Reset
(TLC)'
S0
TLC / ST
S0: HG
S1: HY
TS'
TS / ST
S1
S3
S2: FG
S3: FY
TS / ST
TL+C' / ST
S2
(TL+C')'
TS'
0
1
1
1
0
0
SA1:
SA2:
SA3:
Present State
TS
0
1
0
1
HG
HG
HG
HY
HY
FG
FG
FG
FY
FY
HG = 00
HG = 00
HG = 0001
Next State
HG
HG
HY
HY
FG
FG
FY
FY
FY
HG
HY = 01
HY = 10
HY = 0010
FG = 11
FG = 01
FG = 0100
Outputs
ST H
0
Green
0
Green
1
Green
0
Yellow
1
Yellow
0
Red
1
Red
1
Red
0
Red
1
Red
FY = 10
FY = 11
FY = 1000
F
Red
Red
Red
Red
Red
Green
Green
Green
Yellow
Yellow
(one-hot)
SA1
NS1 = CTL'PS1PS0 + TSPS1'PS0 + TSPS1PS0' + C'PS1PS0 + TLPS1PS0
NS0 = CTLPS1'PS0' + CTL'PS1PS0 + PS1'PS0
ST = CTLPS1'PS0' + TSPS1'PS0 + TSPS1PS0' + C'PS1PS0 + TLPS1PS0
H1 = PS1
H0 = PS1'PS0
F1 = PS1'
F0 = PS1PS0'
SA2
NS1 = CTLPS1' + TS'PS1 + C'PS1'PS0
NS0 = TSPS1PS0' + PS1'PS0 + TS'PS1PS0
H0 = PS1PS0'
F0 = PS1PS0
SA3
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
State minimization(Cont.)
S0
0/0
S1
0/0
Input
Sequence
Next State
Present State X=0
X=1
Output
X=0
X=1
Reset
0
1
00
01
10
11
S0
S1
S2
S3
S4
S5
S6
0
0
0
0
1
0
1
1/0
S2
1/0
0/0
S3
S4
S5
S6
0/0
0/1
0/0
0/1
1/0
1/0
1/0
1/0
1/0
S1
S3
S5
S0
S0
S0
S0
S2
S4
S6
S0
S0
S0
S0
0
0
0
0
0
0
0
State minimization(Cont.)
Next State
Present State X=0
X=1
Output
X=0
X=1
Reset
0
1
00
01
10
11
S0
S1
S2
S3
S4
S5
S6
0
0
0
0
1
0
1
S1
S3
S5
S0
S0
S0
S0
( S0 S1 S2 S3 S4 S5 S6 )
( S0 S1 S2 S3 S5 ) ( S4 S6 )
( S0 S3 S5 ) ( S1 S2 ) ( S4 S6 )
( S0 ) ( S3 S5 ) ( S1 S2 ) ( S4 S6 )
S2
S4
S6
S0
S0
S0
S0
0
0
0
0
0
0
0
S1 is equivalent to S2
S3 is equivalent to S5
S4 is equivalent to S6
State minimization(Cont.)
Minimized FSM
State minimized sequence detector for 010 or
Input
Next State
Output
110
Sequence
Present State X=0
X=1
X=0
X=1
Reset
0+1
X0
X1
S0
X/0
0/0
S1
1/0
S4
S3
X/0
0/1
1/0
S0
S1'
S3'
S4'
S1'
S3'
S0
S0
S1'
S4'
S0
S0
0
0
0
1
0
0
0
0
State minimization(Cont.)
10
00
S0
[1]
01
10
S2
[1]
11
01
10
01
S4
[1]
S3
[0]
11
10
10
00
present
state
S0
S1
S2
S3
S4
S5
11
00 01
01
11
00
10
S1
[0]
11
S5
[0]
01
00
11
00
S0
S0
S1
S1
S0
S1
next state
01 10 11
S1 S2 S3
S3 S1 S4
S3 S2 S4
S0 S4 S5
S1 S2 S5
S4 S0 S5
symbolic state
transition table
output
1
0
1
0
1
0
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
present
state
S0'
S1
S2
S3'
S1
S2
S0-S1
S1-S3
S2-S2
S3-S4
S3
S4
S0-S0
S1-S1
S2-S2
S3-S5
S5
S0
S0-S1
S3-S0
S1-S4
S4-S5
S0-S1
S3-S4
S1-S0
S4-S5
S1
S1-S0
S3-S1
S2-S2
S4-S5
S2
next state
00 01 10 11
S0' S1 S2 S3'
S0' S3' S1 S3'
S1 S3' S2 S0'
S1 S0' S0' S3'
minimized state table
(S0==S4) (S3==S5)
S1-S1
S0-S4
S4-S0
S5-S5
S3
S4
output
1
0
1
0
State minimization(Cont.)
0
1
1
State minimization(Cont.)
00
[0]
01
[1]
11
[0]
X
0
0
0
1
1
1
0
0
1
0
0
1
1
0
1
1
0
1
1
0
0
0
0
0
1
1
0
X
Q1+ = X (Q1 xor Q0)
Q0+ = X Q1 Q0
0
0
0
1
1
1
0
10
[0]
X
00
[0]
X
X
11
[0]
X
01
[1]
X
State assignment
Choose bit vectors to assign to each symbolic state
With n state bits for m states there are 2n! / (2n m)!
[log n <= m <= 2n]
2n codes possible for 1st state, 2n1 for 2nd, 2n2 for 3rd,
State assignment(Cont.)
State assignment(Cont.)
State assignment(Cont.)
Q
a
b
Q+
c
c
O
j
k
a
i/j
c=i*a + i*b
i/k
Q
a
a
Q+
b
c
O
j
l
i/j
b=i *a
c=k*a
k/l
Group
1'sQ in Qoutput
map
+
I
O
i
i
a
c
b
d
j
j
j=i *a+ i *c
b=i*a
d=i*c
c
i/j
i/j
State assignment(Cont.)
State assignment(Cont.)
Output-Based encoding
Reuse outputs as state bits - use outputs to help
distinguish states
Why create new functions for state bits when output can
serve as well
Fits in nicely with synchronous Mealy implementations
Inputs
C
TL
0
0
1
1
1
0
0
Present State
TS
0
1
0
1
HG
HG
HG
HY
HY
FG
FG
FG
FY
FY
HG = ST H1 H0 F1 F0 + ST H1 H0 F1 F0
HY = ST H1 H0 F1 F0 + ST H1 H0 F1 F0
FG = ST H1 H0 F1 F0 + ST H1 H0 F1 F0
HY = ST H1 H0 F1 F0 + ST H1 H0 F1 F0
Next State
HG
HG
HY
HY
FG
FG
FY
FY
FY
HG
Outputs
ST H
0
00
0
00
1
00
0
01
1
01
0
10
1
10
1
10
0
10
1
10
F
10
10
10
10
10
00
00
00
01
01
State assignment(Cont.)
One-hot encoding
Output-based encoding
Ad hoc - no tools
Most common approach taken by human designers
Yields very small circuits for most FSMs
X: 1 1 0 1 1 0 1 0 0 1 0
Z: 0 0 0 0 0 0 0 1 0 0 0
1
S2
[0]
0
S3
[1]
S4
[0]
0
S5
[0]
0
S6
[0]
0 or 1
S1
[0]
...0
S0
[0]
1
...1
...01
0
...010
S2
[0]
S5
[0]
1
S3
[1]
S4
[0]
...100
S6
[0]
0 or 1
reset
S0
[0]
0
0
S1
[0]
...0
...01
0
...010
1
...1
1
1
S3
[1]
S2
[0]
S4
[0]
S5
[0] ...10
...100
S6
[0]
0 or 1
Simulate realization
Verify I/O behavior of your state diagram to ensure it matches
specification
Complex counter
Synchronous 3-bit counter has a mode control M
When M = 0, the counter counts up in the binary sequence
When M = 1, the counter advances through the Gray code
sequence
binary: 000, 001, 010, 011, 100, 101, 110, 111
Gray: 000, 001, 011, 010, 110, 111, 101, 100
Current State
000
001
010
110
111
101
110
Next State
001
010
110
111
101
110
111
Complex counter(Cont.)
reset
S0
[000]
S1
[001]
S2
[010]
0
1
S3
[011]
S4
[100]
S5
[101]
S6
[110]
S7
[111]
TS'
S1a
TS/ST
S1b
S1c
traffic light
controller
ST
TS TL
timer
/ST
FSM 1
FSM 2
CLK
FSM1
Y==0
Y==0
A
[1]
X==0
C
[0]
X==1
Y==1
B
[0]
X==0
FSM2
D
[1]
X==1
X==0
control
status
info and
inputs
state
data-path
control
signal
outputs
"puppet"
Implementation in software
integer combination_lock ( ) {
integer v1, v2, v3;
integer error = 0;
static integer c[3] = 3, 4, 2;
while (!new_value( ));
v1 = read_value( );
if (v1 != c[1]) then error = 1;
while (!new_value( ));
v2 = read_value( );
if (v2 != c[2]) then error = 1;
while (!new_value( ));
v3 = read_value( );
if (v2 != c[3]) then error = 1;
if (error == 1) then return(0); else return (1);
}
value
reset
clock
open/closed
closed
not new
C1=value
& new
S2
closed
not new
C2=value
& new
ERR
closed
C2!=value
& new
S3
closed
not new
C3!=value
& new
C3=value
& new
OPEN
open
Control
C2
4
new
C3
4
multiplexer
mux
control
4
value
comparator
reset
controller
clock
equal
open/closed
new
0
1
1
equal
0
1
state
S1
S1
S1
next
state
S1
S1
ERR
S2
mux
C1
C1
C2
open/closed
closed
closed
closed
closed
S3
OPEN
open
controller
new
0
1
1
equal
0
1
state
0001
0001
0001
0100
1000
reset
mux
control
next
state
0001
0001
0000
0010
new
equal
clock
open/closed
mux
001
001
010
open/closed
0
mux is identical to last 3 bits of state
0
open/closed is identical to first bit of state
0
therefore, we do not even need to implement
0
FFs to hold state, just use outputs
Design
A single input X single output Z synchronous sequential
circuit will give a 1 output when the input sequence starting
from reset up to present time includes odd number of 1s,
otherwise the circuit will give a 0 output.
Design a clock synchronous sequential circuit with two inputs
A, B and a single output Z that is 1 if:
A had the same value at each of the two previous clock
ticks, or
B has been 1 since the last time that the first condition
was true.
Otherwise, output should be 0.
Digital design
Other flip-flop types
For actual use, see Reading Supplement Design and Analysis Using J-K and T Flip-Flops
J-K flip-flop
Behavior
J-K flip-flop(Cont.)
Symbol
Implementation
To avoid 1s catching
behavior, one solution
used is to use an
edge-triggered D as
the core of the flip-flop
J
K
T flip-flop
Behavior
Has a single input T
For T = 0, no change to state
For T = 1, changes to opposite state
T flip-flop(Cont.)
Implementation
To avoid 1s catching
behavior, one solution
used is to use an
edge-triggered D as
the core of the flip-flop
Symbol
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)
0
1
0
1
Operation
Reset
Set
Characteristic Equation
Q(t+1) = D
Excitation Table
Q(t +1)
Operation
0
1
0
1
Reset
Set
T flip-flop descriptors
Characteristic Table
T
Q(t + 1)
Operation
Q ( t)
No change
Q ( t)
Complement
Characteristic Equation
Q(t+1) = T Q
Excitation Table
Q(t +1)
Operation
Q ( t)
No change
Q ( t)
Complement
S R
Q(t + 1)
Operation
0 0
0 1
1 0
Q ( t)
0
1
No change
Reset
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
1
0
1
0
0 X
1 0
0 1
No change
Set
Reset
X 0
No change
J K
Characteristic Equation
Q(t+1) = J Q + K Q
Excitation Table
Q(t)
0
0
1
1
0
0
1
1
0
1
0
1
Q(t + 1)
Q ( t)
0
1
Q ( t)
Q(t + 1) J K
0
1
0
1
0
1
X
X
X
X
1
0
Operation
No change
Reset
Set
Complement
Operation
No change
Set
Reset
No Change
Flip-flop behavior
Use the characteristic tables to find the output waveforms for the flipflops shown:
Clock
D,T
Flip-flop behavior(Cont.)
Use the characteristic tables to find the output waveforms for the flipflops shown:
Clock
S,J
R,K
S QSR
R
J QJK
K
T = D Q + D Q
D
D
Q
Q
Q+
00
JK
00
01
01
11
11
10
10
D
0
D = J Q + K Q
D
K
Q
Q
Q
JK
00
JK
00
01
01
11
11
10
10
JK
Q+
00
01
10
11
T = J Q + K Q
T
K
Q+
Q
Q
Q Q+
00
01
10
11
Q
T
J=T
K=T
thanks
digital design