indic_4reg_dec_test.vhd 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. -- Vhdl test bench created from schematic /home/lusius/Devel/STM32_Devel/FPGA/CNC/step_driver_control/indic_4reg_decoder.sch - Tue Jul 24 03:25:54 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 indic_4reg_decoder_indic_4reg_decoder_sch_tb IS
  21. END indic_4reg_decoder_indic_4reg_decoder_sch_tb;
  22. ARCHITECTURE behavioral OF indic_4reg_decoder_indic_4reg_decoder_sch_tb IS
  23. COMPONENT indic_4reg_decoder
  24. PORT( DIRECTION : IN STD_LOGIC;
  25. COUNT : IN STD_LOGIC;
  26. RESET : IN STD_LOGIC;
  27. COUNT_EN : IN STD_LOGIC;
  28. SEG_SWITCH : IN STD_LOGIC;
  29. SEG_A : OUT STD_LOGIC;
  30. SEG_B : OUT STD_LOGIC;
  31. SEG_C : OUT STD_LOGIC;
  32. SEG_D : OUT STD_LOGIC;
  33. SEG_E : OUT STD_LOGIC;
  34. SEG_F : OUT STD_LOGIC;
  35. SEG_G : OUT STD_LOGIC);
  36. END COMPONENT;
  37. SIGNAL DIRECTION : STD_LOGIC;
  38. SIGNAL COUNT : STD_LOGIC;
  39. SIGNAL RESET : STD_LOGIC;
  40. SIGNAL COUNT_EN : STD_LOGIC;
  41. SIGNAL SEG_SWITCH : STD_LOGIC;
  42. SIGNAL SEG_A : STD_LOGIC;
  43. SIGNAL SEG_B : STD_LOGIC;
  44. SIGNAL SEG_C : STD_LOGIC;
  45. SIGNAL SEG_D : STD_LOGIC;
  46. SIGNAL SEG_E : STD_LOGIC;
  47. SIGNAL SEG_F : STD_LOGIC;
  48. SIGNAL SEG_G : STD_LOGIC;
  49. BEGIN
  50. UUT: indic_4reg_decoder PORT MAP(
  51. DIRECTION => DIRECTION,
  52. COUNT => COUNT,
  53. RESET => RESET,
  54. COUNT_EN => COUNT_EN,
  55. SEG_SWITCH => SEG_SWITCH,
  56. SEG_A => SEG_A,
  57. SEG_B => SEG_B,
  58. SEG_C => SEG_C,
  59. SEG_D => SEG_D,
  60. SEG_E => SEG_E,
  61. SEG_F => SEG_F,
  62. SEG_G => SEG_G
  63. );
  64. -- *** Test Bench - User Defined Section ***
  65. tb : PROCESS
  66. BEGIN
  67. DIRECTION <= '0';
  68. COUNT <= '0';
  69. RESET <= '0';
  70. COUNT_EN <= '0';
  71. SEG_SWITCH <= '0';
  72. wait for 100 ns;
  73. RESET <= '1';
  74. wait for 10 ns;
  75. RESET <= '0';
  76. wait for 10 ns;
  77. DIRECTION <= '1';
  78. COUNT_EN <= '1';
  79. wait for 100 ns;
  80. for i in 0 to 24 loop
  81. wait for 10 ns;
  82. COUNT <= '1';
  83. wait for 10 ns;
  84. COUNT <= '0';
  85. end loop;
  86. wait for 100 ns;
  87. for k in 0 to 3 loop
  88. wait for 10 ns;
  89. SEG_SWITCH <= '1';
  90. wait for 10 ns;
  91. SEG_SWITCH <= '0';
  92. end loop;
  93. WAIT; -- will wait forever
  94. END PROCESS;
  95. -- *** End Test Bench - User Defined Section ***
  96. END;