voila cmt j ai procedé:
jai commencé par affecter les valeurs "0" ou "Z" aux lignes li:l0..l4.
voila à ce aue j ai aboutit
!!s il y a d'autres choses à ajouter ,parce j sais pas est ce que j ai bien repondu au probleme ou pas !?,veuillez me repondre afin que je puisse achève mon mini projet
Merci d'avance
library ieee ;
use ieee.std_logic_1164.all, ieee.numeric_std.all ;
entity decodeur_clavier is
port (hor,c3,c2,c1,c0 : in std_logic;
l3,l2,l1,l0,strobe: out std_logic ;
sort : out std_logic_vector(3 downto 0)) ;
end decodeur_clavier;
architecture arch of decodeur_clavier is
signal touche : std_logic ;
signal etat, colnum : integer range 0 to 3 ;
begin
l0 <= '0' when etat = 0 else 'Z' ;--l etat de ligne change au rythme de l'horloge hor :voir,en bas,le process automate
l1 <= '0' when etat = 1 else 'Z' ;
l2 <= '0' when etat = 2 else 'Z' ;
l3 <= '0' when etat = 3 else 'Z' ;
strobe <= touche ;
strob : process
begin
wait until rising_edge(hor);
touche <= c3 and c2 and c1 and c0 ;--permet de tester s il y a une touche --enfoncée
end process strob ;
automate : process
begin
wait until rising_edge(hor);
if touche = '1' then
etat <= (etat + 1) ;-- les lignes sont pilotées par une automate : toutes à --'Z' sauf une qui est à '0' et change au rythme d'une --horloge.
end if ;
end process automate ;
code_gen : process(c3)
begin
wait until rising_edge(hor) ;
if touche = '0' then
-- l'expression ci-dessous convertit un nombre entier en vecteur:to_unsigned(valeur,nombre de bits).
if c3 = '0' then sort <= std_logic_vector(to_unsigned(colnum-etat + 4*3,4)) ;--cela permet de generer le code de la touvhe enfoncée de la colonne extreme --droite(F,E,D,C).on sait que colnum=3.
elsif(c0=0 and etat=3) then sort <= std_logic_vector(to_unsigned(10,4)) ;--generer "A"
elsif(c1=0 and etat=3) then sort <= std_logic_vector(to_unsigned(0,4)) ;--generer "0"
elsif(c2=0 and etat=3) then sort <= std_logic_vector(to_unsigned(11,4)) ;--generer "B"
else
sort <= std_logic_vector(to_unsigned(1+colnum + 3*etat,4)) ;--generer les autres code de la matrice carrée 3-3 dont le diagonal est (1,5,9).
end if ;
end if;
end process code_gen ;
encodeur : process(c0,c1,c2,c3)
begin
if c0 = '0' then
colnum <= 0 ;
elsif c1 = '0' then
colnum <= 1 ;
elsif c2 = '0' then
colnum <= 2 ;
elsif c3 = '0' then
colnum <= 3 ;
else
colnum <= 0 ;
end if ;
end process encodeur ;
end arch ;