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 134

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: 134 $                                                                */
36
/* $LastChangedBy: olivier.girard $                                          */
37
/* $LastChangedDate: 2012-03-22 21:31:06 +0100 (Thu, 22 Mar 2012) $          */
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 134 olivier.gi
`ifdef ASIC
61
      $display(" ===============================================");
62
      $display("|               SIMULATION SKIPPED              |");
63
      $display("|   (this test is not supported in ASIC mode)   |");
64
      $display(" ===============================================");
65
      $finish;
66
`else
67 2 olivier.gi
 
68
      // SCG1   (<=> R2[7]): turn off SMCLK
69
      //--------------------------------------------------------
70
 
71
      @(r15==16'h1001);
72
      smclk_cnt = 0;
73
      repeat (84) @(posedge mclk);
74
      if (smclk_cnt !== 16'h000a) tb_error("====== SCG1 TEST 1: SMCLK IS NOT RUNNING =====");
75
 
76
      @(r15==16'h1002);
77
      smclk_cnt = 0;
78
      repeat (84) @(posedge mclk);
79
      if (smclk_cnt !== 16'h0000) tb_error("====== SCG1 TEST 2: SMCLK IS NOT STOPPED =====");
80
 
81
      @(r15==16'h1003);
82
      p1_din[0] = 1'b1;
83
      repeat (2) @(posedge mclk);
84
      p1_din[0] = 1'b0;
85
      smclk_cnt = 0;
86
      repeat (84) @(posedge mclk);
87
      if (smclk_cnt !== 16'h000a) tb_error("====== SCG1 TEST 3: SMCLK IS NOT RUNNING DURING IRQ =====");
88
 
89
      @(r15==16'h1004);
90
      smclk_cnt = 0;
91
      repeat (84) @(posedge mclk);
92
      if (smclk_cnt !== 16'h0000) tb_error("====== SCG1 TEST 4: SMCLK IS NOT STOPPED =====");
93
 
94
      @(r15==16'h1005);
95
      smclk_cnt = 0;
96
      repeat (80) @(posedge mclk);
97
      if (smclk_cnt !== 16'h000a) tb_error("====== SCG1 TEST 5: SMCLK IS NOT RUNNING =====");
98
 
99
 
100
      // OSCOFF  (<=> R2[5]): turn off LFXT1CLK
101
      //--------------------------------------------------------
102
 
103
      @(r15==16'h2001);
104
      aclk_cnt  = 0;
105
      smclk_cnt = 0;
106
      repeat (104) @(posedge mclk);
107
      if (aclk_cnt  !== 16'h0004) tb_error("====== OSCOFF TEST 1: ACLK  IS NOT RUNNING =====");
108
      if (smclk_cnt !== 16'h0068) tb_error("====== OSCOFF TEST 1: SMCLK IS NOT RUNNING ON MCLK =====");
109
 
110
      @(r15==16'h2002);
111
      aclk_cnt  = 0;
112
      smclk_cnt = 0;
113
      repeat (104) @(posedge mclk);
114
      if (aclk_cnt  !== 16'h0000) tb_error("====== OSCOFF TEST 2: ACLK  IS NOT STOPPED =====");
115
      if (smclk_cnt !== 16'h0068) tb_error("====== OSCOFF TEST 2: SMCLK IS NOT RUNNING ON MCLK =====");
116
 
117
      @(r15==16'h2003);
118
      p1_din[0] = 1'b1;
119
      repeat (2) @(posedge mclk);
120
      p1_din[0] = 1'b0;
121
      aclk_cnt  = 0;
122
      smclk_cnt = 0;
123
      repeat (104) @(posedge mclk);
124
      if (aclk_cnt  !== 16'h0003) tb_error("====== OSCOFF TEST 3: ACLK  IS NOT RUNNING DURING IRQ =====");
125
      if (smclk_cnt !== 16'h0068) tb_error("====== OSCOFF TEST 3: SMCLK IS NOT RUNNING ON MCLK =====");
126
 
127
       @(r15==16'h2004);
128
      aclk_cnt  = 0;
129
      smclk_cnt = 0;
130
      repeat (104) @(posedge mclk);
131
      if (aclk_cnt  !== 16'h0000) tb_error("====== OSCOFF TEST 4: ACLK  IS NOT STOPPED =====");
132
      if (smclk_cnt !== 16'h0068) tb_error("====== OSCOFF TEST 4: SMCLK IS NOT RUNNING ON MCLK =====");
133
 
134
      @(r15==16'h2005);
135
      aclk_cnt  = 0;
136
      smclk_cnt = 0;
137
      repeat (104) @(posedge mclk);
138
      if (aclk_cnt  !== 16'h0004) tb_error("====== OSCOFF TEST 5: ACLK  IS NOT RUNNING =====");
139
      if (smclk_cnt !== 16'h0004) tb_error("====== OSCOFF TEST 5: SMCLK IS NOT RUNNING ON LFXT1 =====");
140
 
141
      @(r15==16'h2006);
142
      aclk_cnt  = 0;
143
      smclk_cnt = 0;
144
      repeat (104) @(posedge mclk);
145
      if (aclk_cnt  !== 16'h0003) tb_error("====== OSCOFF TEST 6: ACLK  IS NOT RUNNING =====");
146
      if (smclk_cnt !== 16'h0068) tb_error("====== OSCOFF TEST 6: SMCLK IS NOT RUNNING ON MCLK =====");
147
 
148
 
149
      // CPUOFF  (<=> R2[4]): turn off CPU
150
      //--------------------------------------------------------
151
 
152
      @(r15==16'h3001);
153
      @(negedge mclk);
154
      inst_cnt  = 0;
155
      repeat (80) @(negedge mclk);
156 95 olivier.gi
      if (inst_cnt  <= 16'h0030) tb_error("====== CPUOFF TEST 1: CPU IS NOT RUNNING =====");
157 2 olivier.gi
 
158
      @(r15==16'h3002);
159
      repeat (3) @(negedge mclk);
160
      inst_cnt  = 0;
161
      repeat (80) @(negedge mclk);
162
      if (inst_cnt  !== 16'h0000) tb_error("====== CPUOFF TEST 2: CPU IS NOT STOPPED =====");
163
 
164
      @(posedge mclk);
165
      p1_din[0] = 1'b1;
166
      repeat (2) @(posedge mclk);
167
      p1_din[0] = 1'b0;
168
      @(negedge mclk);
169
      inst_cnt  = 0;
170
      repeat (80) @(negedge mclk);
171 95 olivier.gi
      if (inst_cnt <= 16'h0025) tb_error("====== CPUOFF TEST 3: CPU IS NOT RUNNING DURING IRQ (PORT 1) =====");
172 79 olivier.gi
 
173 111 olivier.gi
      @(r1==(`PER_SIZE+16'h0050));
174 2 olivier.gi
      repeat (3) @(negedge mclk);
175
      inst_cnt  = 0;
176
      repeat (80) @(negedge mclk);
177
      if (inst_cnt  !== 16'h0000) tb_error("====== CPUOFF TEST 4: CPU IS NOT STOPPED AFTER IRQ =====");
178
 
179
      @(posedge mclk);
180
      p2_din[0] = 1'b1;
181
      repeat (2) @(posedge mclk);
182
      p2_din[0] = 1'b0;
183
      @(negedge mclk);
184
      inst_cnt  = 0;
185
      repeat (80) @(negedge mclk);
186 95 olivier.gi
      if (inst_cnt <= 16'h0025) tb_error("====== CPUOFF TEST 5: CPU IS NOT RUNNING DURING IRQ (PORT 2) =====");
187 2 olivier.gi
 
188
      @(r15==16'h3003);
189
      @(negedge mclk);
190
      inst_cnt  = 0;
191
      repeat (80) @(negedge mclk);
192 95 olivier.gi
      if (inst_cnt  <= 16'h0030) tb_error("====== CPUOFF TEST 6: CPU IS NOT RUNNING =====");
193 2 olivier.gi
 
194 134 olivier.gi
`endif
195
 
196 2 olivier.gi
      stimulus_done = 1;
197
   end
198
 

powered by: WebSVN 2.1.0

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