B.Les instructions du mode concurrent
1.Affectation conditionnelle
Signal <= expression when condition
else expression when condition
else expression when condition
else expression ; Remarque : la dernière ligne "else expression" n'est pas obligatoire mais elle est fortement conseillée. Exercice : Réaliser le programme VHDL d'un multiplexeur 4 vers 1 avec entrée de sélection E1 (1bit) E2 E3 E5
S (1 bit)
SEL
SEL
| S
| 00
| E1
| 01
| E2
| 10
| E3
| 11
| E4
| Library ieee;
USE iee.std_logic_1134.all
Entity multiplex is
Port ( E1,E2,E3,E4 : in std_logic;
SEL : in std_logic_vector (1 downto 0);
S : out std_logic );
End multiplex; Architecture desc_multiplex of multiplex is
Begin S <= E1 when SEL = "00"
Else E2 when SEL = "01"
Else E3 when SEL = "10"
Else E4;
End desc_multiplex; On aurais pu écrire aussi : Library ieee;
USE iee.std_logic_1134.all
Entity multiplex is
Port ( E : in std_logic_vector (3 downto 0);
SEL : in std_logic_vector (1 downto 0);
S : out std_logic );
End multiplex; Architecture desc_multiplex of multiplex is
Begin S <= E(0) when SEL = "00"
Else E(1) when SEL = "01"
Else E(2) when SEL = "10"
Else E(3);
End desc_multiplex;
2.Affectation sélective
Cette instruction permet d'affecter différentes valeurs à un signal selon les valeurs prises par un signal de sélection With signal_de_selection select
signal <= expression when valeur_de_selection
expression when valeur_de_selection
expression when others; Exercice : Réaliser le programme d'un multiplexeur 1 vers 4 avec entrée de sélection SEL et sortie de validation Enable active sur l'état bas S1 (1bit)
S2
S3
S5
SEL
| S
| 00
| S1
| 01
| S2
| 10
| S3
| 11
| S4
| Enable SEL E (1 bit)
Library ieee;
USE iee.std_logic_1134.all
Entity demultiplex is
Port ( SEL : in std_logic_vector (1 downto 0);
E : in std_logic
Enable : in std_logic;
S1,S2,S3,S4 : out std_logic;);
End demultiplex; Architecture desc_demultiplex of demultiplex is
With Enable select
S1 <= E when 0
???
???
End desc_demultiplex;
|