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 192

Go to most recent revision | 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 134 olivier.gi
 
75
      @(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
 
85
      // 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
      $display(" Test NMI falling edge");
130
 
131
      @(r15==16'h3001);
132
 
133
      #(2000);
134
      inst_cnt = 0;
135
      #(2000);
136
      if (inst_cnt !==16'h0000)  tb_error("====== NMI falling edge: CPU is not sleeping =====");
137
      #(2000);
138
      nmi      = 1'b1;
139
 
140
      #(2000);
141
      if (r6       !==16'h0000)  tb_error("====== NMI falling edge: NMI irq was taken with rising edge =====");
142
      if (inst_cnt !==16'h0000)  tb_error("====== NMI falling edge: CPU is not sleeping =====");
143
      #(2000);
144
      if (inst_cnt !==16'h0000)  tb_error("====== NMI falling edge: CPU is not sleeping =====");
145
      #(2000);
146
      nmi      = 1'b0;
147
 
148
      #(2000);
149
      if (r6       !==16'h0001)  tb_error("====== NMI falling edge: NMI irq was not taken first time =====");
150
      if (inst_cnt ===16'h0000)  tb_error("====== NMI falling edge: CPU did not woke up because of NMI =====");
151
      inst_cnt = 0;
152
      #(2000);
153
      if (inst_cnt !==16'h0000)  tb_error("====== NMI falling edge: CPU is not sleeping =====");
154
      #(2000);
155
      nmi      = 1'b1;
156
 
157
      #(2000);
158
      if (r6       !==16'h0001)  tb_error("====== NMI falling edge: NMI irq was taken with rising edge =====");
159
      if (inst_cnt !==16'h0000)  tb_error("====== NMI falling edge: CPU is not sleeping =====");
160
      #(2000);
161
      if (inst_cnt !==16'h0000)  tb_error("====== NMI falling edge: CPU is not sleeping =====");
162
      #(2000);
163
      nmi      = 1'b0;
164
 
165
      #(2000);
166
      if (r6       !==16'h0002)  tb_error("====== NMI falling edge: NMI irq was not taken second time =====");
167
      if (inst_cnt ===16'h0000)  tb_error("====== NMI falling edge: CPU did not woke up because of NMI =====");
168
      inst_cnt = 0;
169
      #(2000);
170
      if (inst_cnt ===16'h0000)  tb_error("====== NMI falling edge: CPU is not out of LPM4 =====");
171
      #(2000);
172
 
173
 
174
      // Test NMI nested from Maskable-IRQ
175
      //-----------------------------------
176
      @(r15==16'h4000);
177
      $display(" Test NMI nested from Maskable-IRQ");
178
 
179
      @(r15==16'h4001);
180
      #(2000);
181
      inst_cnt = 0;
182
      #(2000);
183
      if (inst_cnt !==16'h0000)  tb_error("====== NMI nested: CPU is not sleeping =====");
184
      #(2000);
185 192 olivier.gi
      wkup[0]            = 1'b1;
186
      irq[`IRQ_NR-16]    = 1'b1;
187
      @(negedge irq_acc[`IRQ_NR-16])
188
      wkup[0]            = 1'b0;
189
      irq[`IRQ_NR-16]    = 1'b0;
190
      nmi                = 1'b1;
191 134 olivier.gi
 
192
      @(r15==16'h4002);
193
      if (r6       !==16'h0001)  tb_error("====== NMI nested: NMI irq was not taken =====");
194
      if (inst_cnt ===16'h0000)  tb_error("====== NMI nested: CPU did not woke up   =====");
195
      if (r10      !==16'h5679)  tb_error("====== NMI nested: NMI was not nested from IRQ =====");
196
 
197
 
198
`else
199
      $display(" ===============================================");
200
      $display("|               SIMULATION SKIPPED              |");
201
      $display("|         (the NMI support is not included)     |");
202
      $display(" ===============================================");
203
      $finish;
204
`endif
205
 
206
      stimulus_done = 1;
207
   end
208
 

powered by: WebSVN 2.1.0

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