Explorer les Livres électroniques
Catégories
Explorer les Livres audio
Catégories
Explorer les Magazines
Catégories
Explorer les Documents
Catégories
Exercice 1 : Expliquez le code vhdl hiérarchique suivant. Le but de cet exercice est de vous assurer
que vous pouvez suivre la conception hiérarchique. Ne paniquez pas si le code est trop long!
library ieee;
use ieee.std_logic_1164.all; entity andgate is
entity TCOUNT is port(A,B,C,D: in std_logic := '1';
port (Rst: in std_logic; Y: out std_logic);
Clk: in std_logic; end andgate;
Count: out std_logic_vector(4 downto 0)); architecture gate of andgate is
end TCOUNT; begin
Y <= A and B and C and D;
architecture STRUCTURE of TCOUNT is end gate;
component tff
port(Rst,Clk,T: in std_logic; entity tff is
Q: out std_logic); port(Rst,Clk,T: in std_logic;
end component; Q: out std_logic);
end tff;
component andgate architecture behavior of tff is
port(A,B,C,D: in std_logic := '1'; begin
Y: out std_logic); process(Rst,Clk)
end component; variable Qtmp: std_logic;
begin
constant VCC: std_logic := '1'; if (Rst = '1') then
signal T,Q: std_logic_vector(4 downto 0); Qtmp := '0';
elsif rising_edge(Clk) then
begin if T = '1' then
T(0) <= VCC; Qtmp := not Qtmp;
T0: tff port map (Rst=>Rst,Clk=>Clk, end if;
T=>T(0), Q=>Q(0)); end if;
T(1) <= Q(0); Q <= Qtmp;
T1: tff port map (Rst=>Rst,Clk=>Clk, end process;
T=>T(1), Q=>Q(1)); end behavior;
A1: andgate port map(A=>Q(0), B=>Q(1),C
=>'1',D =>'1', Y=>T(2));
T2: tff port map (Rst=>Rst,Clk=>Clk,
T=>T(2), Q=>Q(2));
Exercice 2 : Ecrivez un processus qui fonctionne comme un doubleur d’horloge. La liste de sensibilité
doit se déclencher sur un signal nommé "clk". Vous pouvez supposer que le signal d’entrée est de
type «std_logic» et qu’il pendra uniquement les valeurs «1» et «0». Vous ne connaissez pas la
fréquence de «clk» à priori.
Exercice 3 : Etant donné un vecteur A de type std_logic_vector, écrivez le code VHDL qui donnera le
nombre de bits dans ce vecteur.
-- D_IN: in STD_LOGIC;
-- RESET: in STD_LOGIC;
-- CLK: in STD_LOGIC;
-- Q_OUT: out STD_LOGIC;
signal Q : std_logic_vector(2 downto 0);
process(CLK, RESET)
begin
if (RESET = '1') then
Q(0) <= '0';
Q(1) <= '0';
Q(2) <= '0';
elsif (CLK'event and CLK = '1') then
Q(0) <= D_IN;
Q(1) <= Q(0);
Q(2) <= Q(1);
end if;
end process;
Exercice 5 : Quel est l'élément logique qui décrit le mieux le code suivant?
-- GATE: in STD_LOGIC;
-- DIN: in STD_LOGIC;
-- DOUT: out STD_LOGIC;
process (GATE, DIN)
begin
if GATE='1' then --GATE active High
DOUT <= DIN;
end if;
end process;
Exercice 6 : Quel est l'élément logique qui décrit le mieux le code suivant?
-- ENABLE: in STD_LOGIC;
-- DIN: in STD_LOGIC;
-- DOUT: out STD_LOGIC;
process (ENABLE, DIN)
begin
if (ENABLE='1') then
DOUT <= DIN;
else
DOUT <= 'Z';
end if;
end process;