Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
8 years ago

Error (10818): Can't infer register for "etat[1]" because it does not hold its value

Hello, I have to write a VHDL code for a project.

I try to describe a game which consist in find the right number and entering it on a 3x4 keyboard.

I'm a debutant! And I can't determine why I have those errors:


Error (10818): Can't infer register for "etat" at projet1.vhd(35) because it does not hold its value outside the clock edge
Info (10041): Inferred latch for "etat" at projet1.vhd(31)
Error (10818): Can't infer register for "etat" at projet1.vhd(35) because it does not hold its value outside the clock edge
Info (10041): Inferred latch for "etat" at projet1.vhd(31)
Error (10818): Can't infer register for "l_vert" at projet1.vhd(35) because it does not hold its value outside the clock edge
Info (10041): Inferred latch for "l_vert" at projet1.vhd(31)
Error (10818): Can't infer register for "l_rouge" at projet1.vhd(35) because it does not hold its value outside the clock edge
Info (10041): Inferred latch for "l_rouge" at projet1.vhd(31)
Error (10818): Can't infer register for "l_jaune" at projet1.vhd(35) because it does not hold its value outside the clock edge
Info (10041): Inferred latch for "l_jaune" at projet1.vhd(31)
Error (10822): HDL error at projet1.vhd(35): couldn't implement registers for assignments on this clock edge
Error (12153): Can't elaborate top-level user hierarchyError: Quartus Prime Analysis & Synthesis was unsuccessful. 
7 errors, 16 warnings    
Error: Peak virtual memory: 644 megabytes    
Error: Processing ended: Sun Apr 30 15:40:11 2017    
Error: Elapsed time: 00:00:32   
Error: Total CPU time (on all processors): 00:01:08

Here's my VHDL code :


library ieee;
use ieee.std_logic_1164.all;
use ieee.math_real.all;
use ieee.numeric_std.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity projet1 is
 port (            
 clk, c2, c1, c0, start,l3,l2,l1,l0, reset : in std_logic;  -- Entrées              
 D, U, bcd_u, bcd_d : buffer std_logic_vector(3 downto 0); -- Valeurs intermédiaires         
l_jaune, l_rouge, l_vert : buffer std_logic  --LEDs       );         
end entity projet1;
architecture behaviour of projet1 is                 
signal count_d : std_logic_vector(3 downto 0) := "0000"; -- vecteur 4 bits des dizaines                
signal count_u : std_logic_vector(3 downto 0) := "0000"; -- vecteur 4 bits des unités                
signal touche : std_logic;                             
signal colnum : integer range 0 to 2;                
signal sortie : std_logic_vector(3 downto 0);               
signal etat : std_logic_vector (0 to 1) := "00"; -- Machine d'états --modif: signal donc <=                
constant l_start : std_logic := '1';   -- Led d'allummage                
signal cnt : std_logic := '0' ;
begin
process (reset, clk)
begin    
if ( rising_edge (clk)) then                 -- Compteur de 1 à 99    
            if count_u = "1010" then      
                count_u <= "0000" ;                    
               count_d <= count_d + 1;     
                    
            if count_d = "1010" then              
              count_d <= "0000" ;                
             end if;       
              
            else                
            count_u <= count_u + 1;                     
            end if;                        
if (etat = "00") then           
 -- Initialisation   
    -- des leds           
 l_jaune <= '0';                 
 l_rouge <= '0';              
 l_vert  <= '0';                           
    -- de l'afficheur 7 segments                  
  bcd_u <= "0000";               
 bcd_d <= "0000";                       
 -- On passe à l'état suivant               
 etat <= "01";                                                  
  elsif (etat = "01") then              -- On attend que le joueur appuie sur Start pour définir le nombre à trouver                               
 if (start = '1' ) then              -- /!\ Bouton poussoir! Code anti-rebonds                               
 D <= count_d ;                   
 U <= count_u ;                                    
etat <= "10"; -- On passe alors à l'état suivant                               
 end if;                                  
  elsif (etat = "10") then   -- Décodeur clavier                                       
           
       if c0='1' and c1='1' and c2='1' then                               
 touche <='1'; -- Pas de touche enfoncée                           
else touche <='0'; -- Une touche est enfoncée
      if (l0='0' and c0='0') then                      
  sortie <="0001"; -- Touche 1                                           
 elsif (l0='0' and c1='0') then                         
sortie <="0010"; --Touche 2                                           
 elsif (l0='0' and c2='0') then                        
 sortie <="0011"; --Touche 3                                           
 elsif (l1='0' and c0='0') then                         
sortie <="0100"; --Touche 4                                           
 elsif (l1='0' and c1='0') then                         
sortie <="0101"; --Touche 5                                            
elsif (l1='0' and c2='0') then                        
 sortie <="0110"; --Touche 6                                            
elsif (l2='0' and c0='0') then                         
sortie <="0111"; --Touche 7                                            
elsif (l2='0' and c1='0') then                         
sortie <="1000"; --Touche 8                                            
elsif (l2='0' and c2='0') then                         
sortie <="1001"; --Touche 9                                            
elsif (l3='0' and c0='0') then                         
sortie <="1010"; --Touche *(->A)                                            
elsif (l3='0' and c1='0') then                        
 sortie <="0000"; --Touche 0                                            
elsif (l3='0' and c2='0') then                       
 sortie <="1011"; --Touche# (->B)
  end if;                                                               
 if (cnt = '0') then -- chiffre des dizaines                                   
 bcd_d <= sortie ;                      
  cnt <= '1';                            
else  -- chiffre des unités                                   
 bcd_u <= sortie ;                        
cnt <= '0';                            
end if ;                        
end if;                
end if;      
  etat <= "11";                       
 elsif (etat = "11") then                                        
if bcd_d > D then                               
     l_rouge <= '1';                                
     etat <= "10";                                                           
elsif bcd_d < D then                               
     l_jaune <= '1';                               
     etat <= "10";                                                  
 elsif bcd_d = D then                                                       
    if bcd_u > U then                                    
        l_rouge <= '1';                                    
        etat <= "10";                                                                   
    elsif bcd_u < U then                                    
        l_jaune <= '1';                                   
        etat <= "10";                                                                    
    elsif bcd_u = U then                                   
         l_vert <= '1';                                 
         etat <= "00";                                                      
    end if;                                        
end if;                                       
end if;     
end process;                    
end architecture behaviour;

Sorry for bad English and French in code !

Thank you very much if you can help me with it :)

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You have written a very complicated nesting of ifs and I am sure the last section is outside clock edge statement.

    You better rewrite using case statements and check your if nesting.