1 ----------------------------------------------------------------------------------
5 -- Create Date: 10:
14:
48 04/20/2014
7 -- Module Name: DAQ_LINK - Behavioral
16 -- Revision 0.
01 -
File Created
17 -- Additional Comments:
19 ----------------------------------------------------------------------------------
21 use IEEE.STD_LOGIC_1164.
ALL;
22 use IEEE.STD_LOGIC_ARITH.
ALL;
23 use IEEE.STD_LOGIC_UNSIGNED.
ALL;
24 use IEEE.std_logic_misc.
all;
26 -- Uncomment the following library declaration if using
27 -- arithmetic functions with or values
28 --use IEEE.NUMERIC_STD.ALL;
30 -- Uncomment the following library declaration if instantiating
31 -- any Xilinx primitives in this code.
33 use UNISIM.VComponents.
all;
35 use UNIMACRO.vcomponents.
all;
39 -- REFCLK frequency, select one among 100,
125,
200 and 250
40 -- If your REFCLK frequency is not in the list, please contact wusx@bu.edu
42 SYSCLK_IN_period : := 10;
-- unit is ns
43 -- If you do not use the trigger port, set it to false
44 USE_TRIGGER_PORT : := true;
45 simulation : := false);
47 reset : in ;
-- asynchronous reset, assert reset until GTX REFCLK stable
57 trig : in (7 downto 0);
59 TTSclk : in ;
-- clock source which clocks TTS signals
60 TTS : in (3 downto 0);
61 -- SYSCLK_IN is required by the GTX ip core, you can connect any clock source(e.g. TTSclk, TTCclk or EventDataClk) as long as its period is in the range of 8-250ns
62 -- do not forget to specify its period in the generic port
66 EventData_valid : in ;
-- used as data write enable
67 EventData_header : in ;
-- first data word
68 EventData_trailer : in ;
-- last data word
69 EventData : in (63 downto 0);
70 AlmostFull : out ;
-- buffer almost full
77 simulation : := false);
85 RXNOTINTABLE :
IN (
1 downto 0);
86 RXCHARISCOMMA :
IN (
1 downto 0);
87 RXCHARISK :
IN (
1 downto 0);
88 RXDATA :
IN (
15 downto 0);
91 trig :
IN (
7 downto 0);
93 TTS :
IN (
3 downto 0);
95 EventData_valid :
IN ;
96 EventData_header :
IN ;
97 EventData_trailer :
IN ;
98 EventData :
IN (
63 downto 0);
99 TXCHARISK :
OUT (
1 downto 0);
100 TXDATA :
OUT (
15 downto 0);
104 L1A_DATA_we :
out ;
-- last data word
105 L1A_DATA :
out (
15 downto 0)
111 EXAMPLE_SIM_GTRESET_SPEEDUP : :=
"TRUE";
-- simulation setting for GT SecureIP model
112 EXAMPLE_SIMULATION : :=
0;
-- Set to 1 for simulation
113 STABLE_CLOCK_PERIOD : :=
16;
--Period of the stable clock driving this state-machine, unit is [ns]
114 EXAMPLE_USE_CHIPSCOPE : :=
0;
-- Set to 1 to use Chipscope
to drive resets
115 -- REFCLK frequency, select one among 100,
125,
200 and 250 If your REFCLK frequency
is not in the list, please contact wusx@bu.edu
122 DONT_RESET_ON_DATA_ERROR_IN :
IN ;
123 GT0_DATA_VALID_IN :
IN ;
124 GT0_CPLLLOCKDETCLK_IN :
IN ;
125 GT0_CPLLRESET_IN :
IN ;
126 GT0_GTREFCLK0_IN :
IN ;
127 GT0_DRPADDR_IN :
IN (
8 downto 0);
129 GT0_DRPDI_IN :
IN (
15 downto 0);
132 GT0_LOOPBACK_IN :
IN (
2 downto 0);
133 GT0_RXUSERRDY_IN :
IN ;
134 GT0_RXUSRCLK_IN :
IN ;
135 GT0_RXUSRCLK2_IN :
IN ;
136 GT0_RXPRBSSEL_IN :
IN (
2 downto 0);
137 GT0_RXPRBSCNTRESET_IN :
IN ;
140 GT0_RXMCOMMAALIGNEN_IN :
IN ;
141 GT0_RXPCOMMAALIGNEN_IN :
IN ;
142 GT0_GTRXRESET_IN :
IN ;
143 GT0_RXPMARESET_IN :
IN ;
144 GT0_GTTXRESET_IN :
IN ;
145 GT0_TXUSERRDY_IN :
IN ;
146 GT0_TXUSRCLK_IN :
IN ;
147 GT0_TXUSRCLK2_IN :
IN ;
148 GT0_TXDIFFCTRL_IN :
IN (
3 downto 0);
149 GT0_TXDATA_IN :
IN (
15 downto 0);
150 GT0_TXCHARISK_IN :
IN (
1 downto 0);
151 GT0_TXPRBSSEL_IN :
IN (
2 downto 0);
152 GT0_GTREFCLK0_COMMON_IN :
IN ;
153 GT0_QPLLLOCKDETCLK_IN :
IN ;
154 GT0_QPLLRESET_IN :
IN ;
155 GT0_TX_FSM_RESET_DONE_OUT :
OUT ;
156 GT0_RX_FSM_RESET_DONE_OUT :
OUT ;
157 GT0_CPLLFBCLKLOST_OUT :
OUT ;
158 GT0_CPLLLOCK_OUT :
OUT ;
159 GT0_DRPDO_OUT :
OUT (
15 downto 0);
160 GT0_DRPRDY_OUT :
OUT ;
161 GT0_EYESCANDATAERROR_OUT :
OUT ;
162 GT0_RXCDRLOCK_OUT :
OUT ;
163 GT0_RXCLKCORCNT_OUT :
OUT (
1 downto 0);
164 GT0_RXDATA_OUT :
OUT (
15 downto 0);
165 GT0_RXPRBSERR_OUT :
OUT ;
166 GT0_RXDISPERR_OUT :
OUT (
1 downto 0);
167 GT0_RXNOTINTABLE_OUT :
OUT (
1 downto 0);
168 GT0_RXCHARISCOMMA_OUT :
OUT (
1 downto 0);
169 GT0_RXCHARISK_OUT :
OUT (
1 downto 0);
170 GT0_RXRESETDONE_OUT :
OUT ;
171 GT0_GTXTXN_OUT :
OUT ;
172 GT0_GTXTXP_OUT :
OUT ;
173 GT0_TXOUTCLK_OUT :
OUT ;
174 GT0_TXOUTCLKFABRIC_OUT :
OUT ;
175 GT0_TXOUTCLKPCS_OUT :
OUT ;
176 GT0_TXRESETDONE_OUT :
OUT ;
177 GT0_QPLLLOCK_OUT :
OUT
180 function GTXRESET_SPEEDUP(is_sim : )
return is
188 signal UsrClk : := '0';
189 signal cplllock : := '0';
190 signal TXOUTCLK : := '0';
191 signal RxResetDone : := '0';
192 signal txfsmresetdone : := '0';
193 signal LoopBack : (2 downto 0) := (others => '0');
194 signal K_Cntr : (7 downto 0) := (others => '0');
195 signal reset_SyncRegs : (3 downto 0) := (others => '0');
196 signal RxResetDoneSyncRegs : (2 downto 0) := (others => '0');
197 signal DATA_VALID : := '0';
198 signal RXNOTINTABLE : (1 downto 0) := (others => '0');
199 signal RXCHARISCOMMA : (1 downto 0) := (others => '0');
200 signal RXCHARISK : (1 downto 0) := (others => '0');
201 signal RXDATA : (15 downto 0) := (others => '0');
202 signal TXDIFFCTRL : (3 downto 0) := x"b";
-- 790mV drive
203 signal TXCHARISK : (1 downto 0) := (others => '0');
204 signal TXDATA : (15 downto 0) := (others => '0');
207 generic map(simulation => simulation
)
210 USE_TRIGGER_PORT => USE_TRIGGER_PORT,
212 cplllock => cplllock,
213 RxResetDone => RxResetDone,
214 txfsmresetdone => txfsmresetdone,
215 RXNOTINTABLE => RXNOTINTABLE,
216 RXCHARISCOMMA => RXCHARISCOMMA,
217 RXCHARISK => RXCHARISK,
219 TXCHARISK => TXCHARISK,
226 EventDataClk => EventDataClk,
227 EventData_valid => EventData_valid,
228 EventData_header => EventData_header,
229 EventData_trailer => EventData_trailer,
230 EventData => EventData,
231 AlmostFull => AlmostFull,
237 process(UsrClk,RxResetDone)
239 if(RxResetDone = '0')then
240 RxResetDoneSyncRegs <= (others => '0');
241 elsif(UsrClk'event and UsrClk = '1')then
242 RxResetDoneSyncRegs <= RxResetDoneSyncRegs(1 downto 0) & '1';
245 process(UsrClk,reset,RxResetDone,txfsmresetdone,cplllock)
247 if(reset = '1' or RXRESETDONE = '0' or txfsmresetdone = '0' or cplllock = '0')then
248 reset_SyncRegs <= (others => '1');
249 elsif(UsrClk'event and UsrClk = '1')then
250 reset_SyncRegs <= reset_SyncRegs(2 downto 0) & '0';
255 if(UsrClk'event and UsrClk = '1')then
256 if(RXCHARISK = "11" and RXDATA = x"3cbc")then
258 elsif(RxResetDoneSyncRegs(2) = '0' or or_reduce(RXNOTINTABLE) = '1' or K_Cntr(7) = '1')then
261 if((RXCHARISK = "11" and RXDATA = x"3cbc"))then
262 K_Cntr <= (others => '0');
264 K_Cntr <= K_Cntr + 1;
271 EXAMPLE_SIM_GTRESET_SPEEDUP => GTXRESET_SPEEDUP
(simulation
),
272 EXAMPLE_SIMULATION =>
0,
273 STABLE_CLOCK_PERIOD => sysclk_in_period,
274 EXAMPLE_USE_CHIPSCOPE =>
0,
279 SYSCLK_IN => SYSCLK_IN ,
280 SOFT_RESET_IN => '0',
281 DONT_RESET_ON_DATA_ERROR_IN => '0',
282 GT0_TX_FSM_RESET_DONE_OUT => txfsmresetdone,
283 GT0_RX_FSM_RESET_DONE_OUT =>
open,
284 GT0_DATA_VALID_IN => DATA_VALID,
290 --_____________________________________________________________________
291 --_____________________________________________________________________
294 --------------------------------- CPLL Ports -------------------------------
295 GT0_CPLLFBCLKLOST_OUT =>
open,
296 GT0_CPLLLOCK_OUT => cplllock,
297 GT0_CPLLLOCKDETCLK_IN => sysclk_in,
298 GT0_CPLLRESET_IN => reset,
299 -------------------------- Channel - Clocking Ports ------------------------
300 GT0_GTREFCLK0_IN => GTX_REFCLK,
301 ---------------------------- Channel - DRP Ports --------------------------
302 GT0_DRPADDR_IN =>
(others => '0'
),
303 GT0_DRPCLK_IN => sysclk_in ,
304 GT0_DRPDI_IN =>
(others => '0'
),
305 GT0_DRPDO_OUT =>
open,
307 GT0_DRPRDY_OUT =>
open,
309 ------------------------------- Loopback Ports -----------------------------
310 GT0_LOOPBACK_IN => LOOPBACK,
311 --------------------- RX Initialization and Reset Ports --------------------
312 GT0_RXUSERRDY_IN => '0',
313 -------------------------- RX Margin Analysis Ports ------------------------
314 GT0_EYESCANDATAERROR_OUT =>
open,
315 ------------------------- Receive Ports - CDR Ports ------------------------
316 GT0_RXCDRLOCK_OUT =>
open,
317 ------------------ Receive Ports - FPGA RX Interface Ports -----------------
318 GT0_RXUSRCLK_IN => UsRClk,
319 GT0_RXUSRCLK2_IN => UsRClk,
320 ------------------ Receive Ports - FPGA RX interface Ports -----------------
321 GT0_RXDATA_OUT => RXDATA,
322 ------------------- Receive Ports - Pattern Checker Ports ------------------
323 GT0_RXPRBSERR_OUT =>
open,
324 GT0_RXPRBSSEL_IN =>
(others => '0'
),
325 ------------------- Receive Ports - Pattern Checker ports ------------------
326 GT0_RXPRBSCNTRESET_IN => '0',
327 ------------------ Receive Ports - RX 8B/10B Decoder Ports -----------------
328 GT0_RXDISPERR_OUT =>
open,
329 GT0_RXNOTINTABLE_OUT => RXNOTINTABLE,
330 --------------------------- Receive Ports - RX AFE -------------------------
331 GT0_GTXRXP_IN => GTX_RXP,
332 ------------------------ Receive Ports - RX AFE Ports ----------------------
333 GT0_GTXRXN_IN => GTX_RXN,
334 -------------- Receive Ports - RX Byte and Word Alignment Ports ------------
335 GT0_RXMCOMMAALIGNEN_IN => reset_SyncRegs
(3),
336 GT0_RXPCOMMAALIGNEN_IN => reset_SyncRegs
(3),
337 ------------- Receive Ports - RX Initialization and Reset Ports ------------
338 GT0_GTRXRESET_IN => reset,
339 GT0_RXPMARESET_IN => '0',
340 ------------------- Receive Ports - RX8B/10B Decoder Ports -----------------
341 GT0_RXCHARISCOMMA_OUT => RXCHARISCOMMA,
342 GT0_RXCHARISK_OUT => RXCHARISK,
343 -------------- Receive Ports -RX Initialization and Reset Ports ------------
344 GT0_RXRESETDONE_OUT => RXRESETDONE,
345 --------------------- TX Initialization and Reset Ports --------------------
346 GT0_GTTXRESET_IN => reset,
347 GT0_TXUSERRDY_IN => '0',
348 ------------------ Transmit Ports - FPGA TX Interface Ports ----------------
349 GT0_TXUSRCLK_IN => UsRClk,
350 GT0_TXUSRCLK2_IN => UsRClk,
351 --------------- Transmit Ports - TX Configurable Driver Ports --------------
352 GT0_TXDIFFCTRL_IN => TXDIFFCTRL,
353 ------------------ Transmit Ports - TX Data Path interface -----------------
354 GT0_TXDATA_IN => TXDATA,
355 ---------------- Transmit Ports - TX Driver and OOB signaling --------------
356 GT0_GTXTXN_OUT => GTX_TXN,
357 GT0_GTXTXP_OUT => GTX_TXP,
358 ----------- Transmit Ports - TX Fabric Clock Output Control Ports ----------
359 GT0_TXOUTCLK_OUT => TXOUTCLK,
360 GT0_TXOUTCLKFABRIC_OUT =>
open,
361 GT0_TXOUTCLKPCS_OUT =>
open,
362 --------------------- Transmit Ports - TX Gearbox Ports --------------------
363 GT0_TXCHARISK_IN => TXCHARISK,
364 ------------- Transmit Ports - TX Initialization and Reset Ports -----------
365 GT0_TXRESETDONE_OUT =>
open,
366 ------------------ Transmit Ports - pattern Generator Ports ----------------
367 GT0_TXPRBSSEL_IN => "
000",
372 --____________________________COMMON PORTS________________________________
373 ---------------------- Common Block - Ref Clock Ports ---------------------
374 GT0_GTREFCLK0_COMMON_IN => '0',
375 ------------------------- Common Block - QPLL Ports ------------------------
376 GT0_QPLLLOCK_OUT =>
open,
377 GT0_QPLLLOCKDETCLK_IN => '0',
378 GT0_QPLLRESET_IN => '0'
383 O => UsrClk,
-- Clock buffer output
384 I => TXOUTCLK
-- Clock buffer input