OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [host/] [basic_nexys3/] [ipcore_dir/] [clock/] [simulation/] [clock_tb.v] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 gdevic
// file: clock_tb.v
2
// 
3
// (c) Copyright 2008 - 2011 Xilinx, Inc. All rights reserved.
4
// 
5
// This file contains confidential and proprietary information
6
// of Xilinx, Inc. and is protected under U.S. and
7
// international copyright and other intellectual property
8
// laws.
9
// 
10
// DISCLAIMER
11
// This disclaimer is not a license and does not grant any
12
// rights to the materials distributed herewith. Except as
13
// otherwise provided in a valid license issued to you by
14
// Xilinx, and to the maximum extent permitted by applicable
15
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
16
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
17
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
18
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
19
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
20
// (2) Xilinx shall not be liable (whether in contract or tort,
21
// including negligence, or under any other theory of
22
// liability) for any loss or damage of any kind or nature
23
// related to, arising under or in connection with these
24
// materials, including for any direct, or any indirect,
25
// special, incidental, or consequential loss or damage
26
// (including loss of data, profits, goodwill, or any type of
27
// loss or damage suffered as a result of any action brought
28
// by a third party) even if such damage or loss was
29
// reasonably foreseeable or Xilinx had been advised of the
30
// possibility of the same.
31
// 
32
// CRITICAL APPLICATIONS
33
// Xilinx products are not designed or intended to be fail-
34
// safe, or for use in any application requiring fail-safe
35
// performance, such as life-support or safety devices or
36
// systems, Class III medical devices, nuclear facilities,
37
// applications related to the deployment of airbags, or any
38
// other applications that could lead to death, personal
39
// injury, or severe property or environmental damage
40
// (individually and collectively, "Critical
41
// Applications"). Customer assumes the sole risk and
42
// liability of any use of Xilinx products in Critical
43
// Applications, subject only to applicable laws and
44
// regulations governing limitations on product liability.
45
// 
46
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
47
// PART OF THIS FILE AT ALL TIMES.
48
// 
49
 
50
//----------------------------------------------------------------------------
51
// Clocking wizard demonstration testbench
52
//----------------------------------------------------------------------------
53
// This demonstration testbench instantiates the example design for the 
54
//   clocking wizard. Input clocks are toggled, which cause the clocking
55
//   network to lock and the counters to increment.
56
//----------------------------------------------------------------------------
57
 
58
`timescale 1ps/1ps
59
 
60
`define wait_lock @(posedge LOCKED)
61
 
62
module clock_tb ();
63
 
64
  // Clock to Q delay of 100ps
65
  localparam  TCQ              = 100;
66
 
67
 
68
  // timescale is 1ps/1ps
69
  localparam  ONE_NS      = 1000;
70
  localparam  PHASE_ERR_MARGIN   = 100; // 100ps
71
  // how many cycles to run
72
  localparam  COUNT_PHASE = 1024;
73
  // we'll be using the period in many locations
74
  localparam time PER1    = 10.0*ONE_NS;
75
  localparam time PER1_1  = PER1/2;
76
  localparam time PER1_2  = PER1 - PER1/2;
77
 
78
  // Declare the input clock signals
79
  reg         CLK_IN1     = 1;
80
 
81
  // The high bits of the sampling counters
82
  wire [2:1]  COUNT;
83
  // Status and control signals
84
  wire        LOCKED;
85
  reg         COUNTER_RESET = 0;
86
wire [2:1] CLK_OUT;
87
//Freq Check using the M & D values setting and actual Frequency generated
88
 
89
 
90
  // Input clock generation
91
  //------------------------------------
92
  always begin
93
    CLK_IN1 = #PER1_1 ~CLK_IN1;
94
    CLK_IN1 = #PER1_2 ~CLK_IN1;
95
  end
96
 
97
  // Test sequence
98
  reg [15*8-1:0] test_phase = "";
99
  initial begin
100
    // Set up any display statements using time to be readable
101
    $timeformat(-12, 2, "ps", 10);
102
    COUNTER_RESET = 0;
103
    test_phase = "wait lock";
104
    `wait_lock;
105
    #(PER1*6);
106
    COUNTER_RESET = 1;
107
    #(PER1*20)
108
    COUNTER_RESET = 0;
109
 
110
    test_phase = "counting";
111
    #(PER1*COUNT_PHASE);
112
 
113
    $display("SIMULATION PASSED");
114
    $display("SYSTEM_CLOCK_COUNTER : %0d\n",$time/PER1);
115
    $finish;
116
  end
117
 
118
  // Instantiation of the example design containing the clock
119
  //    network and sampling counters
120
  //---------------------------------------------------------
121
  clock_exdes
122
  #(
123
    .TCQ (TCQ)
124
   ) dut
125
   (// Clock in ports
126
    .CLK_IN1            (CLK_IN1),
127
    // Reset for logic in example design
128
    .COUNTER_RESET      (COUNTER_RESET),
129
    .CLK_OUT            (CLK_OUT),
130
    // High bits of the counters
131
    .COUNT              (COUNT),
132
    // Status and control signals
133
    .LOCKED             (LOCKED));
134
 
135
// Freq Check 
136
 
137
endmodule

powered by: WebSVN 2.1.0

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