2017-05-01 6 views
-3

J'utilise l'horloge 50MHz dans fpga et essaie de faire une minuterie de 5 secondes. en dessous de cnt_t atteindre 5 x 50MHz (x "0EE6B280" -> 250 000 000) puis faire time_tick_32 à 1 et faire cnt_t < = x "00000000" ;. Le code ci-dessous ne fonctionne pas jamais time_tick_32 obtient 1.5 secondes Minuterie en VHDL

signal cnt_t : STD_LOGIC_VECTOR(31 DOWNTO 0) := x"00000000"; 
signal time_tick : STD_LOGIC:= '0' ; 
signal time_tick_32 : STD_LOGIC_VECTOR(31 DOWNTO 0):= x"00000000"; 


process (clk_50) IS 
    begin 
     if falling_edge(clk_50) then 
     cnt_t <= cnt_t + '1'; 
     end if; 
    if (cnt_t = x"0EE6B280") then --if 5 seconds 
     time_tick <= '1'; 
     cnt_t <= x"00000000"; 
     time_tick_32(0)<=time_tick; 
    else 
     time_tick <= '0'; 
     time_tick_32(0)<=time_tick; 
    end if; 

end process; 
+0

Je ne sais pas sur cette langue, mais êtes-vous sûr que vous voulez que vos chiffres à comparer avec des chaînes à l'intérieur condition? – Gogol

+1

@Gogol 'x" .... '' est un littéral de chaîne de bits hexadécimal. Ce n'est donc pas une comparaison avec une chaîne (de caractères). – Paebbels

+1

S'il vous plaît nous montrer le code complet. Voici quelques conseils: 1. changez le type de 'cnt_t' en' unsigned' ou 'natural'. 2. vous n'avez pas besoin de 32 bits. 3. N'utilisez pas de nombres magiques => utilisez des valeurs entières. (Le type unsigned peut être comparé avec integer.) – Paebbels

Répondre

1

Essayez:

signal cnt_t : STD_LOGIC_VECTOR(31 DOWNTO 0) := x"00000000"; 
signal time_tick : STD_LOGIC:= '0' ; 
signal time_tick_32 : STD_LOGIC_VECTOR(31 DOWNTO 0):= x"00000000"; 


-- I assume you begin your architecture somewhere 
-- Can make the following a concurrent statement 
-- (unless it is some kind of shift reg assigned in a diff process... 
-- then you will get multiple driver issues) 
time_tick_32(0) <= time_tick; 

process (clk_50) IS 
begin 
    if rising_edge(clk_50) then -- Changed to rising_edge; 
           -- Any particular reason you are using falling_edge? 
     if (cnt_t = x"0EE6B280") then --if 5 seconds 
      time_tick <= '1'; 
      cnt_t <= x"00000000"; 
     else 
      time_tick <= '0'; 
      cnt_t <= cnt_t + '1'; 
     end if; 
    end if; 
end process; 
+0

Vous pouvez affecter un signal en dehors d'un processus (dans le bloc d'architecture), ce qui constituera une affectation _concurrent_. Il est difficile de déterminer ce que vous utilisez 'time_tick_32' pour; Tant que vous ne l'attribuez pas ailleurs, vous devriez être bien – gsm