tb.vhd 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4. entity tb is
  5. end entity;
  6. architecture beh of tb is
  7. component generic_counter is
  8. generic (
  9. counter_bits : integer
  10. );
  11. port(
  12. clk : in std_logic;
  13. rst : in std_logic;
  14. en : in std_logic;
  15. cnt : out unsigned (counter_bits -1 downto 0)
  16. );
  17. end component;
  18. signal clock : std_logic := '0';
  19. signal enable_counter : std_logic;
  20. signal reset : std_logic;
  21. signal counter_value : unsigned(7 downto 0);
  22. signal running : boolean := true;
  23. begin
  24. running <= true, false after 400 us;
  25. reset <= '0', '1' after 20 us, '0' after 40 us, '1' after 300 us, '0' after 320 us;
  26. enable_counter <= '0', '1' after 60 us, '0' after 200 us, '1' after 240 us;
  27. process is
  28. begin
  29. if running then
  30. wait for 10 us;
  31. clock <= not clock;
  32. else
  33. report "End of simulation!";
  34. wait;
  35. end if;
  36. end process;
  37. cnt_i1 : generic_counter
  38. generic map(
  39. counter_bits => 8
  40. )
  41. port map(
  42. clk => clock,
  43. rst => reset,
  44. en => enable_counter,
  45. cnt => counter_value
  46. );
  47. end architecture;