FSM-based Specification Formalisms: Giovanni de Micheli
FSM-based Specification Formalisms: Giovanni de Micheli
Giovanni De Micheli
Integrated Systems Centre
EPF Lausanne
This presentation can be used for non-commercial purposes as long as this note and the copyright footers are not removed
Giovanni De Micheli All rights reserved
Models of computation
Data-flow oriented models
Focus on computation
Focus on control
Module 1
Objectives
FSM models
Hierarchical FSMs
Expression-based formalisms
Finite-state machines
Primary
Inputs
COMBINATIONAL
CIRCUIT
Primary
Outputs
REGISTERS
clock
State diagrams
Directed graph
Vertices = states
Edges = transitions
Example
ab + r/0
s0
r/0
r/0
abr/0
abr/0
ar/0
br/0
s1
r/0
abr/1
br/1
s2
ar/0
s3
r/1
(c) Giovanni De Micheli
FSM-based models
Synchronous languages:
Graphical formalisms:
StateCharts
Program-state machines
SpecCharts
Strict semantics
Objectives
Synchronous models
Perfect synchrony hypothesis
Instantaneous response
Zero-delay computation
Outputs synchronous with inputs
Discrete-time model
Sequence of tics
Environment driven
Inactivity between ticks
10
Event-controlled blocks
(in Esterel)
Do task watching event
Extension to time-out
11
end every
watching SECOND;
emit SPEED (NB_CM);
end var
end loop
12
Example: jogging
do
loop
do RUN_SLOWLY watching 100 M;
do
every STEP do
JUMP || BREATHE
end
watching 15 S;
RUN_FAST
each LAP
watching 2 LAP
13
trap HEART_ATTACK in
do
loop
do RUN_SLOWLY watching 100 M;
do
every STEP do
JUMP || BREATHE||CHECK_HEART
end
watching 15 S;
RUN_FAST
each LAP
watching 2 LAP
handle HEART_ATTACK
GO_TO_HOSPITAL
end
(c) Giovanni De Micheli
14
State Charts
Proposed by Harel
Graphic formalism to specify FSMs with:
Hierarchy
Concurrency
Communication
15
State Charts
States
Transitions
Hierarchy
OR (sequential) decomposition
16
State charts
Top_level_uart
transmitter
receiver
tx_mode
rx_mode
csr(2)=1
idle
csr(3)=1
transmit
idle
receive
csr(2)=0
csr(3)=0
load_thr / load:=1;
tx_hold_reg;=data_in;
empty
loaded
empty
rd(tx_hold_reg)/load:=0
uart_mode
[read_enable=1] /
filoful:=1
loaded
read_fifo_cmd/filoful:=0
[csr(2..3)=11]
normal_tx_rx
echo_active
[csr(2..3)=11]
17
State Charts
Additional features
State transitions across multiple levels
Timeouts:
Communication:
History feature:
18
StateCharts
Advantages:
Formal basis
Easy to learn
Disadvantages:
19
Sequential states
Concurrent states
20
D
variable i,max:integer;
B
max=0;
e1
for i=0 to 20 do
e2
max = A[i];
end if;
end for
e3
21
22
SpecCharts
Based on Program State Machines
Introduced by Gajski et al.
Extension of VHDL:
Compilable into VHDL for simulation and synthesis
Behavioral hierarchy
Combining FSM and VHDL formalisms
Leaves of the hierarchy are VHDL models
23
State transitions
Sequencing between sub-behaviors are controlled by
transition arcs
A transition arc is labeled by a triple:
Transition types:
Transition on completion
Transition immediate
Timeout arcs
24
Example
E
Z
variable i, max:integer;
x1
max-0;
z1
for i=1 to 20 do
e1
x2
e4
max = A[i];
z2
end if;
e2
end for
e5
e3
TOC: e2, e3
TI: e1
(c) Giovanni De Micheli
25
SpecCharts semantics
Timing semantics similar to VHDL
Synchronization:
Use wait statement
Use TOC looping back to the top of the program
Communication:
Using variables and signals
Message passing (send/receive)
26
SpecCharts
Language
Graphic formalism
Similar to StateCharts
27
Example
entity E is
port ( P:in integer; Q: out integer );
end E
architecture A of E is
begin
behavior B type concurrent subbehaviors is
type int_array is array (natural range<>) of integer;
signal M: int_array (15 downto 0);
begin
X: (TOC, true, complete);
Y: (TOC, e3, complete);
Z: ;
28
Expression-based formalisms
Represent sequential behavior by expressions
Advantages:
Symbolic manipulation
Disadvantages:
29
Regular expressions
Model sequential/concurrent behavior
Expressive power equivalent to FSMs
Known techniques for synthesis and analysis
Disadvantages:
No explicit way to express branching
No distinction between concurrent and alternative behavior
30
of HDLs
Based on the algebra of synchronous processes
(Process Algebra)
(c) Giovanni De Micheli
31
DMA-FRAME
DMA-BUFFER
DMA-BIT
DMA-XMIT
XMIT-FRAME
XMIT-BIT
RXD
TXD
TXE
Transmit Unit
Memory
CRS
ENQUEUE
EXEC-UNIT
CDT
Execute Unit
System Bus
Network
Coprocessor
Problem
32
P1
P2
P3
always
always
always
begin
begin
begin
write bus
initialize
receive data
wait ( tr ready )
read bus
end
read bus
end
end
p = p1 p2 p3
p1 = [a.0]
p2 = [0.(c:0)*.a]
p3 = [(x:0)*.a]
(c) Giovanni De Micheli
33
Control-Flow Expressions
Composition
HDL
CFE
Sequential
begin P; Q end
pq
Parallel
fork P; Q join
pq
if (c)
P;
Alternative
else
c:p+c:q
Q;
while (c)
Loop
P;
wait (!c)
(c: p)*
(c: 0)* .p
P;
Infinite
always
P;
34
Model properties
Fully deterministic model.
Non-determinism captured by decision variables affecting the
clauses
Design space modeled by decision variables
An implementation is an assignment to decision variables over
time
Constraints expressible by CFEs
Timing, synchronization, resource usage
AWAYS and NEVER sets
Set of actions that always/never execute simultaneously
35
Example
Control-Flow Expressions
MEMORY
P1
P2
P3
always
always
always
begin
begin
begin
write bus
initialize
receive data
wait ( tr ready )
read bus
end
read bus
end
end
p = p1 p2 p3
p1 = [a.0]
p2 = [0.(c:0)*.a]
Decision variable x :
p3 = [(x:0)*.a]
36
Example
Control-Flow Expressions
MEMORY
P2
P3
always
always
always
begin
begin
begin
P1
write bus
initialize
receive data
wait ( tr ready )
read bus
end
read bus
end
end
p = p1 p2 p3
p1 = [a.0]
p2 = [0.(c:0)*.a]
p3 = [(x:0)*.a]
NEVER = {a,a}
37
Example
Synchronization
SENDER
RECEIVER
blocking protocol
Sender = (x : r)*.a
Receiver = (y : k)*.a
ALWAYS = {{a; a}}
NEVER = {{r; k}}
38
39
CFE Summary
Control-flow expression are a modeling tool
Formal semantic:
40