Correction TD 2: Conception de Circuits Numériques
Correction TD 2: Conception de Circuits Numériques
Correction TD 2
Conception de circuits numériques
Octobre 2016
1 Correction exercice 1 :
1.1 Buffer Unidirectionnel
1.1.1 Entité
5 -- Definition Entite
6 entity Three_State_Unidir is
7 port ( E,Cde : in std_logic;
8 S : out std_logic);
9 end entity Three_State_Unidir;
1.1.2 Architecture 1
1 -- definition Architecture 1
2 architecture a1 of TriState_Unidir is
3 begin
4 S <= E when cde = ’1’ else ’Z’;
5 end architecture a1;
1.1.3 Architecture 2
1 -- definition Architecture 2
2 architecture a2 of Thrree_State_Unidir is
3 begin
4 process (E,Cde)
5 begin
6 if (Cde = ’1’) then
7 S <= E ;
8 else
9 S<= ’Z’;
10 end if ;
11 end process;
12 end architecture a2;
5 --Entite Definition
6 entity Three_State_bidir is
7 port ( E,Cde : in std_logic;
8 S : out std_logic;
9 IO : inout std_logic);
10 end entity Three_State_bidir;
1.2.2 Architecture
5 S <= IO;
6 end architecture comport;
2 Correction exercice 2 :
2.1 Équation
Q = A · B · I0 + A · B · I1 + A · B · I2 + A · B · I3
2.2 Entité
1 Library IEEE;
2 use IEEE.std_logic_1164.all;
3
4 entity Mux4 is
5 port ( I0,I1,I2,I3,A,B : in std_logic;
6 Q : out std_logic);
7 end entity Mux4;
2.3 Architectures
2.3.1 Description comportementale 1
4 process(I0,I1,I2,I3,A,B)
5 variable sel : std_logic_vector(1 downto 0);
6
7 begin
8 sel := (A,B);
9 case sel is
10 when "00" => Q <= I0;
11 when "01" => Q <= I1;
12 when "10" => Q <= I2;
13 when "11" => Q <= I3;
14 when others => Q <= ’X’;
15 end case;
16 end process;
17 end architecture arch_comb1;
4 process (I0,I1,I2,I3,A,B)
5 begin
6 if ( A = ’0’ and B= ’0’) then Q<= I0;
7 elsif ( A = ’0’ and B= ’1’) then Q<= I1;
8 elsif ( A = ’1’ and B= ’0’) then Q<= I2;
9 elsif ( A = ’1’ and B= ’1’) then Q<= I3;
10 end if;
11 end process;
12 end architecture arch_comb2;
AND3
La figure suivante représente le composant logique AND3
Figure 2 – AND3
1 library IEEE;
2 use IEEE.std_logic_1164.all;
3
4 entity AND3 is
5 Port (e0,e1,e2 : in std_logic ;
6 s : out std_logic);
7 end AND3;
8
OR4
La figure suivante représente le composant logique OR4
Figure 3 – OR4
1 library IEEE;
2 use IEEE.std_logic_1164.all;
3
4 entity OR4 is
5 Port (e0,e1,e2,e3 : in std_logic ;
6 s : out std_logic);
7 end OR4;
8
3 component AND3 is
4 Port (e0,e1,e2 : in std_logic ;
5 s : out std_logic);
6 end component AND3;
8 component OR4 is
9 Port (e0,e1,e2,e3 : in std_logic ;
10 s : out std_logic);
11 end component OR4;
12
13 --signaux internes
14 signal x0,x1,x2,x3 : std_logic ;
15 signal notA, notB : std_logic ;
16
17 begin
18 --Preparation des signaux inversees
19 notA <= not(A);
20 notB <= not(B);
21
1 library IEEE;
2 use IEEE.std_logic_1164.all;
3
19 begin
20 --instatiation et port mapping
21 UT: Mux4 port map (t_I0,t_I1,t_I2,t_I3,t_A,t_B,t_Q);
22
35
3 Correction exercice 3 :
Figure 7 – Demux 1 à 8
1 library IEEE;
2 use IEEE.std_logic_1164.all;
3 use IEEE.std_logic_unsigned.all;
4
6 entity Demux_1_To_8 is
7 port (G : in std_logic;
8 A : in std_logic_vector(2 downto 0);
9 Y : out std_logic_vector(7 downto 0) );
10 end Demux_1_To_8;
11
1 library ieee;
2 use ieee.std_logic_1164.all;
3 use IEEE.numeric_std.all;
4
5 entity Test_Demux is
6 end entity Test_Demux;
7
11 component Demux_1_To_8 is
12 port (G : in std_logic;
13 A : in std_logic_vector(2 downto 0);
14 Y : out std_logic_vector(7 downto 0) );
15 end component Demux_1_To_8;
16
23 begin
24 UU : Demux_1_To_8 port map (t_G,t_A,t_Y);
25
26 process
27 begin
28 t_G<= ’0’;
29 t_A <= (others => ’0’);
30 wait for 100 ns;
31
32 bb : for i in 0 to 8 loop
33 t_A <= std_logic_vector (an);
34 an <= an +1;
35 wait for 50 ns;
36 t_G <=’1’;
37 end loop bb;
38 end process;
39 end architecture testbench;
40
43 for testbench
44 for UU : Demux_1_To_8
45 use entity work.Demux_1_To_8(arch1);
46 end for;
47 end for ;
48 end conf;
4 Correction exercice 4 :
1 library IEEE;
2 use IEEE.std_logic_1164.all;
3 use IEEE.std_logic_arith.all;
4
5 entity Priority_Encode_8_to_3 is
6 port (E: in std_logic_vector (7 downto 0);
7 S : out std_logic_vector (2 downto 0);
8 GS : out std_logic);
9 end entity Priority_Encode_8_to_3;
10
15 if ( E = "00000000") then
16 GS <= ’1’;
17 else
18 GS <= ’0’;
19 end if ;
20
1 library ieee;
2 use ieee.std_logic_1164.all;
3 use IEEE.numeric_std.all;
4
5 entity test_Priority_Encoder is
6 end entity test_Priority_Encoder;
7
10 --Importation du composant
11 component Priority_Encode_8_to_3 is
12 port (E: in std_logic_vector (7 downto 0);
13 S : out std_logic_vector (2 downto 0);
14 GS : out std_logic);
15 end component Priority_Encode_8_to_3;
16
23
24 begin
25 --instantiation et port mapping
26 UT : Priority_Encode_8_to_3 port map(t_E,t_S,t_GS);
27
28 process
29 begin
30 en <= (others => ’0’);
31 wait for 100 ns;
32
39 end process;
40 end architecture testbench;
1 library IEEE;
2 use IEEE.std_logic_1164.all;
3 use IEEE.std_logic_arith.all;
4
5 entity Priority_Encode is
6 generic (n : positive);
7 port (E: in std_logic_vector ((2**n)-1 downto 0);
8 S : out std_logic_vector (n-1 downto 0);
9 GS : out std_logic);
10 end entity Priority_Encode;
11
22 end if ;
23
1 library ieee;
2 use ieee.std_logic_1164.all;
3 use IEEE.numeric_std.all;
4
5 entity test_Priority_Encoder_Gen is
6 generic (m : positive := 8 );
7 end entity test_Priority_Encoder_Gen;
8
11 component Priority_Encode is
12 generic (n : positive);
13 port (E: in std_logic_vector ((2**n)-1 downto 0);
14 S : out std_logic_vector (n-1 downto 0);
15 GS : out std_logic);
16 end component Priority_Encode;
17
24 begin
25 UT : Priority_Encode generic map (m) port map(t_E,t_S,t_GS);
26
27 process
28 begin
38 end process;
39 end architecture testbench;