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

Subversion Repositories openmsp430

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

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
/*                                 DIGITAL I/O                               */
25
/*---------------------------------------------------------------------------*/
26
/* Test the Digital I/O interface:                                           */
27
/*                                   - Interrupts.                           */
28 18 olivier.gi
/*                                                                           */
29
/* Author(s):                                                                */
30
/*             - Olivier Girard,    olgirard@gmail.com                       */
31
/*                                                                           */
32
/*---------------------------------------------------------------------------*/
33 19 olivier.gi
/* $Rev: 111 $                                                                */
34
/* $LastChangedBy: olivier.girard $                                          */
35
/* $LastChangedDate: 2011-05-20 22:39:02 +0200 (Fri, 20 May 2011) $          */
36 2 olivier.gi
/*===========================================================================*/
37
 
38 111 olivier.gi
integer test_step;
39
 
40 2 olivier.gi
initial
41
   begin
42
      $display(" ===============================================");
43
      $display("|                 START SIMULATION              |");
44
      $display(" ===============================================");
45
      repeat(5) @(posedge mclk);
46
      stimulus_done = 0;
47 111 olivier.gi
      test_step     = 0;
48 2 olivier.gi
 
49
      // PORT 1: TEST INTERRUPT FLAGS
50
      //--------------------------------------------------------
51
 
52 111 olivier.gi
      @(r15==(`PER_SIZE+16'h0000)) p1_din = 8'h01;
53
      @(r15==(`PER_SIZE+16'h0001)) p1_din = 8'h03;
54
      @(r15==(`PER_SIZE+16'h0002)) p1_din = 8'h07;
55
      @(r15==(`PER_SIZE+16'h0003)) p1_din = 8'h0f;
56
      @(r15==(`PER_SIZE+16'h0004)) p1_din = 8'h1f;
57
      @(r15==(`PER_SIZE+16'h0005)) p1_din = 8'h3f;
58
      @(r15==(`PER_SIZE+16'h0006)) p1_din = 8'h7f;
59
      @(r15==(`PER_SIZE+16'h0007)) p1_din = 8'hff;
60
      @(r15==(`PER_SIZE+16'h0008));
61 2 olivier.gi
      if (mem200 !== 16'h0201) tb_error("====== RISING EDGE TEST: P1IFG != 0x0201 =====");
62
      if (mem202 !== 16'h0804) tb_error("====== RISING EDGE TEST: P1IFG != 0x0804 =====");
63
      if (mem204 !== 16'h2010) tb_error("====== RISING EDGE TEST: P1IFG != 0x2010 =====");
64
      if (mem206 !== 16'h8040) tb_error("====== RISING EDGE TEST: P1IFG != 0x8040 =====");
65 111 olivier.gi
      test_step = 1;
66 2 olivier.gi
 
67
 
68 111 olivier.gi
      @(r15==(`PER_SIZE+16'h0010)) p1_din = 8'h7f;
69
      @(r15==(`PER_SIZE+16'h0011)) p1_din = 8'h3f;
70
      @(r15==(`PER_SIZE+16'h0012)) p1_din = 8'h1f;
71
      @(r15==(`PER_SIZE+16'h0013)) p1_din = 8'h0f;
72
      @(r15==(`PER_SIZE+16'h0014)) p1_din = 8'h07;
73
      @(r15==(`PER_SIZE+16'h0015)) p1_din = 8'h03;
74
      @(r15==(`PER_SIZE+16'h0016)) p1_din = 8'h01;
75
      @(r15==(`PER_SIZE+16'h0017)) p1_din = 8'h00;
76
      @(r15==(`PER_SIZE+16'h0018));
77 2 olivier.gi
      if (mem210 !== 16'h0000) tb_error("====== RISING EDGE TEST: P1IFG != 0x0000 =====");
78
      if (mem212 !== 16'h0000) tb_error("====== RISING EDGE TEST: P1IFG != 0x0000 =====");
79
      if (mem214 !== 16'h0000) tb_error("====== RISING EDGE TEST: P1IFG != 0x0000 =====");
80
      if (mem216 !== 16'h0000) tb_error("====== RISING EDGE TEST: P1IFG != 0x0000 =====");
81 111 olivier.gi
      test_step = 2;
82 2 olivier.gi
 
83
 
84 111 olivier.gi
      @(r15==(`PER_SIZE+16'h0020)) p1_din = 8'h01;
85
      @(r15==(`PER_SIZE+16'h0021)) p1_din = 8'h03;
86
      @(r15==(`PER_SIZE+16'h0022)) p1_din = 8'h07;
87
      @(r15==(`PER_SIZE+16'h0023)) p1_din = 8'h0f;
88
      @(r15==(`PER_SIZE+16'h0024)) p1_din = 8'h1f;
89
      @(r15==(`PER_SIZE+16'h0025)) p1_din = 8'h3f;
90
      @(r15==(`PER_SIZE+16'h0026)) p1_din = 8'h7f;
91
      @(r15==(`PER_SIZE+16'h0027)) p1_din = 8'hff;
92
      @(r15==(`PER_SIZE+16'h0028));
93 2 olivier.gi
      if (mem220 !== 16'h0301) tb_error("====== RISING EDGE TEST: P1IFG != 0x0301 =====");
94
      if (mem222 !== 16'h0f07) tb_error("====== RISING EDGE TEST: P1IFG != 0x0f07 =====");
95
      if (mem224 !== 16'h3f1f) tb_error("====== RISING EDGE TEST: P1IFG != 0x3f1f =====");
96
      if (mem226 !== 16'hff7f) tb_error("====== RISING EDGE TEST: P1IFG != 0xff7f =====");
97 111 olivier.gi
      test_step = 3;
98 2 olivier.gi
 
99
 
100 111 olivier.gi
      @(r15==(`PER_SIZE+16'h0030)) p1_din = 8'h7f;
101
      @(r15==(`PER_SIZE+16'h0031)) p1_din = 8'h3f;
102
      @(r15==(`PER_SIZE+16'h0032)) p1_din = 8'h1f;
103
      @(r15==(`PER_SIZE+16'h0033)) p1_din = 8'h0f;
104
      @(r15==(`PER_SIZE+16'h0034)) p1_din = 8'h07;
105
      @(r15==(`PER_SIZE+16'h0035)) p1_din = 8'h03;
106
      @(r15==(`PER_SIZE+16'h0036)) p1_din = 8'h01;
107
      @(r15==(`PER_SIZE+16'h0037)) p1_din = 8'h00;
108
      @(r15==(`PER_SIZE+16'h0038));
109 2 olivier.gi
      if (mem230 !== 16'h4080) tb_error("====== FALLING EDGE TEST: P1IFG != 0x4080 =====");
110
      if (mem232 !== 16'h1020) tb_error("====== FALLING EDGE TEST: P1IFG != 0x1020 =====");
111
      if (mem234 !== 16'h0408) tb_error("====== FALLING EDGE TEST: P1IFG != 0x0408 =====");
112
      if (mem236 !== 16'h0102) tb_error("====== FALLING EDGE TEST: P1IFG != 0x0102 =====");
113 111 olivier.gi
      test_step = 4;
114 2 olivier.gi
 
115 111 olivier.gi
      @(r15==(`PER_SIZE+16'h0040)) p1_din = 8'h01;
116
      @(r15==(`PER_SIZE+16'h0041)) p1_din = 8'h03;
117
      @(r15==(`PER_SIZE+16'h0042)) p1_din = 8'h07;
118
      @(r15==(`PER_SIZE+16'h0043)) p1_din = 8'h0f;
119
      @(r15==(`PER_SIZE+16'h0044)) p1_din = 8'h1f;
120
      @(r15==(`PER_SIZE+16'h0045)) p1_din = 8'h3f;
121
      @(r15==(`PER_SIZE+16'h0046)) p1_din = 8'h7f;
122
      @(r15==(`PER_SIZE+16'h0047)) p1_din = 8'hff;
123
      @(r15==(`PER_SIZE+16'h0048));
124 2 olivier.gi
      if (mem240 !== 16'h0000) tb_error("====== FALLING EDGE TEST: P1IFG != 0x0000 =====");
125
      if (mem242 !== 16'h0000) tb_error("====== FALLING EDGE TEST: P1IFG != 0x0000 =====");
126
      if (mem244 !== 16'h0000) tb_error("====== FALLING EDGE TEST: P1IFG != 0x0000 =====");
127
      if (mem246 !== 16'h0000) tb_error("====== FALLING EDGE TEST: P1IFG != 0x0000 =====");
128 111 olivier.gi
      test_step = 5;
129 2 olivier.gi
 
130 111 olivier.gi
      @(r15==(`PER_SIZE+16'h0050)) p1_din = 8'h7f;
131
      @(r15==(`PER_SIZE+16'h0051)) p1_din = 8'h3f;
132
      @(r15==(`PER_SIZE+16'h0052)) p1_din = 8'h1f;
133
      @(r15==(`PER_SIZE+16'h0053)) p1_din = 8'h0f;
134
      @(r15==(`PER_SIZE+16'h0054)) p1_din = 8'h07;
135
      @(r15==(`PER_SIZE+16'h0055)) p1_din = 8'h03;
136
      @(r15==(`PER_SIZE+16'h0056)) p1_din = 8'h01;
137
      @(r15==(`PER_SIZE+16'h0057)) p1_din = 8'h00;
138
      @(r15==(`PER_SIZE+16'h0058));
139 2 olivier.gi
      if (mem250 !== 16'hc080) tb_error("====== FALLING EDGE TEST: P1IFG != 0xc080 =====");
140
      if (mem252 !== 16'hf0e0) tb_error("====== FALLING EDGE TEST: P1IFG != 0xf0e0 =====");
141
      if (mem254 !== 16'hfcf8) tb_error("====== FALLING EDGE TEST: P1IFG != 0xfcf8 =====");
142
      if (mem256 !== 16'hfffe) tb_error("====== FALLING EDGE TEST: P1IFG != 0xfffe =====");
143 111 olivier.gi
      test_step = 6;
144 2 olivier.gi
 
145
 
146
      // PORT 2: TEST INTERRUPT FLAGS
147
      //--------------------------------------------------------
148
 
149 111 olivier.gi
      @(r15==(`PER_SIZE+16'h0000)) p2_din = 8'h01;
150
      @(r15==(`PER_SIZE+16'h0001)) p2_din = 8'h03;
151
      @(r15==(`PER_SIZE+16'h0002)) p2_din = 8'h07;
152
      @(r15==(`PER_SIZE+16'h0003)) p2_din = 8'h0f;
153
      @(r15==(`PER_SIZE+16'h0004)) p2_din = 8'h1f;
154
      @(r15==(`PER_SIZE+16'h0005)) p2_din = 8'h3f;
155
      @(r15==(`PER_SIZE+16'h0006)) p2_din = 8'h7f;
156
      @(r15==(`PER_SIZE+16'h0007)) p2_din = 8'hff;
157
      @(r15==(`PER_SIZE+16'h0008));
158 2 olivier.gi
      if (mem200 !== 16'h0201) tb_error("====== RISING EDGE TEST: P2IFG != 0x0201 =====");
159
      if (mem202 !== 16'h0804) tb_error("====== RISING EDGE TEST: P2IFG != 0x0804 =====");
160
      if (mem204 !== 16'h2010) tb_error("====== RISING EDGE TEST: P2IFG != 0x2010 =====");
161
      if (mem206 !== 16'h8040) tb_error("====== RISING EDGE TEST: P2IFG != 0x8040 =====");
162 111 olivier.gi
      test_step = 7;
163 2 olivier.gi
 
164
 
165 111 olivier.gi
      @(r15==(`PER_SIZE+16'h0010)) p2_din = 8'h7f;
166
      @(r15==(`PER_SIZE+16'h0011)) p2_din = 8'h3f;
167
      @(r15==(`PER_SIZE+16'h0012)) p2_din = 8'h1f;
168
      @(r15==(`PER_SIZE+16'h0013)) p2_din = 8'h0f;
169
      @(r15==(`PER_SIZE+16'h0014)) p2_din = 8'h07;
170
      @(r15==(`PER_SIZE+16'h0015)) p2_din = 8'h03;
171
      @(r15==(`PER_SIZE+16'h0016)) p2_din = 8'h01;
172
      @(r15==(`PER_SIZE+16'h0017)) p2_din = 8'h00;
173
      @(r15==(`PER_SIZE+16'h0018));
174 2 olivier.gi
      if (mem210 !== 16'h0000) tb_error("====== RISING EDGE TEST: P2IFG != 0x0000 =====");
175
      if (mem212 !== 16'h0000) tb_error("====== RISING EDGE TEST: P2IFG != 0x0000 =====");
176
      if (mem214 !== 16'h0000) tb_error("====== RISING EDGE TEST: P2IFG != 0x0000 =====");
177
      if (mem216 !== 16'h0000) tb_error("====== RISING EDGE TEST: P2IFG != 0x0000 =====");
178 111 olivier.gi
      test_step = 8;
179 2 olivier.gi
 
180
 
181 111 olivier.gi
      @(r15==(`PER_SIZE+16'h0020)) p2_din = 8'h01;
182
      @(r15==(`PER_SIZE+16'h0021)) p2_din = 8'h03;
183
      @(r15==(`PER_SIZE+16'h0022)) p2_din = 8'h07;
184
      @(r15==(`PER_SIZE+16'h0023)) p2_din = 8'h0f;
185
      @(r15==(`PER_SIZE+16'h0024)) p2_din = 8'h1f;
186
      @(r15==(`PER_SIZE+16'h0025)) p2_din = 8'h3f;
187
      @(r15==(`PER_SIZE+16'h0026)) p2_din = 8'h7f;
188
      @(r15==(`PER_SIZE+16'h0027)) p2_din = 8'hff;
189
      @(r15==(`PER_SIZE+16'h0028));
190 2 olivier.gi
      if (mem220 !== 16'h0301) tb_error("====== RISING EDGE TEST: P2IFG != 0x0301 =====");
191
      if (mem222 !== 16'h0f07) tb_error("====== RISING EDGE TEST: P2IFG != 0x0f07 =====");
192
      if (mem224 !== 16'h3f1f) tb_error("====== RISING EDGE TEST: P2IFG != 0x3f1f =====");
193
      if (mem226 !== 16'hff7f) tb_error("====== RISING EDGE TEST: P2IFG != 0xff7f =====");
194 111 olivier.gi
      test_step = 9;
195 2 olivier.gi
 
196
 
197 111 olivier.gi
      @(r15==(`PER_SIZE+16'h0030)) p2_din = 8'h7f;
198
      @(r15==(`PER_SIZE+16'h0031)) p2_din = 8'h3f;
199
      @(r15==(`PER_SIZE+16'h0032)) p2_din = 8'h1f;
200
      @(r15==(`PER_SIZE+16'h0033)) p2_din = 8'h0f;
201
      @(r15==(`PER_SIZE+16'h0034)) p2_din = 8'h07;
202
      @(r15==(`PER_SIZE+16'h0035)) p2_din = 8'h03;
203
      @(r15==(`PER_SIZE+16'h0036)) p2_din = 8'h01;
204
      @(r15==(`PER_SIZE+16'h0037)) p2_din = 8'h00;
205
      @(r15==(`PER_SIZE+16'h0038));
206 2 olivier.gi
      if (mem230 !== 16'h4080) tb_error("====== FALLING EDGE TEST: P2IFG != 0x4080 =====");
207
      if (mem232 !== 16'h1020) tb_error("====== FALLING EDGE TEST: P2IFG != 0x1020 =====");
208
      if (mem234 !== 16'h0408) tb_error("====== FALLING EDGE TEST: P2IFG != 0x0408 =====");
209
      if (mem236 !== 16'h0102) tb_error("====== FALLING EDGE TEST: P2IFG != 0x0102 =====");
210 111 olivier.gi
      test_step = 10;
211 2 olivier.gi
 
212 111 olivier.gi
      @(r15==(`PER_SIZE+16'h0040)) p2_din = 8'h01;
213
      @(r15==(`PER_SIZE+16'h0041)) p2_din = 8'h03;
214
      @(r15==(`PER_SIZE+16'h0042)) p2_din = 8'h07;
215
      @(r15==(`PER_SIZE+16'h0043)) p2_din = 8'h0f;
216
      @(r15==(`PER_SIZE+16'h0044)) p2_din = 8'h1f;
217
      @(r15==(`PER_SIZE+16'h0045)) p2_din = 8'h3f;
218
      @(r15==(`PER_SIZE+16'h0046)) p2_din = 8'h7f;
219
      @(r15==(`PER_SIZE+16'h0047)) p2_din = 8'hff;
220
      @(r15==(`PER_SIZE+16'h0048));
221 2 olivier.gi
      if (mem240 !== 16'h0000) tb_error("====== FALLING EDGE TEST: P2IFG != 0x0000 =====");
222
      if (mem242 !== 16'h0000) tb_error("====== FALLING EDGE TEST: P2IFG != 0x0000 =====");
223
      if (mem244 !== 16'h0000) tb_error("====== FALLING EDGE TEST: P2IFG != 0x0000 =====");
224
      if (mem246 !== 16'h0000) tb_error("====== FALLING EDGE TEST: P2IFG != 0x0000 =====");
225 111 olivier.gi
      test_step = 11;
226 2 olivier.gi
 
227 111 olivier.gi
      @(r15==(`PER_SIZE+16'h0050)) p2_din = 8'h7f;
228
      @(r15==(`PER_SIZE+16'h0051)) p2_din = 8'h3f;
229
      @(r15==(`PER_SIZE+16'h0052)) p2_din = 8'h1f;
230
      @(r15==(`PER_SIZE+16'h0053)) p2_din = 8'h0f;
231
      @(r15==(`PER_SIZE+16'h0054)) p2_din = 8'h07;
232
      @(r15==(`PER_SIZE+16'h0055)) p2_din = 8'h03;
233
      @(r15==(`PER_SIZE+16'h0056)) p2_din = 8'h01;
234
      @(r15==(`PER_SIZE+16'h0057)) p2_din = 8'h00;
235
      @(r15==(`PER_SIZE+16'h0058));
236 2 olivier.gi
      if (mem250 !== 16'hc080) tb_error("====== FALLING EDGE TEST: P2IFG != 0xc080 =====");
237
      if (mem252 !== 16'hf0e0) tb_error("====== FALLING EDGE TEST: P2IFG != 0xf0e0 =====");
238
      if (mem254 !== 16'hfcf8) tb_error("====== FALLING EDGE TEST: P2IFG != 0xfcf8 =====");
239
      if (mem256 !== 16'hfffe) tb_error("====== FALLING EDGE TEST: P2IFG != 0xfffe =====");
240 111 olivier.gi
      test_step = 12;
241 2 olivier.gi
 
242
 
243
      // PORT 1: TEST INTERRUPT VECTOR
244
      //--------------------------------------------------------
245
 
246 111 olivier.gi
      @(r15==(`PER_SIZE+16'h0008));
247 2 olivier.gi
      if (mem200 !== 16'h0201) tb_error("====== INTERRUPT VECTOR TEST: P1IFG != 0x0201 =====");
248
      if (mem202 !== 16'h0804) tb_error("====== INTERRUPT VECTOR TEST: P1IFG != 0x0804 =====");
249
      if (mem204 !== 16'h2010) tb_error("====== INTERRUPT VECTOR TEST: P1IFG != 0x2010 =====");
250
      if (mem206 !== 16'h8040) tb_error("====== INTERRUPT VECTOR TEST: P1IFG != 0x8040 =====");
251 111 olivier.gi
      test_step = 13;
252 2 olivier.gi
 
253
 
254
      // PORT 2: TEST INTERRUPT VECTOR
255
      //--------------------------------------------------------
256
 
257 111 olivier.gi
      @(r15==(`PER_SIZE+16'h0018));
258 2 olivier.gi
      if (mem210 !== 16'h0201) tb_error("====== INTERRUPT VECTOR TEST: P1IFG != 0x0201 =====");
259
      if (mem212 !== 16'h0804) tb_error("====== INTERRUPT VECTOR TEST: P1IFG != 0x0804 =====");
260
      if (mem214 !== 16'h2010) tb_error("====== INTERRUPT VECTOR TEST: P1IFG != 0x2010 =====");
261
      if (mem216 !== 16'h8040) tb_error("====== INTERRUPT VECTOR TEST: P1IFG != 0x8040 =====");
262 111 olivier.gi
      test_step = 14;
263 2 olivier.gi
 
264
 
265
      stimulus_done = 1;
266
   end
267
 

powered by: WebSVN 2.1.0

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