21 races and state assignment
TRANSCRIPT
-
7/28/2019 21 Races and State Assignment
1/22
ECE124 Digital Circuits and Systems Page 1
Race Conditions; Critical and Non-Critical Races
A race condition occurs in an asynchronous circuit when 2 or more state variables
change in response to a change in the value of a circuit input.
Unequal circuit delays may imply that the 2 or more state variables may not changesimultaneously this can cause a problem.
Assume two state variables change
If the circuit reaches the same final, stable state regardless of the order in whichthe state variables change, then the race in non-critical.
If the circuit reaches a different final, stable state depending on the order inwhich the state variables change, then the race is critical.
We need to avoid critical races for predictability and to ensure our circuit does theintended function!
-
7/28/2019 21 Races and State Assignment
2/22
ECE124 Digital Circuits and Systems Page 2
Non-Critical Race
Assume current state is 00, and input changes from 0->1. This requires y1y2 to change
from 00->11.
Depending on circuit delays, several possible transition sequences:
00 -> 11 -> 01 (simultaneous change for y1 and y2).
00 -> 01 (y2 changes first).
00 -> 10 -> 11 -> 01 (y1 changes first)
In all cases, we end up in the same stable state, so the race is non-critical.
00
0 1
00
01
y1y2
curr
state
11
x
11
10
00
01
00
00
01
11
-
7/28/2019 21 Races and State Assignment
3/22
ECE124 Digital Circuits and Systems Page 3
Critical Race
Assume current state is 00, and input changes from 0->1. This requires y1y2 to change
from 00->11.
Possible transition sequences:
00->11 (y1 and y2 change simultaneously)
00->01->11 (y2 changes first)
00->10 (y1 changes first)
So, depending on which state variable changes first, we can get into a differentstable
statethe race is critical.
00
0 1
00
01
y1y2
curr
state
11
x
11
10
00
11
00
00
11
10
-
7/28/2019 21 Races and State Assignment
4/22
ECE124 Digital Circuits and Systems Page 4
Why Races Exist
Races are a consequence of how states are assigned when designing a circuit.
That is, races exist in the transition tables, but not in the flow tables.
This should be somewhat clear.
Races are a consequence of state variables changing at the same time andtherefore cant happen until binary state assignment is done.
Flow tables are entirely symbolic, so no problems there
Transition tables have binary values assigned, so potential problems there
-
7/28/2019 21 Races and State Assignment
5/22
ECE124 Digital Circuits and Systems Page 5
Stability and Cycles
We also need to be careful that our circuit does not become unstable.
Assume current state is 00, and input changes from 0->1. This requires y1y2 to change
from 00->01.
Transitions will be 00->01->11->10->01-> So, our circuit oscillates. If this was not ourintention, we are in trouble.
Should have a stable state for each input condition and make sure we get to a stable
state always.
00
0 1
0001
y1y2
curr
state
01
x
11
10
0011
00
00
10
01
-
7/28/2019 21 Races and State Assignment
6/22
ECE124 Digital Circuits and Systems Page 6
Race Free State Assignment
We can prevent races (pre-emptive) by performing state assignment such that
transitions from one stable state to another stable state only require one state
variable to change at a time.
Can consider a few different methods for performing race-free state assignment.
-
7/28/2019 21 Races and State Assignment
7/22
ECE124 Digital Circuits and Systems Page 7
Example
Consider an example flow table
curr
state
next state
x=0 x=1
ab
c
d
ac
c
a
bb
d
d
-
7/28/2019 21 Races and State Assignment
8/22
ECE124 Digital Circuits and Systems Page 8
Example Transition Diagram
Build a transition diagram that shows transitions from one stable state to another
stable state under a changing input.
Each edgeshows a possible transition. Each node represents a state.
curr
state
next state
x=0 x=1
a
b
c
d
a
c
c
a
b
b
d
d
c
a b
d
-
7/28/2019 21 Races and State Assignment
9/22
ECE124 Digital Circuits and Systems Page 9
Example State Assignment (A Bad Choice)
Consider assigning binary patterns to states based on the co-ordinates of the state
in the transition diagram:
c
a b
d
00 01
10 11
This is a BAD assignment, since a transition from b->c or d->a requires two state
variables to change simultaneously.
-
7/28/2019 21 Races and State Assignment
10/22
ECE124 Digital Circuits and Systems Page 10
Example State Assignment (A Good Choice)
Consider shifting states to different co-ordinates:
c
a b
d
This is a GOOD assignment, since a transition from b->c or d->a requires only one state
variables to change.
d
a b
c
00 01
10 11
-
7/28/2019 21 Races and State Assignment
11/22
ECE124 Digital Circuits and Systems Page 11
Method One for Race Free State Assignment
Given a flow table, try and embed the symbolic states into the co-ordinates of a n-
dimensional cube such that the path from stable state to stable state:
Is direct along a single edge of the cube, or
Goes through newly introduced unstable states along edges of the cube.
-
7/28/2019 21 Races and State Assignment
12/22
ECE124 Digital Circuits and Systems Page 12
Example
Consider the following flow table:
curr
state
next state
x1x2=00 x1x2=01
ab
c
d
aa
c
c
ab
b
a
x1x2=10 x1x2=11
cd
c
d
bb
d
d
-
7/28/2019 21 Races and State Assignment
13/22
ECE124 Digital Circuits and Systems Page 13
Example Transition Diagram
We can attempt to embed 4 states into a 2-dimensional cube and draw the transition
diagram:
curr
state
next state
x1x2=00 x1x2=01
a
bc
d
a
ac
c
a
bb
a
x1x2=10 x1x2=11
c
dc
d
b
bd
d
If we try, we see that there is no way to re-arrange the states to the corners of thecube to get rid of the diagonals in the transition diagram
No state assignment that has only one state variable changing at a time.
c
a b
d
-
7/28/2019 21 Races and State Assignment
14/22
ECE124 Digital Circuits and Systems Page 14
Example Transition Diagram
Solution is to introduce additional, unstable states and use them as intermediate
states during transitions.
I.e., embed the 4-states into the corners of a 3-dimensional cube.
c
a b
d
a b
d
c
e
g
f
-
7/28/2019 21 Races and State Assignment
15/22
ECE124 Digital Circuits and Systems Page 15
Example Transition Diagram
All transitions are made properly by introducing extra unstable states (Note: the
new extra states are always unstable!!!):
a b
d
c
e
g
f
000 001
010
100
110
011
101
-
7/28/2019 21 Races and State Assignment
16/22
ECE124 Digital Circuits and Systems Page 16
Example Race Free Flow Table
Can now see the original flow table, and an expanded flow table (extra unstable
states) that has a race-free state assignment (see previous page!):
curr
state
next state
x1x2=00 x1x2=01
a
b
c
d
a
a
c
c
a
b
b
a
x1x2=10 x1x2=11
c
d
c
d
b
b
d
d
curr
state
next state
x1x2=00 x1x2=01
a
b
c
d
a
a
c
g
a
b
b
a
x1x2=10 x1x2=11
c
e
c
d
b
b
g
d
e - - d -
f - b - -
g c - - d
-
7/28/2019 21 Races and State Assignment
17/22
ECE124 Digital Circuits and Systems Page 17
Method Two for Race Free State Assignment
Method useful for flow tables with
-
7/28/2019 21 Races and State Assignment
18/22
ECE124 Digital Circuits and Systems Page 18
Example
Consider the following flow table, and another (larger table) with equivalent states:
curr
state
next state
x1x2=00 x1x2=01
a
b
c
d
a
a
c
c
a
b
b
a
x1x2=10 x1x2=11
c
d
c
d
b
b
d
d
output
0
1
0
1
curr
state
next state
x1x2=00 x1x2=01 x1x2=10 x1x2=11output
d1 c1 d2 d1 d1 1
d2 c2 d1 d2 d2 1
c1 c1 c2 c1 d1 0
c2 c2 b1 c2 d2 0
b1 a1 b1 b2 b1 1
b2 a2 b2 d2 b2 1
a1 a1 a1 c1 b1 0
a2 a2 a2 a1 b2 0
The flow table with equivalent states permits a race free state assignment.
We can see this by looking at the states on a 3-dimensional cube.
-
7/28/2019 21 Races and State Assignment
19/22
ECE124 Digital Circuits and Systems Page 19
Example
curr
state
next state
x1x2=00 x1x2=01 x1x2=10 x1x2=11output
d1 c1 d2 d1 d1 1
d2 c2 d1 d2 d2 1
c1 c1 c2 c1 d1 0
c2 c2 b1 c2 d2 0
b1 a1 b1 b2 b1 1
b2 a2 b2 d2 b2 1
a1 a1 a1 c1 b1 0
a2 a2 a2 a1 b2 0
With equivalent states, we always have 1 of the 2 equivalent states directly adjacent
to every other state!
a1 a2
b1
c1
b2
d1
c2 d2
-
7/28/2019 21 Races and State Assignment
20/22
ECE124 Digital Circuits and Systems Page 20
Method Three for Race Free State Assignment
Can use the idea of one-hot encoding to get a race free state assignment
Given n-states, let the i-th state be encoded as 0010..0 where the 1 is in the i-th
location.
For a transition from i-th stable state to j-th stable state, introduce unstable state with
encoding 0..010..010..0 where the 1s are in the i-th and j-th position.
Again, best illustrated with an example
-
7/28/2019 21 Races and State Assignment
21/22
ECE124 Digital Circuits and Systems Page 21
Example
Consider the following flow table, with one-hot state assignment:
curr
state
next state
x1x2=00 x1x2=01
a
b
c
d
a
a
c
c
a
b
b
a
x1x2=10 x1x2=11
c
d
c
d
b
b
d
d
0001
0010
0100
1000
Look for transitions and introduce new unstable states, as required using one-hot
encoding scheme.
-
7/28/2019 21 Races and State Assignment
22/22
ECE124 Digital Circuits and Systems Page 22
Example
currstate
next state
x1x2=00 x1x2=01
a
b
c
d
a
a
c
c
a
b
b
a
x1x2=10 x1x2=11
c
d
c
d
b
b
d
d
0001
0010
0100
1000
curr
state
next state
x1x2=00 x1x2=01
a
b
c
d
a
f
c
c
a
b
h
j
x1x2=10 x1x2=11
e
g
c
d
f
b
i
d
0001
0010
0100
1000e - - c -0101
f a - - b0011
g - - d -1010
h - b - -0110
i c - - d1100
i - a - -1001