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 2

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

powered by: WebSVN 2.1.0

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