332:437 Lecture 13 FSM Asynchronous Inputs, Clocks, and Hazards

Download Report

Transcript 332:437 Lecture 13 FSM Asynchronous Inputs, Clocks, and Hazards

332:437 Lecture 13
FSM Asynchronous Inputs, Clocks,
and Hazards








5/22/2016
Asynchronous inputs
Clock distribution
Counters
State reduction
Synchronizing Sequences
Races and Hazards
One-Hot Design
Summary
Bushnell: Digital Systems
Design Lecture 13
1
Material from An Engineering Approach to Digital Design, by
William I. Fletcher, Prentice-Hall Inc.
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
2
Asynchronous Inputs to FlipFlops – Big Problem



Asynchronous input changes may cause flip-flop
values to change immediately
Differing gate propagation delays may cause
machine to enter wrong state
Timing requirements for positive edge-triggered
flip-flops 1
tlow
C
D
0
1
0
thigh
tsetup thold
D must
be fixed here
D may change here
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
3
Runt Pulse


Logic gate inputs – pulse must have minimum
width to cause gate output to change
Very short pulses do not cause output to change,
but could cause a blip on gate output much later
after a randomly-chosen Dt
1
1
0
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
4
Maximum Clock Frequency


Determined by setup and hold time on flip-flops
Necessary relationships
 Tclock  thigh + tlow
tclock
C
1
0
thigh
tff

tlow
tcomb
tsetup
Tclock  tff + tcomb + tsetup
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
5
Clock Skew


Very big problem in all electronics systems
Caused by unequal wire length or gate delays
D1 Q1
x
C Q1
C1
CLK
tff
C1
C2
1
0
y1
D2 Q2
C2
y2
C Q2
delay
t
td
td
1
0
5/22/2016
thold
Bushnell: Digital Systems
Design Lecture 13
6
New Clock Skew Constraints



td + thold  tff (min)
Minimum flip-flop delay
So td  tff (min) – thold
Solutions:
1. Never Gate the Clock! Violated all the time
by VLSI designers to save circuit power
2. Introduce matched delay l on clock line to C1
3. Design clock wiring so that same wire length
exists from clock source to all flip-flops (Htree)
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
7
Example H-Tree

Most of VLSI circuit signal propagation delay is
caused by the wiring
 Same distance from clock source to all X’s
CLK
Chip
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
8
Counters







Repeat a state after some number, N, of clock
pulses
Mod N – remainder after dividing by N
If counter in state n after m clock pulses, will be
in state n after m + N, m + 2N, … pulses
States assigned as 0 to 2N – 1
Binary Up Counter – sequence 0 to 2N – 1
Binary down counter – reversed up counter
sequence
Decade up counter – 0, 1, 2, …, 10n – 1, 0, 1, 2
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
9
Ripple Counter – 4-bit Binary
A0
1 J Q
0
0
CLK
C
1 K0
5/22/2016
A2
A1
1 J Q
1
1
C
1 K1
1 J Q
2
2
C
1 K
2
Bushnell: Digital Systems
Design Lecture 13
A3
1
1
J3 Q3
C
K3
10
Counter Timing Behavior
CLK
A0 0
1
0
1
0
1
0
1
0
0
1
t
1
0
0
1
1
0
A2 0
0
0
0
1
1
1
0
A3 0
0
0
0
1
t
0
0
0
0
1
t
A1 0
t
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
11
Counter Categories
ripple (asynchronous)
binary
octal
decimal
special
synchronous ripple carry
parallel carry
 To make a counter decimal:
From count 1001 go to 0000
Right after we enter 1010 state
Q1
Q3
up
down
up/down
000
Reset
NOT USED because of gate races &
unpredictable counting results
• Considered to be a poor design
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
12
Up/Down Control


Change direction:
1. Use Q side to drive next clock
2. Use Q signals as counter outputs
3. Change negative edge to positive edge flipflops
Problems:
1. Very Slow
2. Varying gate & flip-flop delays can cause
malfunctions
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
13
Better (More Reliable)
Counters

1.
2.
3.
Synchronous
All clocks connected in parallel
Faster
Operation Mode: Whenever all least significant
bits are 1, next digit must change
0000
0001
0010
Use T flip-flops
0011
0100
…
Bushnell: Digital Systems
5/22/2016
Design Lecture 13
14
Parallel Carry Generation

Counts only when both EnableP & EnableT are 1
EnableP
RCO
T0Q0
EnableT
C
CLR
/CLR
T1Q1
C
CLR
T2Q2
C
CLR
T3Q3
C
CLR
CLK
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
15
Synchronous Counter with
Ripple Carry

EnableP
4 Gate delays for output carry generation as
opposed to 1 gate delay
T0Q0
EnableT
C
CLR
/CLR
T1Q1
C
CLR
T2Q2
C
CLR
RCO
T3Q3
C
CLR
CLK
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
16
Shift Registers


Types:
1. Serial-in, serial-out
2. Serial-in, parallel-out
3. Parallel-in, parallel-out
4. Bidirectional parallel-in, parallel-out
Use a barrel shifter whenever possible:
1. Less hardware
2. Faster
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
17
Reduction of Finite State
Machines


Method:
 Try all possible input sequences & note
differences in output sequences
• Note non-equivalent states
x
z
Example Mealy machine: 0
1
1
0
A
0
A B
0
C
0
B D
0
B
0
C E
0
F
0
D E
0
F
0
E D
0
1
F C D/1 0
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
18
Problems of State Partitioning


Cannot just look for identical rows in State
Transition Table
Frequently, the machine cycles between three or
more states that are actually equivalent, but the
rows in the State Transition Table for these 3
states do not look the same
 Therefore, just looking for identical rows
causes you to miss equivalent states
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
19
State Reduction by Method of
Partitions



First partition – all states
P0: (ABCDEF)
 Apply X = 0 – No difference in behavior
 Apply X = 1 – If in F, output is 1, otherwise
output is 0
• Leads to second partition
P1: (ABCDE) (F)
 Apply X = 0 to ABCDE – no output difference
 Apply X = 1 to ABCDE – If in ABC, stay in
ABCDE partition, if in DE, go into another
partition (F)
• Leads to third partition
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
20
Method of Partitions
(concluded)



P2: (ABC) (DE) (F)
 Apply X = 0 to ABC – If in A, stay in ABC, if in
BC, go to DE
• Leads to fourth partition
P3: (A) (BC) (DE) (F)
 Apply X = 0 to BC – goes to DE
 Apply X = 1 to BC – stays in BC
 Apply X = 0 to DE – stays in DE
 Apply X = 1 to DE – goes to F
• No further partitioning possible
Also works for Moore Machines
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
21
Synchronizing Sequences


Input sequence that causes a Finite State
Machine to be in a specified state, regardless of
its initial state at the beginning of the sequence
Example:
X
0 1
A A B
B C B
C B B
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
22
Example

Ambiguity Tree finds synchronizing sequences
 Implicitly computes differences in state
ABC
behavior
0
1
0
ABC
0
1
ABC
B
5/22/2016
ABC
1
0
C
B
0
1
B
0
B
C
B
1
1
0
B
Bushnell: Digital Systems
Design Lecture 13
C
B
1
B
23
Synchronizing Sequences




Exist for B & C but not for A
State
Shortest Synchronizing Sequence
B
1
C
10
Not all sequences are synchronizing sequences –
e.g., 00
If a Synchronizing Sequence Exists for State Si,
then it exists for all States Sj reachable from
state Si
Strongly Connected Finite State Machine
 All states reachable from every state
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
24
Search of Ambiguity Tree



Want to find SHORTEST synchronizing sequence
for each state, so:
 Search tree in a breadth-first manner
Labels in tree are called the ambiguity – indicate
the uncertainty about which state the machine is
in
Once you have explored the tree for a given
ambiguity
 If you encounter the same ambiguity again,
you need not search it, as you will get the
same answer you got last time you explored it
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
25
Synchronizing Sequences



If  Synchronizing Sequence, then for a FSM
to be strongly connected, we must have a
synchronizing sequence for all states
Must first reduce FSM to find the shortest
synchronizing sequence
Finite Memory Span: FSM has finite memory
span of length K if:
1. All input sequences  K are synchronizing
sequences
2. Each state can be reached by a
synchronizing sequence of length  K
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
26
Example

Reduce:
 P0: (ABCD)
 P1: (ABD) (C)
 P2: (AD) (B) (C)
 P3: (AD) (B) (C)
5/22/2016
A
B
C
D
0
B
B
B
B
Bushnell: Digital Systems
Design Lecture 13
1
A
C
D/1
D
27
Reduced Machine
A
B
C



0
B
B
B
1
A
C
A/1
ABC
0
1
B
0
B
AC
1
C
0
B
1
A
Use synchronizing sequences as state
assignments: B = 00 or 10, C = 01, A = 11
Use D flip-flops
Get a shift register realization of machine
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
28
Coded State Transition Table
State
B
C
A
B

May be an
inexpensive
realization
State
Assignment
00
01
11
10
x
CLK
5/22/2016
X
0
X0/0
X0/0
X0/0
X0/0
1
01/0
11/1
11/0
01/0
D2 Q2
D1 Q1
C Q2
C Q1
Bushnell: Digital Systems
Design Lecture 13
z
29
Races and Hazards




Z-hazard – a glitch on a state machine output
Race – change of more than one Flip-Flop
required by State Transition Table
 Example: going from state 10 to 01
Non-critical race – correct operation occurs no
matter which Flip-Flop changes first
Critical race – possible to make a mistake and
end up in the wrong state when the wrong FlipFlop changes first
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
30
Static and Dynamic Hazards



Static Hazard – Momentary transient in output signal that
should have remained static in response to input change
 Exists whenever there are adjacent input combinations
in K-Map with same output & no map sub–code covers
both combinations
 Generally, 1
0 transition causes hazard
Dynamic Hazard – Multiple momentary transient in output
signal that should have changed only once in response to
input change
Essential Hazard -- Operational error causing transition to
improper state in response to input changes, caused by
excessive delay on feedback variable in response to input
change
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
31
Hazard Examples
Static
Dynamic
Input
Output
1.
2.
3.
4.
Caused by circuit delays, which are randomly
distributed during chip manufacturing
Essential hazards exist only in sequential
circuits with 2+ feedbacks
Result from a combination of both delay &
design specifications
Can be controlled by adjusting the state
assignment
 Requires understanding of asynchronous
circuit design
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
32
Static Hazards



Theorem: A static 0 (1) hazard exists if there is a pair of
adjacent states with 0 (1) outputs and there is no 0 (1)
set that covers both
No static hazards in network if:
1.
There is a 1 (0) set that covers every adjacent input
state having an output of 1 (0)
2.
There are no 1 (0) sets containing exactly 1 pair of
complemented literals
Essential Hazard – a property of the circuit input/output
behavior
1.
No way to eliminate it
2.
There will be some combination of circuit delays will
cause a glitch, no matter how you realize the circuit
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
33
Static Hazard Example
c

ab
0
1
00 01
0
1
0
1
11
1
0
10
1
0
Static Hazard due to transition between 2
implicants not being covered in the Karnaugh
map
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
34
Static Hazard Example
z
0
1



xy
00 01 11 10
0
0 0
1
1
1 0
1
Hazard-free SOP realization
 SOP is hazard-free, here, provided that we do
not factor it
Hazard in POS
Tradeoff between simplicity of design and
hazard-free operation
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
35
SOP and POS Realizations
x
z
x
y
z
z
x
y


T
x
y
1
O
2
When y = 1, z = 0, x 0
1, and Gate 1 is faster
than Gate 2 in the POS realization, there is a
Hazard in the POS realization
SOP is hazard-free, here, provided that we do
not factor it
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
36
Shift Register Implementation
of State Machines


Possible if synchronizing sequence exists for all
states and synchronizing sequence is used as
state assignment
Example:
X
a/0
b/0
State Assignment:
X
a 1000
X
b 0100
X
c 0010
d/1
c/0
d 0001
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
37
Realization
D1 Q1
D2 Q2
D3 Q3
D4 Q4
C Q1
C Q2
C Q3
C Q4
OUTPUT
CLOCK
INIT
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
38
Moebius (Johnson) Counter
A shift register whose rightmost bit is inverted
and fed back into its leftmost bit
 Leads to very efficient state machine
realization

CLOCK
INIT
5/22/2016
D1 Q1
D2 Q2
C Q1
C Q2
OUTPUT
State Assignment:
a 00
b 10
c 11
d 01
Bushnell: Digital Systems
Design Lecture 13
39
One-Hot Design




Use 1 D Flip-Flop (FF) for each state, only 1 D FF
set to 1 at any given time
Advantage: Look at appropriate D FF to see if
the machine is in the corresponding state
 Grossly simplifies output decoder
Disadvantage: In a mprocessor, could lead to
billions of FFs
 Leads to huge amounts of hardware and an
untestable machine
Use this method ONLY for relatively simple
machines
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
40
One-Hot Design of Prior
Example
0/0
1
1/0
5/22/2016
0/0
2
0/0
0/0
1/0
3
1/0
4
1/0
5
1/1
0/0
Bushnell: Digital Systems
Design Lecture 13
41
State Transition Table
X
State
1
2
3
4
5
5/22/2016
0
2/0
2/0
2/0
2/0
2/0
1
1/0
3/0
4/0
5/0
5/1

State Assignment:
1 10000
2 01000
3 00100
4 00010
5 00001
Bushnell: Digital Systems
Design Lecture 13
42
Example (continued)
Code
D1D2D3D4D5
10000
01000
00100
00010
00001

X
0
1
State
01000/0 10000/0
1
01000/0 00100/0
2
01000/0 00010/0
3
01000/0 00001/0
4
01000/0 00001/1
5
Read out equations from Coded Table:
D1 = XQ1
Z = XQ5
D2 = X
D3 = XQ2
D4 = XQ3
D5 = XQ4 + XQ5 = X (Q4 + Q5)
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
43
Logic Gate Realization
x
D1 Q1
D2 Q2
D3 Q3
D4 Q4
D5 Q5
C Q1
C Q2
C Q3
C Q4
C Q5
CLOCK
INIT
x
5/22/2016
Bushnell: Digital Systems
Design Lecture 13
z
44
Summary







5/22/2016
Asynchronous inputs
Clock distribution
Counters
State reduction
Synchronizing Sequences
Races and Hazards
One-Hot Design
Bushnell: Digital Systems
Design Lecture 13
45