Docsity

FSM-based Control in Digital Design II: Synthesis and Safe Implementations - Prof. Patrick, Study notes of Electrical and Electronics Engineering

Partial preview of the text

Download FSM-based Control in Digital Design II: Synthesis and Safe Implementations - Prof. Patrick and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

ECE 4514

Digital Design II

Spring 2008

Lecture 15:

Patrick Schaumont

Lecture 15:

FSM-based Control

A

Design

Lecture

Patrick Schaumont

Overview 

Finite State Machines

Verilog Mapping: one, two, three always blocks

State Encoding

User-defined or tool-defined

State encoding techniques: one-hot, user-defined, gray

Synthesis Issues

Patrick Schaumont

Synthesis Issues

Default state assignment

Safe Implementations

Next-state logic: RAM or LUT

FSM-based control of Datapath (gcd)

Design Process

Designer Creates
State Transition Graph
Extract
State Transition Table
Choose
State Encoding

Patrick Schaumont

State Transition Table
Create Next State Logic

Design Process

Designer Creates
State Transition Graph
Extract
State Transition Table
Choose
State Encoding

Patrick Schaumont

State Transition Table
Create Next State Logic

full-structural Verilog Model (design all gates)

Design Process

Designer Creates
State Transition Graph
Extract
State Transition Table
Choose
State Encoding
We will
focus on
and Patrick Schaumont
State Transition Table
Create Next State Logic

Structural Verilog Model

Behavioral Verilog Model (with explicit state encoding)Behavioral Verilog Model (with automatic state assignment)

Example FSM Design 

Create an FSM that turns the first '1' of a string ofconsecutive '1' into a '0'.

Input
Each clock cycle, a new input is provided

Patrick Schaumont

Output

Example FSM Design 

How many states?

x ( = I have not seen a '1')
current state
Input
Output

Patrick Schaumont

3 states
x ( = I have not seen a '1') 1 ( = I have seen a single '1')1 ( = I have seen more then a single '1')

Example FSM Design 

How many states?

S
Input
Output

Patrick Schaumont

S1 S

Verilog Mapping of FSM - Generic Ideas 

Use 'parameter' to express state encoding

This is a

symbolic

encoding, not necessarily the

encoding that will be used by the synthesis tool

Use standard conventions for coding logic

Use non

blocking <= for registers, specify correct reset and

parameter
s0 = 2'b00, s1 = 2'b01, s2 = 2'b10;

Patrick Schaumont

Use non

blocking <= for registers, specify correct reset and

edge-triggered behavior

Use blocking = for combinational logic, make sure sensitivitylists are complete

Example FSM Design - Verilog Mapping I

S0 S

module

fsm(q,

i,

clk,

rst);

input

i,

clk,

rst;

output

q;

reg

q;

reg

[1:0]

state;

parameter

s

=

2'b00,

s

=

2'b01,

s

=

2'b10;

always

@(

posedge

clk

or

posedge

rst)

if

(rst)

begin

state

<=

s0;

q

<=

1'b0;

end

else

begin

Patrick Schaumont

Spring 2008

S
output^ S0 -> 0S1 -> 0S2 -> 1

end

else

begin

case

(state)

s0:

if

(i

==

1'b1)

begin

state

<=

s1;

q

<=

1'b0;

end

else

begin

state

<=

s0;

q

<=

1'b0;

end

s1:

..

s2:

..

endcase

end

endmodule

Example FSM Design - Verilog Mapping II

S0 S

reg

q;

reg

[1:0]

state;

parameter

s

=

2'b00,

s

=

2'b01,

s

=

2'b10;

always

@(

posedge

clk

or

posedge

rst)

if

(rst) state

<=

s0;

else

case

(state)

s0:

if

(i

==

1'b1)

state

<=

s1;

else

Patrick Schaumont

Spring 2008

S
output S0 -> 0S1 -> 0S2 -> 1

else

state

<=

s0;

s1:

..

endcase

always

@

(state)

q

=

1'b0;

//

default

assignment

case

(state)

s0:

q

=

1'b0;

s1:

q

=

1'b0;

s2:

q

=

1'b1;

endcase

endmodule

Example FSM Design - Verilog Mapping II 

Two always block

Reset and update still in same block

Output can be combinational

Patrick Schaumont

inputs
outputs

next-state

function

state register

output function

Example FSM Design - Verilog Mapping III 

Three always block

Reset and update in different blocks

Output can be combinational

Patrick Schaumont

inputs
outputs

next-state

function

state register

output function

One, two, three always block

Combinational
Output
1 always
block
2 always
block
3 always
block

Patrick Schaumont

Output
Reset/Updateseparate from
next-state Logic

√√√√^ √√√√