OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src/] [tA_capture.v] - Blame information for rev 219

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 olivier.gi
/*===========================================================================*/
2
/* Copyright (C) 2001 Authors                                                */
3
/*                                                                           */
4
/* This source file may be used and distributed without restriction provided */
5
/* that this copyright statement is not removed from the file and that any   */
6
/* derivative work contains the original copyright notice and the associated */
7
/* disclaimer.                                                               */
8
/*                                                                           */
9
/* This source file is free software; you can redistribute it and/or modify  */
10
/* it under the terms of the GNU Lesser General Public License as published  */
11
/* by the Free Software Foundation; either version 2.1 of the License, or    */
12
/* (at your option) any later version.                                       */
13
/*                                                                           */
14
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
15
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     */
16
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public       */
17
/* License for more details.                                                 */
18
/*                                                                           */
19
/* You should have received a copy of the GNU Lesser General Public License  */
20
/* along with this source; if not, write to the Free Software Foundation,    */
21
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA        */
22
/*                                                                           */
23
/*===========================================================================*/
24
/*                                  TIMER A                                  */
25
/*---------------------------------------------------------------------------*/
26
/* Test the timer A:                                                         */
27
/*                        - Check the timer capture unit.                    */
28 18 olivier.gi
/*                                                                           */
29
/* Author(s):                                                                */
30
/*             - Olivier Girard,    olgirard@gmail.com                       */
31
/*                                                                           */
32
/*---------------------------------------------------------------------------*/
33 19 olivier.gi
/* $Rev: 202 $                                                                */
34
/* $LastChangedBy: olivier.girard $                                          */
35
/* $LastChangedDate: 2015-07-01 23:13:32 +0200 (Wed, 01 Jul 2015) $          */
36 2 olivier.gi
/*===========================================================================*/
37
 
38
integer my_counter;
39
always @ (posedge mclk)
40
  my_counter <=  my_counter+1;
41
 
42
wire [15:0] tar = timerA_0.tar;
43 202 olivier.gi
 
44 2 olivier.gi
initial
45
   begin
46
      $display(" ===============================================");
47
      $display("|                 START SIMULATION              |");
48
      $display(" ===============================================");
49
      repeat(5) @(posedge mclk);
50
      stimulus_done = 0;
51
 
52 180 olivier.gi
`ifdef ASIC_CLOCKING
53 202 olivier.gi
      tb_skip_finish("|   (this test is not supported in ASIC mode)   |");
54 134 olivier.gi
`else
55
 
56 2 olivier.gi
      // TIMER A TEST:  INPUT MUX (CCI)
57
      //--------------------------------------------------------
58
 
59
                                // --------- Comparator 0 ----------
60
      @(mem200 === 16'h0001);
61
      ta_cci0a = 1'b1;
62
      ta_cci0b = 1'b0;
63
      ta_cci1a = 1'b0;
64
      ta_cci1b = 1'b0;
65
      ta_cci2a = 1'b0;
66
      ta_cci2b = 1'b0;
67 202 olivier.gi
      @(mem200 === 16'h0002);
68 2 olivier.gi
      ta_cci0a = 1'b0;
69
      ta_cci0b = 1'b1;
70
      ta_cci1a = 1'b1;
71
      ta_cci1b = 1'b1;
72
      ta_cci2a = 1'b1;
73
      ta_cci2b = 1'b1;
74 202 olivier.gi
      @(mem200 === 16'h0003);
75 2 olivier.gi
      if (mem202 !== 16'h0008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - CCIxA =====");
76
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - CCIxA =====");
77
 
78
      @(mem200 === 16'h0004);
79
      ta_cci0a = 1'b0;
80
      ta_cci0b = 1'b1;
81
      ta_cci1a = 1'b0;
82
      ta_cci1b = 1'b0;
83
      ta_cci2a = 1'b0;
84
      ta_cci2b = 1'b0;
85 202 olivier.gi
      @(mem200 === 16'h0005);
86 2 olivier.gi
      ta_cci0a = 1'b1;
87
      ta_cci0b = 1'b0;
88
      ta_cci1a = 1'b1;
89
      ta_cci1b = 1'b1;
90
      ta_cci2a = 1'b1;
91
      ta_cci2b = 1'b1;
92 202 olivier.gi
      @(mem200 === 16'h0006);
93 2 olivier.gi
      if (mem202 !== 16'h1008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - CCIxB =====");
94
      if (mem204 !== 16'h1000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - CCIxB =====");
95
 
96
      @(mem200 === 16'h0007);
97
      ta_cci0a = 1'b0;
98
      ta_cci0b = 1'b0;
99
      ta_cci1a = 1'b0;
100
      ta_cci1b = 1'b0;
101
      ta_cci2a = 1'b0;
102
      ta_cci2b = 1'b0;
103 202 olivier.gi
      @(mem200 === 16'h0008);
104 2 olivier.gi
      ta_cci0a = 1'b1;
105
      ta_cci0b = 1'b1;
106
      ta_cci1a = 1'b1;
107
      ta_cci1b = 1'b1;
108
      ta_cci2a = 1'b1;
109
      ta_cci2b = 1'b1;
110 202 olivier.gi
      @(mem200 === 16'h0009);
111 2 olivier.gi
      if (mem202 !== 16'h2000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - GND =====");
112
      if (mem204 !== 16'h2000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - GND =====");
113
 
114
      @(mem200 === 16'h000A);
115
      ta_cci0a = 1'b0;
116
      ta_cci0b = 1'b0;
117
      ta_cci1a = 1'b0;
118
      ta_cci1b = 1'b0;
119
      ta_cci2a = 1'b0;
120
      ta_cci2b = 1'b0;
121 202 olivier.gi
      @(mem200 === 16'h000B);
122 2 olivier.gi
      ta_cci0a = 1'b1;
123
      ta_cci0b = 1'b1;
124
      ta_cci1a = 1'b1;
125
      ta_cci1b = 1'b1;
126
      ta_cci2a = 1'b1;
127
      ta_cci2b = 1'b1;
128 202 olivier.gi
      @(mem200 === 16'h000C);
129 2 olivier.gi
      if (mem202 !== 16'h3008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - VDD =====");
130
      if (mem204 !== 16'h3008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - VDD =====");
131
 
132 202 olivier.gi
 
133 2 olivier.gi
                                // --------- Comparator 1 ----------
134
      @(mem200 === 16'h0011);
135
      ta_cci0a = 1'b0;
136
      ta_cci0b = 1'b0;
137
      ta_cci1a = 1'b1;
138
      ta_cci1b = 1'b0;
139
      ta_cci2a = 1'b0;
140
      ta_cci2b = 1'b0;
141 202 olivier.gi
      @(mem200 === 16'h0012);
142 2 olivier.gi
      ta_cci0a = 1'b1;
143
      ta_cci0b = 1'b1;
144
      ta_cci1a = 1'b0;
145
      ta_cci1b = 1'b1;
146
      ta_cci2a = 1'b1;
147
      ta_cci2b = 1'b1;
148 202 olivier.gi
      @(mem200 === 16'h0013);
149 2 olivier.gi
      if (mem202 !== 16'h0008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - CCIxA =====");
150
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - CCIxA =====");
151
 
152
      @(mem200 === 16'h0014);
153
      ta_cci0a = 1'b0;
154
      ta_cci0b = 1'b0;
155
      ta_cci1a = 1'b0;
156
      ta_cci1b = 1'b1;
157
      ta_cci2a = 1'b0;
158
      ta_cci2b = 1'b0;
159 202 olivier.gi
      @(mem200 === 16'h0015);
160 2 olivier.gi
      ta_cci0a = 1'b1;
161
      ta_cci0b = 1'b1;
162
      ta_cci1a = 1'b1;
163
      ta_cci1b = 1'b0;
164
      ta_cci2a = 1'b1;
165
      ta_cci2b = 1'b1;
166 202 olivier.gi
      @(mem200 === 16'h0016);
167 2 olivier.gi
      if (mem202 !== 16'h1008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - CCIxB =====");
168
      if (mem204 !== 16'h1000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - CCIxB =====");
169
 
170
      @(mem200 === 16'h0017);
171
      ta_cci0a = 1'b0;
172
      ta_cci0b = 1'b0;
173
      ta_cci1a = 1'b0;
174
      ta_cci1b = 1'b0;
175
      ta_cci2a = 1'b0;
176
      ta_cci2b = 1'b0;
177 202 olivier.gi
      @(mem200 === 16'h0018);
178 2 olivier.gi
      ta_cci0a = 1'b1;
179
      ta_cci0b = 1'b1;
180
      ta_cci1a = 1'b1;
181
      ta_cci1b = 1'b1;
182
      ta_cci2a = 1'b1;
183
      ta_cci2b = 1'b1;
184 202 olivier.gi
      @(mem200 === 16'h0019);
185 2 olivier.gi
      if (mem202 !== 16'h2000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - GND =====");
186
      if (mem204 !== 16'h2000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - GND =====");
187
 
188
      @(mem200 === 16'h001A);
189
      ta_cci0a = 1'b0;
190
      ta_cci0b = 1'b0;
191
      ta_cci1a = 1'b0;
192
      ta_cci1b = 1'b0;
193
      ta_cci2a = 1'b0;
194
      ta_cci2b = 1'b0;
195 202 olivier.gi
      @(mem200 === 16'h001B);
196 2 olivier.gi
      ta_cci0a = 1'b1;
197
      ta_cci0b = 1'b1;
198
      ta_cci1a = 1'b1;
199
      ta_cci1b = 1'b1;
200
      ta_cci2a = 1'b1;
201
      ta_cci2b = 1'b1;
202 202 olivier.gi
      @(mem200 === 16'h001C);
203 2 olivier.gi
      if (mem202 !== 16'h3008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - VDD =====");
204
      if (mem204 !== 16'h3008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - VDD =====");
205
 
206 202 olivier.gi
 
207 2 olivier.gi
                                // --------- Comparator 2 ----------
208
      @(mem200 === 16'h0021);
209
      ta_cci0a = 1'b0;
210
      ta_cci0b = 1'b0;
211
      ta_cci1a = 1'b0;
212
      ta_cci1b = 1'b0;
213
      ta_cci2a = 1'b1;
214
      ta_cci2b = 1'b0;
215 202 olivier.gi
      @(mem200 === 16'h0022);
216 2 olivier.gi
      ta_cci0a = 1'b1;
217
      ta_cci0b = 1'b1;
218
      ta_cci1a = 1'b1;
219
      ta_cci1b = 1'b1;
220
      ta_cci2a = 1'b0;
221
      ta_cci2b = 1'b1;
222 202 olivier.gi
      @(mem200 === 16'h0023);
223 2 olivier.gi
      if (mem202 !== 16'h0008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - CCIxA =====");
224
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - CCIxA =====");
225
 
226
      @(mem200 === 16'h0024);
227
      ta_cci0a = 1'b0;
228
      ta_cci0b = 1'b0;
229
      ta_cci1a = 1'b0;
230
      ta_cci1b = 1'b0;
231
      ta_cci2a = 1'b0;
232
      ta_cci2b = 1'b1;
233 202 olivier.gi
      @(mem200 === 16'h0025);
234 2 olivier.gi
      ta_cci0a = 1'b1;
235
      ta_cci0b = 1'b1;
236
      ta_cci1a = 1'b1;
237
      ta_cci1b = 1'b1;
238
      ta_cci2a = 1'b1;
239
      ta_cci2b = 1'b0;
240 202 olivier.gi
      @(mem200 === 16'h0026);
241 2 olivier.gi
      if (mem202 !== 16'h1008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - CCIxB =====");
242
      if (mem204 !== 16'h1000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - CCIxB =====");
243
 
244
      @(mem200 === 16'h0027);
245
      ta_cci0a = 1'b0;
246
      ta_cci0b = 1'b0;
247
      ta_cci1a = 1'b0;
248
      ta_cci1b = 1'b0;
249
      ta_cci2a = 1'b0;
250
      ta_cci2b = 1'b0;
251 202 olivier.gi
      @(mem200 === 16'h0028);
252 2 olivier.gi
      ta_cci0a = 1'b1;
253
      ta_cci0b = 1'b1;
254
      ta_cci1a = 1'b1;
255
      ta_cci1b = 1'b1;
256
      ta_cci2a = 1'b1;
257
      ta_cci2b = 1'b1;
258 202 olivier.gi
      @(mem200 === 16'h0029);
259 2 olivier.gi
      if (mem202 !== 16'h2000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - GND =====");
260
      if (mem204 !== 16'h2000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - GND =====");
261
 
262
      @(mem200 === 16'h002A);
263
      ta_cci0a = 1'b0;
264
      ta_cci0b = 1'b0;
265
      ta_cci1a = 1'b0;
266
      ta_cci1b = 1'b0;
267
      ta_cci2a = 1'b0;
268
      ta_cci2b = 1'b0;
269 202 olivier.gi
      @(mem200 === 16'h002B);
270 2 olivier.gi
      ta_cci0a = 1'b1;
271
      ta_cci0b = 1'b1;
272
      ta_cci1a = 1'b1;
273
      ta_cci1b = 1'b1;
274
      ta_cci2a = 1'b1;
275
      ta_cci2b = 1'b1;
276 202 olivier.gi
      @(mem200 === 16'h002C);
277 2 olivier.gi
      if (mem202 !== 16'h3008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - VDD =====");
278
      if (mem204 !== 16'h3008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - VDD =====");
279
      ta_cci0a = 1'b0;
280
      ta_cci0b = 1'b0;
281
      ta_cci1a = 1'b0;
282
      ta_cci1b = 1'b0;
283
      ta_cci2a = 1'b0;
284
      ta_cci2b = 1'b0;
285
 
286 202 olivier.gi
 
287 2 olivier.gi
      // TIMER A TEST:  CAPTURE, EDGE SELECTION AND INTERRUPT
288
      //--------------------------------------------------------
289
      @(r15 === 16'h1000);
290
 
291
                                // --------- Comparator 0 ----------
292
      @(mem200 === 16'h0001);
293
      ta_cci0a = 1'b1;
294
      repeat(5) @(posedge mclk);
295
      if (irq_ta0) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: NO CAPTURE 1 =====");
296
      @(mem200 === 16'h0002);
297
      ta_cci0a = 1'b0;
298
      repeat(5) @(posedge mclk);
299
      if (irq_ta0) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: NO CAPTURE 2 =====");
300
      @(mem200 === 16'h0003);
301
      if (mem202 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: NO CAPTURE 3 =====");
302
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: NO CAPTURE 4 =====");
303
 
304
      @(mem200 === 16'h0004);
305
      ta_cci0a = 1'b1;
306
      repeat(5) @(posedge mclk);
307
      if (!irq_ta0) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: RISING EDGE 1 =====");
308
      @(mem200 === 16'h0005);
309
      ta_cci0a = 1'b0;
310
      repeat(5) @(posedge mclk);
311
      if (irq_ta0) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: RISING EDGE 2 =====");
312
      @(mem200 === 16'h0006);
313
      if (mem202 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: RISING EDGE 3 =====");
314
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: RISING EDGE 4 =====");
315
 
316
      @(mem200 === 16'h0007);
317
      ta_cci0a = 1'b1;
318
      repeat(5) @(posedge mclk);
319
      if (irq_ta0) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: FALLING EDGE 1 =====");
320
      @(mem200 === 16'h0008);
321
      ta_cci0a = 1'b0;
322
      repeat(5) @(posedge mclk);
323
      if (!irq_ta0) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: FALLING EDGE 2 =====");
324
      @(mem200 === 16'h0009);
325
      if (mem202 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: FALLING EDGE 3 =====");
326
      if (mem204 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: FALLING EDGE 4 =====");
327
 
328
      @(mem200 === 16'h000A);
329
      ta_cci0a = 1'b1;
330
      repeat(5) @(posedge mclk);
331
      if (!irq_ta0) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: RISING/FALLING EDGE 1 =====");
332
      @(mem200 === 16'h000B);
333
      ta_cci0a = 1'b0;
334
      repeat(5) @(posedge mclk);
335
      if (!irq_ta0) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: RISING/FALLING EDGE 2 =====");
336
      @(mem200 === 16'h000C);
337
      if (mem202 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: RISING/FALLING EDGE 3 =====");
338
      if (mem204 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: RISING/FALLING EDGE 4 =====");
339
 
340 202 olivier.gi
 
341 2 olivier.gi
                                // --------- comparator 1 ----------
342
      @(mem200 === 16'h0001);
343
      ta_cci1a = 1'b1;
344
      repeat(5) @(posedge mclk);
345
      if (irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: NO CAPTURE 1 =====");
346
      @(mem200 === 16'h0002);
347
      ta_cci1a = 1'b0;
348
      repeat(5) @(posedge mclk);
349
      if (irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: NO CAPTURE 2 =====");
350
      @(mem200 === 16'h0003);
351
      if (mem202 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: NO CAPTURE 3 =====");
352
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: NO CAPTURE 4 =====");
353
 
354
      @(mem200 === 16'h0004);
355
      ta_cci1a = 1'b1;
356
      repeat(5) @(posedge mclk);
357
      if (!irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: RISING EDGE 1 =====");
358
      @(mem200 === 16'h0005);
359
      ta_cci1a = 1'b0;
360
      repeat(5) @(posedge mclk);
361
      if (irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: RISING EDGE 2 =====");
362
      @(mem200 === 16'h0006);
363
      if (mem202 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: RISING EDGE 3 =====");
364
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: RISING EDGE 4 =====");
365
 
366
      @(mem200 === 16'h0007);
367
      ta_cci1a = 1'b1;
368
      repeat(5) @(posedge mclk);
369
      if (irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: FALLING EDGE 1 =====");
370
      @(mem200 === 16'h0008);
371
      ta_cci1a = 1'b0;
372
      repeat(5) @(posedge mclk);
373
      if (!irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: FALLING EDGE 2 =====");
374
      @(mem200 === 16'h0009);
375
      if (mem202 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: FALLING EDGE 3 =====");
376
      if (mem204 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: FALLING EDGE 4 =====");
377
 
378
      @(mem200 === 16'h000A);
379
      ta_cci1a = 1'b1;
380
      repeat(5) @(posedge mclk);
381
      if (!irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: RISING/FALLING EDGE 1 =====");
382
      @(mem200 === 16'h000B);
383
      ta_cci1a = 1'b0;
384
      repeat(5) @(posedge mclk);
385
      if (!irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: RISING/FALLING EDGE 2 =====");
386
      @(mem200 === 16'h000C);
387
      if (mem202 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: RISING/FALLING EDGE 3 =====");
388
      if (mem204 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: RISING/FALLING EDGE 4 =====");
389
 
390 202 olivier.gi
 
391 2 olivier.gi
                                // --------- comparator 2 ----------
392
      @(mem200 === 16'h0001);
393
      ta_cci2a = 1'b1;
394
      repeat(5) @(posedge mclk);
395
      if (irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: NO CAPTURE 1 =====");
396
      @(mem200 === 16'h0002);
397
      ta_cci2a = 1'b0;
398
      repeat(5) @(posedge mclk);
399
      if (irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: NO CAPTURE 2 =====");
400
      @(mem200 === 16'h0003);
401
      if (mem202 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: NO CAPTURE 3 =====");
402
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: NO CAPTURE 4 =====");
403
 
404
      @(mem200 === 16'h0004);
405
      ta_cci2a = 1'b1;
406
      repeat(5) @(posedge mclk);
407
      if (!irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: RISING EDGE 1 =====");
408
      @(mem200 === 16'h0005);
409
      ta_cci2a = 1'b0;
410
      repeat(5) @(posedge mclk);
411
      if (irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: RISING EDGE 2 =====");
412
      @(mem200 === 16'h0006);
413
      if (mem202 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: RISING EDGE 3 =====");
414
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: RISING EDGE 4 =====");
415
 
416
      @(mem200 === 16'h0007);
417
      ta_cci2a = 1'b1;
418
      repeat(5) @(posedge mclk);
419
      if (irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: FALLING EDGE 1 =====");
420
      @(mem200 === 16'h0008);
421
      ta_cci2a = 1'b0;
422
      repeat(5) @(posedge mclk);
423
      if (!irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: FALLING EDGE 2 =====");
424
      @(mem200 === 16'h0009);
425
      if (mem202 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: FALLING EDGE 3 =====");
426
      if (mem204 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: FALLING EDGE 4 =====");
427
 
428
      @(mem200 === 16'h000A);
429
      ta_cci2a = 1'b1;
430
      repeat(5) @(posedge mclk);
431
      if (!irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: RISING/FALLING EDGE 1 =====");
432
      @(mem200 === 16'h000B);
433
      ta_cci2a = 1'b0;
434
      repeat(5) @(posedge mclk);
435
      if (!irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: RISING/FALLING EDGE 2 =====");
436
      @(mem200 === 16'h000C);
437
      if (mem202 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: RISING/FALLING EDGE 3 =====");
438
      if (mem204 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: RISING/FALLING EDGE 4 =====");
439
 
440 202 olivier.gi
 
441 2 olivier.gi
      // TIMER A TEST:  CAPTURE OVERFLOW
442
      //--------------------------------------------------------
443
      @(r15 === 16'h2000);
444
 
445
                                // --------- Comparator 0 ----------
446
      @(mem200 === 16'h0001);
447
      ta_cci0a = 1'b1;
448
      @(mem200 === 16'h0002);
449
      ta_cci0a = 1'b0;
450
      @(mem200 === 16'h0003);
451
      if (mem202 !== 16'hC008) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 0 =====");
452
      if (mem204 !== 16'hC002) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 0 =====");
453
 
454
      @(mem200 === 16'h0004);
455
      ta_cci0a = 1'b1;
456
      @(mem200 === 16'h0005);
457
      ta_cci0a = 1'b0;
458
      @(mem200 === 16'h0006);
459
      if (mem202 !== 16'hC008) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 0 =====");
460
      if (mem204 !== 16'hC000) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 0 =====");
461
 
462 202 olivier.gi
 
463 2 olivier.gi
                                // --------- Comparator 1 ----------
464
      @(mem200 === 16'h0001);
465
      ta_cci1a = 1'b1;
466
      @(mem200 === 16'h0002);
467
      ta_cci1a = 1'b0;
468
      @(mem200 === 16'h0003);
469
      if (mem202 !== 16'hC008) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 1 =====");
470
      if (mem204 !== 16'hC002) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 1 =====");
471
 
472
      @(mem200 === 16'h0004);
473
      ta_cci1a = 1'b1;
474
      @(mem200 === 16'h0005);
475
      ta_cci1a = 1'b0;
476
      @(mem200 === 16'h0006);
477
      if (mem202 !== 16'hC008) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 1 =====");
478
      if (mem204 !== 16'hC000) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 1 =====");
479
 
480 202 olivier.gi
 
481 2 olivier.gi
                                // --------- Comparator 2 ----------
482
      @(mem200 === 16'h0001);
483
      ta_cci2a = 1'b1;
484
      @(mem200 === 16'h0002);
485
      ta_cci2a = 1'b0;
486
      @(mem200 === 16'h0003);
487
      if (mem202 !== 16'hC008) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 2 =====");
488
      if (mem204 !== 16'hC002) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 2 =====");
489
 
490
      @(mem200 === 16'h0004);
491
      ta_cci2a = 1'b1;
492
      @(mem200 === 16'h0005);
493
      ta_cci2a = 1'b0;
494
      @(mem200 === 16'h0006);
495
      if (mem202 !== 16'hC008) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 2 =====");
496
      if (mem204 !== 16'hC000) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 2 =====");
497
 
498
 
499 202 olivier.gi
`endif
500 134 olivier.gi
 
501 2 olivier.gi
      stimulus_done = 1;
502
   end

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.