Cours:TP M1102 TP 5 Corr : Différence entre versions

De troyesGEII
Aller à : navigation, rechercher
m (Question 1)
m (Question 1)
Ligne 5 : Ligne 5 :
 
==Exercice 2==
 
==Exercice 2==
 
===Question 1===
 
===Question 1===
 +
Le compteur 8 bits utilisé ici était donné dans le TP4. On a simplement modifié le nom de son horloge.
 +
<source lang=VHDL>
 
library IEEE;
 
library IEEE;
 
use IEEE.STD_LOGIC_1164.ALL;
 
use IEEE.STD_LOGIC_1164.ALL;
 
ENTITY compteur IS PORT (
 
ENTITY compteur IS PORT (
 
   clk: IN std_logic;
 
   clk: IN std_logic;
   HEX0: OUT std_logic_vector(6 downto 0));
+
   Leds8: OUT std_logic_vector(7 downto 0));
 
END compteur;
 
END compteur;
  
 
ARCHITECTURE arch_compteur OF compteur IS
 
ARCHITECTURE arch_compteur OF compteur IS
-- les somposants :
+
-- les composants :
COMPONENT cmpt7seg IS
+
COMPONENT cmpt8bits IS
   PORT(CLK : IN STD_LOGIC;
+
   PORT(clk : IN STD_LOGIC;
     s_7segs : OUT STD_LOGIC_VECTOR(6 DOWNTO 0));
+
     cnt : OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
END COMPONENT cmpt7seg;
+
END COMPONENT cmpt8bits;
  
 
COMPONENT cmpt24bits IS
 
COMPONENT cmpt24bits IS
Ligne 27 : Ligne 29 :
 
BEGIN
 
BEGIN
 
   i1 : cmpt24bits PORT MAP(
 
   i1 : cmpt24bits PORT MAP(
    clk_50MHz => clk,
+
      clk_50MHz => clk,
clk_slow => s_hologe_lente);
+
      clk_slow => s_hologe_lente);
 
 
 
 
   i2 : cmpt7seg PORT MAP (
+
   i2 : cmpt8bits PORT MAP (
    clk_lent => s_hologe_lente,
+
        clk => s_hologe_lente,
a => HEX0(0),
+
cnt => leds8);
        b => HEX0(1),
 
c => HEX0(2),
 
d => HEX0(3),
 
e => HEX0(4),
 
f => HEX0(5),
 
g => HEX0(6));
 
 
END arch_compteur;
 
END arch_compteur;
  
 
-- Compteur 8 bits
 
-- Compteur 8 bits
 
+
library IEEE;
 +
use IEEE.STD_LOGIC_1164.ALL;
 +
use ieee.std_logic_arith.all;
 +
use ieee.std_logic_unsigned.all;
 +
ENTITY cmpt8bits IS
 +
  PORT(clk : IN STD_LOGIC;
 +
    cnt : OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
 +
END cmpt8bits;
 +
 +
ARCHITECTURE arch_cmpt8bits OF cmpt8bits IS
 +
  signal cmpt : std_logic_vector(7 downto 0);
 +
BEGIN
 +
  process(clk_50) begin
 +
    if rising_edge(clk_50) then
 +
      cmpt <= cmpt + 1;
 +
    end if;
 +
  end process;
 +
  cnt <= cmpt; 
 +
END arch_cmpt8bits;
  
 
-- horloge lente 3 Hz
 
-- horloge lente 3 Hz
Ligne 64 : Ligne 78 :
 
   clk_slow <= cmpt(23);  -- partie combinatoire de construction de l'horloge lente
 
   clk_slow <= cmpt(23);  -- partie combinatoire de construction de l'horloge lente
 
END arch_cmpt24bits;
 
END arch_cmpt24bits;
 +
</source>
  
 
===Question 2===
 
===Question 2===

Version du 29 septembre 2020 à 14:32

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

Le compteur 8 bits utilisé ici était donné dans le TP4. On a simplement modifié le nom de son horloge.

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
ENTITY compteur IS PORT (
  clk: IN std_logic;
  Leds8: OUT std_logic_vector(7 downto 0));
END compteur;

ARCHITECTURE arch_compteur OF compteur IS
-- les composants :
COMPONENT cmpt8bits IS
  PORT(clk : IN STD_LOGIC;
    cnt : OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
END COMPONENT cmpt8bits;

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 : cmpt8bits PORT MAP (
         clk => s_hologe_lente,
	 cnt => leds8);
END arch_compteur;

-- Compteur 8 bits
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
ENTITY cmpt8bits IS
  PORT(clk : IN STD_LOGIC;
    cnt : OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
END cmpt8bits;
 
ARCHITECTURE arch_cmpt8bits OF cmpt8bits IS
  signal cmpt : std_logic_vector(7 downto 0);
BEGIN
  process(clk_50) begin
    if rising_edge(clk_50) then
      cmpt <= cmpt + 1;
    end if;
  end process;
  cnt <= cmpt;  
END arch_cmpt8bits;

-- 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 3

Exercice 3

Exercice 4