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 155

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 18 olivier.gi
/*                                                                           */
29
/* Author(s):                                                                */
30
/*             - Olivier Girard,    olgirard@gmail.com                       */
31
/*                                                                           */
32
/*---------------------------------------------------------------------------*/
33 19 olivier.gi
/* $Rev: 134 $                                                                */
34
/* $LastChangedBy: olivier.girard $                                          */
35
/* $LastChangedDate: 2012-03-22 21:31:06 +0100 (Thu, 22 Mar 2012) $          */
36 2 olivier.gi
/*===========================================================================*/
37
 
38
integer my_counter;
39
always @ (negedge mclk)
40
  my_counter <=  my_counter+1;
41
 
42
wire [15:0] tar = timerA_0.tar;
43
 
44
// Generate TACLK as MCLK/3
45
integer taclk_cnt;
46 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
47
  if (puc_rst)           taclk_cnt <=  0;
48 2 olivier.gi
  else if (taclk_cnt==2) taclk_cnt <=  0;
49
  else                   taclk_cnt <=  taclk_cnt+1;
50
 
51
always @ (taclk_cnt)
52
  if (taclk_cnt==2) taclk = 1'b1;
53
  else              taclk = 1'b0;
54
 
55
// Generate INCLK as MCLK/5
56
integer inclk_cnt;
57 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
58
  if (puc_rst)           inclk_cnt <=  0;
59 2 olivier.gi
  else if (inclk_cnt==4) inclk_cnt <=  0;
60
  else                   inclk_cnt <=  inclk_cnt+1;
61
 
62
always @ (inclk_cnt)
63
  if (inclk_cnt==4) inclk = 1'b1;
64
  else              inclk = 1'b0;
65
 
66
 
67
initial
68
   begin
69
      $display(" ===============================================");
70
      $display("|                 START SIMULATION              |");
71
      $display(" ===============================================");
72
      repeat(5) @(posedge mclk);
73
      stimulus_done = 0;
74
 
75
 
76 134 olivier.gi
`ifdef ASIC
77
      $display(" ===============================================");
78
      $display("|               SIMULATION SKIPPED              |");
79
      $display("|   (this test is not supported in ASIC mode)   |");
80
      $display(" ===============================================");
81
      $finish;
82
`else
83
 
84 2 olivier.gi
      // TIMER A TEST:  INPUT MUX - TACLK
85
      //--------------------------------------------------------
86
//      @(r15 === 16'h0000);
87
 
88
      @(r15 === 16'h0001);
89
      @(tar === 1);
90
      my_counter = 0;
91
      repeat(300) @(posedge mclk);
92
      if (tar !== 16'h0032) tb_error("====== TIMER A TEST:  INPUT MUX - TACLK =====");
93
 
94
 
95
      // TIMER A TEST:  INPUT MUX - ACLK
96
      //--------------------------------------------------------
97
      @(r15 === 16'h1000);
98
 
99
      @(r15 === 16'h1001);
100
      @(tar === 1);
101
      my_counter = 0;
102
      repeat(300) @(posedge mclk);
103
      if (tar !== 16'h0005) tb_error("====== TIMER A TEST:  INPUT MUX - ACLK =====");
104
 
105
 
106
      // TIMER A TEST:  INPUT MUX - SMCLK
107
      //--------------------------------------------------------
108
      @(r15 === 16'h2000);
109
 
110
      @(r15 === 16'h2001);
111
      @(tar === 1);
112
      my_counter = 0;
113
      repeat(300) @(posedge mclk);
114
      if (tar !== 16'h0013) tb_error("====== TIMER A TEST:  INPUT MUX - SMCLK =====");
115
 
116
 
117
      // TIMER A TEST:  INPUT MUX - INCLK
118
      //--------------------------------------------------------
119
      @(r15 === 16'h3000);
120
 
121
      @(r15 === 16'h3001);
122
      @(tar === 1);
123
      my_counter = 0;
124
      repeat(300) @(posedge mclk);
125
      if (tar !== 16'h001E) tb_error("====== TIMER A TEST:  INPUT MUX - INCLK =====");
126
 
127 134 olivier.gi
`endif
128
 
129 2 olivier.gi
      stimulus_done = 1;
130
   end
131
 

powered by: WebSVN 2.1.0

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