Guest User

Untitled

a guest
May 20th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.std_logic_unsigned.all;
  4.  
  5. entity counter_tb is
  6. end entity;
  7.  
  8. architecture TB of counter_tb is
  9.  
  10. component counter
  11. port(
  12. A :out std_logic;
  13. Di :in std_logic_vector (10 downto 0);
  14. clk :in std_logic;
  15. reset :in std_logic
  16. );
  17. end component;
  18.  
  19. -- register counter ports as signals
  20. signal A: std_logic;
  21. signal Di: std_logic_vector (10 downto 0);
  22. signal clk: std_logic;
  23. signal reset: std_logic;
  24.  
  25. begin
  26. -- set as SST
  27. set: counter port map (A, Di, clk, reset);
  28.  
  29. -- simulate hardware clock
  30. process
  31. begin
  32. clk <= '0';
  33. wait for 500000 ns;
  34. clk <= '1';
  35. wait for 500000 ns;
  36. end process;
  37.  
  38. -- test metronome
  39. process
  40. begin
  41. -- 60bpm (1 beat per second) for 3s
  42. Di <= "01111101000";
  43. wait for 3000 ms;
  44. -- 120bpm (2 beats per second) for 1.5s
  45. Di <= "00111110100";
  46. wait for 1500 ms;
  47. -- reset
  48. reset <= '1';
  49. wait for 50 ns;
  50. -- again reset after a minimal period of time, should be triggered although not in clock
  51. reset <= '0';
  52. end process;
  53. end;
Add Comment
Please, Sign In to add comment