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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src/] [wdt_wkup.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
/*                            WATCHDOG TIMER                                 */
25
/*---------------------------------------------------------------------------*/
26
/* Test the Watdog timer:                                                    */
27
/*                        - Interval timer mode.                             */
28
/*                                                                           */
29
/* Author(s):                                                                */
30
/*             - Olivier Girard,    olgirard@gmail.com                       */
31
/*                                                                           */
32
/*---------------------------------------------------------------------------*/
33
/* $Rev: 19 $                                                                */
34
/* $LastChangedBy: olivier.girard $                                          */
35
/* $LastChangedDate: 2009-08-04 23:47:15 +0200 (Tue, 04 Aug 2009) $          */
36
/*===========================================================================*/
37 202 olivier.gi
 
38 134 olivier.gi
`define LONG_TIMEOUT
39
 
40
integer dco_clk_cnt;
41
always @(negedge dco_clk)
42
  dco_clk_cnt <= dco_clk_cnt+1;
43
 
44
integer mclk_cnt;
45
always @(negedge mclk)
46
  mclk_cnt <= mclk_cnt+1;
47
 
48
integer smclk_cnt;
49
always @(negedge smclk)
50
  smclk_cnt <= smclk_cnt+1;
51
 
52
integer aclk_cnt;
53 180 olivier.gi
`ifdef ASIC_CLOCKING
54 134 olivier.gi
always @(negedge aclk)
55
  aclk_cnt <= aclk_cnt+1;
56
`else
57
always @(negedge lfxt_clk)
58
  aclk_cnt <= aclk_cnt+1;
59
`endif
60
 
61
integer inst_cnt;
62
always @(inst_number)
63
  inst_cnt <= inst_cnt+1;
64
 
65
reg watchdog_clock;
66 180 olivier.gi
`ifdef ASIC_CLOCKING
67 134 olivier.gi
  `ifdef WATCHDOG_MUX
68
       always @(posedge lfxt_clk or negedge lfxt_clk) watchdog_clock <= lfxt_clk;
69
  `else
70
    `ifdef WATCHDOG_NOMUX_ACLK
71
       always @(posedge lfxt_clk or negedge lfxt_clk) watchdog_clock <= lfxt_clk;
72
    `else
73
       always @(posedge dco_clk  or negedge dco_clk)  watchdog_clock <= dco_clk;
74
    `endif
75
  `endif
76
`else
77
       always @(posedge lfxt_clk or negedge lfxt_clk) watchdog_clock <= lfxt_clk;
78
`endif
79
 
80
integer watchdog_clock_cnt;
81
always @(posedge watchdog_clock)
82
  watchdog_clock_cnt <= watchdog_clock_cnt+1;
83
 
84
always @(posedge dut.wdt_irq)
85
  watchdog_clock_cnt = 1'b0;
86
 
87
 
88
integer ii;
89
integer jj;
90 202 olivier.gi
 
91 134 olivier.gi
initial
92
   begin
93
      $display(" ===============================================");
94
      $display("|                 START SIMULATION              |");
95
      $display(" ===============================================");
96
      repeat(5) @(posedge mclk);
97
      stimulus_done = 0;
98
      ii = 0;
99
      jj = 0;
100 202 olivier.gi
 
101 134 olivier.gi
`ifdef WATCHDOG
102
 
103 202 olivier.gi
 
104 134 olivier.gi
      // WATCHDOG TEST:  INTERVAL MODE /64
105
      //--------------------------------------------------------
106
 
107
      @(r15==16'h1000);
108
 
109 180 olivier.gi
`ifdef ASIC_CLOCKING
110 134 olivier.gi
  `ifdef WATCHDOG_MUX
111
    `ifdef ACLK_DIVIDER
112
      repeat(5) @(posedge watchdog_clock);
113
    `else
114
      repeat(4) @(posedge watchdog_clock);
115
    `endif
116
  `else
117
    `ifdef WATCHDOG_NOMUX_ACLK
118
      `ifdef ACLK_DIVIDER
119
        repeat(6) @(posedge watchdog_clock);
120
      `else
121
        repeat(5) @(posedge watchdog_clock);
122
      `endif
123
    `else
124
      repeat(21) @(posedge watchdog_clock);
125
    `endif
126
  `endif
127
`endif
128
 
129
      for ( ii=0; ii < 9; ii=ii+1)
130
        begin
131
           repeat(1) @(posedge watchdog_clock);
132
           jj = 1;
133
           dco_clk_cnt = 0;
134
           mclk_cnt    = 0;
135
           smclk_cnt   = 0;
136
           aclk_cnt    = 0;
137
           inst_cnt    = 0;
138 180 olivier.gi
           `ifdef ASIC_CLOCKING
139 134 olivier.gi
             `ifdef WATCHDOG_MUX
140
                 repeat(62) @(posedge watchdog_clock);
141
                 jj = 2;
142
                 if (dco_clk_cnt !==  0)   tb_error("====== DCO_CLK is running                     (CONFIG 1) =====");
143
                 if (mclk_cnt    !==  0)   tb_error("====== MCLK    is running                     (CONFIG 1) =====");
144
                 if (smclk_cnt   !==  0)   tb_error("====== SMCLK   is running                     (CONFIG 1) =====");
145
                 if (aclk_cnt    !== 62)   tb_error("====== ACLK    is not running                 (CONFIG 1) =====");
146
                 if (inst_cnt    !== 0)    tb_error("====== CPU is executing                       (CONFIG 1) =====");
147
                 if (r6          !== ii)   tb_error("====== WATCHDOG interrupt was taken too early (CONFIG 1) =====");
148
                 repeat(1) @(posedge watchdog_clock);
149
                 jj = 3;
150
                 if (r6          !== ii+1) tb_error("====== WATCHDOG interrupt was not taken       (CONFIG 1) =====");
151
             `else
152
               `ifdef WATCHDOG_NOMUX_ACLK
153
                 repeat(62) @(posedge watchdog_clock);
154
                 jj = 2;
155
                 if (dco_clk_cnt !== 0)    tb_error("====== DCO_CLK is running                     (CONFIG 2) =====");
156
                 if (mclk_cnt    !== 0)    tb_error("====== MCLK    is running                     (CONFIG 2) =====");
157
                 if (smclk_cnt   !== 0)    tb_error("====== SMCLK   is running                     (CONFIG 2) =====");
158
                 if (aclk_cnt    !== 62)   tb_error("====== ACLK    is not running                 (CONFIG 2) =====");
159
                 if (inst_cnt    !== 0)    tb_error("====== CPU is executing                       (CONFIG 2) =====");
160
                 if (r6          !== ii)   tb_error("====== WATCHDOG interrupt was taken too early (CONFIG 2) =====");
161
                 repeat(1) @(posedge watchdog_clock);
162
                 jj = 3;
163
                 if (r6          !== ii+1) tb_error("====== WATCHDOG interrupt was not taken       (CONFIG 2) =====");
164
               `else
165
                 repeat(39) @(posedge watchdog_clock);
166
                 jj = 2;
167
                 if (dco_clk_cnt !== 39)   tb_error("====== DCO_CLK is not running                 (CONFIG 3) =====");
168
                 if (mclk_cnt    !== 0)    tb_error("====== MCLK    is running                     (CONFIG 3) =====");
169
                 if (smclk_cnt   !== 39)   tb_error("====== SMCLK   is not running                 (CONFIG 3) =====");
170
                 if (aclk_cnt    === 0)    tb_error("====== ACLK    is not running                 (CONFIG 3) =====");
171
                 if (inst_cnt    !== 0)    tb_error("====== CPU is executing                       (CONFIG 3) =====");
172
                 if (r6          !== ii)   tb_error("====== WATCHDOG interrupt was taken too early (CONFIG 3) =====");
173
                 repeat(24) @(posedge watchdog_clock);
174
                 jj = 3;
175
                 if (r6          !== ii+1) tb_error("====== WATCHDOG interrupt was not taken       (CONFIG 3) =====");
176
               `endif
177
             `endif
178
           `else
179
                 repeat(62) @(posedge watchdog_clock);
180
                 jj = 2;
181
                 if (dco_clk_cnt  <  1800) tb_error("====== DCO_CLK is not running                 (CONFIG 4) =====");
182
                 if (mclk_cnt     <  1800) tb_error("====== MCLK    is not running                 (CONFIG 4) =====");
183
                 if (smclk_cnt    <  1800) tb_error("====== SMCLK   is not running                 (CONFIG 4) =====");
184
                 if (aclk_cnt    !== 62)   tb_error("====== ACLK    is not running                 (CONFIG 4) =====");
185
                 if (inst_cnt    !== 0)    tb_error("====== CPU is executing                       (CONFIG 4) =====");
186
                 if (r6          !== ii)   tb_error("====== WATCHDOG interrupt was taken too early (CONFIG 4) =====");
187
                 repeat(1) @(posedge watchdog_clock);
188
                 jj = 3;
189
                 if (r6          !== ii+1) tb_error("====== WATCHDOG interrupt was not taken       (CONFIG 4) =====");
190
           `endif
191
        end
192
 
193
      // WATCHDOG TEST:  RESET MODE /64
194
      //--------------------------------------------------------
195
 
196
      @(r15==16'h5000);
197
      if (r7 !== 16'h0000) tb_error("====== WATCHDOG reset was not taken =====");
198
 
199
 
200
`else
201 202 olivier.gi
      tb_skip_finish("|         (the Watchdog is not included)        |");
202 134 olivier.gi
`endif
203
 
204
      stimulus_done = 1;
205
   end

powered by: WebSVN 2.1.0

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