1 ------------------------------------------------------------------------ 3 -- b2tt_clk_s6.vhd --- clock for Spartan 6 5 -- Mikihiko Nakao, KEK IPNS 8 -- 20130411 0.02 renamed from mnictrl 9 -- 20130718 0.03 packed into b2tt_clk 10 -- 20131011 0.04 renamed to b2tt_clk_v5 for virtex5 11 -- 20131012 0.05 unification with v6 as much as possible 12 -- 20131101 0.06 no more std_logic_arith 13 -- 20141008 0.08 rawclkg 14 -- 20150105 0.09 rawclk after bufg (no more rawclkg) / no more FLIPCLK 15 -- 20150630 0.10 dummy USE254IN generic 16 ------------------------------------------------------------------------ 18 ------------------------------------------------------------------------ 20 ------------------------------------------------------------------------ 22 use ieee.std_logic_1164.
all;
23 use ieee.std_logic_unsigned.
all;
24 use ieee.numeric_std.
all;
26 use unisim.vcomponents.
all;
30 USEPLL : := '1';
-- unused flag, PLL is always used in s6 32 USE254IN : := '0' );
-- dummy for s6 (only used by v6/DHH) 39 invclock : out ;
-- (only for Spartan-6) 40 dblclock : out ;
-- (only for Virtex-6) 41 dblclockb : out ;
-- (only for Virtex-6) 44 stat : out (1 downto 0) );
48 signal clk_127 : := '0';
49 signal sig_127 : := '0';
51 signal sig_fbout : := '0';
52 -- signal sig_xcm203 : std_logic := '0'; -- #CK commented out this line 53 signal clk_fb : := '0';
54 -- signal clk_203 : std_logic := '0'; -- #CK commented out this line 56 signal sta_xcm : := '0';
57 signal clr_xcm : := '0';
58 signal sta_ictrl : := '1';
59 signal clr_ictrl : := '0';
60 signal cnt_xcmreset : (3 downto 0) := (others => '0');
61 signal cnt_xcmlock : (13 downto 0) := (others => '0');
62 signal cnt_ictrl : (9 downto 0) := (others => '0');
64 signal clk_xcm127 : := '0';
65 signal sig_xcm127 : := '0';
66 signal sig_xcm127b : := '0';
67 signal sig_inv127 : := '0';
71 signal cnt_lck : (15 downto 0) := (others => '0');
72 signal sig_lckd : := '0';
75 ------------------------------------------------------------------------ 77 ------------------------------------------------------------------------ 79 map_ick: ibufds
port map ( o => sig_127, i => clkp, ib => clkn );
80 map_ig: bufg
port map ( i => sig_127, o => clk_127 );
82 map_fb: bufg
port map ( i => sig_fbout, o => clk_fb );
83 -- map_203g: bufg port map ( i => sig_xcm203, o => clk_203 ); -- #CK commented out this line 85 ----------------------------------------------------------------------- 86 -- PLL (always needed in Spartan 6) 87 ------------------------------------------------------------------------ 89 -- unused in the Spartan 6 design 90 --dblclock <= '0'; --! comment 94 map_127g: bufg
port map ( i => sig_xcm127, o => clk_xcm127 );
95 map_invg: bufg
port map ( i => sig_xcm127b, o => invclock );
96 map_254g: bufg
port map ( i => sig_xcm254, o => dblclock );--!add
97 map_64g: bufg
port map ( i => sig_clk3, o => hlfclock );--!add
101 CLKIN_PERIOD =>
7.861,
-- F_VCO has to be between 400 - 1000 MHz #CK 102 -- CLKIN_PERIOD => 7.8, -- F_VCO has to be between 400 - 1000 MHz 103 CLKFBOUT_MULT =>
16,
-- F_VCO = F_CLKIN * CLKFBOUT_MULT --8 104 DIVCLK_DIVIDE =>
2,
-- / DIVCLK_DIVIDE --1 105 CLKOUT0_DIVIDE =>
8,
-- F_OUT = F_VCO / CLKOUTn_DIVIDE --8 106 CLKOUT1_DIVIDE =>
8,
--8 107 CLKOUT1_PHASE =>
180.0,
109 CLKOUT2_PHASE =>
0.0,
110 CLKOUT3_DIVIDE =>
16,
--16 111 CLKOUT3_PHASE =>
0.0,
112 --CLKOUT4_DIVIDE => 5, 113 REF_JITTER =>
0.2,
-- #CK 114 BANDWIDTH =>
"OPTIMIZED" ) 118 clkfbout => sig_fbout,
119 clkout0 => sig_xcm127,
120 clkout1 => sig_xcm127b,
123 --clkout4 => sig_clk4, 127 ------------------------------------------------------------------------ 128 -- no idelayctrl for Spartan 6 129 ------------------------------------------------------------------------ 132 ------------------------------------------------------------------------ 134 -- idelayctrl initial reset (>3us or >385clk) 135 -- XCM at least 3 clkin to reset, several thousand clocks to lock 136 ------------------------------------------------------------------------ 137 proc_reset:
process (clk_127)
139 if clk_127'event and clk_127 = '1' then 141 if cnt_xcmreset(3) = '0' then 143 cnt_xcmreset <= cnt_xcmreset + 1;
144 cnt_xcmlock <= (others => '0');
145 elsif cnt_xcmlock(13) = '0' then 147 cnt_xcmlock <= cnt_xcmlock + 1;
148 elsif reset = '1' or sta_xcm = '0' then 149 cnt_xcmreset <= (others => '0');
153 if clr_xcm = '1' or sta_xcm = '0' then 154 cnt_ictrl <= (others => '0');
155 elsif cnt_ictrl(9) = '0' then 157 cnt_ictrl <= cnt_ictrl + 1;
166 if rising_edge(clk_xcm127) then 167 if sta_xcm = '1' then 168 if cnt_lck(13) = '1' then 172 cnt_lck <= cnt_lck + 1;
178 --stat <= sta_ictrl & sig_lckd; 179 --locked <= sig_lckd and sta_xcm; 182 stat <= sta_ictrl & sta_xcm;
183 locked <= sta_ictrl
and sta_xcm;
pll_base map_pllmap_pll
add
std_logic := '0' sig_xcm254
uncomment
out hlfclockstd_logic
add
std_logic := '0' sig_clk3
add