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 2

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
/*===========================================================================*/
29
 
30
integer my_counter;
31
always @ (posedge mclk)
32
  my_counter <=  my_counter+1;
33
 
34
wire [15:0] tar = timerA_0.tar;
35
 
36
initial
37
   begin
38
      $display(" ===============================================");
39
      $display("|                 START SIMULATION              |");
40
      $display(" ===============================================");
41
      repeat(5) @(posedge mclk);
42
      stimulus_done = 0;
43
 
44
      // TIMER A TEST:  INPUT MUX (CCI)
45
      //--------------------------------------------------------
46
 
47
                                // --------- Comparator 0 ----------
48
      @(mem200 === 16'h0001);
49
      ta_cci0a = 1'b1;
50
      ta_cci0b = 1'b0;
51
      ta_cci1a = 1'b0;
52
      ta_cci1b = 1'b0;
53
      ta_cci2a = 1'b0;
54
      ta_cci2b = 1'b0;
55
      @(mem200 === 16'h0002);
56
      ta_cci0a = 1'b0;
57
      ta_cci0b = 1'b1;
58
      ta_cci1a = 1'b1;
59
      ta_cci1b = 1'b1;
60
      ta_cci2a = 1'b1;
61
      ta_cci2b = 1'b1;
62
      @(mem200 === 16'h0003);
63
      if (mem202 !== 16'h0008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - CCIxA =====");
64
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - CCIxA =====");
65
 
66
      @(mem200 === 16'h0004);
67
      ta_cci0a = 1'b0;
68
      ta_cci0b = 1'b1;
69
      ta_cci1a = 1'b0;
70
      ta_cci1b = 1'b0;
71
      ta_cci2a = 1'b0;
72
      ta_cci2b = 1'b0;
73
      @(mem200 === 16'h0005);
74
      ta_cci0a = 1'b1;
75
      ta_cci0b = 1'b0;
76
      ta_cci1a = 1'b1;
77
      ta_cci1b = 1'b1;
78
      ta_cci2a = 1'b1;
79
      ta_cci2b = 1'b1;
80
      @(mem200 === 16'h0006);
81
      if (mem202 !== 16'h1008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - CCIxB =====");
82
      if (mem204 !== 16'h1000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - CCIxB =====");
83
 
84
      @(mem200 === 16'h0007);
85
      ta_cci0a = 1'b0;
86
      ta_cci0b = 1'b0;
87
      ta_cci1a = 1'b0;
88
      ta_cci1b = 1'b0;
89
      ta_cci2a = 1'b0;
90
      ta_cci2b = 1'b0;
91
      @(mem200 === 16'h0008);
92
      ta_cci0a = 1'b1;
93
      ta_cci0b = 1'b1;
94
      ta_cci1a = 1'b1;
95
      ta_cci1b = 1'b1;
96
      ta_cci2a = 1'b1;
97
      ta_cci2b = 1'b1;
98
      @(mem200 === 16'h0009);
99
      if (mem202 !== 16'h2000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - GND =====");
100
      if (mem204 !== 16'h2000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - GND =====");
101
 
102
      @(mem200 === 16'h000A);
103
      ta_cci0a = 1'b0;
104
      ta_cci0b = 1'b0;
105
      ta_cci1a = 1'b0;
106
      ta_cci1b = 1'b0;
107
      ta_cci2a = 1'b0;
108
      ta_cci2b = 1'b0;
109
      @(mem200 === 16'h000B);
110
      ta_cci0a = 1'b1;
111
      ta_cci0b = 1'b1;
112
      ta_cci1a = 1'b1;
113
      ta_cci1b = 1'b1;
114
      ta_cci2a = 1'b1;
115
      ta_cci2b = 1'b1;
116
      @(mem200 === 16'h000C);
117
      if (mem202 !== 16'h3008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - VDD =====");
118
      if (mem204 !== 16'h3008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 0 - VDD =====");
119
 
120
 
121
                                // --------- Comparator 1 ----------
122
      @(mem200 === 16'h0011);
123
      ta_cci0a = 1'b0;
124
      ta_cci0b = 1'b0;
125
      ta_cci1a = 1'b1;
126
      ta_cci1b = 1'b0;
127
      ta_cci2a = 1'b0;
128
      ta_cci2b = 1'b0;
129
      @(mem200 === 16'h0012);
130
      ta_cci0a = 1'b1;
131
      ta_cci0b = 1'b1;
132
      ta_cci1a = 1'b0;
133
      ta_cci1b = 1'b1;
134
      ta_cci2a = 1'b1;
135
      ta_cci2b = 1'b1;
136
      @(mem200 === 16'h0013);
137
      if (mem202 !== 16'h0008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - CCIxA =====");
138
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - CCIxA =====");
139
 
140
      @(mem200 === 16'h0014);
141
      ta_cci0a = 1'b0;
142
      ta_cci0b = 1'b0;
143
      ta_cci1a = 1'b0;
144
      ta_cci1b = 1'b1;
145
      ta_cci2a = 1'b0;
146
      ta_cci2b = 1'b0;
147
      @(mem200 === 16'h0015);
148
      ta_cci0a = 1'b1;
149
      ta_cci0b = 1'b1;
150
      ta_cci1a = 1'b1;
151
      ta_cci1b = 1'b0;
152
      ta_cci2a = 1'b1;
153
      ta_cci2b = 1'b1;
154
      @(mem200 === 16'h0016);
155
      if (mem202 !== 16'h1008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - CCIxB =====");
156
      if (mem204 !== 16'h1000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - CCIxB =====");
157
 
158
      @(mem200 === 16'h0017);
159
      ta_cci0a = 1'b0;
160
      ta_cci0b = 1'b0;
161
      ta_cci1a = 1'b0;
162
      ta_cci1b = 1'b0;
163
      ta_cci2a = 1'b0;
164
      ta_cci2b = 1'b0;
165
      @(mem200 === 16'h0018);
166
      ta_cci0a = 1'b1;
167
      ta_cci0b = 1'b1;
168
      ta_cci1a = 1'b1;
169
      ta_cci1b = 1'b1;
170
      ta_cci2a = 1'b1;
171
      ta_cci2b = 1'b1;
172
      @(mem200 === 16'h0019);
173
      if (mem202 !== 16'h2000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - GND =====");
174
      if (mem204 !== 16'h2000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - GND =====");
175
 
176
      @(mem200 === 16'h001A);
177
      ta_cci0a = 1'b0;
178
      ta_cci0b = 1'b0;
179
      ta_cci1a = 1'b0;
180
      ta_cci1b = 1'b0;
181
      ta_cci2a = 1'b0;
182
      ta_cci2b = 1'b0;
183
      @(mem200 === 16'h001B);
184
      ta_cci0a = 1'b1;
185
      ta_cci0b = 1'b1;
186
      ta_cci1a = 1'b1;
187
      ta_cci1b = 1'b1;
188
      ta_cci2a = 1'b1;
189
      ta_cci2b = 1'b1;
190
      @(mem200 === 16'h001C);
191
      if (mem202 !== 16'h3008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - VDD =====");
192
      if (mem204 !== 16'h3008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 1 - VDD =====");
193
 
194
 
195
                                // --------- Comparator 2 ----------
196
      @(mem200 === 16'h0021);
197
      ta_cci0a = 1'b0;
198
      ta_cci0b = 1'b0;
199
      ta_cci1a = 1'b0;
200
      ta_cci1b = 1'b0;
201
      ta_cci2a = 1'b1;
202
      ta_cci2b = 1'b0;
203
      @(mem200 === 16'h0022);
204
      ta_cci0a = 1'b1;
205
      ta_cci0b = 1'b1;
206
      ta_cci1a = 1'b1;
207
      ta_cci1b = 1'b1;
208
      ta_cci2a = 1'b0;
209
      ta_cci2b = 1'b1;
210
      @(mem200 === 16'h0023);
211
      if (mem202 !== 16'h0008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - CCIxA =====");
212
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - CCIxA =====");
213
 
214
      @(mem200 === 16'h0024);
215
      ta_cci0a = 1'b0;
216
      ta_cci0b = 1'b0;
217
      ta_cci1a = 1'b0;
218
      ta_cci1b = 1'b0;
219
      ta_cci2a = 1'b0;
220
      ta_cci2b = 1'b1;
221
      @(mem200 === 16'h0025);
222
      ta_cci0a = 1'b1;
223
      ta_cci0b = 1'b1;
224
      ta_cci1a = 1'b1;
225
      ta_cci1b = 1'b1;
226
      ta_cci2a = 1'b1;
227
      ta_cci2b = 1'b0;
228
      @(mem200 === 16'h0026);
229
      if (mem202 !== 16'h1008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - CCIxB =====");
230
      if (mem204 !== 16'h1000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - CCIxB =====");
231
 
232
      @(mem200 === 16'h0027);
233
      ta_cci0a = 1'b0;
234
      ta_cci0b = 1'b0;
235
      ta_cci1a = 1'b0;
236
      ta_cci1b = 1'b0;
237
      ta_cci2a = 1'b0;
238
      ta_cci2b = 1'b0;
239
      @(mem200 === 16'h0028);
240
      ta_cci0a = 1'b1;
241
      ta_cci0b = 1'b1;
242
      ta_cci1a = 1'b1;
243
      ta_cci1b = 1'b1;
244
      ta_cci2a = 1'b1;
245
      ta_cci2b = 1'b1;
246
      @(mem200 === 16'h0029);
247
      if (mem202 !== 16'h2000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - GND =====");
248
      if (mem204 !== 16'h2000) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - GND =====");
249
 
250
      @(mem200 === 16'h002A);
251
      ta_cci0a = 1'b0;
252
      ta_cci0b = 1'b0;
253
      ta_cci1a = 1'b0;
254
      ta_cci1b = 1'b0;
255
      ta_cci2a = 1'b0;
256
      ta_cci2b = 1'b0;
257
      @(mem200 === 16'h002B);
258
      ta_cci0a = 1'b1;
259
      ta_cci0b = 1'b1;
260
      ta_cci1a = 1'b1;
261
      ta_cci1b = 1'b1;
262
      ta_cci2a = 1'b1;
263
      ta_cci2b = 1'b1;
264
      @(mem200 === 16'h002C);
265
      if (mem202 !== 16'h3008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - VDD =====");
266
      if (mem204 !== 16'h3008) tb_error("====== TIMER_A INPUT MUX: COMPARATOR 2 - VDD =====");
267
      ta_cci0a = 1'b0;
268
      ta_cci0b = 1'b0;
269
      ta_cci1a = 1'b0;
270
      ta_cci1b = 1'b0;
271
      ta_cci2a = 1'b0;
272
      ta_cci2b = 1'b0;
273
 
274
 
275
      // TIMER A TEST:  CAPTURE, EDGE SELECTION AND INTERRUPT
276
      //--------------------------------------------------------
277
      @(r15 === 16'h1000);
278
 
279
                                // --------- Comparator 0 ----------
280
      @(mem200 === 16'h0001);
281
      ta_cci0a = 1'b1;
282
      repeat(5) @(posedge mclk);
283
      if (irq_ta0) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: NO CAPTURE 1 =====");
284
      @(mem200 === 16'h0002);
285
      ta_cci0a = 1'b0;
286
      repeat(5) @(posedge mclk);
287
      if (irq_ta0) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: NO CAPTURE 2 =====");
288
      @(mem200 === 16'h0003);
289
      if (mem202 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: NO CAPTURE 3 =====");
290
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: NO CAPTURE 4 =====");
291
 
292
      @(mem200 === 16'h0004);
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: RISING EDGE 1 =====");
296
      @(mem200 === 16'h0005);
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: RISING EDGE 2 =====");
300
      @(mem200 === 16'h0006);
301
      if (mem202 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: RISING EDGE 3 =====");
302
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: RISING EDGE 4 =====");
303
 
304
      @(mem200 === 16'h0007);
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: FALLING EDGE 1 =====");
308
      @(mem200 === 16'h0008);
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: FALLING EDGE 2 =====");
312
      @(mem200 === 16'h0009);
313
      if (mem202 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: FALLING EDGE 3 =====");
314
      if (mem204 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: FALLING EDGE 4 =====");
315
 
316
      @(mem200 === 16'h000A);
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: RISING/FALLING EDGE 1 =====");
320
      @(mem200 === 16'h000B);
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: RISING/FALLING EDGE 2 =====");
324
      @(mem200 === 16'h000C);
325
      if (mem202 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: RISING/FALLING EDGE 3 =====");
326
      if (mem204 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 0: RISING/FALLING EDGE 4 =====");
327
 
328
 
329
                                // --------- comparator 1 ----------
330
      @(mem200 === 16'h0001);
331
      ta_cci1a = 1'b1;
332
      repeat(5) @(posedge mclk);
333
      if (irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: NO CAPTURE 1 =====");
334
      @(mem200 === 16'h0002);
335
      ta_cci1a = 1'b0;
336
      repeat(5) @(posedge mclk);
337
      if (irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: NO CAPTURE 2 =====");
338
      @(mem200 === 16'h0003);
339
      if (mem202 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: NO CAPTURE 3 =====");
340
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: NO CAPTURE 4 =====");
341
 
342
      @(mem200 === 16'h0004);
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: RISING EDGE 1 =====");
346
      @(mem200 === 16'h0005);
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: RISING EDGE 2 =====");
350
      @(mem200 === 16'h0006);
351
      if (mem202 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: RISING EDGE 3 =====");
352
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: RISING EDGE 4 =====");
353
 
354
      @(mem200 === 16'h0007);
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: FALLING EDGE 1 =====");
358
      @(mem200 === 16'h0008);
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: FALLING EDGE 2 =====");
362
      @(mem200 === 16'h0009);
363
      if (mem202 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: FALLING EDGE 3 =====");
364
      if (mem204 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: FALLING EDGE 4 =====");
365
 
366
      @(mem200 === 16'h000A);
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: RISING/FALLING EDGE 1 =====");
370
      @(mem200 === 16'h000B);
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: RISING/FALLING EDGE 2 =====");
374
      @(mem200 === 16'h000C);
375
      if (mem202 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: RISING/FALLING EDGE 3 =====");
376
      if (mem204 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 1: RISING/FALLING EDGE 4 =====");
377
 
378
 
379
                                // --------- comparator 2 ----------
380
      @(mem200 === 16'h0001);
381
      ta_cci2a = 1'b1;
382
      repeat(5) @(posedge mclk);
383
      if (irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: NO CAPTURE 1 =====");
384
      @(mem200 === 16'h0002);
385
      ta_cci2a = 1'b0;
386
      repeat(5) @(posedge mclk);
387
      if (irq_ta1) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: NO CAPTURE 2 =====");
388
      @(mem200 === 16'h0003);
389
      if (mem202 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: NO CAPTURE 3 =====");
390
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: NO CAPTURE 4 =====");
391
 
392
      @(mem200 === 16'h0004);
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: RISING EDGE 1 =====");
396
      @(mem200 === 16'h0005);
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: RISING EDGE 2 =====");
400
      @(mem200 === 16'h0006);
401
      if (mem202 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: RISING EDGE 3 =====");
402
      if (mem204 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: RISING EDGE 4 =====");
403
 
404
      @(mem200 === 16'h0007);
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: FALLING EDGE 1 =====");
408
      @(mem200 === 16'h0008);
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: FALLING EDGE 2 =====");
412
      @(mem200 === 16'h0009);
413
      if (mem202 !== 16'h0000) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: FALLING EDGE 3 =====");
414
      if (mem204 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: FALLING EDGE 4 =====");
415
 
416
      @(mem200 === 16'h000A);
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: RISING/FALLING EDGE 1 =====");
420
      @(mem200 === 16'h000B);
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: RISING/FALLING EDGE 2 =====");
424
      @(mem200 === 16'h000C);
425
      if (mem202 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: RISING/FALLING EDGE 3 =====");
426
      if (mem204 !== 16'h1234) tb_error("====== TIMER_A CAPTURE, EDGE SELECTION AND INTERRUPT COMPARATOR 2: RISING/FALLING EDGE 4 =====");
427
 
428
 
429
      // TIMER A TEST:  CAPTURE OVERFLOW
430
      //--------------------------------------------------------
431
      @(r15 === 16'h2000);
432
 
433
                                // --------- Comparator 0 ----------
434
      @(mem200 === 16'h0001);
435
      ta_cci0a = 1'b1;
436
      @(mem200 === 16'h0002);
437
      ta_cci0a = 1'b0;
438
      @(mem200 === 16'h0003);
439
      if (mem202 !== 16'hC008) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 0 =====");
440
      if (mem204 !== 16'hC002) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 0 =====");
441
 
442
      @(mem200 === 16'h0004);
443
      ta_cci0a = 1'b1;
444
      @(mem200 === 16'h0005);
445
      ta_cci0a = 1'b0;
446
      @(mem200 === 16'h0006);
447
      if (mem202 !== 16'hC008) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 0 =====");
448
      if (mem204 !== 16'hC000) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 0 =====");
449
 
450
 
451
                                // --------- Comparator 1 ----------
452
      @(mem200 === 16'h0001);
453
      ta_cci1a = 1'b1;
454
      @(mem200 === 16'h0002);
455
      ta_cci1a = 1'b0;
456
      @(mem200 === 16'h0003);
457
      if (mem202 !== 16'hC008) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 1 =====");
458
      if (mem204 !== 16'hC002) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 1 =====");
459
 
460
      @(mem200 === 16'h0004);
461
      ta_cci1a = 1'b1;
462
      @(mem200 === 16'h0005);
463
      ta_cci1a = 1'b0;
464
      @(mem200 === 16'h0006);
465
      if (mem202 !== 16'hC008) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 1 =====");
466
      if (mem204 !== 16'hC000) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 1 =====");
467
 
468
 
469
                                // --------- Comparator 2 ----------
470
      @(mem200 === 16'h0001);
471
      ta_cci2a = 1'b1;
472
      @(mem200 === 16'h0002);
473
      ta_cci2a = 1'b0;
474
      @(mem200 === 16'h0003);
475
      if (mem202 !== 16'hC008) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 2 =====");
476
      if (mem204 !== 16'hC002) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 2 =====");
477
 
478
      @(mem200 === 16'h0004);
479
      ta_cci2a = 1'b1;
480
      @(mem200 === 16'h0005);
481
      ta_cci2a = 1'b0;
482
      @(mem200 === 16'h0006);
483
      if (mem202 !== 16'hC008) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 2 =====");
484
      if (mem204 !== 16'hC000) tb_error("====== TIMER_A CAPTURE OVERFLOW: COMPARATOR 2 =====");
485
 
486
 
487
 
488
      stimulus_done = 1;
489
   end
490
 

powered by: WebSVN 2.1.0

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