eFEX firmware  1.7.3
ATLAS l1-calo - electron and tau feature extraction firmware for eFEX boards

Back to eFEX documentation
top_ctrl_synch.vhd
Go to the documentation of this file.
1 
11 
12 
13 library IEEE;
14 use IEEE.STD_LOGIC_1164.ALL;
15 use IEEE.NUMERIC_STD.all;
16 LIBRARY xil_defaultlib;
17 
19 entity top_cntrl_synch is
20 
21 Port (
23  rx_clk160 : in std_logic;
25  TTC_clk : IN std_logic;
27  reset : in std_logic;
29  enable_mgt : in std_logic;
31  MGT_Commadet : in std_logic;
33  reg_sel : in std_logic_vector(3 downto 0);
35  mux_sel : in std_logic_vector(3 downto 0);
37  delay_num : out std_logic_vector(3 downto 0);
39  start : in std_logic;
41  rx_resetdone : in std_logic;
43  reg128_latch : out std_logic;
45  data_out : out std_logic_vector(128 downto 0);
47  data_in : in std_logic_vector(31 downto 0);
49  crc_error_in : in std_logic
50  );
51 end top_cntrl_synch;
53 
54 architecture Behavioral of top_cntrl_synch is
55 --COMPONENT ila_crc
56 
57 --PORT (
58 -- clk : IN STD_LOGIC;
59 
60 
61 -- probe0 : IN STD_LOGIC_VECTOR(167 DOWNTO 0)
62 --);
63 --END COMPONENT ;
64 
65 
66 
67 
68 
69 SIGNAL latch_enable,temp0,temp1,Reg_enable,commdet_delay : std_logic;
70 signal delay_cnt, mux_cntrl,data_delay : std_logic_vector (3 downto 0);
71 signal data_out_int, dataout: std_logic_vector (128 downto 0);
72 signal temp2,temp3, ttc_redge, ttc_20M : std_logic;
73 signal bcn : std_logic_vector (4 downto 0);
74 signal probe0 : std_logic_vector (165 downto 0);
75 
76 
77 begin
78 
79 
80 
81 data_out <= data_out_int; --dataout;
82 delay_num <= data_delay;
83 
84 
85 
86 
87 -- Capture the incoming TTC 40M clk by dtype flipflop
88 dtype: entity work.d_type
89  port map (
90  clk => ttc_clk,
91  q => ttc_20M
92 
93  );
94 
95 
96 
97 -- Two register synchorization for the ttc clock in to rx clock of 160M Hz
98 pipe_ttc_clk: process (rx_clk160)
99 
100  begin
101  if rx_clk160' event and rx_clk160 ='1' then
102  temp0<= ttc_20M;
103  temp1<= temp0;
104  temp2<= temp1;
105  temp3<= temp2;
106  ttc_redge <= temp3 xor temp2 after 1ns;
107  end if;
108 
109  end process;
110 
111  -- First stage timing auto calibration state machine that will generate delay count
112 state_machine: entity work.tac_sm
113 
114  PORT MAP (
115  clk_280M => rx_clk160,
116  MGT_COMMADET => MGT_COMMADET,
117  RESET => reset,
118  rx_resetdone => rx_resetdone, -- wait rx reset done to go high
119  TTC_CLK_edge => ttc_redge,
120  start => start, -- kick start pulse for the state machine to count the diffrence edges
121  Reg_enable => Reg_enable,
122  Mux_value => Delay_cnt
123  );
124 
125 
126 
127 
128  -- Delay count register that holds the number of delay that was counted by the state machine
129 
130 reg_delay_cnt: process (rx_clk160)
131 
132  begin
133  if rx_clk160' event and rx_clk160 ='1' then
134  if reg_enable ='1' then -- time difference between the ttc edge and 280Mhz is ready
135  data_delay <= delay_cnt; -- read the edge difference value between two clocks
136  end if;
137  end if;
138  end process;
139 
140 
141 synch_1: entity work.first_stage_synch
142 
143  PORT MAP (
144  clk160 => rx_clk160,
145  reset => reset,
147  mux_cntrl => mux_sel, -- first stage mux setting
148  latch_enable => latch_enable,
149  MGT_Commadet => MGT_Commadet, -- mgt comma detect input from the rx
150  commdet_delay => commdet_delay,
151  data_in => data_in, -- in coming rx_data 32 bits
152  data_out => data_out_int , --outgoing data of 128 bits that goes to the fibre mapping
154  );
155 
156 
157 
158  -- Generates latch enable for the output data of 128 bits (4 x 32 bits)
159 latch: entity work.ctrl_synch_latch
160  Port MAP(
161  CLK160 => rx_clk160,
162  MGT_COMMADET => commdet_delay,
163  latch_enable => latch_enable -- latches when 4 32 bit of data are ready
164 
165  );
166 
167 
168 
169 reg128_latch <= latch_enable;
170 
171 
172 --synch_scope : ila_crc
173 --PORT MAP (
174 -- clk => rx_clk160,
175 -- probe0(31 downto 0) => data_in,
176 -- probe0 (32)=> ttc_clk,
177 -- probe0 (33)=> latch_enable,
178 -- probe0 (36 downto 34)=> data_delay(2 downto 0),
179 -- probe0 (37 ) => MGT_Commadet,
180 -- probe0( 166 downto 38) => data_out_int ,
181 -- probe0(167) => crc_error_in
182 -- );
183 
184 
185 
186 
187 
188 
189 
190 end Behavioral;
latch enable for the control FPGA
in MGT_COMMADET std_logic
mgt commadet
out latch_enable std_logic
latch enable
in CLK160 std_logic
rx clock
d_type
Definition: d_type.vhd:12
in clk std_logic
ttc clock
Definition: d_type.vhd:15
out q std_logic
out of d_type
Definition: d_type.vhd:20
First Stage Synchronisation of the control FPGA.
in reset std_logic
reset
in MGT_Commadet std_logic
MGT commadet.
in latch_enable std_logic
latch enable of 128 bits
out data_out std_logic_vector( 128 downto 0)
frame data out of 128 bits
in clk160 std_logic
MGT rx clock.
in mux_cntrl std_logic_vector( 3 downto 0)
first stage mux slect bits
out commdet_delay std_logic
MGT commadet pipe.
in data_in std_logic_vector( 31 downto 0)
rx data
in enable_mgt std_logic
MGT register enbale.
in crc_error std_logic
crc error in
First Stage state machine.
Definition: tac_sm.vhd:15
out Reg_enable std_logic
enable
Definition: tac_sm.vhd:30
in TTC_CLK_edge std_logic
raising edge of TTC clock of 40NHz
Definition: tac_sm.vhd:22
in clk_280M std_logic
MGT rx clock of 280MHz for process and 160MHz for control.
Definition: tac_sm.vhd:18
Top Synchronisation of the control FPGA.
Top Synchronisation of the control FPGA.
out delay_num std_logic_vector( 3 downto 0)
counted delay on the first stage of the synchronisation
in reset std_logic
reset active high
in rx_resetdone std_logic
rx reset done of the MGT
in MGT_Commadet std_logic
comma detected for incoming data
in mux_sel std_logic_vector( 3 downto 0)
setting the first stage mux
out data_out std_logic_vector( 128 downto 0)
data out of 128 bits
out reg128_latch std_logic
latch enable
in data_in std_logic_vector( 31 downto 0)
rx data in
in start std_logic
start pulse for the calibration to start
in crc_error_in std_logic
crc_error input
in enable_mgt std_logic
enable mgt rx register
in TTC_clk std_logic
ttc clk of 40MHz
in reg_sel std_logic_vector( 3 downto 0)
setting BC mux
in rx_clk160 std_logic
rx clock of the mgt