-- Fichier : compteur_gen_asynchrone.vhd -- Societe : ENSEIRB -- Auteur : P.Nouel -- Date de creation : 12-93 -- Genericite, synthétisable -- Revu en 1999, 2003 --------------------------------------------------------------- LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE ieee.numeric_std.ALL; ENTITY compteur_gen IS GENERIC (Nb_Bits : natural := 4; --les valeurs par defaut Modulo : natural :=16); -- sont optionelles PORT ( h, compter, raz : IN std_ulogic; sortie : OUT std_logic_vector(Nb_bits-1 DOWNTO 0); retenue : OUT std_ulogic); BEGIN ASSERT ----- controle des parametres Modulo <= 2**Nb_bits REPORT "erreur sur les parametres" SEVERITY warning; END compteur_gen; ARCHITECTURE asynchrone OF compteur_gen IS SIGNAL s : unsigned(Nb_bits-1 DOWNTO 0); BEGIN P1 :PROCESS VARIABLE c : natural range 0 TO Modulo -1; BEGIN WAIT ON raz, h; IF raz = '1' THEN c :=0; ELSIF RISING_EDGE(h) THEN IF compter = '1' THEN IF c < Modulo -1 THEN c := c + 1; ELSE c := 0; END IF; END IF; END IF ; s <= to_unsigned(c, Nb_bits) ; END PROCESS; sortie <= std_logic_vector(s); -- cast retenue <= '1' WHEN s = to_unsigned( Modulo-1, Nb_bits) ELSE '0'; END asynchrone;