Prepa Exam
Prepa Exam
html
decodeur :
library IEEE;
use IEEE.std_logic_1164.all;
entity decodeur is
port( E : in std_logic_vector(1 downto 0);
S0,S1,S2 : out std_logic);
end decodeur;
comparateur :
library IEEE;
use IEEE.std_logic_1164.all;
entity comparateur is
port( A,B : in std_logic_vector(7 downto 0);
egal : out std_logic);
end comparateur;
end arch_comparateur;
diviseur_10
-- div_10.vhd
entity div_10 is
port( hor : in bit ;
sort : buffer bit );
end div_10 ;
architecture piege of div_10 is
begin
diviseur : process
variable compte : integer range 0 to 5 := 0 ;
begin
wait until hor = '1' ;
compte := compte + 1 ;
if compte = 5 then
compte := 0 ;
sort <= not sort ;
end if ;
end process diviseur ;
end piege ;
architecture perverse of div_10 is
signal compte : integer range 0 to 4 := 0 ;
begin
diviseur : process
begin
wait until hor = '1' ;
compte <= compte + 1 ;
if compte = 4 then
compte <= 0 ;
sort <= not sort ;
end if ;
end process diviseur ;
end perverse ;
exercice google :
Soit une bascule D avec remise à zéro RST asynchrone
library ieee;
use ieee.std_logic_1164.all;
entity bascule is
port (
rst,H,D : in std_logic;
Q : out std_logic);
end bascule;
architecture arch of bascule is
begin
process(H,rst)
begin
if rst<='1' then
Q<='0';
elsif H'event and H='1' then
Q<=D;
end if;
end process;
end arch;
3 bascule (decalage)
library ieee;
use ieee.std_logic_1164.all;
entity decalage is
port (
E,clk, rst : in std_logic;
Q1, Q2, Q0 : out std_logic);
end decalage;
architecture arch of decalage is
component bascule
port (
rst,H,D : in std_logic;
Q : out std_logic);
end component;
signal S1,S2 : std_logic;
Q0<=S1;
Q1<=S2;
U1 : bascule port map( E,clk,rst,S1);
U2 : bascule port map(clk,rst,S1,S2);
U3 : bascule port map(clk,rst,S2,Q2);
end arch;
implusion de periode 40 ns
ARCHITECTURE simple OF hor_simple IS
BEGIN
horloge: PROCESS
BEGIN
WAIT FOR 20 ns;
hor <= NOT hor;
END PROCESS horloge;
END simple;
Boucle :
7segment:
entity decod7seg is
port(
InSeg : IN std_logic_vector(3 downto 0);
OutSeg : OUT std_logic_vector(6 downto 0)
);
end decod7seg;
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
--definition de l'architecture
architecture arch_dec_7seg of decod7seg is
-- definition d'un nouveau type
-- tableau de 16 elements de 7 bits
type MemROM is array(15 downto 0) of
std_logic_vector(6 downto 0);
--initialisaion du tableau
-- tableau vu comme une memoire(LUT)
signal Tableau : MemROM := (
"1000000","1111001","0100100","0110000","0011001",
"0010010","0000010","1111000","0000000","0011000","
0001000","0000011" ,"1000110","0100001","0000110","
0001110");
begin
-- pour indexer tableau il faut un entier
-- fonction de conversion conv_integer dans
IEEE.std_logic_unsigned.all
OutSeg <= Tableau(conv_integer(InSeg));
end arch_dec_7seg;