]> rtime.felk.cvut.cz Git - fpga/quadcount.git/blob - qctest.vhdl
silly manual testbench added (now should be makeable)
[fpga/quadcount.git] / qctest.vhdl
1 --
2 -- created by hand&mouse in Xilinx ISE
3 --
4
5 library ieee;
6 use ieee.std_logic_1164.all;
7 use ieee.std_logic_arith.all;
8 use ieee.std_logic_unsigned.all;
9 use ieee.numeric_std.all;
10 USE IEEE.STD_LOGIC_TEXTIO.ALL;
11 USE STD.TEXTIO.ALL;
12
13 ENTITY qctest IS
14 END qctest;
15
16 ARCHITECTURE testbench_arch OF qctest IS
17     FILE RESULTS: TEXT OPEN WRITE_MODE IS "results.txt";
18
19     COMPONENT qcounter
20         PORT (
21             clock : In std_logic;
22             reset : In std_logic;
23             a0 : In std_logic;
24             b0 : In std_logic;
25             qcount : Out std_logic_vector (31 DownTo 0);
26             a_rise : Out std_logic;
27             a_fall : Out std_logic;
28             b_rise : Out std_logic;
29             b_fall : Out std_logic;
30             ab_event : Out std_logic;
31             ab_error : Out std_logic
32         );
33     END COMPONENT;
34
35     SIGNAL clock : std_logic := '0';
36     SIGNAL reset : std_logic := '0';
37     SIGNAL a : std_logic := '0';
38     SIGNAL b : std_logic := '0';
39     SIGNAL qcount : std_logic_vector (31 DownTo 0) := "00000000000000000000000000000000";
40     SIGNAL a_rise : std_logic := '0';
41     SIGNAL a_fall : std_logic := '0';
42     SIGNAL b_rise : std_logic := '0';
43     SIGNAL b_fall : std_logic := '0';
44     SIGNAL ab_event : std_logic := '0';
45     SIGNAL ab_error : std_logic := '0';
46
47     constant PERIOD : time := 200 ns;
48     constant DUTY_CYCLE : real := 0.5;
49     constant OFFSET : time := 100 ns;
50
51     BEGIN
52         UUT : qcounter
53         PORT MAP (
54             clock => clock,
55             reset => reset,
56             a0 => a,
57             b0 => b,
58             qcount => qcount,
59             a_rise => a_rise,
60             a_fall => a_fall,
61             b_rise => b_rise,
62             b_fall => b_fall,
63             ab_event => ab_event,
64             ab_error => ab_error
65         );
66
67         PROCESS    -- clock process for clock
68         BEGIN
69             WAIT for OFFSET;
70             CLOCK_LOOP : LOOP
71                 clock <= '0';
72                 WAIT FOR (PERIOD - (PERIOD * DUTY_CYCLE));
73                 clock <= '1';
74                 WAIT FOR (PERIOD * DUTY_CYCLE);
75             END LOOP CLOCK_LOOP;
76         END PROCESS;
77
78         PROCESS
79             BEGIN
80                 -- -------------  Current Time:  185ns
81                 WAIT FOR 185 ns;
82                 a <= '1';
83                 -- -------------------------------------
84                 -- -------------  Current Time:  385ns
85                 WAIT FOR 200 ns;
86                 b <= '1';
87                 -- -------------------------------------
88                 -- -------------  Current Time:  585ns
89                 WAIT FOR 200 ns;
90                 a <= '0';
91                 -- -------------------------------------
92                 -- -------------  Current Time:  785ns
93                 WAIT FOR 200 ns;
94                 b <= '0';
95                 -- -------------------------------------
96                 -- -------------  Current Time:  985ns
97                 WAIT FOR 200 ns;
98                 a <= '1';
99                 -- -------------------------------------
100                 -- -------------  Current Time:  1185ns
101                 WAIT FOR 200 ns;
102                 b <= '1';
103                 -- -------------------------------------
104                 -- -------------  Current Time:  1385ns
105                 WAIT FOR 200 ns;
106                 a <= '0';
107                 -- -------------------------------------
108                 -- -------------  Current Time:  1585ns
109                 WAIT FOR 200 ns;
110                 b <= '0';
111                 -- -------------------------------------
112                 -- -------------  Current Time:  1785ns
113                 WAIT FOR 200 ns;
114                 b <= '1';
115                 -- -------------------------------------
116                 -- -------------  Current Time:  1985ns
117                 WAIT FOR 200 ns;
118                 a <= '1';
119                 b <= '0';
120                 -- -------------------------------------
121                 -- -------------  Current Time:  2385ns
122                 WAIT FOR 400 ns;
123                 a <= '0';
124                 b <= '1';
125                 -- -------------------------------------
126                 -- -------------  Current Time:  2585ns
127                 WAIT FOR 200 ns;
128                 b <= '0';
129                 -- -------------------------------------
130                 -- -------------  Current Time:  2785ns
131                 WAIT FOR 200 ns;
132                 a <= '1';
133                 -- -------------------------------------
134                 -- -------------  Current Time:  2985ns
135                 WAIT FOR 200 ns;
136                 b <= '1';
137                 -- -------------------------------------
138                 -- -------------  Current Time:  3185ns
139                 WAIT FOR 200 ns;
140                 b <= '0';
141                 -- -------------------------------------
142                 -- -------------  Current Time:  3385ns
143                 WAIT FOR 200 ns;
144                 a <= '0';
145                 -- -------------------------------------
146                 -- -------------  Current Time:  3585ns
147                 WAIT FOR 200 ns;
148                 b <= '1';
149                 -- -------------------------------------
150                 -- -------------  Current Time:  3785ns
151                 WAIT FOR 200 ns;
152                 a <= '1';
153                 -- -------------------------------------
154                 -- -------------  Current Time:  3985ns
155                 WAIT FOR 200 ns;
156                 b <= '0';
157                 -- -------------------------------------
158                 -- -------------  Current Time:  4185ns
159                 WAIT FOR 200 ns;
160                 a <= '0';
161                 -- -------------------------------------
162                 -- -------------  Current Time:  4385ns
163                 WAIT FOR 200 ns;
164                 b <= '1';
165                 -- -------------------------------------
166                 -- -------------  Current Time:  4785ns
167                 WAIT FOR 400 ns;
168                 a <= '1';
169                 -- -------------------------------------
170                 -- -------------  Current Time:  4985ns
171                 WAIT FOR 200 ns;
172                 b <= '0';
173                 -- -------------------------------------
174                 -- -------------  Current Time:  5585ns
175                 WAIT FOR 600 ns;
176                 a <= '0';
177                 -- -------------------------------------
178                 -- -------------  Current Time:  5985ns
179                 WAIT FOR 400 ns;
180                 a <= '1';
181                 -- -------------------------------------
182                 -- -------------  Current Time:  6385ns
183                 WAIT FOR 400 ns;
184                 a <= '0';
185                 -- -------------------------------------
186                 -- -------------  Current Time:  6585ns
187                 WAIT FOR 200 ns;
188                 b <= '1';
189                 -- -------------------------------------
190                 -- -------------  Current Time:  6985ns
191                 WAIT FOR 400 ns;
192                 b <= '0';
193                 -- -------------------------------------
194                 WAIT FOR 993215 ns;
195
196             END PROCESS;
197
198     END testbench_arch;
199