No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Compteur.vhd 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 28.06.2021 14:59:39
  6. -- Design Name:
  7. -- Module Name: Compteur - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool Versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. entity Compteur is
  23. Generic (Min : Natural;
  24. Max : Natural
  25. );
  26. Port (CLK : in STD_LOGIC;
  27. RST : in STD_LOGIC;
  28. Value : out Natural;
  29. Carry : out STD_LOGIC);
  30. end Compteur;
  31. architecture Behavioral of Compteur is
  32. signal current : Natural := Min;
  33. signal InternCarry : STD_LOGIC := '0';
  34. begin
  35. process
  36. begin
  37. wait until CLK'event and CLK = '1';
  38. if (RST = '0') then
  39. current <= Min;
  40. else
  41. current <= current + 1;
  42. if (current = Max) then
  43. InternCarry <= '1';
  44. current <= Min;
  45. else
  46. InternCarry <= '0';
  47. end if;
  48. end if;
  49. end process;
  50. Value <= current;
  51. Carry <= InternCarry;
  52. end Behavioral;