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 202

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: 202 $                                                                */
34
/* $LastChangedBy: olivier.girard $                                          */
35
/* $LastChangedDate: 2015-07-01 23:13:32 +0200 (Wed, 01 Jul 2015) $          */
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 202 olivier.gi
 
67 2 olivier.gi
initial
68
   begin
69
      $display(" ===============================================");
70
      $display("|                 START SIMULATION              |");
71
      $display(" ===============================================");
72
      repeat(5) @(posedge mclk);
73
      stimulus_done = 0;
74
 
75
 
76 180 olivier.gi
`ifdef ASIC_CLOCKING
77 202 olivier.gi
      tb_skip_finish("|   (this test is not supported in ASIC mode)   |");
78 134 olivier.gi
`else
79
 
80 2 olivier.gi
      // TIMER A TEST:  INPUT MUX - TACLK
81
      //--------------------------------------------------------
82
//      @(r15 === 16'h0000);
83
 
84
      @(r15 === 16'h0001);
85
      @(tar === 1);
86
      my_counter = 0;
87
      repeat(300) @(posedge mclk);
88
      if (tar !== 16'h0032) tb_error("====== TIMER A TEST:  INPUT MUX - TACLK =====");
89
 
90 202 olivier.gi
 
91 2 olivier.gi
      // TIMER A TEST:  INPUT MUX - ACLK
92
      //--------------------------------------------------------
93
      @(r15 === 16'h1000);
94
 
95
      @(r15 === 16'h1001);
96
      @(tar === 1);
97
      my_counter = 0;
98
      repeat(300) @(posedge mclk);
99
      if (tar !== 16'h0005) tb_error("====== TIMER A TEST:  INPUT MUX - ACLK =====");
100
 
101 202 olivier.gi
 
102 2 olivier.gi
      // TIMER A TEST:  INPUT MUX - SMCLK
103
      //--------------------------------------------------------
104
      @(r15 === 16'h2000);
105
 
106
      @(r15 === 16'h2001);
107
      @(tar === 1);
108
      my_counter = 0;
109
      repeat(300) @(posedge mclk);
110
      if (tar !== 16'h0013) tb_error("====== TIMER A TEST:  INPUT MUX - SMCLK =====");
111
 
112 202 olivier.gi
 
113 2 olivier.gi
      // TIMER A TEST:  INPUT MUX - INCLK
114
      //--------------------------------------------------------
115
      @(r15 === 16'h3000);
116
 
117
      @(r15 === 16'h3001);
118
      @(tar === 1);
119
      my_counter = 0;
120
      repeat(300) @(posedge mclk);
121
      if (tar !== 16'h001E) tb_error("====== TIMER A TEST:  INPUT MUX - INCLK =====");
122
 
123 202 olivier.gi
`endif
124 134 olivier.gi
 
125 2 olivier.gi
      stimulus_done = 1;
126
   end

powered by: WebSVN 2.1.0

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