count_bench.vhd 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. -- Vhdl test bench created from schematic /home/lusius/Devel/STM32_Devel/FPGA/CNC/step_driver_control/count_bidir_4.sch - Fri Jul 20 04:38:38 2018
  2. --
  3. -- Notes:
  4. -- 1) This testbench template has been automatically generated using types
  5. -- std_logic and std_logic_vector for the ports of the unit under test.
  6. -- Xilinx recommends that these types always be used for the top-level
  7. -- I/O of a design in order to guarantee that the testbench will bind
  8. -- correctly to the timing (post-route) simulation model.
  9. -- 2) To use this template as your testbench, change the filename to any
  10. -- name of your choice with the extension .vhd, and use the "Source->Add"
  11. -- menu in Project Navigator to import the testbench. Then
  12. -- edit the user defined section below, adding code to generate the
  13. -- stimulus for your design.
  14. --
  15. LIBRARY ieee;
  16. USE ieee.std_logic_1164.ALL;
  17. USE ieee.numeric_std.ALL;
  18. LIBRARY UNISIM;
  19. USE UNISIM.Vcomponents.ALL;
  20. ENTITY count_bidir_4_count_bidir_4_sch_tb IS
  21. END count_bidir_4_count_bidir_4_sch_tb;
  22. ARCHITECTURE behavioral OF count_bidir_4_count_bidir_4_sch_tb IS
  23. COMPONENT count_bidir_4
  24. PORT( Q0 : OUT STD_LOGIC;
  25. DIR : IN STD_LOGIC;
  26. Q1 : OUT STD_LOGIC;
  27. Q2 : OUT STD_LOGIC;
  28. RST : IN STD_LOGIC;
  29. COUNT : IN STD_LOGIC;
  30. Q3 : OUT STD_LOGIC);
  31. END COMPONENT;
  32. SIGNAL Q0 : STD_LOGIC;
  33. SIGNAL DIR : STD_LOGIC;
  34. SIGNAL Q1 : STD_LOGIC;
  35. SIGNAL Q2 : STD_LOGIC;
  36. SIGNAL RST : STD_LOGIC;
  37. SIGNAL COUNT : STD_LOGIC;
  38. SIGNAL Q3 : STD_LOGIC;
  39. BEGIN
  40. UUT: count_bidir_4 PORT MAP(
  41. Q0 => Q0,
  42. DIR => DIR,
  43. Q1 => Q1,
  44. Q2 => Q2,
  45. RST => RST,
  46. COUNT => COUNT,
  47. Q3 => Q3
  48. );
  49. -- *** Test Bench - User Defined Section ***
  50. tb : PROCESS
  51. BEGIN
  52. RST <= '1';
  53. DIR <= '1';
  54. COUNT <= '0';
  55. wait for 100 ns;
  56. RST <= '0';
  57. for i in 0 to 20 loop
  58. wait for 10 ns;
  59. COUNT <= '1';
  60. wait for 10 ns;
  61. COUNT <= '0';
  62. end loop;
  63. wait for 10 ns;
  64. DIR <= '0';
  65. for i in 0 to 20 loop
  66. wait for 10 ns;
  67. COUNT <= '1';
  68. wait for 10 ns;
  69. COUNT <= '0';
  70. end loop;
  71. WAIT; -- will wait forever
  72. END PROCESS;
  73. -- *** End Test Bench - User Defined Section ***
  74. END;