AMC13
Firmwares for the different applications of the AMC13 uTCA board made at Boston University
 All Classes Variables
s6link_adapt_top_lpm.vhd
1 --////////////////////////////////////////////////////////////////////////////////
2 --// ____ ____
3 --// / /\/ /
4 --// /___/ \ / Vendor: Xilinx
5 --// \ \ \/ Version : 2.5
6 --// \ \ Application : 7 Series FPGAs Transceivers Wizard
7 --// / / Filename :s6link_adapt_top_lpm.vhd
8 --// /___/ /\
9 --// \ \ / \
10 --// \___\/\___\
11 --//
12 --//
13 -- Description : This module performs TX reset and initialization.
14 --
15 --
16 --
17 -- Module S6Link_adapt_top_lpm
18 -- Generated by Xilinx 7 Series FPGAs Transceivers Wizard
19 --
20 --
21 -- (c) Copyright 2010-2012 Xilinx, Inc. All rights reserved.
22 --
23 -- This file contains confidential and proprietary information
24 -- of Xilinx, Inc. and is protected under U.S. and
25 -- international copyright and other intellectual property
26 -- laws.
27 --
28 -- DISCLAIMER
29 -- This disclaimer is not a license and does not grant any
30 -- rights to the materials distributed herewith. Except as
31 -- otherwise provided in a valid license issued to you by
32 -- Xilinx, and to the maximum extent permitted by applicable
33 -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
34 -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
35 -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
36 -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
37 -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
38 -- (2) Xilinx shall not be liable (whether in contract or tort,
39 -- including negligence, or under any other theory of
40 -- liability) for any loss or damage of any kind or nature
41 -- related to, arising under or in connection with these
42 -- materials, including for any direct, or any indirect,
43 -- special, incidental, or consequential loss or damage
44 -- (including loss of data, profits, goodwill, or any type of
45 -- loss or damage suffered as a result of any action brought
46 -- by a third party) even if such damage or loss was
47 -- reasonably foreseeable or Xilinx had been advised of the
48 -- possibility of the same.
49 --
50 -- CRITICAL APPLICATIONS
51 -- Xilinx products are not designed or intended to be fail-
52 -- safe, or for use in any application requiring fail-safe
53 -- performance, such as life-support or safety devices or
54 -- systems, Class III medical devices, nuclear facilities,
55 -- applications related to the deployment of airbags, or any
56 -- other applications that could lead to death, personal
57 -- injury, or severe property or environmental damage
58 -- (individually and collectively, "Critical
59 -- Applications"). Customer assumes the sole risk and
60 -- liability of any use of Xilinx products in Critical
61 -- Applications, subject only to applicable laws and
62 -- regulations governing limitations on product liability.
63 --
64 -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
65 -- PART OF THIS FILE AT ALL TIMES.
66 
67 
68 --*****************************************************************************
69 
70 library IEEE;
71 use IEEE.STD_LOGIC_1164.ALL;
72 use IEEE.STD_LOGIC_UNSIGNED.ALL;
73 use IEEE.STD_LOGIC_ARITH.ALL;
74 use IEEE.NUMERIC_STD.ALL;
75 
77 generic (
78  TIMER : integer range 0 to 4095:= 150
79 );
80 port
81  (
82  EN : in STD_LOGIC;
83  GTRXRESET : in STD_LOGIC;
84  RXPMARESET : in STD_LOGIC;
85  RXDFELPMRESET : in STD_LOGIC;
86  --DRP
87  DCLK : in STD_LOGIC;
88  DO : in STD_LOGIC_VECTOR(15 downto 0);
89  DRDY : in STD_LOGIC;
90  DADDR : out STD_LOGIC_VECTOR(8 downto 0);
91  DI : out STD_LOGIC_VECTOR(15 downto 0);
92  DEN : out STD_LOGIC;
93  DWE : out STD_LOGIC;
94 
95  KLHOLD : out STD_LOGIC;
96  KHHOLD : out STD_LOGIC;
97  --DONE
98  DONE : out STD_LOGIC;
99  --Debug
100  DEBUG : out STD_LOGIC_VECTOR(53 downto 0)
101 );
102 end S6Link_ADAPT_TOP_LPM;
103 
104 architecture Behavioral of S6Link_ADAPT_TOP_LPM is
105 
106 component S6Link_adapt_starter
107 generic(
108  WAIT_CYC :integer range 0 to 16 := 10
109 );
110 port (
111 RST : in STD_LOGIC;
112 CLK : in STD_LOGIC;
113 DO : in STD_LOGIC_VECTOR(15 downto 0);
114 DRDY : in STD_LOGIC;
115 DADDR : out STD_LOGIC_VECTOR(8 downto 0);
116 DEN : out STD_LOGIC;
117 DWE : out STD_LOGIC;
118 READY : out STD_LOGIC;
119 curr_state_debug : out STD_LOGIC_VECTOR(3 downto 0);
120 counter_debug : out STD_LOGIC_VECTOR(2 downto 0);
121 rst_int_debug : out STD_LOGIC
122 );
123 end component;
124 
125 component S6Link_lpm_loop_fsm is
126 generic (
127  usr_clk: integer range 0 to 4095 := 3
128  );
129 Port(
130 DCLK : in std_logic;
131 reset : in std_logic;
132 DRDY : in std_logic;
133 DO : in std_logic_vector(15 downto 0);
134 holds : out std_logic_vector(1 downto 0);
135 DI : out std_logic_vector(15 downto 0);
136 DADDR : out std_logic_vector(8 downto 0);
137 DWE,DEN,kill3 : out std_logic;
138 state : out std_logic_vector(4 downto 0);
139 count_lock_out : out std_logic_vector(31 downto 0);
140 store_di0 : out std_logic_vector(15 downto 0);
141 start,enable,kill0,kill1,kill2,lock0,lock1,lock2,lock3 : out std_logic
142 );
143 end component;
144 
145 signal rst : std_logic;
146 signal start_done : std_logic;
147 signal done_pre : std_logic;
148 signal lock_done : std_logic;
149 signal en_b : std_logic;
150 
151 --DRP-related
152 signal daddr_starter : std_logic_vector(8 downto 0);
153 signal den_starter : std_logic;
154 signal dwe_starter : std_logic;
155 
156 signal daddr_lock : std_logic_vector(8 downto 0);
157 signal den_lock : std_logic;
158 signal dwe_lock : std_logic;
159 signal di_lock : std_logic_vector(15 downto 0);
160 signal holds : std_logic_vector(1 downto 0);
161 signal rst_lock : std_logic;
162 signal lock_done_r, lock_done_r2 : std_logic;
163 
164 --Debug signals
165 signal lock_statek : std_logic_vector(4 downto 0);
166 signal lock_countk : std_logic_vector(31 downto 0);
167 signal lock0, lock1, lock2, lock3 : std_logic;
168 signal starter_state : std_logic_vector(3 downto 0);
169 signal starter_count : std_logic_vector(2 downto 0);
170 signal starter_rst_int : std_logic;
171 signal lock_done_rise : std_logic;
172 signal store_di0k : std_logic_vector(15 downto 0);
173 signal lock_state : std_logic_vector(4 downto 0);
174 signal lock_count : std_logic_vector(31 downto 0);
175 signal store_di0 : std_logic_vector(15 downto 0);
176 signal start, enable, kill0, kill1, kill2 : std_logic;
177 
178 begin
179 ------------------------------------------------------------/
180 rst <= ((GTRXRESET or RXPMARESET or RXDFELPMRESET) and EN);
181 en_b <= not(EN);
182 rst_lock <= not(start_done);
183 done_pre <= lock_done;
184 DONE <= done_pre and start_done; --So that DONE goes low immediately after any of RESET's is asserted
185 
186 
187 process(DCLK)
188 begin
189  if rising_edge(DCLK) then
190  lock_done_r <= lock_done;
191  lock_done_r2 <= lock_done_r;
192  end if;
193 end process;
194 
195 lock_done_rise <= not(lock_done_r2) and lock_done_r;
196 
197 DEBUG <= lock_state(4 downto 0) & lock_count(31 downto 9) & store_di0(15 downto 0) & lock0 & lock1 & lock2 & lock3 & start & enable & kill0 & kill1 & kill2 & rst_lock;
198 
199 KLHOLD <= holds(0);
200 KHHOLD <= holds(1);
201 
202 --When a block is not active, it will hold DADDR,DI,DEN,DWE low
203 DADDR <= (others => '0') when (en_b='1') else (daddr_starter or daddr_lock);
204 DI <= (others => '0') when (en_b='1') else di_lock;
205 DEN <= '0' when (en_b='1') else (den_starter or den_lock);
206 DWE <= '0' when (en_b='1') else (dwe_starter or dwe_lock);
207 
208 ----/***************************************
209 ---- Sequence of operation:
210 ---- -adapt_starter -> triggered by any of above resets to deassert then waits for DFE LPM reset to complete
211 ---- -agc_loop_fsm -> triggered by adapt_starter completion then waits for all loops to lock
212 ----***************************************/
213 i_starter : S6Link_adapt_starter
214 generic map(
215  WAIT_CYC => 10
216 )
217 port map
218 (
219  RST => rst,
220  CLK => DCLK,
221  DO => DO,
222  DRDY => DRDY,
223  DADDR => daddr_starter,
224  DEN => den_starter,
225  DWE => dwe_starter,
226  READY => start_done,
227  curr_state_debug => starter_state(3 downto 0),
228  counter_debug => starter_count(2 downto 0),
229  rst_int_debug => starter_rst_int
230 );
231 
232 i_lock : S6Link_lpm_loop_fsm
233 generic map(
234  usr_clk => TIMER
235 )
236 port map
237 (
238  DCLK => DCLK,
239  reset => rst_lock,
240  DRDY => DRDY,
241  DO => DO,
242  holds => holds , --KLHOLD,KHHOLD
243  DI => di_lock,
244  DADDR => daddr_lock,
245  DWE => dwe_lock,
246  DEN => den_lock,
247  kill3 => lock_done,
248  state => lock_state(4 downto 0),
249  count_lock_out => lock_count(31 downto 0),
250  store_di0 => store_di0,
251  start => start ,
252  enable => enable,
253  kill0 => kill0 ,
254  kill1 => kill1 ,
255  kill2 => kill2 ,
256  lock0 => lock0 ,
257  lock1 => lock1 ,
258  lock2 => lock2 ,
259  lock3 => lock3
260 );
261 
262 end Behavioral;
263