| 1 |
2 |
peteralieb |
//------------------------------------------------------------------------------
|
| 2 |
|
|
// Title : Reset Logic for DCM
|
| 3 |
|
|
// Project : Virtex-4 Embedded Tri-Mode Ethernet MAC Wrapper
|
| 4 |
|
|
// File : dcm_reset.v
|
| 5 |
|
|
// Version : 4.8
|
| 6 |
|
|
//-----------------------------------------------------------------------------
|
| 7 |
|
|
//
|
| 8 |
|
|
// (c) Copyright 2004-2010 Xilinx, Inc. All rights reserved.
|
| 9 |
|
|
//
|
| 10 |
|
|
// This file contains confidential and proprietary information
|
| 11 |
|
|
// of Xilinx, Inc. and is protected under U.S. and
|
| 12 |
|
|
// international copyright and other intellectual property
|
| 13 |
|
|
// laws.
|
| 14 |
|
|
//
|
| 15 |
|
|
// DISCLAIMER
|
| 16 |
|
|
// This disclaimer is not a license and does not grant any
|
| 17 |
|
|
// rights to the materials distributed herewith. Except as
|
| 18 |
|
|
// otherwise provided in a valid license issued to you by
|
| 19 |
|
|
// Xilinx, and to the maximum extent permitted by applicable
|
| 20 |
|
|
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
|
| 21 |
|
|
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
|
| 22 |
|
|
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
|
| 23 |
|
|
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
|
| 24 |
|
|
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
|
| 25 |
|
|
// (2) Xilinx shall not be liable (whether in contract or tort,
|
| 26 |
|
|
// including negligence, or under any other theory of
|
| 27 |
|
|
// liability) for any loss or damage of any kind or nature
|
| 28 |
|
|
// related to, arising under or in connection with these
|
| 29 |
|
|
// materials, including for any direct, or any indirect,
|
| 30 |
|
|
// special, incidental, or consequential loss or damage
|
| 31 |
|
|
// (including loss of data, profits, goodwill, or any type of
|
| 32 |
|
|
// loss or damage suffered as a result of any action brought
|
| 33 |
|
|
// by a third party) even if such damage or loss was
|
| 34 |
|
|
// reasonably foreseeable or Xilinx had been advised of the
|
| 35 |
|
|
// possibility of the same.
|
| 36 |
|
|
//
|
| 37 |
|
|
// CRITICAL APPLICATIONS
|
| 38 |
|
|
// Xilinx products are not designed or intended to be fail-
|
| 39 |
|
|
// safe, or for use in any application requiring fail-safe
|
| 40 |
|
|
// performance, such as life-support or safety devices or
|
| 41 |
|
|
// systems, Class III medical devices, nuclear facilities,
|
| 42 |
|
|
// applications related to the deployment of airbags, or any
|
| 43 |
|
|
// other applications that could lead to death, personal
|
| 44 |
|
|
// injury, or severe property or environmental damage
|
| 45 |
|
|
// (individually and collectively, "Critical
|
| 46 |
|
|
// Applications"). Customer assumes the sole risk and
|
| 47 |
|
|
// liability of any use of Xilinx products in Critical
|
| 48 |
|
|
// Applications, subject only to applicable laws and
|
| 49 |
|
|
// regulations governing limitations on product liability.
|
| 50 |
|
|
//
|
| 51 |
|
|
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
|
| 52 |
|
|
// PART OF THIS FILE AT ALL TIMES.
|
| 53 |
|
|
//
|
| 54 |
|
|
//------------------------------------------------------------------------------
|
| 55 |
|
|
// Description: DCM Reset Logic.
|
| 56 |
|
|
//
|
| 57 |
|
|
// This logic creates a 200ms reset pulse required by the
|
| 58 |
|
|
// Virtex-4 DCM.
|
| 59 |
|
|
//
|
| 60 |
|
|
// The resetwill fire under the following conditions:
|
| 61 |
|
|
//
|
| 62 |
|
|
// * When the DCM timeout counter wraps around
|
| 63 |
|
|
// * When the falling edge of DCM locked is detected
|
| 64 |
|
|
//
|
| 65 |
|
|
// The timeout counter will time a > 1ms interval. If the DCM
|
| 66 |
|
|
// locked signal has been low for this duration then it will be
|
| 67 |
|
|
// issued with a reset and the timer will reset. This is
|
| 68 |
|
|
// required for DCMs connected to Ethernet PHYs since the PHYs
|
| 69 |
|
|
// may source discontinuous clocks under certain network
|
| 70 |
|
|
// conditions.
|
| 71 |
|
|
//------------------------------------------------------------------------------
|
| 72 |
|
|
|
| 73 |
|
|
`timescale 1 ps/1 ps
|
| 74 |
|
|
|
| 75 |
|
|
//------------------------------------------------------------------------------
|
| 76 |
|
|
// The module declaration for the DCM Reset Logic
|
| 77 |
|
|
//------------------------------------------------------------------------------
|
| 78 |
|
|
|
| 79 |
|
|
module dcm_reset (
|
| 80 |
|
|
ref_reset,
|
| 81 |
|
|
ref_clk,
|
| 82 |
|
|
dcm_locked,
|
| 83 |
|
|
dcm_reset);
|
| 84 |
|
|
|
| 85 |
|
|
input ref_reset ; // Synchronous reset in ref_clk domain
|
| 86 |
|
|
input ref_clk; // Reliable reference clock of known frequency (125MHz)
|
| 87 |
|
|
input dcm_locked; // The DCM locked signal
|
| 88 |
|
|
output dcm_reset; // The reset signal which should be connected to the DCM
|
| 89 |
|
|
|
| 90 |
|
|
|
| 91 |
|
|
|
| 92 |
|
|
//----------------------------------------------------------------------------
|
| 93 |
|
|
// Signals used in this module
|
| 94 |
|
|
//----------------------------------------------------------------------------
|
| 95 |
|
|
|
| 96 |
|
|
// Signals required for DCM timeout reset in the reference clock domain
|
| 97 |
|
|
wire dcm_locked_sync; //dcm_locked registered twice in the ref_clk
|
| 98 |
|
|
//domain.
|
| 99 |
|
|
reg dcm_locked_sync_reg; //dcm_locked registered thrice in the ref_clk
|
| 100 |
|
|
//domain.
|
| 101 |
|
|
|
| 102 |
|
|
wire ref_reset_sync; //ref_reset registered twice in the ref_clk
|
| 103 |
|
|
//domain
|
| 104 |
|
|
|
| 105 |
|
|
reg [16:0] timeout; //the timeout counter
|
| 106 |
|
|
reg timeout_msbit_reg;
|
| 107 |
|
|
reg timeout_reset; //a reset created by a timeout condition
|
| 108 |
|
|
reg dcm_reset_init; //automatic reset pulse applied to dcm on loss of lock.
|
| 109 |
|
|
reg [8:0] reset_counter;
|
| 110 |
|
|
reg reset_200ms_int; //200ms reset pulse for the DCM
|
| 111 |
|
|
|
| 112 |
|
|
|
| 113 |
|
|
//-----------------------
|
| 114 |
|
|
// Reference clock domain
|
| 115 |
|
|
//-----------------------
|
| 116 |
|
|
// The reference clock will always be present and of frequency 125MHz.
|
| 117 |
|
|
// Since this clock is predictable, it is used to create the DCM timeout
|
| 118 |
|
|
// counter.
|
| 119 |
|
|
// This counter will increment when the locked signal is low (not locked).
|
| 120 |
|
|
// When the timer expires, a further reset of the DCM will be issued.
|
| 121 |
|
|
|
| 122 |
|
|
// Synchronize ref_reset in the reference clock domain
|
| 123 |
|
|
sync_block ref_reset_sync_inst (
|
| 124 |
|
|
.clk (ref_clk),
|
| 125 |
|
|
.data_in (ref_reset),
|
| 126 |
|
|
.data_out (ref_reset_sync)
|
| 127 |
|
|
);
|
| 128 |
|
|
|
| 129 |
|
|
// Reclock DCM locked in the reference clock domain
|
| 130 |
|
|
sync_block dcm_locked_sync_inst (
|
| 131 |
|
|
.clk (ref_clk),
|
| 132 |
|
|
.data_in (dcm_locked),
|
| 133 |
|
|
.data_out (dcm_locked_sync)
|
| 134 |
|
|
);
|
| 135 |
|
|
|
| 136 |
|
|
|
| 137 |
|
|
// When the DCM is locked, the timeout counter is held at zero.
|
| 138 |
|
|
// When not locked the timeout counter will increment.
|
| 139 |
|
|
always @(posedge ref_clk)
|
| 140 |
|
|
begin : dcm_timeout_counter
|
| 141 |
|
|
if (timeout_reset) begin
|
| 142 |
|
|
timeout <= 17'b0;
|
| 143 |
|
|
timeout_msbit_reg <= 1'b0;
|
| 144 |
|
|
end
|
| 145 |
|
|
|
| 146 |
|
|
else begin
|
| 147 |
|
|
timeout_msbit_reg <= timeout[16];
|
| 148 |
|
|
if (dcm_locked_sync & !reset_200ms_int) begin
|
| 149 |
|
|
timeout <= 17'b0;
|
| 150 |
|
|
end
|
| 151 |
|
|
else begin
|
| 152 |
|
|
timeout <= timeout + 1'b1;
|
| 153 |
|
|
end
|
| 154 |
|
|
end
|
| 155 |
|
|
end // dcm_timeout_counter
|
| 156 |
|
|
|
| 157 |
|
|
|
| 158 |
|
|
// A reset pulse is generated when the timeout counter wraps around.
|
| 159 |
|
|
always @(posedge ref_clk)
|
| 160 |
|
|
begin : dcm_timeout_reset_p
|
| 161 |
|
|
if (ref_reset_sync) begin
|
| 162 |
|
|
timeout_reset <= 1'b1;
|
| 163 |
|
|
end
|
| 164 |
|
|
else begin
|
| 165 |
|
|
timeout_reset <= !timeout[16] & timeout_msbit_reg & !dcm_locked_sync & !reset_200ms_int;
|
| 166 |
|
|
end
|
| 167 |
|
|
end // dcm_timeout_reset_p
|
| 168 |
|
|
|
| 169 |
|
|
|
| 170 |
|
|
// Create a reset to fire under the following conditions:
|
| 171 |
|
|
// * When the DCM timeout counter wraps around
|
| 172 |
|
|
// * When the falling edge of DCM locked is detected
|
| 173 |
|
|
always @(posedge ref_clk)
|
| 174 |
|
|
begin : reset_dcm_prelim
|
| 175 |
|
|
if (timeout_reset) begin
|
| 176 |
|
|
dcm_locked_sync_reg <= 1'b1;
|
| 177 |
|
|
dcm_reset_init <= 1'b1;
|
| 178 |
|
|
end
|
| 179 |
|
|
|
| 180 |
|
|
else begin
|
| 181 |
|
|
dcm_locked_sync_reg <= dcm_locked_sync;
|
| 182 |
|
|
dcm_reset_init <= !dcm_locked_sync & dcm_locked_sync_reg;
|
| 183 |
|
|
end
|
| 184 |
|
|
end // reset_dcm_prelim;
|
| 185 |
|
|
|
| 186 |
|
|
// generate a large counter to time ~200ms
|
| 187 |
|
|
always @(posedge ref_clk)
|
| 188 |
|
|
begin : dcm_reset_timer_p
|
| 189 |
|
|
if (dcm_reset_init) begin
|
| 190 |
|
|
reset_counter <= 9'b110000000;
|
| 191 |
|
|
reset_200ms_int <= 1'b1;
|
| 192 |
|
|
end
|
| 193 |
|
|
|
| 194 |
|
|
else begin
|
| 195 |
|
|
if (reset_counter == 9'b0) begin
|
| 196 |
|
|
reset_200ms_int <= 1'b0;
|
| 197 |
|
|
end
|
| 198 |
|
|
|
| 199 |
|
|
else begin
|
| 200 |
|
|
reset_200ms_int <= 1'b1;
|
| 201 |
|
|
|
| 202 |
|
|
if (timeout[16] ^ timeout_msbit_reg) begin
|
| 203 |
|
|
reset_counter <= reset_counter - 1'b1;
|
| 204 |
|
|
end
|
| 205 |
|
|
|
| 206 |
|
|
end
|
| 207 |
|
|
end
|
| 208 |
|
|
end // dcm_reset_timer_p;
|
| 209 |
|
|
|
| 210 |
|
|
// This is the produced reset signal for the Virtex-4 DCM
|
| 211 |
|
|
assign dcm_reset = reset_200ms_int;
|
| 212 |
|
|
|
| 213 |
|
|
endmodule
|
| 214 |
|
|
|