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

Subversion Repositories openmsp430

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 134 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
/*                                                                           */
28
/* Author(s):                                                                */
29
/*             - Olivier Girard,    olgirard@gmail.com                       */
30
/*                                                                           */
31
/*---------------------------------------------------------------------------*/
32
/* $Rev: 95 $                                                                */
33
/* $LastChangedBy: olivier.girard $                                          */
34
/* $LastChangedDate: 2011-02-24 21:37:57 +0100 (Thu, 24 Feb 2011) $          */
35
/*===========================================================================*/
36
 
37
integer    i;
38
reg [15:0] temp_val;
39
 
40
integer inst_cnt;
41
always @(inst_number)
42
  inst_cnt <= inst_cnt+1;
43
 
44
initial
45
   begin
46
      $display(" ===============================================");
47
      $display("|                 START SIMULATION              |");
48
      $display(" ===============================================");
49
      repeat(5) @(posedge mclk);
50
      stimulus_done = 0;
51
 
52
`ifdef NMI
53
 
54
      // Test NMI disabled
55
      //--------------------------
56
      @(r15==16'h1000);
57
      $display(" Test NMI disabled");
58
 
59
      @(r15==16'h1001);
60
      #(2000);
61
      inst_cnt = 0;
62
      #(2000);
63
      if (inst_cnt !==16'h0000)  tb_error("====== NMI rising edge: CPU is not sleeping =====");
64
      nmi       = 1'b1;
65
      #(6000);
66
      if (inst_cnt !==16'h0000)  tb_error("====== NMI rising edge: CPU is not sleeping =====");
67
 
68 192 olivier.gi
      wkup[0]            = 1'b1;
69 134 olivier.gi
      @(negedge mclk)
70 192 olivier.gi
      irq[`IRQ_NR-16]    = 1'b1;
71
      @(negedge irq_acc[`IRQ_NR-16])
72
      wkup[0]            = 1'b0;
73
      irq[`IRQ_NR-16]    = 1'b0;
74 200 olivier.gi
 
75 134 olivier.gi
      @(r15==16'h1002);
76
      nmi       = 1'b0;
77
 
78
      if (r6    !==16'h0000)  tb_error("====== NMI disabled: NMI irq was taken       =====");
79
      if (r14   !==16'h0000)  tb_error("====== NMI disabled: flag is set after reset =====");
80
      if (r13   !==16'h0010)  tb_error("====== NMI disabled: flag is not set         =====");
81
      if (r12   !==16'h0000)  tb_error("====== NMI disabled: flag was not cleared    =====");
82
      if (r11   !==16'h0000)  tb_error("====== NMI disabled: flag is set             =====");
83
 
84 200 olivier.gi
 
85 134 olivier.gi
      // Test NMI rising edge
86
      //--------------------------
87
      @(r15==16'h2000);
88
      $display(" Test NMI rising edge");
89
 
90
      @(r15==16'h2001);
91
 
92
      #(2000);
93
      inst_cnt = 0;
94
      #(2000);
95
      if (inst_cnt !==16'h0000)  tb_error("====== NMI rising edge: CPU is not sleeping =====");
96
      #(2000);
97
      nmi      = 1'b1;
98
 
99
      #(2000);
100
      if (r6       !==16'h0001)  tb_error("====== NMI rising edge: NMI irq was not taken first time =====");
101
      if (inst_cnt ===16'h0000)  tb_error("====== NMI rising edge: CPU did not woke up because of NMI =====");
102
      inst_cnt = 0;
103
      #(2000);
104
      if (inst_cnt !==16'h0000)  tb_error("====== NMI rising edge: CPU is not sleeping =====");
105
      #(2000);
106
      nmi      = 1'b0;
107
 
108
      #(4000);
109
      if (r6       !==16'h0001)  tb_error("====== NMI rising edge: NMI irq was taken with falling edge =====");
110
      if (inst_cnt !==16'h0000)  tb_error("====== NMI rising edge: CPU is not sleeping =====");
111
      #(2000);
112
      nmi      = 1'b1;
113
 
114
      #(2000);
115
      if (r6       !==16'h0002)  tb_error("====== NMI rising edge: NMI irq was not taken second time =====");
116
      if (inst_cnt ===16'h0000)  tb_error("====== NMI rising edge: CPU did not woke up because of NMI =====");
117
      inst_cnt = 0;
118
      #(2000);
119
      if (inst_cnt ===16'h0000)  tb_error("====== NMI rising edge: CPU is not running =====");
120
      #(2000);
121
      nmi      = 1'b0;
122
      #(4000);
123
      if (r6       !==16'h0002)  tb_error("====== NMI rising edge: NMI irq was taken with falling edge =====");
124
 
125
 
126
      // Test NMI falling edge
127
      //--------------------------
128
      @(r15==16'h3000);
129 200 olivier.gi
`ifdef WATCHDOG
130 134 olivier.gi
      $display(" Test NMI falling edge");
131 200 olivier.gi
`else
132
      $display(" Skip NMI falling edge (Watchdog is not included)");
133
`endif
134
 
135 134 olivier.gi
      @(r15==16'h3001);
136
 
137
      #(2000);
138
      inst_cnt = 0;
139
      #(2000);
140
      if (inst_cnt !==16'h0000)  tb_error("====== NMI falling edge: CPU is not sleeping =====");
141
      #(2000);
142
      nmi      = 1'b1;
143
 
144
      #(2000);
145 200 olivier.gi
`ifdef WATCHDOG
146 134 olivier.gi
      if (r6       !==16'h0000)  tb_error("====== NMI falling edge: NMI irq was taken with rising edge =====");
147
      if (inst_cnt !==16'h0000)  tb_error("====== NMI falling edge: CPU is not sleeping =====");
148
      #(2000);
149
      if (inst_cnt !==16'h0000)  tb_error("====== NMI falling edge: CPU is not sleeping =====");
150 200 olivier.gi
`else
151 134 olivier.gi
      #(2000);
152 200 olivier.gi
`endif
153
      #(2000);
154 134 olivier.gi
      nmi      = 1'b0;
155
 
156
      #(2000);
157
      if (r6       !==16'h0001)  tb_error("====== NMI falling edge: NMI irq was not taken first time =====");
158
      if (inst_cnt ===16'h0000)  tb_error("====== NMI falling edge: CPU did not woke up because of NMI =====");
159
      inst_cnt = 0;
160
      #(2000);
161
      if (inst_cnt !==16'h0000)  tb_error("====== NMI falling edge: CPU is not sleeping =====");
162
      #(2000);
163
      nmi      = 1'b1;
164
 
165
      #(2000);
166 200 olivier.gi
`ifdef WATCHDOG
167 134 olivier.gi
      if (r6       !==16'h0001)  tb_error("====== NMI falling edge: NMI irq was taken with rising edge =====");
168
      if (inst_cnt !==16'h0000)  tb_error("====== NMI falling edge: CPU is not sleeping =====");
169
      #(2000);
170
      if (inst_cnt !==16'h0000)  tb_error("====== NMI falling edge: CPU is not sleeping =====");
171 200 olivier.gi
`else
172 134 olivier.gi
      #(2000);
173 200 olivier.gi
`endif
174
      #(2000);
175 134 olivier.gi
      nmi      = 1'b0;
176
 
177
      #(2000);
178
      if (r6       !==16'h0002)  tb_error("====== NMI falling edge: NMI irq was not taken second time =====");
179
      if (inst_cnt ===16'h0000)  tb_error("====== NMI falling edge: CPU did not woke up because of NMI =====");
180
      inst_cnt = 0;
181
      #(2000);
182
      if (inst_cnt ===16'h0000)  tb_error("====== NMI falling edge: CPU is not out of LPM4 =====");
183
      #(2000);
184
 
185
      // Test NMI nested from Maskable-IRQ
186
      //-----------------------------------
187
      @(r15==16'h4000);
188
      $display(" Test NMI nested from Maskable-IRQ");
189 200 olivier.gi
 
190 134 olivier.gi
      @(r15==16'h4001);
191
      #(2000);
192
      inst_cnt = 0;
193
      #(2000);
194
      if (inst_cnt !==16'h0000)  tb_error("====== NMI nested: CPU is not sleeping =====");
195
      #(2000);
196 192 olivier.gi
      wkup[0]            = 1'b1;
197
      irq[`IRQ_NR-16]    = 1'b1;
198
      @(negedge irq_acc[`IRQ_NR-16])
199
      wkup[0]            = 1'b0;
200
      irq[`IRQ_NR-16]    = 1'b0;
201
      nmi                = 1'b1;
202 134 olivier.gi
 
203
      @(r15==16'h4002);
204
      if (r6       !==16'h0001)  tb_error("====== NMI nested: NMI irq was not taken =====");
205
      if (inst_cnt ===16'h0000)  tb_error("====== NMI nested: CPU did not woke up   =====");
206
      if (r10      !==16'h5679)  tb_error("====== NMI nested: NMI was not nested from IRQ =====");
207
 
208
 
209
`else
210 202 olivier.gi
      tb_skip_finish("|         (the NMI support is not included)     |");
211 134 olivier.gi
`endif
212
 
213
      stimulus_done = 1;
214
   end

powered by: WebSVN 2.1.0

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