Download Sequential Circuit Design - Lecture Slides | CS 231 and more Assignments Computer Architecture and Organization in PDF only on Docsity!
Sequential circuit design
Sequential circuit design
Now let’s reverse the process: In
sequential circuit design
, we turn
some description into a working circuit.
We first make a state table or diagram to express the computation.
Then we can turn that table or diagram into a sequential circuit.
Sequential circuit design
Sequence recognizers
A
sequence recognizer
is a special kind of sequential circuit that looks
for a special bit pattern in some input.
The recognizer circuit has only one input, X.
One bit of input is supplied on every clock cycle. For example, itwould take 20 cycles to scan a 20-bit input.
This is an easy way to permit arbitrarily long input sequences.
There is one output, Z, which is 1 when the desired pattern is found.
Our example will detect the bit pattern “1001”:
Inputs:
Outputs:
Here, one input and one output bit appear every clock cycle.
This requires a sequential circuit because the circuit has to “remember”the inputs from previous clock cycles, in order to determine whether ornot a match was found.
Sequential circuit design
Step 1: Making a state table
The first thing you have to figure out is precisely how the use of statewill help you solve the given problem.
Make a state table based on the problem statement. The tableshould show the present states, inputs, next states and outputs.
Sometimes it is easier to first find a state diagram and thenconvert that to a table.
This is usually the most difficult step. Once you have the state table,the rest of the design procedure is the same for all sequential circuits.
Sequence recognizers are especially hard! They’re the hardest examplewe’ll see in this class, so if you understand this you’re in good shape.
Sequential circuit design
A basic state diagram
What state do we need for the sequence recognizer?
We have to “remember” inputs from previous clock cycles.
For example, if the previous three inputs were 100 and the currentinput is 1, then the output should be 1.
In general, we will have to remember occurrences of parts of thedesired pattern—in this case, 1, 10, and 100.
We’ll start with a basic state diagram:
A
B
C
D
State
Meaning
A
None of the desired pattern (1001) has been input yet.
B
We’ve already seen the first bit (1) of the desired pattern.
C
We’ve already seen the first two bits (10) of the desired pattern.
D
We’ve already seen the first three bits (100) of the desired pattern.
Sequential circuit design
Filling in the other arrows
Remember that we need
two
outgoing arrows for each node, to account
for the possibilities of X=0 and X=1.
The remaining arrows we need are shown in blue. They also allow for thecorrect detection of overlapping occurrences of 1001.
A
B
C
D
State
Meaning
A
None of the desired pattern (1001) has been input yet.
B
We’ve already seen the first bit (1) of the desired pattern.
C
We’ve already seen the first two bits (10) of the desired pattern.
D
We’ve already seen the first three bits (100) of the desired pattern.
Sequential circuit design
Finally, making the state table
A
B
C
D
Present
State
Input
Next State
Output
A
A
A
B
B
C
B
B
C
D
C
B
D
A
D
B
input/output
present
state
next state
Remember how the state diagramarrows correspond to rows of thestate table:
Sequential circuit design
Present
State
Input
Next State
Output
A
A
A
B
B
C
B
B
C
D
C
B
D
A
D
B
Step 2: Assigning binary codes to states
Present
State
Input
Next State
Output
Q
1
Q
0
X
Q
1
Q
0
Z
We have four states ABCD, so we need at least two flip-flops Q
1
Q
0
The easiest thing to do is represent state A with Q
1
Q
0
= 00, B with 01,
C with 10, and D with 11.
The state assignment can have a big impact on circuit complexity, butwe won’t worry about that too much in this class.
Sequential circuit design
Step 3: Finding flip-flop input values
Present
State
Input
Next State
Flip flop inputs
Output
Q
1
Q
0
X
Q
1
Q
0
J
1
K
1
J
0
K
0
Z
Next we have to figure out how to actually make the flip-flops changefrom their present state into the desired next state.
This depends on what kind of flip-flops you use!
We’ll use two JKs. For each flip-flip Q
i
, look at its present and next
states, and determine what the inputs J
i
and K
i
should be in order to
make that state change.
Sequential circuit design
JK excitation table
An
excitation table
shows what flip-flop inputs are required in order to
make a desired state change.
This is the same information that’s given in the characteristic table,but presented “backwards.”
J
K
Q(t+1)
Operation
Q(t)
No change
Reset
Set
Q’(t)
Complement
Q(t)
Q(t+1)
J
K
Operation
x
No change/reset
x
Set/complement
x
Reset/complement
x
No change/set
Sequential circuit design
Excitation tables for all flip-flops
Q(t)
Q(t+1)
J
K
Operation
x
No change/reset
x
Set/complement
x
Reset/complement
x
No change/set
Q(t)
Q(t+1)
D
Operation
Reset
Set
Reset
Set
Q(t)
Q(t+1)
T
Operation
No change
Complement
Complement
No change
Sequential circuit design
Back to the example
Present
State
Input
Next State
Flip flop inputs
Output
Q
1
Q
0
X
Q
1
Q
0
J
1
K
1
J
0
K
0
Z
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
We can now use the JK excitation table onthe right to find the correct values for
each
flip-flop’s inputs, based on its present andnext states.
Q(t)
Q(t+1)
J
K
x
x
x
x
Sequential circuit design
Now you can make K-maps and find equations for each of the four flip-flop inputs, as well as for the output Z.
These equations are in terms of the present state and the inputs.
The advantage of using JK flip-flops is that there are many don’t careconditions, which can result in simpler MSP equations.
J
1
= X’ Q
0
K
1
= X + Q
0
J
0
= X + Q
1
K
0
= X’
Z = Q
1
Q
0
X
Step 4: Find equations for the FF inputs and output
Present
State
Input
Next State
Flip flop inputs
Output
Q
1
Q
0
X
Q
1
Q
0
J
1
K
1
J
0
K
0
Z
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
Sequential circuit design
Step 5: Build the circuit
Lastly, we use these simplified equations to build the completedcircuit.
J
1
= X’ Q
0
K
1
= X + Q
0
J
0
= X + Q
1
K
0
= X’
Z = Q
1
Q
0
X
Sequential circuit design
Timing diagram
Here is one example timing diagram for our sequence detector.
The flip-flops Q
1
Q
0
start in the initial state, 00.
On the first three positive clock edges, X is 1, 0, and 0. Theseinputs cause Q
1
Q
0
to change, so after the third edge Q
1
Q
0
Then when X=1, Z becomes 1 also, meaning that 1001 was found.
The output Z does not have to change at positive clock edges. Instead,it may change whenever X changes, since Z = Q
1
Q
0
X.
CLK
Q
1
Q
0
X Z