------------------------------------------------------------------------------- -- Title : test compteur générique programmable -- Project : ------------------------------------------------------------------------------- -- File : test_compteur_prog.vhd -- Author : NOUEL Patrice -- Company : -- Last update: 2004/03/22 -- Platform : ------------------------------------------------------------------------------- -- Description: ------------------------------------------------------------------------------- -- Revisions : -- Date Version Author Description -- 2004/03/22 1.0 nouel Created ------------------------------------------------------------------------------- LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE ieee.numeric_std.ALL; ENTITY test_compteur_prog IS END; --------------------------------------------------------------- ARCHITECTURE par_assertion OF test_compteur_prog IS COMPONENT compteur_prog_gen GENERIC (Nb_Bits : natural := 4; --les valeurs par defaut Modulo : natural :=16); -- sont optionelles PORT ( h, compter, raz, charger : IN std_ulogic; entree : IN std_logic_vector(Nb_bits-1 DOWNTO 0); sortie : OUT std_logic_vector(Nb_bits-1 DOWNTO 0)); END COMPONENT; CONSTANT Periode : TIME := 10 ns; -- 100 MegaH CONSTANT M : natural := 17; CONSTANT N : natural := 5; SIGNAL h, co, ra, ch : STD_ULOGIC; SIGNAL s, e : std_logic_vector(N-1 downto 0); BEGIN horloge: PROCESS BEGIN -- PROCESS horloge h <= '1', '0' AFTER Periode/2 ; WAIT FOR periode; END PROCESS horloge; C1: compteur_prog_gen GENERIC MAP ( N,M) -- compteur modulo 17 PORT MAP ( h => h, compter => co, raz => ra, charger => ch, entree => e, sortie => s); ra <= '1', '0' AFTER (Periode + 4 ns); -- raz initial ch <= '1', '0' AFTER (3*periode + 4 ns); -- chargement initial apres raz co <= '0', '1' AFTER (5*periode + 4 ns); -- liberation compteur e <= "00111"; -- 7 verif:PROCESS VARIABLE s0 : unsigned(N-1 downto 0); -- puisque le compteur fonctionne sur front montant, on le teste -- sur front descendant BEGIN WAIT UNTIL FALLING_EDGE(h); ASSERT unsigned(s) < To_unsigned(M,N) REPORT "sortie hors intervalle"; ASSERT (unsigned(s) - s0) < "00010" REPORT "on doit etre en fin de comptage ou en phase d'initialisation"; s0 := unsigned(s); END PROCESS; END par_assertion;