Devoir : conception de systèmes numérique sur FPGA
Série 2 :
Exercice 4 : additionneur complet 1 bit
La description VHDL d’un additionneur complet 1 bit :
Library IEEE ;
Use IEEE.STD_LOGIC_1164.all ;
Entity full_adder is
Port ( A,B, Cin : in std_logic;
S, Cout : out std_logic
);
End full_adder;
Architecture bhv of full_adder is
Begin
S <= A XOR B XOR Cin;
Cout <= (A and B) or (A and Cin) or (B and Cin);;
End bhv;
Exercice 5 : additionneur complet 4 bits
Pour la réalisation de l’exercice 5 (additionneur complet 4 bits), j’ai réutilisé et
adapté le code VHDL du full adder 1 bit développé dans l’exercice 4.
La description VHDL d’additionneur complet 4 bits
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity full_adder4 is
Port ( A , B : in STD_LOGIC_VECTOR (3 downto 0);
Cin : in STD_LOGIC;
S : out STD_LOGIC_VECTOR (3 downto 0);
Cout : out STD_LOGIC);
end full_adder4;
architecture bhv of full_adder4 is
component full_adder
Port ( A , B ,Cin : in STD_LOGIC;
S , Cout : out STD_LOGIC
);
end component;
signal c1,c2,c3: STD_LOGIC;
begin
FA1: full_adder port map (A(0), B(0), Cin, S(0), c1);
FA2: full_adder port map (A(1), B(1), c1, S(1), c2);
FA3: full_adder port map (A(2), B(2), c2, S(2), c3);
FA4: full_adder port map (A(3), B(3), c3, S(3), Cout);
end bhv;
Série 3 :
Exercice 5 : Démultiplexeur 1 vers 4
1. Description VHDL de ce circuit à partir d’une instruction de choix :
Pour la description comportementale, nous avons choisi d'utiliser
l'instruction de choix case. Cette méthode nous permet de nous baser
directement sur la table de vérité du démultiplexeur pour décrire son
fonctionnement.
Entrées Sorties
Enable S2 S1 Q0 Q1 Q2 Q3
1 0 0 I 0 0 0
1 0 1 0 I 0 0
1 1 0 0 0 I 0
1 1 1 0 0 0 I
0 X X 0 0 0 0
library ieee;
use ieee.std_logic_1164.all;
entity Demux_1_4 is
Port (
I : in STD_LOGIC;
Enable : in STD_LOGIC; -- Entrée de validation (active haut)
SEL : in STD_LOGIC_VECTOR (1 downto 0);
Y0, Y1, Y2, Y3 : out STD_LOGIC -- Sorties
);
end Demux_1_4;
architecture Behavioral of Demux_1_4 is
begin
process (I, Enable, SEL)
begin
Y0 <= '0';
Y1 <= '0';
Y2 <= '0';
Y3 <= '0';
if Enable = '1' then
case SEL is
when "00" =>
Y0 <= I;
Y1 <= '0';
Y2 <= '0';
Y3 <= '0';
when "01" =>
Y0 <= '0';
Y1 <= I;
Y2 <= '0';
Y3 <= '0';
when "10" =>
Y0 <= '0';
Y1 <= '0';
Y2 <= I;
Y3 <= '0';
when others =>
Y0 <= '0';
Y1 <= '0';
Y2 <= '0';
Y3 <= I;
end case;
end if;
end process;
end Behavioral;
2. Description VHDL de ce circuit à partir d’une affectation sélective :
library ieee;
use ieee.std_logic_1164.all;
entity Demux_1_4_with_select is
port (
I ,S1 ,S2,E : in std_logic;
Q0,Q1,Q2,Q3 : out std_logic
);
end Demux_1_4_with_select;
architecture bhv of Demux_1_4_with_select is
signal SEL : std_logic_vector(1 downto 0);
begin
SEL <= S1 & S2;
Q0 <= I when (SEL = "00" and E = '1') else '0';
Q1 <= I when (SEL = "01" and E = '1') else '0';
Q2 <= I when (SEL = "10" and E = '1') else '0';
Q3 <= I when (SEL = "11" and E = '1') else '0';
end bhv;
Exercice 6 :
1. Description VHDL correspondant au schéma fonctionnel :
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity mux_2_vers_1 is
port(
A , B , sel : in std_logic;
Q : out std_logic
);
end mux_2_vers_1;
architecture bhv of mux_2_vers_1 is
begin
Q<= A when sel='0' else B;
end bhv;
library ieee;
use ieee.std_logic_1164.all;
entity circuit is
port (
Y,Z : in std_logic;
A, B : in std_logic;
X : in std_logic;
C : in std_logic;
F : out std_logic
);
end circuit;
architecture Structural of circuit is
component mux_2_vers_1 is
port (
A,B,sel : in std_logic;
Q: out std_logic
);
end component;
signal Q_NOR : std_logic;
signal Q_MUX1 : std_logic;
begin
Q_NOR <= Y nor Z;
MUX1: mux_2_vers_1 port map ( A,B, Q_NOR, Q_MUX1 );
MUX2:mux_2_vers_1 port map ( C, Q_MUX1,X, F);
end Structural;
2. La description nécessaire pour décrire le schéma fonctionnel :
La description structurelle est le type de description requis pour modéliser ce
circuit en VHDL en utilisant les blocs fonctionnels (MUX) comme composants.