Code source VHDL_TP4
Code source VHDL_TP4
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.numeric_std.all;
Use ieee.std_logic_unsigned.all;
entity traffic_light is
PORT ( CLOCK : in std_logic;
LED_COM : out std_logic;
Lout : out std_logic_vector ( 11 downto 0 ) );
end traffic_light;
begin
LED_COM <= '1';
process( CLOCK )
begin
if CLOCK'event and CLOCK='1' then
if e>10000000 then
e<=(others=>'0');
else e<=e+1;
end if;
if e<5000000 then
c<='0';
else c<='1';
end if;
end if;
end process;
process ( c, OutTmp )
begin
if ( c = '1' and c'event) then
if (OutTmp = "100100001001" or OutTmp = "001001100100")
then
CMP10 <= CMP10 + 1;
if (CMP10 = "1001") then
C10 <= '1';
CMP10 <= "0000";
end if;
else C10 <= '0';
end if;
end if;
end process;
process ( c )
begin
if ( c = '1' and c'event) then
if (OutTmp = "100100010010" or OutTmp = "010010100100")
then
CMP2 <= CMP2 + 1;
if (CMP2 = "01") then
C2 <= '1';
CMP2 <= "00";
end if;
else C2 <= '0';
end if;
end if;
end process;
end if;
end process;
Lout <= OutTmp;
end DESCRIPTION;
begin
Rows(0)<="00000001";
Rows(1)<="00000010";
Rows(2)<="00000100";
Rows(3)<="00001000";
Rows(4)<="00010000";
Rows(5)<="00100000";
Rows(6)<="01000000";
Rows(7)<="10000000";
--Letter H
CRH(0)<="11000011";
CRH(1)<="11000011";
CRH(2)<="11000011";
CRH(3)<="11111111";
CRH(4)<="11111111";
CRH(5)<="11000011";
CRH(6)<="11000011";
CRH(7)<="11000011";
--Letter T
CRT(0)<="11111111";
CRT(1)<="11111111";
CRT(2)<="00011000";
CRT(3)<="00011000";
CRT(4)<="00011000";
CRT(5)<="00011000";
CRT(6)<="00011000";
CRT(7)<="00011000";
--letter Z
CRZ(0)<="11111111";
CRZ(1)<="11111111";
Par M. JAROU 3|Page
Code des sources des TP VHDL
CRZ(2)<="11000000";
CRZ(3)<="00110000";
CRZ(4)<="00001100";
CRZ(5)<="00000011";
CRZ(6)<="11111111";
CRZ(7)<="11111111";
--signe "up"
CRU(0)<="00011000";
CRU(1)<="00111100";
CRU(2)<="01111110";
CRU(3)<="11111111";
CRU(4)<="00011000";
CRU(5)<="00011000";
CRU(6)<="00011000";
CRU(7)<="00011000";
--sign interdit
CRIN(0)<="00011000";
CRIN(1)<="00111100";
CRIN(2)<="01111110";
CRIN(3)<="10000001";
CRIN(4)<="01111110";
CRIN(5)<="00111100";
CRIN(6)<="00011000";
CRIN(7)<="00000000";
if e<5000 then
c<='0';
else c<='1';
end if;
--if add>6 then
--add<=(others=>'0');
--else add<=add+1;
--end if;
end if;
end process;
process(c)
begin
Par M. JAROU 4|Page
Code des sources des TP VHDL
else if (m = 3) then
CG<=(Na(m)(n));
CR<="00000000";
n<=n+1;
else
CR<=Na(m)(n);
CG<=(Na(m)(n));
n<=n+1;
end if;
end if;
if (n=8)then
n<=0;
end if;
if(cpt=400) then
m<=m+1;
cpt<=0;
end if;
end if;
end process;
end description_matrix;
else etat_futur<=etat_rien;
end if;
com<="000";
fct<="00000000";
when etat_efface=>
com<="100";
fct<="00000001";
etat_futur<=etat_efface2;
when etat_efface2 =>
com<="000";
fct<="00000001";
etat_futur<=etat_retour;
when etat_retour=>
com<="100";
fct<="00000010";
etat_futur<=etat_retour2;
when etat_retour2=>
com<="000";
fct<="00000001";
etat_futur<=etat_rien;
when etat_conf=>
com<="100";
fct<="00111000";
etat_futur<=etat_conf2;
when etat_conf2=>
com<="000";
fct<="00001100";
etat_futur<=etat_allume;
when etat_allume=>
com<="100";
fct<="00001110";
etat_futur<=etat_allume2;
when etat_allume2=>
com<="000";
fct<="00001110";
etat_futur<=etat_mode;
when etat_mode=>
com<="100";
fct<="00000110";
etat_futur<=etat_mode2;
when etat_mode2=>
com<="000";
fct<="00000110";
etat_futur<=etat_ecrit;
when etat_ecrit=>
com<="110";
fct<=tab_a(i);
etat_futur<=etat_rien;
end case;
end process;
end cmp;
entity freq_div_10 is
PORT ( s_in : in std_logic;
s_out : out std_logic );
end freq_div_10;
begin
process( s_in )
begin
if (s_in'event and s_in='1') then
if e>=9 then
e<=(others=>'0');
else e<=e+1;
end if;
if e<=4 then
s_out<='0';
else s_out<='1';
end if;
end if;
end process;
end description;
--Multiplexeur_vhdl.vhdl
library ieee;
use ieee.std_logic_1164.all;
Par M. JAROU 9|Page
Code des sources des TP VHDL
entity Multiplexeur_vhdl is
port (a, b, c, d, e, f, g, h: in std_logic;
Sel: in std_logic_vector(2 downto 0);
ledOut : out std_logic_vector (7 downto 0);
Output: out std_logic);
end Multiplexeur_vhdl;
-- frequency_generator.vhd
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.numeric_std.all;
Use ieee.std_logic_unsigned.all;
entity frequency_generator is
PORT ( OSC : in std_logic;
c_10M,c_1M,c_100K,c_10K,c_1K,c_100,c_10,c_1 : out std_logic );
end frequency_generator;
component freq_div_10
PORT(s_in : in std_logic;
s_out : out std_logic
);
end component;
begin
c_10M <= OSC;
c_1M <= wire_1;
c_100K <= wire_2;
Par M. JAROU 10 | P a g e
Code des sources des TP VHDL
U1 : freq_div_10
PORT MAP(s_in => OSC,
s_out => wire_1);
U2 : freq_div_10
PORT MAP(s_in => wire_1,
s_out => wire_2);
U3 : freq_div_10
PORT MAP(s_in => wire_2,
s_out => wire_3);
U4 : freq_div_10
PORT MAP(s_in => wire_3,
s_out => wire_4);
U5 : freq_div_10
PORT MAP(s_in => wire_4,
s_out => wire_5);
U6 : freq_div_10
PORT MAP(s_in => wire_5,
s_out => wire_6);
U7 : freq_div_10
PORT MAP(s_in => wire_6,
s_out => c_1);
end description;
--Freq_gen_mux.vhd
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.numeric_std.all;
Use ieee.std_logic_unsigned.all;
entity Freq_gen_mux is
PORT ( OSCIL, up, down : in std_logic;
LED : out std_logic_vector (7 downto 0);
DE : out std_logic_vector (2 downto 0);
Csel : out std_logic;
LEDCOM : out std_logic );
end Freq_gen_mux;
component frequency_generator
PORT ( OSC : in std_logic;
c_10M,c_1M,c_100K,c_10K,c_1K,c_100,c_10,c_1 : out
std_logic );
Par M. JAROU 11 | P a g e
Code des sources des TP VHDL
end component;
component Multiplexeur_vhdl
PORT (a, b, c, d, e, f, g, h: in std_logic;
Sel: in std_logic_vector(2 downto 0);
ledOut : out std_logic_vector (7 downto 0);
Output: out std_logic);
end component;
begin
upDown <= up xor down;
CupDown <= wire_7 and upDown;
LEDCOM <= '1';
DE <= "110";
process (CupDown)
begin
if (CupDown'event and CupDown='0') then
if (cmp_wire < "111" and down = '0') then cmp_wire <= cmp_wire + 1;
else if (cmp_wire > "000" and up = '0') then cmp_wire <= cmp_wire - 1; end
if;
end if;
end if;
end process;
U1 : frequency_generator
PORT MAP( OSC => OSCIL,
c_10M => wire_1,
c_1M => wire_2,
c_100K => wire_3,
c_10K => wire_4,
c_1K => wire_5,
c_100 => wire_6,
c_10 => wire_7,
c_1 => wire_8);
U2 : Multiplexeur_vhdl
PORT MAP(a => wire_1,
b => wire_2,
c => wire_3,
Par M. JAROU 12 | P a g e
Code des sources des TP VHDL
d => wire_4,
e => wire_5,
f => wire_6,
g => wire_7,
h => wire_8,
ledOut => LED,
Sel => cmp_wire,
Output => Csel);
end description;
Par M. JAROU 13 | P a g e
Code des sources des TP VHDL
Chronomètre
Par M. JAROU 14 | P a g e