Finite State Machine Design: Outputs Inputs
Finite State Machine Design: Outputs Inputs
First
• Does the input signal equal the value
specified Binary decision - ‘yes’ or ‘no’
Yes – generally flows forward (down)
No – generally flows back (to the side and
Wait Decision up)
• If a Wait operation is specified or there is a
requirement to transition to the next state
OP = 0 on the next clock, then no ‘Decision’ box is
required.
State x
Flow • Flow between diagram function boxes
2
Dr. P.J. Mather
NHE2483 Digital Systems Integration
•
Typically, if the input is equal to the specified condition
(yes) the flow is vertical (down) to the next state.
• If the result of the decision box is false/no then the flow
arrow returns to the initial/previous State box.
c) Continue the process for each following state and repeat
until the full state transition diagram has been created.
3
Dr. P.J. Mather
NHE2483 Digital Systems Integration
4
Dr. P.J. Mather
NHE2483 Digital Systems Integration
FF outputs (Q).
• Number of possible states = 2n 3 Flip Flops A, B, C gives 23
• where n is the number of flip-flops. possible states
b) List all the named states Number QA QB QC
of states
2 Flip Flops A, B gives 22
possible states
1 0 0 0
QA DA Number QA QB 2 0 0 1
of states
3 0 1 0
1 0 0 4 0 1 1
QB DB
2 0 1 5 1 0 0
3 1 0 6 1 0 1
clk 4 1 1 7 1 1 0
8 1 1 1
5
Dr. P.J. Mather
NHE2483 Digital Systems Integration
a) Take the state transition table and replace all the states with
the assigned state values as determined in Step 2.
Next state
Present
X= 0 X=1 Output
State
000 0
001 0
011 0
010 0
100 0
101 0
111 0
110 1
7
Dr. P.J. Mather
NHE2483 Digital Systems Integration
10
D1 =
11
Q1,Q0 Q1,Q0
D0 OP
00 01 11 10 00 01 11 10
0 0
IP IP
1 1
D0 = OP =
Dr. P.J. Mather
NHE2483 Digital Systems Integration
OP
IP
Present Next
State State
Q1 D1
Q0 D0
0 000 1 0 0 0 MUX
EPROM 0 001 1 0 0 0 0
0
OP
1 8:1
0 010 1 0 1 0 0
0 MUX
0 011 1 1 1 0 0
1
OP
IP 0 100 1 0 1 0 0
0
0 101 1 0 1 0 1
0
1 8:1
A 0 110 1 0 0 D0
0
1
MUX
D
D 0 111 1 0 0 0 1
1
0
R
E 1 000 0 0 1 0
S
S
1 001 0 1 0 0 0
1
0
1 010 1 1 0 0 D1 0 8:1
0 MUX
1 011 0 1 1 0 0
1
1 100 1 0 0 0 0
1 101 1 1 1 0
1 110 0 0 1 1 Present
1 111 1 1 0 0 State Next
Present QA DA
OP Q1 D1
State
State IP
QB DB
Next Q0 D0
QC DC
State clk
12
clk
Dr. P.J. Mather
NHE2483 Digital Systems Integration
N N IP
IP’ IP = 0
IP = 1
Y Y
IP IP’
13
Dr. P.J. Mather
NHE2483 Digital Systems Integration
10 10 1
0
IP logic Pre
logic logic
D Q D Q D Q
Clr Clr
Rst
14
Dr. P.J. Mather
NHE2483 Digital Systems Integration
n
DET-=1
y
Count3 (D)
COUNT3(D) = C.DET
OP = 1
15
Dr. P.J. Mather
NHE2483 Digital Systems Integration
IP RST
COUNTER
Pre
OP
Next
State
Present
Q1 D 1 Next Q1 D 1
State State Present
State
Q0 D 0 Q0 D 0
clk
4 States 4 States
2 Flip-Flops 2 Flip-Flops
Dr. P.J. Mather
NHE2483 Digital Systems Integration
Assume a
single design
if ‘multi stage’ 1 Hot Coding
is not
specified
18
Dr. P.J. Mather
NHE2483 Digital Systems Integration
2. Determine number of
Generic – implement FFs and perform
using either EPROM or State assignment Develop Waveform
Multiplexer (MUX) if not the circuit Analysis
specified 3. State Assignment Table design
4. Rearrange into
truthtable format
Design a synchronous sequential circuit with one input (A) and one
output (Z). The machine produces an output Z=1 only whenever
one of the following input sequences occur 1101, 0011. Sequences
may start at any time, so avoid designing the flow diagram so that
sequences are recognized only if they line up on some multiple of
four clock periods. The circuit resets to its initial state after Z=1 has
been generated.
A) Implement the circuit using an appropriate number of
multiplexers and flip-flops.
B) Implement the circuit using an appropriate sized EPROM and
flip-flops.
NOTE the register representation 0 0 1 1
is used to show the valid parts of an input sequence (blue or green for the two
separate sequences). Where part of the input no longer forms part of a valid
sequence it is shown with a orange background
20
Dr. P.J. Mather
NHE2483 Digital Systems Integration
Reset
Develop State Transition Diagram
1 1 0 1 Z=0 0 0 1 1
y n
X=1
1 0
S1_1 S2_1
Z=0
1 0
n
X=1
1 1 y
S1_2
21
Dr. P.J. Mather
NHE2483 Digital Systems Integration
101100
22
Dr. P.J. Mather
NHE2483 Digital Systems Integration
‘One-Hot’ Coding Implementation: Develop State
Transition Diagram
Reset
23
Dr. P.J. Mather
NHE2483 Digital Systems Integration
Unpipelined Circuit
Time taken for each stage to perform an operation
2 ns 3 ns 1 ns 2 ns 2 ns Data O/P
Data I/P
2 ns 3 ns 1 ns 2 ns 2 ns
Data I/P Data O/P Pipelined version.
A new computation
clk can be launched
every (longest circuit
Data I/P
block delay) in
pipelined structure.
2 ns 3 ns 1 ns 2 ns 2 ns
Clock speed
= 1/(stage delay)
3 ns 3 ns 3 ns 3 ns = 1/3ns
= 333 MHz
Latency
= stage delay*stages
‘Pipeline registers’ D-type flip-flop break up = 3ns * 4
computation into stages = 12ns
Guide to Answering
6. Pipelining of Digital Systems
Based Exam Questions
Latency: Time taken for output to
respond for a given input )equal to
Develop a circuit
the overall maximum propagation
block diagram - Non- delay) (critical path - CP).
generally a polynomial pipelined Maximum clock frequency =
function will be
(1/T) where T : Max propagation
specified.
delay (CP)
6. Pipelining
of Digital
Systems Latency: Time taken for output to
Pipelined respond for a given input -
equal to the stage delay (max.
block delay) * number of stages
Restrictions and
Maximum clock frequency =
Hazards when
Next 2 (1/T) where T equal to the block
pipelining a circuit.
slides with the highest propagation delay
26
Dr. P.J. Mather
NHE2483 Digital Systems Integration
Pipelining Restrictions
27
Dr. P.J. Mather
NHE2483 Digital Systems Integration
tclk
Pipelining Hazards
Data Hazards
Hazards Instruction depends on result of prior
Complex systems computation which is not ready yet
due to concurrent stage operations
generally incorporate
feedback, thus
complications can Structural Hazards
When two or more instructions want
occur in the form of to use the same hardware resource
hazards in the same cycle.
Overcome by replicating hardware
resources.
• Data
• Structural
• Control Control Hazards
Pipelining of non-sequential branch
operations and other instructions
which change the Program Count
(PC)
29
Dr. P.J. Mather
NHE2483 Digital Systems Integration
+ Latency = 8 ns
- = 1ns
Clock speed = 1/8 ns = 125 MHz
Step 2: Determine the longest signal propagation delay (critical path) from input
to output.
Critical path propagation delay is termed the Latency (un-pipelined circuit)
Maximum operation frequency is determined by 1/longest delay.
Note: If the circuit was clocked at a faster rate, then data samples would be
mixed, producing a non-valid output.
Dr. P. J. Mather
3030
NHE2483 Digital Systems Integration
clk D4 D7
Waveform representation b
of a Pipelined Circuit c
D3
7
D2 D6
X X
D1 D5
a X + - F
3 ns 3 ns 3 ns
Time(ns)
0 3 6 9 12 15 18
IP a0b0c0 a1b1c1 a2b2c2 a3b3c3 a4b4c4 a5b5c5
Outputs
D1 0 a 02 a 12 a22 a32 a42
D2 0 7a0 7a1 7a2 7a3 7a4
D3 0 c0 c1 c2 c3 c4
D4 0 b0 b1 b2 b3 b4
D5 0 0 a 02 a12 a22 a32
D6 0 0 7a 0c0 7a1c1 7a2c2 7a3c3
D7 0 0 b0 b1 b2 b3
F 0 0 0 a02+7a0c0-b0 a12+7a1c1-b1 a22+7a2c2-b2 32
Dr. P. J. Mather
NHE2483 Digital Systems Integration
Computer Architectures
Stage 1 Stage 2 Stage 3 Stage 4 Stage 5
Instruction Fetch Register - Decode ALU Data Memory Register Write
Back
IF REG(R) ALU DM REG(W)
Current PC Adder
Adder
4 Instruction Memory M
(RAM)
PC U
<<2 X
Read Reg 1
Data Memory
Read (RAM)
Data 1
Zero
Read Reg 2
Write Reg
ALUSrc M
0010101110001011 M Read
U
Data 2
U Write Data M X
1100111000000010 X U
ALU
X
ADD R16,R0,R1
SUB R20,R21,R22 32
16
Sign Extend
Dr. P. J. Mather
33
NHE2483 Digital Systems Integration
2 0.8 ns
IF REG(R) ALU DM REG(W)
2
IF REG(R) ALU DM REG(W)
Instruction Interference:
After 3 successive instruction functions the first instruction READS register file and the
fourth instruction WRITES to the register file (.
Time
Program Clock
execution Cycle 1 2 3 4 5 6 7 8 9
Reg
Reg
ADD R30,R17,R18
R ALU REG
IF R17 DM (W)
Solution: since the write and read operations take less than half the maximum
block delay both can be performed in the same clock period
Allow WRITE-then-READ in one clock cycle (termed “double pump”).
Dr. P. J. Mather
36
NHE2483 Digital Systems Integration
Reg
ADD R30,R17,R18 R ALU REG
IF R17 DM (W)
Dr. P. J. Mather
37
NHE2483 Digital Systems Integration
Instruction Conflict
Time
Program Clock
Cycle 1 2 3 4 5 6 7 8 9
execution
R ALU REG
ADD R12,R10,R11 IF R10 DM (W)
Read
ReadValue
Value
out
outof
of R10
R10
The 2nd instruction needs to read the contents of register R10 before the first
instruction has written the result of an instruction into R10.
Name for this: NO Operation or Pipeline stall.
Dr. P. J. Mather
38
NHE2483 Digital Systems Integration
REG ALU
W
ADD R10,R11,R12 IF (R) DM R10
Dr. P. J. Mather
39