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

Subversion Repositories openmsp430

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

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
/*                            CPU OPERATING MODES                            */
25
/*---------------------------------------------------------------------------*/
26
/* Test the CPU Operating modes:                                             */
27
/*                                 - CPUOFF (<=> R2[4]): turn off CPU.       */
28
/*                                 - OSCOFF (<=> R2[5]): turn off LFXT_CLK.  */
29
/*                                 - SCG1   (<=> R2[7]): turn off SMCLK.     */
30 18 olivier.gi
/*                                                                           */
31
/* Author(s):                                                                */
32
/*             - Olivier Girard,    olgirard@gmail.com                       */
33
/*                                                                           */
34
/*---------------------------------------------------------------------------*/
35 19 olivier.gi
/* $Rev: 111 $                                                                */
36
/* $LastChangedBy: olivier.girard $                                          */
37
/* $LastChangedDate: 2011-05-20 22:39:02 +0200 (Fri, 20 May 2011) $          */
38 2 olivier.gi
/*===========================================================================*/
39
 
40
integer smclk_cnt;
41
always @(negedge mclk)
42
  if (smclk_en) smclk_cnt <= smclk_cnt+1;
43
 
44
integer aclk_cnt;
45
always @(negedge mclk)
46
  if (aclk_en) aclk_cnt <= aclk_cnt+1;
47
 
48
integer inst_cnt;
49
always @(inst_number)
50
  inst_cnt = inst_cnt+1;
51
 
52
initial
53
   begin
54
      $display(" ===============================================");
55
      $display("|                 START SIMULATION              |");
56
      $display(" ===============================================");
57
      repeat(5) @(posedge mclk);
58
      stimulus_done = 0;
59
 
60
 
61
      // SCG1   (<=> R2[7]): turn off SMCLK
62
      //--------------------------------------------------------
63
 
64
      @(r15==16'h1001);
65
      smclk_cnt = 0;
66
      repeat (84) @(posedge mclk);
67
      if (smclk_cnt !== 16'h000a) tb_error("====== SCG1 TEST 1: SMCLK IS NOT RUNNING =====");
68
 
69
      @(r15==16'h1002);
70
      smclk_cnt = 0;
71
      repeat (84) @(posedge mclk);
72
      if (smclk_cnt !== 16'h0000) tb_error("====== SCG1 TEST 2: SMCLK IS NOT STOPPED =====");
73
 
74
      @(r15==16'h1003);
75
      p1_din[0] = 1'b1;
76
      repeat (2) @(posedge mclk);
77
      p1_din[0] = 1'b0;
78
      smclk_cnt = 0;
79
      repeat (84) @(posedge mclk);
80
      if (smclk_cnt !== 16'h000a) tb_error("====== SCG1 TEST 3: SMCLK IS NOT RUNNING DURING IRQ =====");
81
 
82
      @(r15==16'h1004);
83
      smclk_cnt = 0;
84
      repeat (84) @(posedge mclk);
85
      if (smclk_cnt !== 16'h0000) tb_error("====== SCG1 TEST 4: SMCLK IS NOT STOPPED =====");
86
 
87
      @(r15==16'h1005);
88
      smclk_cnt = 0;
89
      repeat (80) @(posedge mclk);
90
      if (smclk_cnt !== 16'h000a) tb_error("====== SCG1 TEST 5: SMCLK IS NOT RUNNING =====");
91
 
92
 
93
      // OSCOFF  (<=> R2[5]): turn off LFXT1CLK
94
      //--------------------------------------------------------
95
 
96
      @(r15==16'h2001);
97
      aclk_cnt  = 0;
98
      smclk_cnt = 0;
99
      repeat (104) @(posedge mclk);
100
      if (aclk_cnt  !== 16'h0004) tb_error("====== OSCOFF TEST 1: ACLK  IS NOT RUNNING =====");
101
      if (smclk_cnt !== 16'h0068) tb_error("====== OSCOFF TEST 1: SMCLK IS NOT RUNNING ON MCLK =====");
102
 
103
      @(r15==16'h2002);
104
      aclk_cnt  = 0;
105
      smclk_cnt = 0;
106
      repeat (104) @(posedge mclk);
107
      if (aclk_cnt  !== 16'h0000) tb_error("====== OSCOFF TEST 2: ACLK  IS NOT STOPPED =====");
108
      if (smclk_cnt !== 16'h0068) tb_error("====== OSCOFF TEST 2: SMCLK IS NOT RUNNING ON MCLK =====");
109
 
110
      @(r15==16'h2003);
111
      p1_din[0] = 1'b1;
112
      repeat (2) @(posedge mclk);
113
      p1_din[0] = 1'b0;
114
      aclk_cnt  = 0;
115
      smclk_cnt = 0;
116
      repeat (104) @(posedge mclk);
117
      if (aclk_cnt  !== 16'h0003) tb_error("====== OSCOFF TEST 3: ACLK  IS NOT RUNNING DURING IRQ =====");
118
      if (smclk_cnt !== 16'h0068) tb_error("====== OSCOFF TEST 3: SMCLK IS NOT RUNNING ON MCLK =====");
119
 
120
       @(r15==16'h2004);
121
      aclk_cnt  = 0;
122
      smclk_cnt = 0;
123
      repeat (104) @(posedge mclk);
124
      if (aclk_cnt  !== 16'h0000) tb_error("====== OSCOFF TEST 4: ACLK  IS NOT STOPPED =====");
125
      if (smclk_cnt !== 16'h0068) tb_error("====== OSCOFF TEST 4: SMCLK IS NOT RUNNING ON MCLK =====");
126
 
127
      @(r15==16'h2005);
128
      aclk_cnt  = 0;
129
      smclk_cnt = 0;
130
      repeat (104) @(posedge mclk);
131
      if (aclk_cnt  !== 16'h0004) tb_error("====== OSCOFF TEST 5: ACLK  IS NOT RUNNING =====");
132
      if (smclk_cnt !== 16'h0004) tb_error("====== OSCOFF TEST 5: SMCLK IS NOT RUNNING ON LFXT1 =====");
133
 
134
      @(r15==16'h2006);
135
      aclk_cnt  = 0;
136
      smclk_cnt = 0;
137
      repeat (104) @(posedge mclk);
138
      if (aclk_cnt  !== 16'h0003) tb_error("====== OSCOFF TEST 6: ACLK  IS NOT RUNNING =====");
139
      if (smclk_cnt !== 16'h0068) tb_error("====== OSCOFF TEST 6: SMCLK IS NOT RUNNING ON MCLK =====");
140
 
141
 
142
      // CPUOFF  (<=> R2[4]): turn off CPU
143
      //--------------------------------------------------------
144
 
145
      @(r15==16'h3001);
146
      @(negedge mclk);
147
      inst_cnt  = 0;
148
      repeat (80) @(negedge mclk);
149 95 olivier.gi
      if (inst_cnt  <= 16'h0030) tb_error("====== CPUOFF TEST 1: CPU IS NOT RUNNING =====");
150 2 olivier.gi
 
151
      @(r15==16'h3002);
152
      repeat (3) @(negedge mclk);
153
      inst_cnt  = 0;
154
      repeat (80) @(negedge mclk);
155
      if (inst_cnt  !== 16'h0000) tb_error("====== CPUOFF TEST 2: CPU IS NOT STOPPED =====");
156
 
157
      @(posedge mclk);
158
      p1_din[0] = 1'b1;
159
      repeat (2) @(posedge mclk);
160
      p1_din[0] = 1'b0;
161
      @(negedge mclk);
162
      inst_cnt  = 0;
163
      repeat (80) @(negedge mclk);
164 95 olivier.gi
      if (inst_cnt <= 16'h0025) tb_error("====== CPUOFF TEST 3: CPU IS NOT RUNNING DURING IRQ (PORT 1) =====");
165 79 olivier.gi
 
166 111 olivier.gi
      @(r1==(`PER_SIZE+16'h0050));
167 2 olivier.gi
      repeat (3) @(negedge mclk);
168
      inst_cnt  = 0;
169
      repeat (80) @(negedge mclk);
170
      if (inst_cnt  !== 16'h0000) tb_error("====== CPUOFF TEST 4: CPU IS NOT STOPPED AFTER IRQ =====");
171
 
172
      @(posedge mclk);
173
      p2_din[0] = 1'b1;
174
      repeat (2) @(posedge mclk);
175
      p2_din[0] = 1'b0;
176
      @(negedge mclk);
177
      inst_cnt  = 0;
178
      repeat (80) @(negedge mclk);
179 95 olivier.gi
      if (inst_cnt <= 16'h0025) tb_error("====== CPUOFF TEST 5: CPU IS NOT RUNNING DURING IRQ (PORT 2) =====");
180 2 olivier.gi
 
181
      @(r15==16'h3003);
182
      @(negedge mclk);
183
      inst_cnt  = 0;
184
      repeat (80) @(negedge mclk);
185 95 olivier.gi
      if (inst_cnt  <= 16'h0030) tb_error("====== CPUOFF TEST 6: CPU IS NOT RUNNING =====");
186 2 olivier.gi
 
187
 
188
      stimulus_done = 1;
189
   end
190
 

powered by: WebSVN 2.1.0

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