Cours:TP M1102 TP 5 Corr : Différence entre versions
m (→Exercice 2) |
m (→Question 1) |
||
| Ligne 5 : | Ligne 5 : | ||
==Exercice 2== | ==Exercice 2== | ||
===Question 1=== | ===Question 1=== | ||
| + | library IEEE; | ||
| + | use IEEE.STD_LOGIC_1164.ALL; | ||
| + | ENTITY compteur IS PORT ( | ||
| + | clk: IN std_logic; | ||
| + | HEX0: OUT std_logic_vector(6 downto 0)); | ||
| + | END compteur; | ||
| + | |||
| + | ARCHITECTURE arch_compteur OF compteur IS | ||
| + | -- les somposants : | ||
| + | COMPONENT cmpt7seg IS | ||
| + | PORT(CLK : IN STD_LOGIC; | ||
| + | s_7segs : OUT STD_LOGIC_VECTOR(6 DOWNTO 0)); | ||
| + | END COMPONENT cmpt7seg; | ||
| + | |||
| + | COMPONENT cmpt24bits IS | ||
| + | PORT(clk_50MHz : IN STD_LOGIC; -- une seule entrée | ||
| + | clk_slow : OUT STD_LOGIC); -- une seule sortie | ||
| + | END COMPONENT cmpt24bits; | ||
| + | -- LE FIL INTENE | ||
| + | SIGNAL s_hologe_lente : std_logic; | ||
| + | BEGIN | ||
| + | i1 : cmpt24bits PORT MAP( | ||
| + | clk_50MHz => clk, | ||
| + | clk_slow => s_hologe_lente); | ||
| + | |||
| + | i2 : cmpt7seg PORT MAP ( | ||
| + | clk_lent => s_hologe_lente, | ||
| + | a => HEX0(0), | ||
| + | b => HEX0(1), | ||
| + | c => HEX0(2), | ||
| + | d => HEX0(3), | ||
| + | e => HEX0(4), | ||
| + | f => HEX0(5), | ||
| + | g => HEX0(6)); | ||
| + | END arch_compteur; | ||
| + | |||
| + | -- Compteur 8 bits | ||
| + | |||
| + | |||
| + | -- horloge lente 3 Hz | ||
| + | library IEEE; | ||
| + | use IEEE.STD_LOGIC_1164.ALL; | ||
| + | use ieee.std_logic_arith.all; | ||
| + | use ieee.std_logic_unsigned.all; | ||
| + | ENTITY cmpt24bits IS | ||
| + | PORT(clk_50MHz : IN STD_LOGIC; -- une seule entrée | ||
| + | clk_slow : OUT STD_LOGIC); -- une seule sortie | ||
| + | END cmpt24bits; | ||
| + | |||
| + | ARCHITECTURE arch_cmpt24bits OF cmpt24bits IS | ||
| + | signal cmpt : std_logic_vector(23 downto 0); | ||
| + | BEGIN | ||
| + | process(clk_50MHz) begin | ||
| + | if rising_edge(clk_50MHz) then | ||
| + | cmpt <= cmpt + 1; | ||
| + | end if; | ||
| + | end process; | ||
| + | clk_slow <= cmpt(23); -- partie combinatoire de construction de l'horloge lente | ||
| + | END arch_cmpt24bits; | ||
===Question 2=== | ===Question 2=== | ||
Version du 29 septembre 2020 à 13:25
Sommaire
TP 5
Exercice 1
L'exercice 1 a déjà été corrigé dans Corrigé du TP4 (Exercice 4). Il ne sera donc réalisé en TP5 que s'il ne l'a pas été en TP 4.
Exercice 2
Question 1
library IEEE; use IEEE.STD_LOGIC_1164.ALL; ENTITY compteur IS PORT (
clk: IN std_logic; HEX0: OUT std_logic_vector(6 downto 0));
END compteur;
ARCHITECTURE arch_compteur OF compteur IS -- les somposants : COMPONENT cmpt7seg IS
PORT(CLK : IN STD_LOGIC; s_7segs : OUT STD_LOGIC_VECTOR(6 DOWNTO 0));
END COMPONENT cmpt7seg;
COMPONENT cmpt24bits IS
PORT(clk_50MHz : IN STD_LOGIC; -- une seule entrée clk_slow : OUT STD_LOGIC); -- une seule sortie
END COMPONENT cmpt24bits; -- LE FIL INTENE SIGNAL s_hologe_lente : std_logic; BEGIN
i1 : cmpt24bits PORT MAP( clk_50MHz => clk,
clk_slow => s_hologe_lente);
i2 : cmpt7seg PORT MAP ( clk_lent => s_hologe_lente,
a => HEX0(0),
b => HEX0(1),
c => HEX0(2), d => HEX0(3), e => HEX0(4), f => HEX0(5), g => HEX0(6)); END arch_compteur;
-- Compteur 8 bits
-- horloge lente 3 Hz
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
ENTITY cmpt24bits IS
PORT(clk_50MHz : IN STD_LOGIC; -- une seule entrée clk_slow : OUT STD_LOGIC); -- une seule sortie
END cmpt24bits;
ARCHITECTURE arch_cmpt24bits OF cmpt24bits IS
signal cmpt : std_logic_vector(23 downto 0);
BEGIN
process(clk_50MHz) begin
if rising_edge(clk_50MHz) then
cmpt <= cmpt + 1;
end if;
end process;
clk_slow <= cmpt(23); -- partie combinatoire de construction de l'horloge lente
END arch_cmpt24bits;