Escolar Documentos
Profissional Documentos
Cultura Documentos
Parte 5
(Sequencial)
FSM
• Usado para modelar um sistema que transita entre um
número finito de estados internos
• Transições dependem do estado atual e de entradas externas
• Na prática, a principal aplicação de uma máquina de
estados é:
• Controlar um sistema digital maior (complexo)
• Examina o estado do sistema e as entradas e ativa os
sinais de controle apropriados
108
Saídas Moore e Mealy
FSM
Mealy
INTRODUCTIONMealy109
output
- logic
output
- next-state d
> state
' state:eg "
input - logic state-next
-
i
register Moore
Moore
output
clk output
logic
mo: Moore output
me: Mealy output
Figure 5.1 Block diagram of a synchronous FSM.
state-name
Mealy output. The Moore and Mealy outputs
mo <=are
valuesimilar
but not identical. Understanding
their subtle differences is the key for a controller design. The example in Section 5.3.1
logic expression I me <= value logic expression I me <= value
illustrates the behaviors and constructions of the two types of outputs.
An FSM is usually specified by an abstract state diagram or ASM chart (algorithmic state
(a) Node
state-name
mo <= value
(a) Node
...........................
.................
r state entry
state box
state
mo <= value
Boolean
conditional
output box
..................................
t-----
- exit to other ASM
block
'L exit to other ASM
block
state-next <
state register, next-state logic, Moore output logic, and Mealy output logic.
30 i f b = ’ lend ) t h ec na s e ;
begin
Listing 5.1 FSM example s t a t e -pnreoxcte s s<= ; s2;
c a s e s t a t e - r e g end is
else
library i e e e ; when S O = > -- M o o r e o u t p u t l o g i c
s tpartoec-enses x( ts t a<=
t e - sr le ;g )
use i e e e . s t d - l o g i c - 1 1 6 4 , a l l ; i f a = ’ 1 ’ t h e n
end bi fe g; i n
e n t i t y fsm-eg i s 30 i f50
b=’l) then
else
port ( s t a t e - cnaesxet <=
s t a t e - n e x t when
a t es- 2r e; g i s
s t<=
SsOo;l s 2 =>
5 c l k , r e s e t : in s t d - l o g i c ; ende l s ei f ;
a , b : in s t d - l o g i c ; when sl s=> t a t e - n e x t y<= l <=s l ;’ 0 ’ ;
when sl = >
y o , y l : out s t d - l o g i c i fend ( a =i f’ 1; ’ ) then
); 40 e l s e 5 5s t a t e - n e x t <=y lS O<= ;
’1’;
end c a s e ;
end f s m - e g ; e lsst ea t e - n e x t <= S O ;
10 end i sft;a t eend process;
- n e x t <= s l ;
a r c h i t e c t u r e m u l t - s e g - a r c h of fsm-eg i s when end sl => i f ;-- M e a l y o u t p u t l o g i c
...
type e g - s t a t e - t y p e i s ( s o , s l , s 2 ) ; i f (sa2= ’=>
when 1p ’ )r othen
cess ( s t a t e - r e g , a , b
s i g n a l s t a t e - r e g , s t a t e - n e x t : e g - s t a t e - t y p e ;40 45 s tsatMtaet-en-en bxeetgxitn<=<=S O S; O ;
begin end ceal s e ; case s t a t e - r e g i s
I5 -- s t a t e r e g i s t e r end p r o c e s ss ;t a t e - n e x t when <= s lS;O =>
process ( c l k , r e s e t ) -- M o o r eend o u tipf u;t l o g i c if ( a = ’ l ’ ) a
begin p r o c when
e s s ( s tsa2t e=> -reg) yo <= > 1 ’ ;
i f ( r e s e t = ’ l ’ ) then begin s t a t e - n e x t <= S O ; e l s e
50 65
45
s t a t e - r e g <= S O ; y o <= ) O ’ ;
endc a scea sset;a t e - r e g i s
20 e 1 s i f ( c l k ’ e v e n t and c l k = ’ 1 ’ ) t h e n end p r o cwhen e s s ; s o l s 2 => end i f ;
s t a t e - r e g <= s t a t e - n e x t ; y l <= l ’o0g’ i; c
-- M o o r e o u t p u t
when sl I s 2 = >
end i f ; p r o c e s s (when
s t a t e sl- r e =g>) yo <= ’ 0 ’ ;
end p r o c e s s ; 50
55
begin y l 70<= ’ 1 ’ ;end c a s e ;
-_ n e x t - s t a t e logic s e s ct aa ts ee -; r e g end
c a end is process;
25 p r o c e s s ( s t a t e - r e g , a ,b ) end p r o c e s s ; end m u l t - s e g - a r c h ;
when s o l s 2 =>
-- M e a l y o u t p u t l o g i c
y l <= ’ 0 ’ ;
p r o c e s s ( s t a t eThe-reg key, apart, b)is the next-state logic
else
signal s t a t e - r e g , s t a t e - n e x t : eg-state-type; s t a t e - n e x t <= s l ;
end i f ;
During synthesis, software automatically maps the values in an enumerated data type to else
binary representations, a process known as state assignment. Although there is a mechanism s t a t e - n e x t <= S O ;
to perform this manually, it is rarely needed.
...
a r c h i t e c t u r e m u l t - s e g - a r c h of fsm-eg i s
y l i f<= ( a’=1 ’’ 1; ’ ) then
type e g - s t a t e - t y p e i s ( s o , s l , s 2 ) ; 55
end c a s e ; s t a t e - n e x t <= S O ;
signal s t a t e - r e g , s t a t e - n e x t : eg-state-type ;
40
end p r o c e s s e; l s e
begin -- M e a l y o u t p u st t altoeg- ince x t <= s l ;
I5 -- s t a t e r e g i s t e r p r o c e s s ( s t a tende - r eigf ;, a , b)
process ( c l k , r e s e t ) M begin when s 2 =>
begin 45 c a s e s t a tset a- rt e -gn e ixst <= S O ;
i f ( r e s e t = ’ l ’ ) then endwhenc a Ss Oe ; =>
s t a t e - r e g <= S O ; end p r o icfe s s( ;a = ’ l ’ ) and (b=)l’) t h e n
-- M o o r e yo o u t p<=u t >l1o’g;i c
20 e 1 s i f ( c l k ’ e v e n t and c l k = ’ 1 ’ ) t h e n
65 p r o c e s s e( sl st ae t e - r e g )
s t a t e - r e g <= s t a t e - n e x t ; 50 begin y o <= ) O ’ ;
end i f ; c a s e ends t a tief - ;r e g i s
end p r o c e s s ; whenwhensl s oI l ss22 => =>
-_ n e x t - s t a t e logic yo y <= l <=’ 0 ’ 0; ’ ;
25 p r o c e s s ( s t a t e - r e g , a ,b ) 70 end c when a s e ; sl = >
55 end p r o c e s sy; l <= ’ 1 ’ ;
end m u l t -end
s e g -caar sceh;;
end p r o c e s s ;
The key--partMise the
a l y next-state l o g i cIt uses a case statement with th
o u t p u t logic.
FSM em VHDL
bounces bounces
(last less than 20 ms) (last less than 20 ms)
--
original
switch output
-- -
debounced output
(scheme 1) *Oms I 20 ms-
2 possibilidades DESIGN EXAMPLES 119
bounces bounces
(last less than 20 ms) (last less than 20 ms)
--
original
switch output
-- -
debounced output
(scheme 1) *Oms I 20 ms-
L
I , 20ms
debounced output
(scheme 2)
- ; 20 ms
Solução 1
Figure 5.8 Original and debounced waveforms.
bounces
DESIGN EXAMPLES
bounces
119
debounced output
(scheme 1) *Oms I 20 ms-
L
I , 20ms
debounced output
(scheme 2)
- ; 20 ms
Problema:
Figure 5.8 Original and debounced waveforms.
atraso na entrada
e na saída
• Solução no livro...