| 1 | --------------------------------------------------------------------------------
|
|---|
| 2 | -- Company: Patrick Vogler
|
|---|
| 3 | -- Engineer:
|
|---|
| 4 | --
|
|---|
| 5 | -- Create Date: 14:01:52 05/18/2011
|
|---|
| 6 | -- Design Name:
|
|---|
| 7 | -- Module Name: /home/pavogler/ISDC_repos/firmware/FTM/Timing_counters/Timing_counters_V2//Timing_counter_tb.vhd
|
|---|
| 8 | -- Project Name: Timing_counter_2
|
|---|
| 9 | -- Target Device:
|
|---|
| 10 | -- Tool versions:
|
|---|
| 11 | -- Description:
|
|---|
| 12 | --
|
|---|
| 13 | -- VHDL Test Bench Created by ISE for module: Timing_counter
|
|---|
| 14 | --
|
|---|
| 15 | -- Dependencies:
|
|---|
| 16 | --
|
|---|
| 17 | -- Revision:
|
|---|
| 18 | -- Revision 0.01 - File Created
|
|---|
| 19 | -- Additional Comments:
|
|---|
| 20 | --
|
|---|
| 21 | -- Notes:
|
|---|
| 22 | -- This testbench has been automatically generated using types std_logic and
|
|---|
| 23 | -- std_logic_vector for the ports of the unit under test. Xilinx recommends
|
|---|
| 24 | -- that these types always be used for the top-level I/O of a design in order
|
|---|
| 25 | -- to guarantee that the testbench will bind correctly to the post-implementation
|
|---|
| 26 | -- simulation model.
|
|---|
| 27 | --------------------------------------------------------------------------------
|
|---|
| 28 | LIBRARY ieee;
|
|---|
| 29 | USE ieee.std_logic_1164.ALL;
|
|---|
| 30 | USE ieee.std_logic_unsigned.all;
|
|---|
| 31 | USE ieee.numeric_std.ALL;
|
|---|
| 32 |
|
|---|
| 33 | library ftm_definitions;
|
|---|
| 34 | USE ftm_definitions.ftm_array_types.all;
|
|---|
| 35 | USE ftm_definitions.ftm_constants.all;
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | ENTITY Timing_counter_tb IS
|
|---|
| 40 | END Timing_counter_tb;
|
|---|
| 41 |
|
|---|
| 42 | ARCHITECTURE behavior OF Timing_counter_tb IS
|
|---|
| 43 |
|
|---|
| 44 | -- Component Declaration for the Unit Under Test (UUT)
|
|---|
| 45 |
|
|---|
| 46 | COMPONENT Timing_counter
|
|---|
| 47 | PORT(
|
|---|
| 48 | clk : IN std_logic;
|
|---|
| 49 | enable : IN std_logic;
|
|---|
| 50 | reset : IN std_logic;
|
|---|
| 51 | read_counter : IN std_logic;
|
|---|
| 52 | reading_started : OUT std_logic;
|
|---|
| 53 | reading_valid : OUT std_logic;
|
|---|
| 54 | counter_reading : OUT std_logic_vector(TC_WIDTH - 1 downto 0)
|
|---|
| 55 | );
|
|---|
| 56 | END COMPONENT;
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 | --Inputs
|
|---|
| 60 | signal clk : std_logic := '0';
|
|---|
| 61 | signal enable : std_logic := '0';
|
|---|
| 62 | signal reset : std_logic := '0';
|
|---|
| 63 | signal read_counter : std_logic := '0';
|
|---|
| 64 |
|
|---|
| 65 | --Outputs
|
|---|
| 66 | signal reading_started : std_logic;
|
|---|
| 67 | signal reading_valid : std_logic;
|
|---|
| 68 | signal counter_reading : std_logic_vector(TC_WIDTH - 1 downto 0);
|
|---|
| 69 |
|
|---|
| 70 | -- Clock period definitions
|
|---|
| 71 | constant clk_period : time := 20 ns;
|
|---|
| 72 |
|
|---|
| 73 | BEGIN
|
|---|
| 74 |
|
|---|
| 75 | -- Instantiate the Unit Under Test (UUT)
|
|---|
| 76 | uut: Timing_counter PORT MAP (
|
|---|
| 77 | clk => clk,
|
|---|
| 78 | enable => enable,
|
|---|
| 79 | reset => reset,
|
|---|
| 80 | read_counter => read_counter,
|
|---|
| 81 | reading_started => reading_started,
|
|---|
| 82 | reading_valid => reading_valid,
|
|---|
| 83 | counter_reading => counter_reading
|
|---|
| 84 | );
|
|---|
| 85 |
|
|---|
| 86 | -- Clock process definitions
|
|---|
| 87 | clk_process :process
|
|---|
| 88 | begin
|
|---|
| 89 | clk <= '0';
|
|---|
| 90 | wait for clk_period/2;
|
|---|
| 91 | clk <= '1';
|
|---|
| 92 | wait for clk_period/2;
|
|---|
| 93 | end process;
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | -- Stimulus process
|
|---|
| 97 | stim_proc: process
|
|---|
| 98 | begin
|
|---|
| 99 | -- hold reset state for 100 ms.
|
|---|
| 100 | -- wait for 100 ms;
|
|---|
| 101 |
|
|---|
| 102 | wait for clk_period*10;
|
|---|
| 103 |
|
|---|
| 104 | -- insert stimulus here
|
|---|
| 105 |
|
|---|
| 106 | -- insert stimulus here
|
|---|
| 107 |
|
|---|
| 108 | reset <= '0';
|
|---|
| 109 | enable <= '0';
|
|---|
| 110 | wait for clk_period*10;
|
|---|
| 111 | reset <= '1';
|
|---|
| 112 | wait for clk_period*10;
|
|---|
| 113 | reset <= '0';
|
|---|
| 114 | wait for clk_period*10;
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 | -- readout
|
|---|
| 121 | read_counter <= '1';
|
|---|
| 122 | wait for clk_period*2;
|
|---|
| 123 | read_counter <= '0';
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 | -- counting 50 periodes
|
|---|
| 131 | enable <= '1';
|
|---|
| 132 | wait for clk_period*500;
|
|---|
| 133 | enable <= '0';
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 | -- readout
|
|---|
| 137 | read_counter <= '1';
|
|---|
| 138 | wait for clk_period*2;
|
|---|
| 139 | read_counter <= '0';
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 | -- new run
|
|---|
| 145 |
|
|---|
| 146 | reset <= '0';
|
|---|
| 147 | enable <= '0';
|
|---|
| 148 | wait for clk_period*10;
|
|---|
| 149 | reset <= '1';
|
|---|
| 150 | wait for clk_period*10;
|
|---|
| 151 | reset <= '0';
|
|---|
| 152 | wait for clk_period*10;
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 | -- counting 251 periodes
|
|---|
| 156 | enable <= '1';
|
|---|
| 157 | wait for clk_period*250;
|
|---|
| 158 | enable <= '0';
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 | -- readout
|
|---|
| 162 | read_counter <= '1';
|
|---|
| 163 | wait for clk_period*2;
|
|---|
| 164 | read_counter <= '0';
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 | -- new run
|
|---|
| 173 |
|
|---|
| 174 | reset <= '0';
|
|---|
| 175 | enable <= '0';
|
|---|
| 176 | wait for clk_period*10;
|
|---|
| 177 | reset <= '1';
|
|---|
| 178 | wait for clk_period*10;
|
|---|
| 179 | reset <= '0';
|
|---|
| 180 | wait for clk_period*10;
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 | -- counting 70251 periodes
|
|---|
| 184 | enable <= '0';
|
|---|
| 185 | wait for clk_period*70251;
|
|---|
| 186 | enable <= '0';
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 | wait for clk_period*10;
|
|---|
| 190 | -- readout
|
|---|
| 191 | read_counter <= '1';
|
|---|
| 192 | wait for clk_period*2;
|
|---|
| 193 | read_counter <= '0';
|
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 | wait for clk_period*10;
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 | enable <= '0';
|
|---|
| 201 | wait for clk_period*10;
|
|---|
| 202 | reset <= '1';
|
|---|
| 203 | wait for clk_period*10;
|
|---|
| 204 | reset <= '0';
|
|---|
| 205 | wait for clk_period*10;
|
|---|
| 206 |
|
|---|
| 207 |
|
|---|
| 208 | -- readout
|
|---|
| 209 | read_counter <= '1';
|
|---|
| 210 | wait for clk_period*2;
|
|---|
| 211 | read_counter <= '0';
|
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 | wait;
|
|---|
| 217 | end process;
|
|---|
| 218 |
|
|---|
| 219 | END;
|
|---|