Exercice 1:
Solution : (4pts)
a b c s
1- T.V.
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 0
A. ZAKRITI Page 1
Royaume du Maroc المملكة المغربية
Université Abdelmalek Essaâdi جامعة عبد المالك السعدي
Ecole Nationale des Sciences Appliquées
المدرسة الوطنية للعلوم التطبيقية
Tétouan
تطوان
2- Description VHDL
library ieee;
use ieee.std_logic_1164.all;
entity STRUCT4 is
port (a,b,c: in std_logic;
s : out std_logic);
end STRUCT4;
architecture DESCRIPTION of STRUCT4 is
begin
s <= a when (b = '0') else not c when (b = '1');
end DESCRIPTION;
Exercice 2
A. ZAKRITI Page 2
Royaume du Maroc المملكة المغربية
Université Abdelmalek Essaâdi جامعة عبد المالك السعدي
Ecole Nationale des Sciences Appliquées
المدرسة الوطنية للعلوم التطبيقية
Tétouan
تطوان
Solution : (5pts)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity BCD27SEG is
Port ( E : in std_logic_vector(3 downto 0);
a, b, c, d, e, f, g : out std_logic; -- déclarer les sorties séparément
end BCD27SEG;
BEGIN
Process (E)
case E is
WHEN "0000" => seg <= "1111110";
WHEN "0001" => seg <= "0110000;
WHEN "0010" => seg <= "1101101" ;
WHEN "0011" => seg <= "1111001" ;
WHEN "0100" => seg <= "0110011" ;
WHEN "0101" => seg <= "1011011" ;
WHEN "0110" => seg <= "1011111" ;
WHEN "0111" => seg <= "1110000" ;
WHEN "1000" => seg <= "1111111" ;
WHEN "1001" => seg <= "1111011" ;
WHEN OTHERS => seg <= "1001111 ";
end case;
end process;
a <= seg(6);
b <= seg(5);
c <= seg(4);
d <= seg(3);
e <= seg(2);
f <= seg(1);
g <= seg(0);
end Behavioral;
A. ZAKRITI Page 3
Royaume du Maroc المملكة المغربية
Université Abdelmalek Essaâdi جامعة عبد المالك السعدي
Ecole Nationale des Sciences Appliquées
المدرسة الوطنية للعلوم التطبيقية
Tétouan
تطوان
Exercice 3
Solution (6pts):
library IEEE;
use IEEE.std_logic_1164.all;
entity FLIPFLOP is
port (D1, D2, reset, clk: in std_logic;
Q : out std_logic);
end FLIPFLOP;
architecture EG of FLIPFLOP is
begin
process (clk)
begin
end EG;
A. ZAKRITI Page 4
Royaume du Maroc المملكة المغربية
Université Abdelmalek Essaâdi جامعة عبد المالك السعدي
Ecole Nationale des Sciences Appliquées
المدرسة الوطنية للعلوم التطبيقية
Tétouan
تطوان
Exercice 4
Donner une description VHDL d’un circuit séquentiel qui réalise le comptage ou décomptage
selon une entrée de commande C. Le cycle effectué est de 0 à 15 ou de 15 à 0.
Solution : (5pts)
library ieee;
use ieee.std_logic_1164.all;
Use ieee.numeric_std.all;
Use ieee.std_logic_unsigned.all;
entity UPDOWN is
port( H, R, C : in std_logic;
Q: out std_logic_vector(3 downto 0));
end entity;
begin
process(H, R)
begin
If R='1' then x<= "0000";
elsif (H'event and H='1') then
if C='0' then x<=x-1; else x<= x+1;
end if ;
end if;
end process;
Q<= x;
end data;
A. ZAKRITI Page 5