Upload
doantu
View
216
Download
0
Embed Size (px)
Citation preview
MSS simples partiel VHDL,
Unité: Base de systèmes logiques (SysLog1-2)Conception de systèmes numériques (CSN)
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
MSS simples(Machines Séquentielles Synchrones)
Etienne Messerli& collègues de l'institut REDS
Avril 2017
E. Messerli (HES-SO / HEIG-VD / REDS), 2017 p 1
Partiel: description VHDL
MSS simples partiel VHDL,
Rappel: schéma bloc d'une MSS simple
Etat_Present
REG
D Q
Décodeurd'états futurEntrées
Etat_Futur
Horloge
Actions_Asynchrone
Sorties
Décodeurde sorties
Machine de Mealy : sorties dépendent des entrées
E. Messerli (HES-SO / HEIG-VD / REDS), 2017 p 2
MSS simples partiel VHDL,
Description VHDL machine d'état …
architecture M_Etat of Exemple is
-- Machine d'etat avec n bits d'etat
signal Etat_Present, Etat_Futur : Std_Logic_Vector(n downto 0);
--Les constantes permettent de fixer le codage
--En cas de modification, seul les constantes sont a modifier.
constant Etat_0 : Std_Logic_Vector(n downto 0) := "0..00";
constant Etat_1 : Std_Logic_Vector(n downto 0) := "0..01";
"
begin
Fut: process (Toutes_Les_Entrees, Etat_Present)
begin
case Etat_Present is
E. Messerli (HES-SO / HEIG-VD / REDS), 2017 p 3
architecture M_Etat of Exemple is-- Machine d'etat avec n bits d'etatsignal Etat_Present, Etat_Futur :
Std_Logic_Vector(n downto 0);
--Les constantes permettent de fixer le codage--Si modification : seul les constantes sont a corriger. constant Etat_0 : Std_Logic_Vector(n downto 0) := "0..00";constant Etat_1 : Std_Logic_Vector(n downto 0) := "0..01";
"begin
Fut: process (Toutes_Les_Entrees, Etat_Present)beginEtat_Futur <= Etat_0; --valeur par defautSortie_A <= '0'; Sortie_B <= '0'; --valeur par defaut
MSS simples partiel VHDL,
… description VHDL machine d'état …
E. Messerli (HES-SO / HEIG-VD / REDS), 2017 p 4
case Etat_Present iswhen Etat_0 => Sortie_A <= '1'; --sortie de type Mooreif (condition) thenEtat_Futur <= Etat_0;Sortie_B <= '1'; --sortie de type Mealy
elseEtat_Futur <= Etat_1;Sortie_B <= '0'; --sortie de type Mealy
end if;when Etat_1 => ...
"
when others => Sortie_A <= '0'; Sortie_B <= '0';Etat_Futur <= Etat_0;
end case;
MSS simples partiel VHDL,
… description VHDL machine d'état
end process;
Mem: process (Horloge, RAZ)begin
if (RAZ = '1') thenEtat_Present <= Etat_0;
elsif Rising_Edge(Horloge) thenEtat_Present <= Etat_Futur;end if;
end process;
end Comport;
E. Messerli (HES-SO / HEIG-VD / REDS), 2017 p 5
MSS simples partiel VHDL,
Dia laissé vide volontairement
E. Messerli (HES-SO / HEIG-VD / REDS), 2017 p 6
MSS simples partiel VHDL,
Exemple de machine d'état …
Etatcondition
Sortie activeAttent
RAZ
Load = ‘1’
Transmet
Transmet
Charge Emet
Transmetand Actif
Transmetor Actif
Convention graphe
Entrées:- Transmet, Actif
Sortie:- Load
E. Messerli (HES-SO / HEIG-VD / REDS), 2017 p 7
MSS simples partiel VHDL,
… exemple de machine d'état …
E. Messerli (HES-SO / HEIG-VD / REDS), 2017 p 8
library IEEE;use IEEE.Std_Logic_1164.all;
entity UC_Emetteur isport ( Transmet, Actif : in std_logic;
Clock, Reset : in std_logic;Load : out std_logic);
end UC_Emetteur;
architecture M_Etat of UC_Emetteur is
signal Etat_Present, Etat_Futur : std_logic_vector(1 downto 0);
--Les constantes permettent de fixer le codage--Si modification : seul les constantes sont a corriger. constant ATTENT : std_logic_vector(1 downto 0) := "00";constant CHARGE : std_logic_vector(1 downto 0) := "01";constant EMET : std_logic_vector(1 downto 0) := "10";
begin
MSS simples partiel VHDL,E. Messerli (HES-SO / HEIG-VD / REDS), 2017 p 9
--process combinatoire, calcul etat futurFut:process (Transmet, Actif, Etat_Present)beginEtat_Futur <= Attent; -- valeur par defautcase Etat_Present iswhen ATTENT =>
if Transmet = '1' thenEtat_Futur <= CHARGE;
elseEtat_Futur <= ATTENT;
end if;when CHARGE =>
Etat_Futur <= EMET;when EMET =>
if Transmet = '0' and Actif = '1' thenEtat_Futur <= ATTENT;
elseEtat_Futur <= EMET;
end if;when others =>
Etat_Futur <= ATTENT;end case;
end process;
MSS simples partiel VHDL,
… exemple de machine d'état …--processus de memorisationMem:process (Clock, Reset)beginif Reset = '1' then-- reset asynchrone prioritaireEtat_Present <= ATTENT;
elsif rising_edge(Clock) thenEtat_Present <= Etat_Futur;
end if;end process;
-- equations combinatoire de sortieLoad <= '1' when Etat_Present = CHARGE else '0';
end M_Etat;
E. Messerli (HES-SO / HEIG-VD / REDS), 2017 p 10
MSS simples partiel VHDL,
… exemple de machine d'état
Utilisation d'un type énuméré pour les états▪ Avantage: les noms des états apparaissent lors de la simulation▪ Inconvénient: codage non maitrisé
E. Messerli (HES-SO / HEIG-VD / REDS), 2017 p 11
…
architecture M_Etat of UC_Emetteur is
type T_etat is (ATTENT, --attente du startCHARGE, --chargement regEMET --transfert en cours);
signal Etat_Present, Etat_Futur : T_etat
begin…