1 |
2 |
john_fpga |
--*****************************************************************************
|
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 : DDR2_Ram_Core_cal_ctl.vhd
|
54 |
|
|
-- /___/ /\ Date Last Modified : $Date: 2010/11/26 18:25:42 $
|
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 dynalically
|
62 |
|
|
-- by finding the number of LUTs in a clock phase.
|
63 |
|
|
--*****************************************************************************
|
64 |
|
|
|
65 |
|
|
library ieee;
|
66 |
|
|
library UNISIM;
|
67 |
|
|
use ieee.std_logic_1164.all;
|
68 |
|
|
use ieee.std_logic_unsigned.all;
|
69 |
|
|
use UNISIM.VCOMPONENTS.all;
|
70 |
|
|
|
71 |
|
|
entity DDR2_Ram_Core_cal_ctl is
|
72 |
|
|
port (
|
73 |
|
|
clk : in std_logic;
|
74 |
|
|
reset : in std_logic;
|
75 |
|
|
flop2 : in std_logic_vector(31 downto 0);
|
76 |
|
|
tapfordqs : out std_logic_vector(4 downto 0);
|
77 |
|
|
-- debug signals
|
78 |
|
|
dbg_phase_cnt : out std_logic_vector(4 downto 0);
|
79 |
|
|
dbg_cnt : out std_logic_vector(5 downto 0);
|
80 |
|
|
dbg_trans_onedtct : out std_logic;
|
81 |
|
|
dbg_trans_twodtct : out std_logic;
|
82 |
|
|
dbg_enb_trans_two_dtct : out std_logic
|
83 |
|
|
);
|
84 |
|
|
end DDR2_Ram_Core_cal_ctl;
|
85 |
|
|
|
86 |
|
|
architecture arc_cal_ctl of DDR2_Ram_Core_cal_ctl is
|
87 |
|
|
|
88 |
|
|
signal cnt : std_logic_vector(5 downto 0);
|
89 |
|
|
signal cnt1 : std_logic_vector(5 downto 0);
|
90 |
|
|
signal trans_onedtct : std_logic;
|
91 |
|
|
signal trans_twodtct : std_logic;
|
92 |
|
|
signal phase_cnt : std_logic_vector(4 downto 0);
|
93 |
|
|
signal tap_dly_reg : std_logic_vector(31 downto 0);
|
94 |
|
|
signal enb_trans_two_dtct : std_logic;
|
95 |
|
|
signal tapfordqs_val : std_logic_vector(4 downto 0);
|
96 |
|
|
signal cnt_val : integer;
|
97 |
|
|
signal reset_r : std_logic;
|
98 |
|
|
|
99 |
|
|
constant tap1 : std_logic_vector(4 downto 0) := "01111";
|
100 |
|
|
constant tap2 : std_logic_vector(4 downto 0) := "10111";
|
101 |
|
|
constant tap3 : std_logic_vector(4 downto 0) := "11011";
|
102 |
|
|
constant tap4 : std_logic_vector(4 downto 0) := "11101";
|
103 |
|
|
constant tap5 : std_logic_vector(4 downto 0) := "11110";
|
104 |
|
|
constant tap6 : std_logic_vector(4 downto 0) := "11111";
|
105 |
|
|
constant default_tap : std_logic_vector(4 downto 0) := "11101";
|
106 |
|
|
|
107 |
|
|
attribute syn_keep : boolean;
|
108 |
|
|
attribute syn_keep of cnt : signal is true;
|
109 |
|
|
attribute syn_keep of cnt1 : signal is true;
|
110 |
|
|
attribute syn_keep of trans_onedtct : signal is true;
|
111 |
|
|
attribute syn_keep of trans_twodtct : signal is true;
|
112 |
|
|
attribute syn_keep of tap_dly_reg : signal is true;
|
113 |
|
|
attribute syn_keep of enb_trans_two_dtct : signal is true;
|
114 |
|
|
attribute syn_keep of phase_cnt : signal is true;
|
115 |
|
|
attribute syn_keep of tapfordqs_val : signal is true;
|
116 |
|
|
|
117 |
|
|
begin
|
118 |
|
|
|
119 |
|
|
dbg_phase_cnt <= phase_cnt;
|
120 |
|
|
dbg_cnt <= cnt1;
|
121 |
|
|
dbg_trans_onedtct <= trans_onedtct;
|
122 |
|
|
dbg_trans_twodtct <= trans_twodtct;
|
123 |
|
|
dbg_enb_trans_two_dtct <= enb_trans_two_dtct;
|
124 |
|
|
|
125 |
|
|
process(clk)
|
126 |
|
|
begin
|
127 |
|
|
if(clk'event and clk = '1') then
|
128 |
|
|
reset_r <= reset;
|
129 |
|
|
end if;
|
130 |
|
|
end process;
|
131 |
|
|
|
132 |
|
|
process(clk)
|
133 |
|
|
begin
|
134 |
|
|
if(clk'event and clk = '1') then
|
135 |
|
|
tapfordqs <= tapfordqs_val;
|
136 |
|
|
end if;
|
137 |
|
|
end process;
|
138 |
|
|
|
139 |
|
|
-----------For Successive Transition-------------------
|
140 |
|
|
|
141 |
|
|
process(clk)
|
142 |
|
|
begin
|
143 |
|
|
if (clk'event and clk = '1') then
|
144 |
|
|
if(reset_r = '1') then
|
145 |
|
|
enb_trans_two_dtct <= '0';
|
146 |
|
|
elsif(phase_cnt >= "00001") then
|
147 |
|
|
enb_trans_two_dtct <= '1';
|
148 |
|
|
else
|
149 |
|
|
enb_trans_two_dtct <= '0';
|
150 |
|
|
end if;
|
151 |
|
|
end if;
|
152 |
|
|
end process;
|
153 |
|
|
|
154 |
|
|
process (clk)
|
155 |
|
|
begin
|
156 |
|
|
if(clk'event and clk = '1') then
|
157 |
|
|
if(reset_r = '1') then
|
158 |
|
|
tap_dly_reg <= "00000000000000000000000000000000";
|
159 |
|
|
elsif(cnt(5) = '1') then
|
160 |
|
|
tap_dly_reg <= flop2;
|
161 |
|
|
else
|
162 |
|
|
tap_dly_reg <= tap_dly_reg;
|
163 |
|
|
end if;
|
164 |
|
|
end if;
|
165 |
|
|
end process;
|
166 |
|
|
|
167 |
|
|
--------Free Running Counter For Counting 32 States ----------------------
|
168 |
|
|
------- Two parallel counters are used to fix the timing ------------------
|
169 |
|
|
|
170 |
|
|
process (clk)
|
171 |
|
|
begin
|
172 |
|
|
if(clk'event and clk = '1') then
|
173 |
|
|
if(reset_r = '1' or cnt(5) = '1') then
|
174 |
|
|
cnt(5 downto 0) <= "000000";
|
175 |
|
|
else
|
176 |
|
|
cnt(5 downto 0) <= cnt(5 downto 0) + "000001";
|
177 |
|
|
end if;
|
178 |
|
|
end if;
|
179 |
|
|
end process;
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
process(clk)
|
183 |
|
|
begin
|
184 |
|
|
if(clk'event and clk = '1') then
|
185 |
|
|
if(reset_r = '1' or cnt1(5) = '1') then
|
186 |
|
|
cnt1(5 downto 0) <= "000000";
|
187 |
|
|
else
|
188 |
|
|
cnt1(5 downto 0) <= cnt1(5 downto 0) + "000001";
|
189 |
|
|
end if;
|
190 |
|
|
end if;
|
191 |
|
|
end process;
|
192 |
|
|
|
193 |
|
|
process(clk)
|
194 |
|
|
begin
|
195 |
|
|
if clk'event and clk = '1' then
|
196 |
|
|
if(reset_r = '1' or cnt(5) = '1') then
|
197 |
|
|
phase_cnt <= "00000";
|
198 |
|
|
elsif (trans_onedtct = '1' and trans_twodtct = '0') then
|
199 |
|
|
phase_cnt <= phase_cnt + "00001";
|
200 |
|
|
else
|
201 |
|
|
phase_cnt <= phase_cnt;
|
202 |
|
|
end if;
|
203 |
|
|
end if;
|
204 |
|
|
end process;
|
205 |
|
|
|
206 |
|
|
----------- Checking For The First Transition ------------------
|
207 |
|
|
|
208 |
|
|
process (clk)
|
209 |
|
|
begin
|
210 |
|
|
if clk'event and clk = '1' then
|
211 |
|
|
if (reset_r = '1' or cnt(5) = '1') then
|
212 |
|
|
trans_onedtct <= '0';
|
213 |
|
|
trans_twodtct <= '0';
|
214 |
|
|
elsif (cnt(4 downto 0) = "00000" and tap_dly_reg(0) = '1') then
|
215 |
|
|
trans_onedtct <= '1';
|
216 |
|
|
trans_twodtct <= '0';
|
217 |
|
|
elsif (tap_dly_reg(cnt_val) = '1' and trans_twodtct = '0') then
|
218 |
|
|
if(trans_onedtct = '1' and enb_trans_two_dtct = '1') then
|
219 |
|
|
trans_twodtct <= '1';
|
220 |
|
|
else
|
221 |
|
|
trans_onedtct <= '1';
|
222 |
|
|
end if;
|
223 |
|
|
end if;
|
224 |
|
|
end if;
|
225 |
|
|
end process;
|
226 |
|
|
|
227 |
|
|
cnt_val <= conv_integer(cnt(4 downto 0));
|
228 |
|
|
|
229 |
|
|
-- Tap values for Left/Right banks
|
230 |
|
|
process (clk)
|
231 |
|
|
begin
|
232 |
|
|
if clk'event and clk = '1' then
|
233 |
|
|
if(reset_r = '1') then
|
234 |
|
|
tapfordqs_val <= default_tap;
|
235 |
|
|
elsif(cnt1(4) = '1' and cnt1(3) = '1' and cnt1(2) = '1' and cnt1(1) = '1'
|
236 |
|
|
and cnt1(0) = '1') then
|
237 |
|
|
if ((trans_onedtct = '0') or (trans_twodtct = '0')
|
238 |
|
|
or (phase_cnt > "01100")) then
|
239 |
|
|
tapfordqs_val <= tap6;
|
240 |
|
|
elsif (phase_cnt > "01001") then
|
241 |
|
|
tapfordqs_val <= tap4;
|
242 |
|
|
elsif (phase_cnt > "00111") then
|
243 |
|
|
tapfordqs_val <= tap3;
|
244 |
|
|
elsif (phase_cnt > "00100") then
|
245 |
|
|
tapfordqs_val <= tap2;
|
246 |
|
|
else
|
247 |
|
|
tapfordqs_val <= tap1;
|
248 |
|
|
end if;
|
249 |
|
|
else
|
250 |
|
|
tapfordqs_val <= tapfordqs_val;
|
251 |
|
|
end if;
|
252 |
|
|
end if;
|
253 |
|
|
end process;
|
254 |
|
|
|
255 |
|
|
end arc_cal_ctl;
|