sdc_div_test.vhd 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. -- Vhdl test bench created from schematic /home/trurl/STM32_Devel/FPGA/CNC/step_driver_control/sdc_divider.sch - Thu Jul 19 19:41:44 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 sdc_divider_sdc_divider_sch_tb IS
  21. END sdc_divider_sdc_divider_sch_tb;
  22. ARCHITECTURE behavioral OF sdc_divider_sdc_divider_sch_tb IS
  23. COMPONENT sdc_divider
  24. PORT( SYS_CLK : IN STD_LOGIC;
  25. RST : IN STD_LOGIC;
  26. DIV_EN : IN STD_LOGIC;
  27. MAIN_TICK : OUT STD_LOGIC;
  28. SET_DIV_DATA_div2 : IN STD_LOGIC;
  29. SET_DIV_EN : IN STD_LOGIC;
  30. SET_DIV_CLK : IN STD_LOGIC);
  31. END COMPONENT;
  32. SIGNAL SYS_CLK : STD_LOGIC;
  33. SIGNAL RST : STD_LOGIC;
  34. SIGNAL DIV_EN : STD_LOGIC;
  35. SIGNAL MAIN_TICK : STD_LOGIC;
  36. SIGNAL SET_DIV_DATA_div2 : STD_LOGIC;
  37. SIGNAL SET_DIV_EN : STD_LOGIC;
  38. SIGNAL SET_DIV_CLK : STD_LOGIC;
  39. BEGIN
  40. UUT: sdc_divider PORT MAP(
  41. SYS_CLK => SYS_CLK,
  42. RST => RST,
  43. DIV_EN => DIV_EN,
  44. MAIN_TICK => MAIN_TICK,
  45. SET_DIV_DATA_div2 => SET_DIV_DATA_div2,
  46. SET_DIV_EN => SET_DIV_EN,
  47. SET_DIV_CLK => SET_DIV_CLK
  48. );
  49. -- *** Test Bench - User Defined Section ***
  50. tb : PROCESS
  51. BEGIN
  52. SYS_CLK <='0';
  53. RST <='0';
  54. DIV_EN <='0';
  55. SET_DIV_DATA_div2 <='0';
  56. SET_DIV_EN <='0';
  57. SET_DIV_CLK <='0';
  58. wait for 100 ns;
  59. RST <= '1';
  60. wait for 10 ns;
  61. RST <= '0';
  62. wait for 10 ns;
  63. SET_DIV_EN <='1';
  64. SET_DIV_DATA_div2 <='1';
  65. for i in 0 to 4 loop
  66. wait for 10 ns;
  67. SET_DIV_CLK <='1';
  68. wait for 10 ns;
  69. SET_DIV_CLK <='0';
  70. end loop;
  71. wait for 10 ns;
  72. SET_DIV_EN <='0';
  73. DIV_EN <='1';
  74. SET_DIV_DATA_div2 <='0';
  75. for k in 0 to 256 loop
  76. wait for 10 ns;
  77. SYS_CLK <='1';
  78. wait for 10 ns;
  79. SYS_CLK <='0';
  80. end loop; END PROCESS;
  81. -- *** End Test Bench - User Defined Section ***
  82. END;