CENG 5133: Computer Architecture Design: Sequential Circuits
CENG 5133: Computer Architecture Design: Sequential Circuits
Introduction
Circuits:
Combinational Circuit
Sequential Circuit
CENG 5133
General Models for Sequential Circuits General Model for Mealy Circuits
General Form:
A sequential circuit can be divided conveniently into two parts
- the flip-flops (which serve as memory) and combinational
logic which realizes the input and output functions.
The combinational logic may be implemented with gates, with
a ROM, or with a PLA.
3 4
The combinational circuit realizes the n output functions and the k Determining Minimum Clock Period:
next-state functions, which serve as inputs to the D flip-flops: The minimum clock period is:
5 6
7 8
9 10
Design the sequence detector so that any input First, we will draw the state graph based on problem
sequence ending in 101 will produce an output Z=1. description
The circuit does not reset when a 1 output occurs. A
typical input sequence and the corresponding output Initially, we do not know how many flip-flops will be
sequence are: required.
So we will designate the circuit states as S0, S1, etc.
We will start with a reset state (initial state) designated as
X= 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 0
S 0.
Z= 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 (14-1)
(time: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
11 12
If X=0, the circuit stays in S0 because the input sequence When in state S1, if X=0, the circuit must change to a new
does not start with a 0. state (S2) to remember that the first two inputs of the
If X=1, the circuit must go to a new state (S1) to desired sequence (101) have been received.
“remember” that the first input in the desired sequence
has been received.
13 14
If X=1 in state S2, the desired input sequence (101) is If X=1 in state S1, we can stay in S1
complete and the output should be 1. The sequence is simply restarted
Since the last 1 in a sequence can also be the first 1 in a If X=0 in state S2, reset the circuit to S0
new sequence, we should return to S1. Two 0’s in a row are received and 00 is not part of ‘101’
15 16
We can then convert our state graph to a state table: Now we convert our state table into a transition table:
From the transition table, we can plot Now we can draw the circuit corresponding to the
The next-state maps for the flip-flops and equations:
The map for the output function Z
19 20
21 22
When the machine is in S2 and input is 1, the output must Completed graph is below:
become 1; therefore, it cannot go S1 and we need a new The sequence 100 resets the circuit to S0.
state S3 with a 1 output: A sequence 1010 takes the circuit back to S2 because another 1
input should cause Z to become 1 again.
23 24
25 26
Mealy Example
We will start construction of the state graph by working First Sequence: “010”
with the two sequences which lead to a 1 output.
Then, we will later add arrows and states as required to
make sure that the output is correct for other cases.
27 28
Next, we construct the part of the graph corresponding to Now we fill in the missing arcs
the sequence 1001, starting from the reset state S0. With each arc, we first ask if we can go back to one of the
previous states or do we have to create a new state?
Moore Example
Design a Moore sequential circuit with one input X and
one output Z.
The output Z is to be 1 if the total number of 1’s received
is odd and at least two consecutive 0’s have been
received.
31 32
33 34
35 36
37 38
4. Another way to get started is to determine what 6. Check your graph to make sure there is one and only
sequences or groups of sequences must be one path leaving each state for each combination of
remembered by the circuit and set up states accordingly. values of the input variables.
State Description
S0 No progress on 100 No progress on 010
S1 Progress of 1 on 100 No progress on 010
S2 Progress of 10 on 100 Progress of 0 on 010 010 has never occurred
S3 No progress on 100 Progress of 0 on 010
S4 Progress of 1 on 100 Progress of 01 on 010
S5 Progress of 0 on 010
S6 Progress of 01 on 010 010 has occurred
S7 No progress on 010
State Graphs for Example 2
43 44
Before applying these rules, copy any ‘-’ from next state maps
into FF input maps
45 46
Rework a previous example The first solution with minimum number of states:
49 50
Now, lets set up enough states to “remember” first three bits State table for sequence detector:
of every possible input sequence.
After fourth input, machine goes to reset state
States:
State Input Sequence
A Reset
B 0
C 1
D 00
… …
G 11
H 000
… …
P 111
51 52
53 54
After making these changes, in the new table Reduced State Table:
States D and G are identical (D ≡ G)
States E and F are identical (E ≡ F)
So, eliminate F and G
55 56
Reduced State Graph The technique used in the example is called row matching
Row matching is not sufficient to find all equivalent states
Except in the special case where the circuit resets to the starting state
after receiving a fixed number of inputs
57 58
59 60
Definition 15.1: Theorem: Two states p and q of a sequential circuit are equivalent
Let N1 and N2 be sequential circuits (not necessarily different). Let X iff for every single input X, the outputs are the same and the next
represent a sequence of inputs of arbitrary length.Then, state p in N1 is states are equivalent, that is,
equivalent to state q in N2 iff λ1(p, X) = λ 2(q, X) for every possible input
sequence X.
λ(p, X) is the output given the present state p and input X
λ(p, X) is the output given the present state p and input X
δ(p, X) is the next state given the present state p and input X
Note that the next states do not have to be equal, just equivalent.
This is practical!
61 62
63 64
Implication chart after first pass Implication chart after second pass
67 68
69 70
The following guidelines are useful in making assignments: How to use these guidelines,
This will place 1’s together (or 0’s) on the next-state maps: First, write down the sets of states which should be adjacent
1. States which have the same next state for a given input should be given Then, using K-maps try to satisfy as many adjacencies as possible
adjacent assignments A fair amount of trial-and-error may be required
2. States which are the next states of the same state should be given
adjacent assignments
3. States which have the same output for a given input should be given
adjacent assignments
Place 1’s together on the output maps
71 72
Example
When filling the map, Guideline 1:
Assign the starting state to ‘0’ square on the map S0, S2, S4, S6 be adjacent
Simplifies the initialization of the circuit S1 is next state when X=0
Adjacency conditions from Guide 1 and 2 that are required 2 or 3 times S3 and S5
should be satisfied first S5 is next state when X=0
When 3 or 4 states are required to be adjacent, these states should be S 0 , S1 , S 3 , S5
placed within a group of four adjacent squares S2 is next state when X=1
If output table is considered, then Guide 3 should be considered S4 and S6
Guide 3 has less priority than Guide 1 and 2 if there is single output S6 is next state when X=1
Guideline 2:
If there are 2 or more outputs, Guide 3 may have higher priority
S1, S2 (next states of S0)
*Guideline 3 is not considered in this
S2, S3 (next states of S1) example
S 1 , S4
S2, S5 (two times: S3 & S5)
S1, S6 (two times: S4 & S6)
73 74
75 76
Example
Partial graph is given How to write next-state equations?
4 states (S0, S1, S2, S3) There are 4 arcs leading into S3
4 FFs (Q0, Q1, Q2, Q3) So, 4 conditions under which next state is S3
State Assignment PS=S0 and X1=1
S0 = 1000 (Q0Q1Q2Q3) PS=S1 and X2=1
S1 = 0100 PS=S2 and X3=1
S2 = 0010 PS=S3 and X4=1
S3 = 0001
Next state of Q3 =1 under these conditions; otherwise, Q3=0
Q3+= X1(Q0Q1’Q2’Q3’) + X2(Q0’Q1Q2’Q3’) + X3(Q0’Q1’Q2Q3’) +
X4(Q0’Q1’Q2’Q3)
Next-state and output equations can be written by Q0 = 1 implies that Q1=Q2=Q3= 0
inspecting the state graph Q3+= X1Q0 + X2Q1 + X3Q2+ X4Q3
77 78
How to write output equations? What if the FFs used do not have a preset input?
Z1=1 when PS=S0 and X1=1 & when PS=S2 and X3=1 That is, Q0 can not be set to 1 for initial state
Z1 = X1Q0 + X3Q2 Replace Q0 with Q0’ throughout
Modified Equations:
In general, each term in next-state equation contains exactly Q3+= X1Q0’ + X2Q1 + X3Q2+ X4Q3
one state variable
Z1 = X1Q0’ + X3Q2
Similarly, each term in output equation contains exactly one
Z2 = X2Q1 + X4Q3
state variable
79 80
Example 2
A sequential circuit that controls a binary multiplier Next state equation for Q0+:
3 inputs: St, M, K 2 arcs leading to S0 2 terms in the equation
4 outputs: Load, Ad, Sh, Done Q0+ = Q0St′ + Q3
Starting in S0
Next state equation for Q1+:
3 arcs leading to S0 3 terms
Q1+ = Q0St + Q1K′M′ + Q2K′
How many FFs?
4 states 4 FFs
S0=1000 Output equation for Sh:
S1=0100 Sh appears in 4 places
S2=0010 Sh=1 in S1 if K’M’=1 or KM’=1; also in S2 if K’=1 or K=1
S3=0001 Sh = Q1(K′M′ + KM′) + Q2(K′ + K) = Q1M′ + Q2
81 82
83 84
85 86
Example: For a circuit with four inputs (X1, X2, X3, and X4)
and four outputs (Z1, Z2, Z3, and Z4),
X1X4′ / Z2Z3 ------> 1--0 / 0110.