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

Back to eFEX documentation
top_synch.vhd
Go to the documentation of this file.
1 
14 
15 
16 
17 library IEEE;
18 use IEEE.STD_LOGIC_1164.all;
19 use IEEE.NUMERIC_STD.all;
20 library xil_defaultlib;
21 --use work.EfexDataFormats.all;
22 
24 entity top_synch is
25 
26  port (
28  rx_clk280 : in std_logic;
30  TTC_clk : in std_logic;
32  reset : in std_logic;
34  enable_mgt : in std_logic;
36  MGT_Commadet : in std_logic;
38  reg_sel : in std_logic_vector(3 downto 0);
40  mux_sel : in std_logic_vector(3 downto 0);
42  start : in std_logic;
44  rx_resetdone : in std_logic;
46  reg224_latch : out std_logic;
48  delay_latch : out std_logic;
50  ttc_pipe : out std_logic;
52  delay_num : out std_logic_vector (3 downto 0);
54  bcn_synch : out std_logic;
56  data_out_reg224 : out std_logic_vector(223 downto 0):= (others => '0'); -- data before mux
58  disp_notable_error : out std_logic_vector(1 downto 0);
60  align_frame_out : out std_logic;
62  crc_error_out : out std_logic;
64  data_out : out std_logic_vector(223 downto 0); -- data after mux
66  align_frame : in std_logic;
68  data_in : in std_logic_vector(31 downto 0);
70  disperr_error : in std_logic;
72  notable_error : in std_logic;
74  crc_error_in : in std_logic
75  );
76 
77 end top_synch;
79 architecture Behavioral of top_synch is
80  signal latch_enable, temp0, temp1, Reg_enable, commdet_delay : std_logic;
81  signal delay_cnt, mux_cntrl, data_delay : std_logic_vector (3 downto 0);
82  signal data_out_int, dataout : std_logic_vector (227 downto 0);
83  signal temp2, ttc_redge, ttc_20M : std_logic;
84  signal bcn, reg_sel_i : std_logic_vector (4 downto 0);
85  signal data_out_int_i : std_logic_vector(227 downto 0);
86  signal crc_error_i : std_logic;
87 
88 begin
89 
90  ttc_pipe <= temp1;
91  delay_num <= data_delay;
92  delay_latch <= reg_enable;
93  bcn <= dataout(196 downto 192); --MGT_to_SuperCells('0' & dataout).BCID(4 downto 0); --dataout(196 downto 192);
94  data_out <= dataout(223 downto 0); -- data output after mux
95  disp_notable_error <= dataout(225 downto 224);
96  crc_error_out <= dataout(227);
97  align_frame_out <= dataout(226);
98 
99  data_out_reg224 <= data_out_int_i (223 downto 0); -- data output before
100 --data_out_reg224 <= dataout (223 downto 0); -- ensure
101 
102  reg_sel_i <= '0' & reg_sel;
103 
104 
105 -- This process generates pulse if bcn = 11111
106  synch_bcn : process (TTC_clk)
107  begin
108  if TTC_clk' event and TTC_clk = '1' then
109  if (bcn = "11111") then -- check if bcbn is equal 31
110  bcn_synch <= '1'; -- generate single pulse of 40 MHz
111  else
112  bcn_synch <= '0'; --- not generate
113  end if;
114 
115  end if;
116  end process;
117 
118 
119 
120 
121  shift_register : entity work.SRLC32E_226
122  port map (
123  clk => ttc_clk,
124  srl_en => enable_mgt,
125  address => reg_sel_i,
126  data_in => data_out_int_i, --data_out_int, -- before second stage MUX
127  data_out => dataout -- after second stage MUX
128  );
129  --data_out_int <= crc_error_40 & data_out_int_i;
130 
131 -- Capture the incoming TTC 40M clk by dtype flipflop
132  dtype : entity work.d_type
133  port map (
134  clk => ttc_clk,
135  q => ttc_20M
136 
137  );
138 
139 
140 -- Two register synchorization for the ttc clock in to rx clock of 280M Hz
141  pipe_ttc_clk : process (rx_clk280)
142 
143  begin
144  if rx_clk280' event and rx_clk280 = '1' then
145  temp0 <= ttc_20M;
146  temp1 <= temp0;
147  temp2 <= temp1;
148  ttc_redge <= temp1 xor temp2 after 1 ns;
149  end if;
150 
151  end process;
152 
153  -- First stage timing auto calibration state machine that will generate delay count
154  state_machine : entity work.tac_sm
155 
156  port map (
157  clk_280M => rx_clk280,
158  MGT_COMMADET => MGT_COMMADET,
159  RESET => reset,
160  rx_resetdone => rx_resetdone, -- wait rx reset done to go high
161  TTC_CLK_edge => ttc_redge,
162  start => start, -- kick start pulse for the state machine to count the diffrence edges
163  Reg_enable => Reg_enable,
164  Mux_value => Delay_cnt
165  );
166 
167  -- Delay count register that holds the number of delay that was counted by the state machine
168 
169  reg_delay_cnt : process (rx_clk280)
170 
171  begin
172  if rx_clk280' event and rx_clk280 = '1' then
173  if reg_enable = '1' then -- time difference between the ttc edge and 280Mhz is ready
174  data_delay <= delay_cnt; -- read the edge difference value between two clocks
175  end if;
176  end if;
177  end process;
178 
179 
180  synch_1 : entity work.synch_stage_1
181 
182  port map (
183  clk_280 => rx_clk280,
184  reset => reset,
186  mux_cntrl => mux_sel, -- first stage mux setting
187  latch_enable => latch_enable,
188  MGT_Commadet => MGT_Commadet, -- mgt comma detect input from the rx
189  commdet_delay => commdet_delay,
190  data_in => data_in, -- in coming rx_data 32 bits
191  data_out => data_out_int_i, --outgoing data of 227 bits that goes to the fibre mapping
192  align_frame => align_frame, -- bit that tells if the data is an alignment frame or not
193  disperr_error => disperr_error, -- disperr error is added in the synch in order to go with the data
194  notable_error => notable_error, -- notable error is added in the synch in order to go with the data
196  );
197 
198  -- Generates latch enable for the output data of 224 bits (7 x 32 bits)
199  latch : entity work.latch_enable
200  port map(
201  CLK_280M => rx_clk280,
202  MGT_COMMADET => commdet_delay,
203  latch_enable => latch_enable -- latches when 7 32bis of data are ready
204 
205  );
206 
207  reg224_latch <= latch_enable;
208 
209 end Behavioral;
shift register
Definition: srl32e_226.vhd:13
in data_in std_logic_vector( 227 downto 0)
data in
Definition: srl32e_226.vhd:22
in address std_logic_vector( 4 downto 0)
shift depth
Definition: srl32e_226.vhd:20
in clk std_logic
clock
Definition: srl32e_226.vhd:16
out data_out std_logic_vector( 227 downto 0)
data out
Definition: srl32e_226.vhd:25
in srl_en std_logic
enable of shifter
Definition: srl32e_226.vhd:18
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
latch enable
in MGT_COMMADET std_logic
mgt commadet
out latch_enable std_logic
latch enable
First Stage Synchronisation of process FPGA.
Definition: synch_stg_1.vhd:21
in reset std_logic
reset
Definition: synch_stg_1.vhd:27
in clk_280 std_logic
MGT rx clock.
Definition: synch_stg_1.vhd:25
in MGT_Commadet std_logic
MGT commadet.
Definition: synch_stg_1.vhd:35
in latch_enable std_logic
latch enable of 226 bits
Definition: synch_stg_1.vhd:31
in align_frame std_logic
align frame
Definition: synch_stg_1.vhd:43
out data_out std_logic_vector( 227 downto 0)
frame data out of 226 bits
Definition: synch_stg_1.vhd:41
in mux_cntrl std_logic_vector( 3 downto 0)
first stage mux slect bits
Definition: synch_stg_1.vhd:29
in notable_error std_logic
nottable error
Definition: synch_stg_1.vhd:47
in disperr_error std_logic
disperr erro
Definition: synch_stg_1.vhd:45
in data_in std_logic_vector( 31 downto 0)
rx data
Definition: synch_stg_1.vhd:39
out commdet_delay std_logic := '0'
MGT commadet pipe.
Definition: synch_stg_1.vhd:37
in crc_error_in std_logic
crc error
Definition: synch_stg_1.vhd:52
in enable_mgt std_logic
MGT rx data regsiter enable.
Definition: synch_stg_1.vhd:33
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.
Definition: top_synch.vhd:79
Top Synchronisation.
Definition: top_synch.vhd:24
in rx_clk280 std_logic
rx clock of the mgt
Definition: top_synch.vhd:28
out delay_num std_logic_vector( 3 downto 0)
first stage dealy counter value
Definition: top_synch.vhd:52
in reset std_logic
reset active high
Definition: top_synch.vhd:32
out crc_error_out std_logic
crc_error to the error counter
Definition: top_synch.vhd:62
in rx_resetdone std_logic
rx reset done of the MGT
Definition: top_synch.vhd:44
in MGT_Commadet std_logic
comma detected for incoming data
Definition: top_synch.vhd:36
out delay_latch std_logic
delay latch
Definition: top_synch.vhd:48
in mux_sel std_logic_vector( 3 downto 0)
setting BC mux
Definition: top_synch.vhd:40
in align_frame std_logic
bit indicating if data is an alignment frame or not
Definition: top_synch.vhd:66
in notable_error std_logic
notable channel error
Definition: top_synch.vhd:72
in disperr_error std_logic
disperr channel error
Definition: top_synch.vhd:70
in data_in std_logic_vector( 31 downto 0)
rx data in
Definition: top_synch.vhd:68
in start std_logic
start pulse for the calibration to start
Definition: top_synch.vhd:42
out reg224_latch std_logic
latch enable
Definition: top_synch.vhd:46
in crc_error_in std_logic
crc channel error
Definition: top_synch.vhd:75
in enable_mgt std_logic
enable mgt rx register
Definition: top_synch.vhd:34
out disp_notable_error std_logic_vector( 1 downto 0)
combined disperr and notable errors
Definition: top_synch.vhd:58
out ttc_pipe std_logic
ttc pipe
Definition: top_synch.vhd:50
out data_out_reg224 std_logic_vector( 223 downto 0) :=( others => '0')
data before mux
Definition: top_synch.vhd:56
out align_frame_out std_logic
align frame output
Definition: top_synch.vhd:60
in TTC_clk std_logic
ttc clk of 40MHz
Definition: top_synch.vhd:30
out bcn_synch std_logic
bcn synch
Definition: top_synch.vhd:54
out data_out std_logic_vector( 223 downto 0)
data out of 224 bits
Definition: top_synch.vhd:64
in reg_sel std_logic_vector( 3 downto 0)
setting the first stage mux
Definition: top_synch.vhd:38