Académique Documents
Professionnel Documents
Culture Documents
VHDL Machine Etat PDF
VHDL Machine Etat PDF
Compléments
Compl ments
Machines d’états
d tats
Machines d’états
Principe de fonctionnement
LA machine d’état s’apparente à un automate ou un grafcet
Le système est dans un état stable ( équivalent d’une étape pour le grafcet)
Il peut évoluer vers un autre état du système en fonction des entrées ( réceptivité
VRAIE)
A chaque état correspond une/des sorties actives ( les actions associées aux
étapes)
La représentation graphique est un diagramme à
bulle
Ne pas oublier de faire un tableau à côté pour
préciser les sorties en fonction de l’état
Contraintes de fonctionnement
Une machine d’état a besoin d’une horloge
(quartz, astable en externe ou PLL embarquée)
Une transition est activée lorsque
L’étape source est active
La réceptivité est vrai (équation logique sur les
entrées
Un front d’horloge survient 2
Machines d’états
3
Machines d’états
4
Machines d’états
library ieee ; use ieee.std_logic_1164.ALL;
entity MAE is
Exemple de codage à la main port ( E,RST,HOR : in STD_LOGIC ;
S : out STD_LOGIC );
Cahier des charges end MAE;
architecture COMPORTEMENT of MAE is
la sortie S recopie l’état logique présent sur son signal REG_ETAT : STD_LOGIC_VECTOR(2 downto 0);
process (HOR,RST)
entrée E si celle-ci est restée stable après 2 coups begin
if RST='0' then REG_ETAT <= "000";
d’horloge successifs. elsif (HOR’event and HOR='1') then
case REG_ETAT is
when "000" => S <= '0' ;
if E = '1' then REG_ETAT <= "001";
else REG_ETAT <= "000";
end if ;
when "001" => S <= '0' ;
if E = '1' then REG_ETAT <= "010";
else REG_ETAT <= "000";
end if ;
when "010" => S <= '0' ;
if E = '1' then REG_ETAT <= "011";
La sortie est else REG_ETAT <= "000";
resynchronisée car end if ;
incluse dans le when "011" => S <= '1' ;
if E = '1' then REG_ETAT <= "011";
process else REG_ETAT <= "100";
end if ;
when "100" => S <= '1' ;
if E = '1' then REG_ETAT <= "011";
else REG_ETAT <= "101";
end if ;
when "101" => S <= '0' ;
if E = '1' then REG_ETAT <= "011";
else REG_ETAT <= "000";
end if ;
when others => REG_ETAT <= "00"; 5
end case ;end if ;end process ;
end COMPORTEMENT ;
Machines d’états
Sortie en dehors du
process
Description
COMBINATOIRE
6
Machines d’états
TYPE type_etat IS (debut,add,decal,fin);
SIGNAL etat : type_etat;
Création d’un type état BEGIN
-- autre process (opérateurs)
Méthode conseillée car plus lisible PROCESS(h,init)
BEGIN
IF (init = ’1’) THEN
etat <= debut;
ELSE
If (h=‘1’ and h’EVENT) THEN
CASE etat IS
WHEN debut =>IF zero THEN etat <= fin;
ELSIF lsb THEN etat <= add;
ELSE etat <= dec;
END IF;
WHEN add => etat <= dec;
WHEN dec => IF zero THEN etat <= fin;
ELSIF lsb THEN etat <= add;
END IF;
WHEN fin => etat <= fin;
Condition =1 WHEN others => etat <=debut;
END CASE;
Ne pas que la condition ne END IF;
sera vrai qu’au coup END PROCESS ;
l’horloge initialiser <= ‘1’ when (etat = debut) else ‘0’;
additionner <= ‘1’ when(etat = add) else ‘0’;
decaler <= ‘1’when (etat = dec) else ‘0’;
8
Applications
Réception simplifiée des périphériques PS/2
Schéma de principe