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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src/] [sing-op_reti.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
/*                 SINGLE-OPERAND ARITHMETIC: RETI  INSTRUCTION              */
25
/*---------------------------------------------------------------------------*/
26
/* Test the RETI instruction.                                                */
27 18 olivier.gi
/*                                                                           */
28
/* Author(s):                                                                */
29
/*             - Olivier Girard,    olgirard@gmail.com                       */
30
/*                                                                           */
31
/*---------------------------------------------------------------------------*/
32 19 olivier.gi
/* $Rev: 192 $                                                                */
33
/* $LastChangedBy: olivier.girard $                                          */
34
/* $LastChangedDate: 2013-12-17 21:15:28 +0100 (Tue, 17 Dec 2013) $          */
35 2 olivier.gi
/*===========================================================================*/
36
 
37
integer    i;
38
reg [15:0] temp_val;
39
 
40
initial
41
   begin
42
      $display(" ===============================================");
43
      $display("|                 START SIMULATION              |");
44
      $display(" ===============================================");
45
      repeat(5) @(posedge mclk);
46
      stimulus_done = 0;
47
 
48
      // RETI Instruction test
49
      //--------------------------
50
      @(r15==16'h1000);
51
      if (r3    !==16'h0000) tb_error("====== RESET Vector: R3  value  =====");
52
      if (r4    !==16'h0000) tb_error("====== RESET Vector: R4  value  =====");
53
      if (r5    !==16'h0000) tb_error("====== RESET Vector: R5  value  =====");
54
      if (r6    !==16'h0000) tb_error("====== RESET Vector: R6  value  =====");
55
      if (r7    !==16'h0000) tb_error("====== RESET Vector: R7  value  =====");
56
      if (r8    !==16'h0000) tb_error("====== RESET Vector: R8  value  =====");
57
      if (r9    !==16'h0000) tb_error("====== RESET Vector: R9  value  =====");
58
      if (r10   !==16'h0000) tb_error("====== RESET Vector: R10 value  =====");
59
      if (r11   !==16'h0000) tb_error("====== RESET Vector: R11 value  =====");
60
      if (r12   !==16'h0000) tb_error("====== RESET Vector: R12 value  =====");
61
      if (r13   !==16'h0000) tb_error("====== RESET Vector: R13 value  =====");
62
      if (r14   !==16'h0000) tb_error("====== RESET Vector: R14 value  =====");
63
 
64
 
65
      // RETI Instruction test
66
      //--------------------------
67
      @(r15==16'h2000);
68 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== RETI: SP value      =====");
69 134 olivier.gi
      if (r2    !==16'h010f)             tb_error("====== RETI: SR value      =====");
70 111 olivier.gi
      if (r5    !==16'h1234)             tb_error("====== RETI: R5 value      =====");
71 2 olivier.gi
 
72
 
73
      // Test interruption 0
74
      //--------------------------
75
      @(r15==16'h3000);
76
      repeat(2) @(posedge mclk);
77 192 olivier.gi
      irq[`IRQ_NR-16:0] = {`IRQ_NR-16+1{1'b1}};
78 2 olivier.gi
      repeat(15) @(posedge mclk);
79 192 olivier.gi
      irq[`IRQ_NR-16:0] = {`IRQ_NR-16+1{1'b0}};
80 2 olivier.gi
 
81
      @(r15==16'h3001);
82 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== IRQ  0: SP value      =====");
83
      if (r2[3] !==1'b1)                 tb_error("====== IRQ  0: GIE value     =====");
84
      if (r6    !==16'h5678)             tb_error("====== IRQ  0: R6 value      =====");
85
      if (r7    !==16'h0000)             tb_error("====== IRQ  0: R7 value      =====");
86
      if (r8    !==(`PER_SIZE+16'h004e)) tb_error("====== IRQ  0: R8 value      =====");
87 2 olivier.gi
 
88
 
89
      // Test interruption 1
90
      //--------------------------
91
      @(r15==16'h4000);
92
      repeat(2) @(posedge mclk);
93 192 olivier.gi
      irq[`IRQ_NR-15:0] = {`IRQ_NR-15+1{1'b1}};
94 2 olivier.gi
      repeat(15) @(posedge mclk);
95 192 olivier.gi
      irq[`IRQ_NR-15:0] = {`IRQ_NR-15+1{1'b0}};
96 2 olivier.gi
 
97
      @(r15==16'h4001);
98 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== IRQ  1: SP value      =====");
99
      if (r2[3] !==1'b1)                 tb_error("====== IRQ  1: GIE value     =====");
100
      if (r6    !==16'h9abc)             tb_error("====== IRQ  1: R6 value      =====");
101
      if (r7    !==16'h0000)             tb_error("====== IRQ  1: R7 value      =====");
102
      if (r8    !==(`PER_SIZE+16'h004e)) tb_error("====== IRQ  1: R8 value      =====");
103 2 olivier.gi
 
104
 
105
      // Test interruption 2
106
      //--------------------------
107
      @(r15==16'h5000);
108
      repeat(2) @(posedge mclk);
109 192 olivier.gi
      irq[`IRQ_NR-14:0] = {`IRQ_NR-14+1{1'b1}};
110 2 olivier.gi
      repeat(15) @(posedge mclk);
111 192 olivier.gi
      irq[`IRQ_NR-14:0] = {`IRQ_NR-14+1{1'b0}};
112 2 olivier.gi
 
113
      @(r15==16'h5001);
114 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== IRQ  2: SP value      =====");
115
      if (r2[3] !==1'b1)                 tb_error("====== IRQ  2: GIE value     =====");
116
      if (r6    !==16'hdef1)             tb_error("====== IRQ  2: R6 value      =====");
117
      if (r7    !==16'h0000)             tb_error("====== IRQ  2: R7 value      =====");
118
      if (r8    !==(`PER_SIZE+16'h004e)) tb_error("====== IRQ  2: R8 value      =====");
119 2 olivier.gi
 
120
 
121
      // Test interruption 3
122
      //--------------------------
123
      @(r15==16'h6000);
124
      repeat(2) @(posedge mclk);
125 192 olivier.gi
      irq[`IRQ_NR-13:0] = {`IRQ_NR-13+1{1'b1}};
126 2 olivier.gi
      repeat(15) @(posedge mclk);
127 192 olivier.gi
      irq[`IRQ_NR-13:0] = {`IRQ_NR-13+1{1'b0}};
128 2 olivier.gi
 
129
      @(r15==16'h6001);
130 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== IRQ  3: SP value      =====");
131
      if (r2[3] !==1'b1)                 tb_error("====== IRQ  3: GIE value     =====");
132
      if (r6    !==16'h2345)             tb_error("====== IRQ  3: R6 value      =====");
133
      if (r7    !==16'h0000)             tb_error("====== IRQ  3: R7 value      =====");
134
      if (r8    !==(`PER_SIZE+16'h004e)) tb_error("====== IRQ  3: R8 value      =====");
135 2 olivier.gi
 
136
 
137
      // Test interruption 4
138
      //--------------------------
139
      @(r15==16'h7000);
140
      repeat(2) @(posedge mclk);
141 192 olivier.gi
      irq[`IRQ_NR-12:0] = {`IRQ_NR-12+1{1'b1}};
142 2 olivier.gi
      repeat(15) @(posedge mclk);
143 192 olivier.gi
      irq[`IRQ_NR-12:0] = {`IRQ_NR-12+1{1'b0}};
144 2 olivier.gi
 
145
      @(r15==16'h7001);
146 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== IRQ  4: SP value      =====");
147
      if (r2[3] !==1'b1)                 tb_error("====== IRQ  4: GIE value     =====");
148
      if (r6    !==16'h6789)             tb_error("====== IRQ  4: R6 value      =====");
149
      if (r7    !==16'h0000)             tb_error("====== IRQ  4: R7 value      =====");
150
      if (r8    !==(`PER_SIZE+16'h004e)) tb_error("====== IRQ  4: R8 value      =====");
151 2 olivier.gi
 
152
 
153
      // Test interruption 5
154
      //--------------------------
155
      @(r15==16'h8000);
156
      repeat(2) @(posedge mclk);
157 192 olivier.gi
      irq[`IRQ_NR-11:0] = {`IRQ_NR-11+1{1'b1}};
158 2 olivier.gi
      repeat(15) @(posedge mclk);
159 192 olivier.gi
      irq[`IRQ_NR-11:0] = {`IRQ_NR-11+1{1'b0}};
160 2 olivier.gi
 
161
      @(r15==16'h8001);
162 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== IRQ  5: SP value      =====");
163
      if (r2[3] !==1'b1)                 tb_error("====== IRQ  5: GIE value     =====");
164
      if (r6    !==16'habcd)             tb_error("====== IRQ  5: R6 value      =====");
165
      if (r7    !==16'h0000)             tb_error("====== IRQ  5: R7 value      =====");
166
      if (r8    !==(`PER_SIZE+16'h004e)) tb_error("====== IRQ  5: R8 value      =====");
167 2 olivier.gi
 
168
 
169
      // Test interruption 6
170
      //--------------------------
171
      @(r15==16'h9000);
172
      repeat(2) @(posedge mclk);
173 192 olivier.gi
      irq[`IRQ_NR-10:0] = {`IRQ_NR-10+1{1'b1}};
174 2 olivier.gi
      repeat(15) @(posedge mclk);
175 192 olivier.gi
      irq[`IRQ_NR-10:0] = {`IRQ_NR-10+1{1'b0}};
176 2 olivier.gi
 
177
      @(r15==16'h9001);
178 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== IRQ  6: SP value      =====");
179
      if (r2[3] !==1'b1)                 tb_error("====== IRQ  6: GIE value     =====");
180
      if (r6    !==16'hef12)             tb_error("====== IRQ  6: R6 value      =====");
181
      if (r7    !==16'h0000)             tb_error("====== IRQ  6: R7 value      =====");
182
      if (r8    !==(`PER_SIZE+16'h004e)) tb_error("====== IRQ  6: R8 value      =====");
183 2 olivier.gi
 
184
 
185
      // Test interruption 7
186
      //--------------------------
187
      @(r15==16'ha000);
188
      repeat(2) @(posedge mclk);
189 192 olivier.gi
      irq[`IRQ_NR-9:0] = {`IRQ_NR-9+1{1'b1}};
190 2 olivier.gi
      repeat(15) @(posedge mclk);
191 192 olivier.gi
      irq[`IRQ_NR-9:0] = {`IRQ_NR-9+1{1'b0}};
192 2 olivier.gi
 
193
      @(r15==16'ha001);
194 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== IRQ  7: SP value      =====");
195
      if (r2[3] !==1'b1)                 tb_error("====== IRQ  7: GIE value     =====");
196
      if (r6    !==16'h3456)             tb_error("====== IRQ  7: R6 value      =====");
197
      if (r7    !==16'h0000)             tb_error("====== IRQ  7: R7 value      =====");
198
      if (r8    !==(`PER_SIZE+16'h004e)) tb_error("====== IRQ  7: R8 value      =====");
199 2 olivier.gi
 
200
 
201
      // Test interruption 8
202
      //--------------------------
203
      @(r15==16'hb000);
204
      repeat(2) @(posedge mclk);
205 192 olivier.gi
      irq[`IRQ_NR-8:0] = {`IRQ_NR-8+1{1'b1}};
206 2 olivier.gi
      repeat(15) @(posedge mclk);
207 192 olivier.gi
      irq[`IRQ_NR-8:0] = {`IRQ_NR-8+1{1'b0}};
208 2 olivier.gi
 
209
      @(r15==16'hb001);
210 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== IRQ  8: SP value      =====");
211
      if (r2[3] !==1'b1)                 tb_error("====== IRQ  8: GIE value     =====");
212
      if (r6    !==16'h789a)             tb_error("====== IRQ  8: R6 value      =====");
213
      if (r7    !==16'h0000)             tb_error("====== IRQ  8: R7 value      =====");
214
      if (r8    !==(`PER_SIZE+16'h004e)) tb_error("====== IRQ  8: R8 value      =====");
215 2 olivier.gi
 
216
 
217
      // Test interruption 9
218
      //--------------------------
219
      @(r15==16'hc000);
220
      repeat(2) @(posedge mclk);
221 192 olivier.gi
      irq[`IRQ_NR-7:0] = {`IRQ_NR-7+1{1'b1}};
222 2 olivier.gi
      repeat(15) @(posedge mclk);
223 192 olivier.gi
      irq[`IRQ_NR-7:0] = {`IRQ_NR-7+1{1'b0}};
224 2 olivier.gi
 
225
      @(r15==16'hc001);
226 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== IRQ  9: SP value      =====");
227
      if (r2[3] !==1'b1)                 tb_error("====== IRQ  9: GIE value     =====");
228
      if (r6    !==16'hbcde)             tb_error("====== IRQ  9: R6 value      =====");
229
      if (r7    !==16'h0000)             tb_error("====== IRQ  9: R7 value      =====");
230
      if (r8    !==(`PER_SIZE+16'h004e)) tb_error("====== IRQ  9: R8 value      =====");
231 2 olivier.gi
 
232
 
233
      // Test interruption 10
234
      //--------------------------
235
      @(r15==16'hd000);
236
      repeat(2) @(posedge mclk);
237 192 olivier.gi
      irq[`IRQ_NR-6:0] = {`IRQ_NR-6+1{1'b1}};
238 2 olivier.gi
      repeat(15) @(posedge mclk);
239 192 olivier.gi
      irq[`IRQ_NR-6:0] = {`IRQ_NR-6+1{1'b0}};
240 2 olivier.gi
 
241
      @(r15==16'hd001);
242 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== IRQ 10: SP value      =====");
243
      if (r2[3] !==1'b1)                 tb_error("====== IRQ 10: GIE value     =====");
244
      if (r6    !==16'hf123)             tb_error("====== IRQ 10: R6 value      =====");
245
      if (r7    !==16'h0000)             tb_error("====== IRQ 10: R7 value      =====");
246
      if (r8    !==(`PER_SIZE+16'h004e)) tb_error("====== IRQ 10: R8 value      =====");
247 2 olivier.gi
 
248
 
249
      // Test interruption 11
250
      //--------------------------
251
      @(r15==16'he000);
252
      repeat(2) @(posedge mclk);
253 192 olivier.gi
      irq[`IRQ_NR-5:0] = {`IRQ_NR-5+1{1'b1}};
254 2 olivier.gi
      repeat(15) @(posedge mclk);
255 192 olivier.gi
      irq[`IRQ_NR-5:0] = {`IRQ_NR-5+1{1'b0}};
256 2 olivier.gi
 
257
      @(r15==16'he001);
258 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== IRQ 11: SP value      =====");
259
      if (r2[3] !==1'b1)                 tb_error("====== IRQ 11: GIE value     =====");
260
      if (r6    !==16'h4567)             tb_error("====== IRQ 11: R6 value      =====");
261
      if (r7    !==16'h0000)             tb_error("====== IRQ 11: R7 value      =====");
262
      if (r8    !==(`PER_SIZE+16'h004e)) tb_error("====== IRQ 11: R8 value      =====");
263 2 olivier.gi
 
264
 
265
      // Test interruption 12
266
      //--------------------------
267
      @(r15==16'hf000);
268
      repeat(2) @(posedge mclk);
269 192 olivier.gi
      irq[`IRQ_NR-4:0] = {`IRQ_NR-4+1{1'b1}};
270 2 olivier.gi
      repeat(15) @(posedge mclk);
271 192 olivier.gi
      irq[`IRQ_NR-4:0] = {`IRQ_NR-4+1{1'b0}};
272 2 olivier.gi
 
273
      @(r15==16'hf001);
274 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== IRQ 12: SP value      =====");
275
      if (r2[3] !==1'b1)                 tb_error("====== IRQ 12: GIE value     =====");
276
      if (r6    !==16'h89ab)             tb_error("====== IRQ 12: R6 value      =====");
277
      if (r7    !==16'h0000)             tb_error("====== IRQ 12: R7 value      =====");
278
      if (r8    !==(`PER_SIZE+16'h004e)) tb_error("====== IRQ 12: R8 value      =====");
279 2 olivier.gi
 
280
 
281
      // Test interruption 13
282
      //--------------------------
283
      @(r15==16'hf100);
284
      repeat(2) @(posedge mclk);
285 192 olivier.gi
      irq[`IRQ_NR-3:0] = {`IRQ_NR-3+1{1'b1}};
286 2 olivier.gi
      repeat(15) @(posedge mclk);
287 192 olivier.gi
      irq[`IRQ_NR-3:0] = {`IRQ_NR-3+1{1'b0}};
288 2 olivier.gi
 
289
      @(r15==16'hf101);
290 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== IRQ 13: SP value      =====");
291
      if (r2[3] !==1'b1)                 tb_error("====== IRQ 13: GIE value     =====");
292
      if (r6    !==16'hcdef)             tb_error("====== IRQ 13: R6 value      =====");
293
      if (r7    !==16'h0000)             tb_error("====== IRQ 13: R7 value      =====");
294
      if (r8    !==(`PER_SIZE+16'h004e)) tb_error("====== IRQ 13: R8 value      =====");
295 2 olivier.gi
 
296
 
297
      // Test interruption NMI:  rising edge
298
      //--------------------------------------
299 134 olivier.gi
  `ifdef NMI
300 2 olivier.gi
      @(r15==16'hf200);
301 95 olivier.gi
      repeat(2) @(negedge mclk);
302
      nmi       = 1'b1;
303
      @(posedge nmi_detect);
304 192 olivier.gi
      irq[`IRQ_NR-3:0] = {`IRQ_NR-3+1{1'b1}};
305 95 olivier.gi
      repeat(8) @(posedge mclk);
306
      nmi       = 1'b0;
307 2 olivier.gi
      repeat(2) @(posedge mclk);
308 192 olivier.gi
      irq[`IRQ_NR-3:0] = {`IRQ_NR-3+1{1'b0}};
309 2 olivier.gi
 
310
      @(r15==16'hf201);
311 111 olivier.gi
      if (r1    !==(`PER_SIZE+16'h0052)) tb_error("====== NMI: SP value      =====");
312
      if (r2[3] !==1'b1)                 tb_error("====== NMI: GIE value     =====");
313
      if (r6    !==16'h0123)             tb_error("====== NMI: R6 value      =====");
314
      if (r7    !==16'h0000)             tb_error("====== NMI: R7 value      =====");
315
      if (r8    !==(`PER_SIZE+16'h004e)) tb_error("====== NMI: R8 value      =====");
316 2 olivier.gi
 
317 111 olivier.gi
      if (r9    !==16'h0000)             tb_error("====== NMI: NMIE   value  =====");
318
      if (r10   !==16'h0010)             tb_error("====== NMI: NMIIFG value  =====");
319 134 olivier.gi
   `endif
320 2 olivier.gi
 
321
      stimulus_done = 1;
322
   end
323
 

powered by: WebSVN 2.1.0

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