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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src/] [tA_clkmux.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
/*                                  TIMER A                                  */
25
/*---------------------------------------------------------------------------*/
26
/* Test the timer A:                                                         */
27
/*                        - Check the timer clock input mux.                 */
28
/*===========================================================================*/
29
 
30
integer my_counter;
31
always @ (negedge mclk)
32
  my_counter <=  my_counter+1;
33
 
34
wire [15:0] tar = timerA_0.tar;
35
 
36
// Generate TACLK as MCLK/3
37
integer taclk_cnt;
38
always @ (posedge mclk or posedge puc)
39
  if (puc)               taclk_cnt <=  0;
40
  else if (taclk_cnt==2) taclk_cnt <=  0;
41
  else                   taclk_cnt <=  taclk_cnt+1;
42
 
43
always @ (taclk_cnt)
44
  if (taclk_cnt==2) taclk = 1'b1;
45
  else              taclk = 1'b0;
46
 
47
// Generate INCLK as MCLK/5
48
integer inclk_cnt;
49
always @ (posedge mclk or posedge puc)
50
  if (puc)               inclk_cnt <=  0;
51
  else if (inclk_cnt==4) inclk_cnt <=  0;
52
  else                   inclk_cnt <=  inclk_cnt+1;
53
 
54
always @ (inclk_cnt)
55
  if (inclk_cnt==4) inclk = 1'b1;
56
  else              inclk = 1'b0;
57
 
58
 
59
initial
60
   begin
61
      $display(" ===============================================");
62
      $display("|                 START SIMULATION              |");
63
      $display(" ===============================================");
64
      repeat(5) @(posedge mclk);
65
      stimulus_done = 0;
66
 
67
 
68
      // TIMER A TEST:  INPUT MUX - TACLK
69
      //--------------------------------------------------------
70
//      @(r15 === 16'h0000);
71
 
72
      @(r15 === 16'h0001);
73
      @(tar === 1);
74
      my_counter = 0;
75
      repeat(300) @(posedge mclk);
76
      if (tar !== 16'h0032) tb_error("====== TIMER A TEST:  INPUT MUX - TACLK =====");
77
 
78
 
79
      // TIMER A TEST:  INPUT MUX - ACLK
80
      //--------------------------------------------------------
81
      @(r15 === 16'h1000);
82
 
83
      @(r15 === 16'h1001);
84
      @(tar === 1);
85
      my_counter = 0;
86
      repeat(300) @(posedge mclk);
87
      if (tar !== 16'h0005) tb_error("====== TIMER A TEST:  INPUT MUX - ACLK =====");
88
 
89
 
90
      // TIMER A TEST:  INPUT MUX - SMCLK
91
      //--------------------------------------------------------
92
      @(r15 === 16'h2000);
93
 
94
      @(r15 === 16'h2001);
95
      @(tar === 1);
96
      my_counter = 0;
97
      repeat(300) @(posedge mclk);
98
      if (tar !== 16'h0013) tb_error("====== TIMER A TEST:  INPUT MUX - SMCLK =====");
99
 
100
 
101
      // TIMER A TEST:  INPUT MUX - INCLK
102
      //--------------------------------------------------------
103
      @(r15 === 16'h3000);
104
 
105
      @(r15 === 16'h3001);
106
      @(tar === 1);
107
      my_counter = 0;
108
      repeat(300) @(posedge mclk);
109
      if (tar !== 16'h001E) tb_error("====== TIMER A TEST:  INPUT MUX - INCLK =====");
110
 
111
 
112
      stimulus_done = 1;
113
   end
114
 

powered by: WebSVN 2.1.0

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