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

Subversion Repositories openmsp430

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

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
/*                               CLOCK MODULE                                */
25
/*---------------------------------------------------------------------------*/
26
/* Test the clock module:                                                    */
27
/*                        - Check the ACLK and SMCLK clock generation.       */
28 18 olivier.gi
/*                                                                           */
29
/* Author(s):                                                                */
30
/*             - Olivier Girard,    olgirard@gmail.com                       */
31
/*                                                                           */
32
/*---------------------------------------------------------------------------*/
33 19 olivier.gi
/* $Rev: 19 $                                                                */
34
/* $LastChangedBy: olivier.girard $                                          */
35
/* $LastChangedDate: 2009-08-04 23:47:15 +0200 (Tue, 04 Aug 2009) $          */
36 2 olivier.gi
/*===========================================================================*/
37
 
38
`define LONG_TIMEOUT
39
 
40
integer mclk_counter;
41
always @ (negedge mclk)
42
  mclk_counter <=  mclk_counter+1;
43
 
44
integer aclk_counter;
45
always @ (negedge mclk)
46
  if (aclk_en) aclk_counter <=  aclk_counter+1;
47
 
48
integer smclk_counter;
49
always @ (negedge mclk)
50
  if (smclk_en) smclk_counter <=  smclk_counter+1;
51
 
52
 
53
initial
54
   begin
55
      $display(" ===============================================");
56
      $display("|                 START SIMULATION              |");
57
      $display(" ===============================================");
58
      repeat(5) @(posedge mclk);
59
      stimulus_done = 0;
60
 
61
 
62
      // ACLK GENERATION
63
      //--------------------------------------------------------
64
 
65
                                // ------- Divider /1 ----------
66
      @(r15 === 16'h0001);
67
      @(negedge aclk_en);
68
      mclk_counter = 0;
69
      aclk_counter = 0;
70
      repeat(735) @(posedge mclk);
71
      if (mclk_counter !== 735) tb_error("====== CLOCK GENERATOR: ACLK (DIV /1) =====");
72
      if (aclk_counter !== 24)  tb_error("====== CLOCK GENERATOR: ACLK (DIV /1) =====");
73
 
74
 
75
                                // ------- Divider /2 ----------
76
      @(r15 === 16'h0002);
77
      @(negedge aclk_en);
78
      mclk_counter = 0;
79
      aclk_counter = 0;
80
      repeat(735) @(posedge mclk);
81
      if (mclk_counter !== 735) tb_error("====== CLOCK GENERATOR: ACLK (DIV /2) =====");
82
      if (aclk_counter !== 12)  tb_error("====== CLOCK GENERATOR: ACLK (DIV /2) =====");
83
 
84
 
85
                                // ------- Divider /4 ----------
86
      @(r15 === 16'h0003);
87
      @(negedge aclk_en);
88
      mclk_counter = 0;
89
      aclk_counter = 0;
90
      repeat(735) @(posedge mclk);
91
      if (mclk_counter !== 735) tb_error("====== CLOCK GENERATOR: ACLK (DIV /4) =====");
92
      if (aclk_counter !== 6)   tb_error("====== CLOCK GENERATOR: ACLK (DIV /4) =====");
93
 
94
 
95
                                // ------- Divider /8 ----------
96
      @(r15 === 16'h0004);
97
      @(negedge aclk_en);
98
      mclk_counter = 0;
99
      aclk_counter = 0;
100
      repeat(735) @(posedge mclk);
101
      if (mclk_counter !== 735) tb_error("====== CLOCK GENERATOR: ACLK (DIV /8) =====");
102
      if (aclk_counter !== 3)   tb_error("====== CLOCK GENERATOR: ACLK (DIV /8) =====");
103
 
104
 
105
      // SMCLK GENERATION - LFXT_CLK INPUT
106
      //--------------------------------------------------------
107
 
108
                                // ------- Divider /1 ----------
109
      @(r15 === 16'h1001);
110
      @(negedge smclk_en);
111
      mclk_counter = 0;
112
      smclk_counter = 0;
113
      repeat(735) @(posedge mclk);
114
      if (mclk_counter !== 735) tb_error("====== CLOCK GENERATOR: SMCLK - LFXT_CLK INPUT (DIV /1) =====");
115
      if (smclk_counter !== 24) tb_error("====== CLOCK GENERATOR: SMCLK - LFXT_CLK INPUT (DIV /1) =====");
116
 
117
 
118
                                // ------- Divider /2 ----------
119
      @(r15 === 16'h1002);
120
      @(negedge smclk_en);
121
      mclk_counter = 0;
122
      smclk_counter = 0;
123
      repeat(735) @(posedge mclk);
124
      if (mclk_counter !== 735) tb_error("====== CLOCK GENERATOR: SMCLK - LFXT_CLK INPUT (DIV /2) =====");
125
      if (smclk_counter !== 12) tb_error("====== CLOCK GENERATOR: SMCLK - LFXT_CLK INPUT (DIV /2) =====");
126
 
127
 
128
                                // ------- Divider /4 ----------
129
      @(r15 === 16'h1003);
130
      @(negedge smclk_en);
131
      mclk_counter = 0;
132
      smclk_counter = 0;
133
      repeat(735) @(posedge mclk);
134
      if (mclk_counter !== 735) tb_error("====== CLOCK GENERATOR: SMCLK - LFXT_CLK INPUT (DIV /4) =====");
135
      if (smclk_counter !== 6)  tb_error("====== CLOCK GENERATOR: SMCLK - LFXT_CLK INPUT (DIV /4) =====");
136
 
137
 
138
                                // ------- Divider /8 ----------
139
      @(r15 === 16'h1004);
140
      @(negedge smclk_en);
141
      mclk_counter = 0;
142
      smclk_counter = 0;
143
      repeat(735) @(posedge mclk);
144
      if (mclk_counter !== 735) tb_error("====== CLOCK GENERATOR: SMCLK - LFXT_CLK INPUT (DIV /8) =====");
145
      if (smclk_counter !== 3)  tb_error("====== CLOCK GENERATOR: SMCLK - LFXT_CLK INPUT (DIV /8) =====");
146
 
147
 
148
      // SMCLK GENERATION - DCO_CLK INPUT
149
      //--------------------------------------------------------
150
 
151
                                // ------- Divider /1 ----------
152
      @(r15 === 16'h2001);
153
      mclk_counter = 0;
154
      smclk_counter = 0;
155
      repeat(600) @(posedge mclk);
156
      if (mclk_counter !== 600)  tb_error("====== CLOCK GENERATOR: SMCLK - DCO_CLK INPUT (DIV /1) =====");
157
      if (smclk_counter !== 600) tb_error("====== CLOCK GENERATOR: SMCLK - DCO_CLK INPUT (DIV /1) =====");
158
 
159
                                // ------- Divider /2 ----------
160
      @(r15 === 16'h2002);
161
      @(negedge smclk_en);
162
      mclk_counter = 0;
163
      smclk_counter = 0;
164
      repeat(600) @(posedge mclk);
165
      if (mclk_counter !== 600)  tb_error("====== CLOCK GENERATOR: SMCLK - DCO_CLK INPUT (DIV /2) =====");
166
      if (smclk_counter !== 300) tb_error("====== CLOCK GENERATOR: SMCLK - DCO_CLK INPUT (DIV /2) =====");
167
 
168
 
169
                                // ------- Divider /4 ----------
170
      @(r15 === 16'h2003);
171
      @(negedge smclk_en);
172
      mclk_counter = 0;
173
      smclk_counter = 0;
174
      repeat(600) @(posedge mclk);
175
      if (mclk_counter !== 600)  tb_error("====== CLOCK GENERATOR: SMCLK - DCO_CLK INPUT (DIV /4) =====");
176
      if (smclk_counter !== 150) tb_error("====== CLOCK GENERATOR: SMCLK - DCO_CLK INPUT (DIV /4) =====");
177
 
178
 
179
                                // ------- Divider /8 ----------
180
      @(r15 === 16'h2004);
181
      @(negedge smclk_en);
182
      mclk_counter = 0;
183
      smclk_counter = 0;
184
      repeat(600) @(posedge mclk);
185
      if (mclk_counter !== 600)  tb_error("====== CLOCK GENERATOR: SMCLK - DCO_CLK INPUT (DIV /8) =====");
186
      if (smclk_counter !== 75)  tb_error("====== CLOCK GENERATOR: SMCLK - DCO_CLK INPUT (DIV /8) =====");
187
 
188
 
189
      stimulus_done = 1;
190
   end
191
 

powered by: WebSVN 2.1.0

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