top_module_test.vhd 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. -- Vhdl test bench created from schematic /home/trurl/STM32_Devel/FPGA/CNC/step_driver_control/topboard.sch - Thu Jul 19 20:19:30 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 topboard_topboard_sch_tb IS
  21. END topboard_topboard_sch_tb;
  22. ARCHITECTURE behavioral OF topboard_topboard_sch_tb IS
  23. COMPONENT topboard
  24. PORT( RESET : IN STD_LOGIC;
  25. WORK_ENABLE : IN STD_LOGIC;
  26. SET_ENABLE : IN STD_LOGIC;
  27. SET_DIV_DATA : IN STD_LOGIC;
  28. SET_DIV_CLK : IN STD_LOGIC;
  29. A1 : OUT STD_LOGIC;
  30. A2 : OUT STD_LOGIC;
  31. B1 : OUT STD_LOGIC;
  32. B2 : OUT STD_LOGIC;
  33. SYS_CLOCK : IN STD_LOGIC;
  34. SET_DIST_CLK : IN STD_LOGIC;
  35. SET_DIST_DATA : IN STD_LOGIC;
  36. DIST_FINISH : OUT STD_LOGIC;
  37. DIR_IS_UP : IN STD_LOGIC);
  38. END COMPONENT;
  39. SIGNAL RESET : STD_LOGIC;
  40. SIGNAL WORK_ENABLE : STD_LOGIC;
  41. SIGNAL SET_ENABLE : STD_LOGIC;
  42. SIGNAL SET_DIV_DATA : STD_LOGIC;
  43. SIGNAL SET_DIV_CLK : STD_LOGIC;
  44. SIGNAL A1 : STD_LOGIC;
  45. SIGNAL A2 : STD_LOGIC;
  46. SIGNAL B1 : STD_LOGIC;
  47. SIGNAL B2 : STD_LOGIC;
  48. SIGNAL SYS_CLOCK : STD_LOGIC;
  49. SIGNAL SET_DIST_CLK : STD_LOGIC;
  50. SIGNAL SET_DIST_DATA : STD_LOGIC;
  51. SIGNAL DIST_FINISH : STD_LOGIC;
  52. SIGNAL DIR_IS_UP : STD_LOGIC;
  53. BEGIN
  54. UUT: topboard PORT MAP(
  55. RESET => RESET,
  56. WORK_ENABLE => WORK_ENABLE,
  57. SET_ENABLE => SET_ENABLE,
  58. SET_DIV_DATA => SET_DIV_DATA,
  59. SET_DIV_CLK => SET_DIV_CLK,
  60. A1 => A1,
  61. A2 => A2,
  62. B1 => B1,
  63. B2 => B2,
  64. SYS_CLOCK => SYS_CLOCK,
  65. SET_DIST_CLK => SET_DIST_CLK,
  66. SET_DIST_DATA => SET_DIST_DATA,
  67. DIST_FINISH => DIST_FINISH,
  68. DIR_IS_UP => DIR_IS_UP
  69. );
  70. -- *** Test Bench - User Defined Section ***
  71. tb : PROCESS
  72. BEGIN
  73. RESET <= '0';
  74. WORK_ENABLE <= '0';
  75. SET_ENABLE <= '0';
  76. SET_DIV_DATA <= '0';
  77. SET_DIV_CLK <= '0';
  78. SYS_CLOCK <= '0';
  79. SET_DIST_CLK <= '0';
  80. SET_DIST_DATA <= '0';
  81. DIR_IS_UP <= '0';
  82. wait for 100 ns;
  83. RESET <= '1';
  84. wait for 10 ns;
  85. RESET <= '0';
  86. wait for 10 ns;
  87. SET_ENABLE <= '1';
  88. SET_DIV_DATA <= '1';
  89. for div in 0 to 1 loop
  90. wait for 10 ns;
  91. SET_DIV_CLK <= '1';
  92. wait for 10 ns;
  93. SET_DIV_CLK <= '0';
  94. end loop;
  95. wait for 10 ns;
  96. SET_DIV_DATA <= '0';
  97. SET_DIST_DATA <= '1';
  98. for dist in 0 to 4 loop
  99. wait for 10 ns;
  100. SET_DIST_CLK <= '1';
  101. wait for 10 ns;
  102. SET_DIST_CLK <= '0';
  103. end loop;
  104. wait for 10 ns;
  105. SET_ENABLE <= '0';
  106. SET_DIST_DATA <= '0';
  107. wait for 10 ns;
  108. WORK_ENABLE <= '1';
  109. for work in 0 to 512 loop
  110. wait for 10 ns;
  111. SYS_CLOCK <= '1';
  112. wait for 10 ns;
  113. SYS_CLOCK <= '0';
  114. end loop;
  115. wait for 10 ns;
  116. WORK_ENABLE <= '0';
  117. wait;
  118. END PROCESS;
  119. -- *** End Test Bench - User Defined Section ***
  120. END;