1 ------------------------------------------------------------------------ 3 -- b2tt_ddr_s6.vhd -- TT-link DDR and delay hander for Belle2link 4 -- frontend for Spartan-6 6 -- Mikihiko Nakao, KEK IPNS 8 -- 20131002 separated from b2tt_decode.vhd and b2tt_encode.vhd 9 -- 20131013 Spartan-6 support 10 -- 20131101 no more std_logic_arith 11 -- 20131113 merging changes to ddr_v5 into ddr_s6 12 -- 20131119 bitddr output from dataout2, sig_inc was forgotten 13 -- 20131120 cal to be asserted with data - once in 1024 times of sig_inc 14 -- 20140614 dbg added for chipscope 15 -- 20140711 new scheme to find the stable delay 16 -- 20150722 "not clock" instead of 180 deg shifted invclock 17 -- (somehow ise14 could not build sp605_b2l006) 19 -- tap calibration based on SP605 (sp605_b2tt09.bit) 20 -- 2.32 ns per 100 inc => about 170 inc to cover (7.86ns/2) 22 -- VARIABLE_FROM_HALF_MAX resets to somewhere not zero 23 -- DIFF_PHASE_DETECTOR does not increment 24 -- VARIABLE_FROM_ZERO resets to zero at 163 inc (maybe internally measured) 26 ------------------------------------------------------------------------ 28 ------------------------------------------------------------------------ 30 ------------------------------------------------------------------------ 32 use ieee.std_logic_1164.
all;
33 use ieee.std_logic_unsigned.
all;
34 use ieee.numeric_std.
all;
36 use unisim.vcomponents.
ALL;
42 SLIPBIT : := 0;
-- 0 for v5/s6, 1 for v6 43 WRAPCOUNT : := 170;
-- 51 for v5, 25 for v6, 170 for s6 44 FULLCOUNT : := 340;
-- *2 for v5/s6, *4 for v6 45 SIM_SPEEDUP : := '0' );
-- to speedup simulation 47 -- Virtex-5 and Virtex-6 (both): 48 -- 1 tap = 7.8 ns / ((8/5*64)) = 78 ps 49 -- [for V5, idelayctrl clock tick = 7.8 ns / (8/5)] 50 -- Virtex-5: 51 taps to cover the delay range (V5) 51 -- Virtex-6: there is no way to cover half clock width of 3.9ns 52 -- since 31 is the max tap which is about 2.4ns 53 -- => oversample with iserdes for 1.95ns period to be covered 54 -- by 25 taps (cnt_islip=0..3) 58 invclock : in ;
-- spartan6 only 59 dblclock : in ;
-- virtex6 only 60 dblclockb : in ;
-- virtex6 only 68 caldelay : in ;
-- spartan6 only 69 staiddr : out (1 downto 0);
71 bit2 : out (1 downto 0);
72 cntdelay : out (6 downto 0);
73 cntwidth : out (5 downto 0);
74 iddrdbg : out (9 downto 0) );
77 ------------------------------------------------------------------------ 79 signal sig_i : := '0';
80 signal sig_q : := '0';
81 signal sig_inc : := '0';
82 signal clr_inc : := '0';
83 signal sig_islip : := '0';
84 signal clr_islip : := '0';
86 signal sig_bit2 : (1 downto 0) := "00";
87 signal sig_raw2 : (1 downto 0) := "00";
88 signal sta_slip : := '0';
89 signal buf_bit : := '0';
92 signal open_do : := '0';
93 signal open_to : := '0';
94 signal sig_busy : := '0';
95 signal sig_caldelay : := '0';
96 signal seq_caldelay : (1 downto 0) := "01";
97 signal sig_invclock : := '0';
100 sig_invclock <= not clock;
103 port map ( o => sig_i, i => inp, ib => inn
);
109 IDELAY_MODE =>
"NORMAL",
110 IDELAY_TYPE =>
"VARIABLE_FROM_ZERO",
112 COUNTER_WRAPAROUND =>
"WRAPAROUND",
113 DELAY_SRC =>
"IDATAIN" ) 119 ioclk1 => sig_invclock,
124 t => '1',
-- 1 for input only / 0 for output only 125 cal => sig_caldelay,
-- no auto-caldelay 133 DDR_ALIGNMENT =>
"C0" ) 144 sig_bit2(0) <= sig_raw2(0) xor FLIPIN;
145 sig_bit2(1) <= sig_raw2(1) xor FLIPIN;
149 if rising_edge(clock) then 150 -- slipped bit is generated upon clock, 151 -- as asynchronous bit2 was timing-tight 152 if sta_slip = '0' then 155 bit2 <= buf_bit & sig_bit2(1);
157 buf_bit <= sig_bit2(0);
160 if clr_islip = '1' then 162 elsif sig_islip = '1' then 163 sta_slip <= not sta_slip;
167 sig_caldelay <= caldelay or seq_caldelay(1);
168 seq_caldelay <= seq_caldelay(0) & '0';
178 WRAPCOUNT => WRAPCOUNT,
179 FULLCOUNT => FULLCOUNT,
180 SIM_SPEEDUP => SIM_SPEEDUP
) 182 -- from/to b2tt_decode 184 staoctet => staoctet,
185 stacrc8ok => stacrc8ok,
187 incdelay => incdelay,
188 clrdelay => clrdelay,
189 staiddr => staiddr,
-- out 190 cntdelay => cntdelay,
-- out 191 cntwidth => cntwidth,
-- out 192 iddrdbg => iddrdbg,
-- out 194 siginc => sig_inc,
-- out 195 sigislip => sig_islip,
-- out 196 clrinc => clr_inc,
-- out 197 clrislip => clr_islip
) ;
-- out 201 ------------------------------------------------------------------------ 203 ------------------------------------------------------------------------ 205 use ieee.std_logic_1164.
all;
206 use ieee.std_logic_unsigned.
all;
207 use ieee.numeric_std.
all;
209 use unisim.vcomponents.
ALL;
214 REFFREQ : := 203.
546 );
219 bit2 : in (1 downto 0);
225 ------------------------------------------------------------------------ 227 signal sig_o : := '0';
228 signal sig_oq : := '0';
229 signal sig_bit2 : (1 downto 0) := "00";
230 signal sig_invclock : := '0';
233 sig_invclock <= not clock;
234 sig_bit2(0) <= bit2(0) xor FLIPOUT;
235 sig_bit2(1) <= bit2(1) xor FLIPOUT;
238 port map ( i => sig_o, o => outp, ob => outn, t => mask
);
243 DELAY_SRC =>
"ODATAIN" ) 260 DDR_ALIGNMENT =>
"C0",
264 d0 => sig_bit2
(1),
-- order: d1 first, d2 second 265 d1 => sig_bit2
(0),
-- (10b: left-most-bit first, right-most last)