1 |
2 |
ndumitrach |
//*****************************************************************************
|
2 |
|
|
// (c) Copyright 2005 - 2009 Xilinx, Inc. All rights reserved.
|
3 |
|
|
//
|
4 |
|
|
// This file contains confidential and proprietary information
|
5 |
|
|
// of Xilinx, Inc. and is protected under U.S. and
|
6 |
|
|
// international copyright and other intellectual property
|
7 |
|
|
// laws.
|
8 |
|
|
//
|
9 |
|
|
// DISCLAIMER
|
10 |
|
|
// This disclaimer is not a license and does not grant any
|
11 |
|
|
// rights to the materials distributed herewith. Except as
|
12 |
|
|
// otherwise provided in a valid license issued to you by
|
13 |
|
|
// Xilinx, and to the maximum extent permitted by applicable
|
14 |
|
|
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
|
15 |
|
|
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
|
16 |
|
|
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
|
17 |
|
|
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
|
18 |
|
|
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
|
19 |
|
|
// (2) Xilinx shall not be liable (whether in contract or tort,
|
20 |
|
|
// including negligence, or under any other theory of
|
21 |
|
|
// liability) for any loss or damage of any kind or nature
|
22 |
|
|
// related to, arising under or in connection with these
|
23 |
|
|
// materials, including for any direct, or any indirect,
|
24 |
|
|
// special, incidental, or consequential loss or damage
|
25 |
|
|
// (including loss of data, profits, goodwill, or any type of
|
26 |
|
|
// loss or damage suffered as a result of any action brought
|
27 |
|
|
// by a third party) even if such damage or loss was
|
28 |
|
|
// reasonably foreseeable or Xilinx had been advised of the
|
29 |
|
|
// possibility of the same.
|
30 |
|
|
//
|
31 |
|
|
// CRITICAL APPLICATIONS
|
32 |
|
|
// Xilinx products are not designed or intended to be fail-
|
33 |
|
|
// safe, or for use in any application requiring fail-safe
|
34 |
|
|
// performance, such as life-support or safety devices or
|
35 |
|
|
// systems, Class III medical devices, nuclear facilities,
|
36 |
|
|
// applications related to the deployment of airbags, or any
|
37 |
|
|
// other applications that could lead to death, personal
|
38 |
|
|
// injury, or severe property or environmental damage
|
39 |
|
|
// (individually and collectively, "Critical
|
40 |
|
|
// Applications"). Customer assumes the sole risk and
|
41 |
|
|
// liability of any use of Xilinx products in Critical
|
42 |
|
|
// Applications, subject only to applicable laws and
|
43 |
|
|
// regulations governing limitations on product liability.
|
44 |
|
|
//
|
45 |
|
|
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
|
46 |
|
|
// PART OF THIS FILE AT ALL TIMES.
|
47 |
|
|
//*****************************************************************************
|
48 |
|
|
// ____ ____
|
49 |
|
|
// / /\/ /
|
50 |
|
|
// /___/ \ / Vendor : Xilinx
|
51 |
|
|
// \ \ \/ Version : 3.6.1
|
52 |
|
|
// \ \ Application : MIG
|
53 |
|
|
// / / Filename : ddr_cal_ctl.v
|
54 |
|
|
// /___/ /\ Date Last Modified : $Date: 2010/11/26 18:25:41 $
|
55 |
|
|
// \ \ / \ Date Created : Mon May 2 2005
|
56 |
|
|
// \___\/\___\
|
57 |
|
|
// Device : Spartan-3/3A/3A-DSP
|
58 |
|
|
// Design Name : DDR2 SDRAM
|
59 |
|
|
// Purpose : This module generates the select lines for the LUT delay
|
60 |
|
|
// circuit that generate the required delay for the DQS with
|
61 |
|
|
// respect to the DQ. It calculates the dealy of a LUT
|
62 |
|
|
// dynamically by finding the number of LUTs in a clock phase.
|
63 |
|
|
//*****************************************************************************
|
64 |
|
|
|
65 |
|
|
`timescale 1ns/100ps
|
66 |
|
|
|
67 |
|
|
module ddr_cal_ctl
|
68 |
|
|
(
|
69 |
|
|
input clk,
|
70 |
|
|
input reset,
|
71 |
|
|
input [31:0] flop2,
|
72 |
|
|
output reg [4:0] tapfordqs/* synthesis syn_keep=1 */,
|
73 |
|
|
// debug signals
|
74 |
|
|
output [4:0] dbg_phase_cnt,
|
75 |
|
|
output [5:0] dbg_cnt,
|
76 |
|
|
output dbg_trans_onedtct,
|
77 |
|
|
output dbg_trans_twodtct,
|
78 |
|
|
output dbg_enb_trans_two_dtct
|
79 |
|
|
);
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
localparam tap1 = 5'b01111;
|
83 |
|
|
localparam tap2 = 5'b10111;
|
84 |
|
|
localparam tap3 = 5'b11011;
|
85 |
|
|
localparam tap4 = 5'b11101;
|
86 |
|
|
localparam tap5 = 5'b11110;
|
87 |
|
|
localparam tap6 = 5'b11111;
|
88 |
|
|
localparam default_tap = 5'b11101;
|
89 |
|
|
|
90 |
|
|
reg [5:0] cnt/* synthesis syn_preserve=1 */;
|
91 |
|
|
reg [5:0] cnt1/* synthesis syn_preserve=1 */;
|
92 |
|
|
reg [4:0] phase_cnt/* synthesis syn_preserve=1 */;
|
93 |
|
|
reg [31:0] tap_dly_reg/* synthesis syn_preserve=1 */;
|
94 |
|
|
reg [4:0] tapfordqs1/* synthesis syn_preserve=1 */;
|
95 |
|
|
reg reset_r/* synthesis syn_preserve=1 */;
|
96 |
|
|
reg trans_onedtct;
|
97 |
|
|
reg trans_twodtct;
|
98 |
|
|
reg enb_trans_two_dtct;
|
99 |
|
|
|
100 |
|
|
assign dbg_phase_cnt = phase_cnt;
|
101 |
|
|
assign dbg_cnt = cnt1;
|
102 |
|
|
assign dbg_trans_onedtct = trans_onedtct;
|
103 |
|
|
assign dbg_trans_twodtct = trans_twodtct;
|
104 |
|
|
assign dbg_enb_trans_two_dtct = enb_trans_two_dtct;
|
105 |
|
|
|
106 |
|
|
always @( posedge clk )
|
107 |
|
|
reset_r <= reset;
|
108 |
|
|
|
109 |
|
|
always @(posedge clk) begin
|
110 |
|
|
if(reset_r)
|
111 |
|
|
enb_trans_two_dtct <= 1'b0;
|
112 |
|
|
else if(phase_cnt >= 5'd1)
|
113 |
|
|
enb_trans_two_dtct <= 1'b1;
|
114 |
|
|
else
|
115 |
|
|
enb_trans_two_dtct <= 1'b0;
|
116 |
|
|
end
|
117 |
|
|
|
118 |
|
|
always @(posedge clk) begin
|
119 |
|
|
if(reset_r)
|
120 |
|
|
tap_dly_reg <= 32'd0;
|
121 |
|
|
else if(cnt[5] == 1'b1)
|
122 |
|
|
tap_dly_reg <= flop2;
|
123 |
|
|
else
|
124 |
|
|
tap_dly_reg <= tap_dly_reg;
|
125 |
|
|
end
|
126 |
|
|
|
127 |
|
|
/*********** Free Running Counter For Counting 32 States *******************/
|
128 |
|
|
/*********** Two parallel counters are used to fix the timing **************/
|
129 |
|
|
|
130 |
|
|
always @(posedge clk) begin
|
131 |
|
|
if(reset_r || (cnt[5] == 1'b1))
|
132 |
|
|
cnt[5:0] <= 6'b0;
|
133 |
|
|
else
|
134 |
|
|
cnt[5:0] <= cnt[5:0] + 1'b1;
|
135 |
|
|
end
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
always @(posedge clk) begin
|
139 |
|
|
if(reset_r || (cnt1[5] == 1'b1))
|
140 |
|
|
cnt1[5:0] <= 6'b0;
|
141 |
|
|
else
|
142 |
|
|
cnt1[5:0] <= cnt1[5:0] + 1'b1;
|
143 |
|
|
end
|
144 |
|
|
|
145 |
|
|
always @(posedge clk) begin
|
146 |
|
|
if(reset_r || (cnt[5] == 1'b1))
|
147 |
|
|
phase_cnt <= 5'd0;
|
148 |
|
|
else if (trans_onedtct && (!trans_twodtct))
|
149 |
|
|
phase_cnt <= phase_cnt + 1;
|
150 |
|
|
else
|
151 |
|
|
phase_cnt <= phase_cnt;
|
152 |
|
|
end
|
153 |
|
|
|
154 |
|
|
/**************** Checking For The First Transition ***************************/
|
155 |
|
|
always @(posedge clk) begin
|
156 |
|
|
if(reset_r || (cnt[5] == 1'b1)) begin
|
157 |
|
|
trans_onedtct <= 1'b0;
|
158 |
|
|
trans_twodtct <= 1'b0;
|
159 |
|
|
end
|
160 |
|
|
else if (cnt[4:0] == 5'd0 && tap_dly_reg[0]) begin
|
161 |
|
|
trans_onedtct <= 1'b1;
|
162 |
|
|
trans_twodtct <= 1'b0;
|
163 |
|
|
end
|
164 |
|
|
else if ((tap_dly_reg[cnt[4:0]]) && (trans_twodtct == 1'b0)) begin
|
165 |
|
|
if((trans_onedtct == 1'b1) && (enb_trans_two_dtct) )
|
166 |
|
|
trans_twodtct <= 1'b1;
|
167 |
|
|
else
|
168 |
|
|
trans_onedtct <= 1'b1;
|
169 |
|
|
end
|
170 |
|
|
end
|
171 |
|
|
// Tap values for Left/Right banks
|
172 |
|
|
always @(posedge clk) begin
|
173 |
|
|
if(reset_r)
|
174 |
|
|
tapfordqs1 <= default_tap;
|
175 |
|
|
else if(cnt1[4] && cnt1[3] &&
|
176 |
|
|
cnt1[2] && cnt1[1] && cnt1[0]) begin
|
177 |
|
|
if((trans_onedtct == 1'b0) || (trans_twodtct == 1'b0)
|
178 |
|
|
|| (phase_cnt > 5'd12))
|
179 |
|
|
tapfordqs1 <= tap6;
|
180 |
|
|
else if((phase_cnt > 5'd9))
|
181 |
|
|
tapfordqs1 <= tap4;
|
182 |
|
|
else if((phase_cnt > 5'd7))
|
183 |
|
|
tapfordqs1 <= tap3;
|
184 |
|
|
else if((phase_cnt > 5'd4))
|
185 |
|
|
tapfordqs1 <= tap2;
|
186 |
|
|
else
|
187 |
|
|
tapfordqs1 <= tap1;
|
188 |
|
|
end
|
189 |
|
|
else
|
190 |
|
|
tapfordqs1 <= tapfordqs1;
|
191 |
|
|
end
|
192 |
|
|
|
193 |
|
|
always @(posedge clk)
|
194 |
|
|
tapfordqs <= default_tap;//tapfordqs1;
|
195 |
|
|
|
196 |
|
|
endmodule
|