12 use IEEE.STD_LOGIC_1164.
all;
13 use IEEE.NUMERIC_STD.
all;
17 library TOB_rdout_lib;
25 generic(n_channels : natural := N_MGT;
26 FPGA_NUMBER : integer);
28 TTC_clk : in std_logic;
29 clk280 : in std_logic;
30 rx_clk280 : in std_logic_vector(n_channels - 1 downto 0);
31 MGT_Commadet : in std_logic_vector(n_channels - 1 downto 0);
32 enable_mgt : in std_logic_vector(n_channels - 1 downto 0);
33 BC_Reg_sel : in std_logic_vector(255 downto 0);
34 mux_sel : in std_logic_vector(255 downto 0);
35 sel_bcn_or_bc_cnt : in std_logic;
36 pseudo_orbit : out std_logic;
38 start_pulse_rst : out std_logic;
39 rx_resetdone : in std_logic_vector(n_channels - 1 downto 0);
41 DataToAlgo : out Algoinput;
42 RAW_data : out RAW_data_227_type;
43 bc_cntr_0 : out std_logic_vector(111 downto 0);
44 bc_cntr_1 : out std_logic_vector(111 downto 0);
45 bc_cntr_2 : out std_logic_vector(111 downto 0);
46 bc_cntr_3 : out std_logic_vector(111 downto 0);
47 bc_mux_cntr_0 : out std_logic_vector(111 downto 0);
48 bc_mux_cntr_1 : out std_logic_vector(111 downto 0);
49 bc_mux_cntr_2 : out std_logic_vector(111 downto 0);
50 bc_mux_cntr_3 : out std_logic_vector(111 downto 0);
51 bcn_synch : out std_logic_vector(63 downto 0);
52 crc_error_chan : out std_logic_vector(63 downto 0);
54 data_readout_0 : out std_logic_vector(223 downto 0);
55 data_readout_1 : out std_logic_vector(223 downto 0);
56 data_readout_2 : out std_logic_vector(223 downto 0);
57 data_readout_3 : out std_logic_vector(223 downto 0);
58 delay_num : out std_logic_vector(255 downto 0);
59 Reg224_latch : out std_logic_vector(n_channels - 1 downto 0);
60 ttc_pipe : out std_logic_vector(n_channels - 1 downto 0);
61 delay_latch : out std_logic_vector(n_channels - 1 downto 0);
63 sel_data_in : in std_logic;
64 ram_data : in ram_data_in;
65 MGT_data : in mgt_data_in;
66 align_frame : in std_logic_vector(n_channels - 1 downto 0);
67 disperr_error : in std_logic_vector(n_channels - 1 downto 0);
68 notable_error : in std_logic_vector(n_channels - 1 downto 0)
78 signal crc_error_chan_i : std_logic_vector(63 downto 0);
79 signal MGT_Commadet_tmp : std_logic_vector(63 downto 0);
83 signal data_in_int, ram_data_tmp : mgt_data_in;
84 signal dataout_after_mux ,dataout_after_mux_i ,ram_data_int : mgt_data_out;
87 signal dataout_before_mux : mgt_data_out;
91 signal sel_reg, sel_mux : std_logic_vector(255 downto 0);
93 signal reg1, reg2, reg3, start_pulse_280 : std_logic;
95 signal temp0, temp1, temp2, start_40, pseudo_orbit_ref, pseudo_orbit_out : std_logic;
96 signal bcn_0, bcn_1, bcn_2, bcn_3, bc_mux_out_0, bc_mux_out_1, bc_mux_out_2, bc_mux_out_3 : std_logic_vector(111 downto 0);
97 signal bcn_tmp_0, bcn_tmp_1, bcn_tmp_2, bcn_tmp_3, bc_mux_tmp_0, bc_mux_tmp_1, bc_mux_tmp_2, bc_mux_tmp_3 : std_logic_vector(111 downto 0);
100 signal MGT_Commadet_i : std_logic_vector(n_channels - 1 downto 0);
102 type crc_error_40_type is array (n_channels - 1 downto 0) of std_logic;
103 signal crc_error_40_i : crc_error_40_type;
108 attribute keep : string;
109 attribute max_fanout : integer;
110 attribute keep of MGT_Commadet_i : signal is "true";
112 attribute keep of bc_cntr_0 : signal is "true";
113 attribute keep of bc_cntr_1 : signal is "true";
114 attribute keep of bc_cntr_2 : signal is "true";
115 attribute keep of bc_cntr_3 : signal is "true";
116 attribute keep of bc_mux_out_0 : signal is "true";
117 attribute keep of bc_mux_out_1 : signal is "true";
118 attribute keep of bc_mux_out_2 : signal is "true";
119 attribute keep of bc_mux_out_3 : signal is "true";
125 data_readout_0 <= dataout_before_mux(16)(223 downto 0);
126 data_readout_1 <= dataout_before_mux(17)(223 downto 0);
127 data_readout_2 <= dataout_before_mux(18)(223 downto 0);
128 data_readout_3 <= dataout_before_mux(19)(223 downto 0);
129 pseudo_orbit <= pseudo_orbit_out;
134 bcn_gen : for i in 0 to (15) generate
135 bcn_0(i * 7 + 6 downto 7 * i) <= MGT_to_SuperCells(dataout_before_mux(i + 3 * i)).BCID(6 downto 0);
136 bcn_1(i * 7 + 6 downto 7 * i) <= MGT_to_SuperCells(dataout_before_mux(i + 1 + 3 * i)).BCID(6 downto 0);
137 bcn_2(i * 7 + 6 downto 7 * i) <= MGT_to_SuperCells(dataout_before_mux(i + 2 + 3 * i)).BCID(6 downto 0);
138 bcn_3(i * 7 + 6 downto 7 * i) <= MGT_to_SuperCells(dataout_before_mux(i + 3 + 3 * i)).BCID(6 downto 0);
139 end generate bcn_gen;
144 bc_alignment_before_mux : for i in 0 to 15 generate
150 bcn_0 => bcn_0
(7 * i +
6 downto 7 * i
),
151 bcn_1 => bcn_1
(7 * i +
6 downto 7 * i
),
152 bcn_2 => bcn_2
(7 * i +
6 downto 7 * i
),
153 bcn_3 => bcn_3
(7 * i +
6 downto 7 * i
),
159 cntr_ch0 => bcn_tmp_0
(7 * i +
6 downto 7 * i
),
160 cntr_ch1 => bcn_tmp_1
(7 * i +
6 downto 7 * i
),
161 cntr_ch2 => bcn_tmp_2
(7 * i +
6 downto 7 * i
),
162 cntr_ch3 => bcn_tmp_3
(7 * i +
6 downto 7 * i
)
165 end generate bc_alignment_before_mux;
167 bcn_before_mux :
process(TTC_clk)
169 if rising_edge(TTC_clk) then
170 if sel_bcn_or_bc_cnt = '1' then
176 bc_cntr_0 <= bcn_tmp_0;
177 bc_cntr_1 <= bcn_tmp_1;
178 bc_cntr_2 <= bcn_tmp_2;
179 bc_cntr_3 <= bcn_tmp_3;
190 bcn => bcn_0
(4 downto 0),
198 bcn_mux_gen : for i in 0 to (15) generate
199 bc_mux_out_0(7 * i + 6 downto 7 * i) <= MGT_to_SuperCells(dataout_after_mux(i + 3 * i)).BCID(6 downto 0);
200 bc_mux_out_1(7 * i + 6 downto 7 * i) <= MGT_to_SuperCells(dataout_after_mux(i + 1 + 3 * i)).BCID(6 downto 0);
201 bc_mux_out_2(7 * i + 6 downto 7 * i) <= MGT_to_SuperCells(dataout_after_mux(i + 2 + 3 * i)).BCID(6 downto 0);
202 bc_mux_out_3(7 * i + 6 downto 7 * i) <= MGT_to_SuperCells(dataout_after_mux(i + 3 + 3 * i)).BCID(6 downto 0);
203 end generate bcn_mux_gen;
208 bc_alignment_after_mux : for i in 0 to 15 generate
214 bcn_0 => bc_mux_out_0
(7 * i +
6 downto 7 * i
),
215 bcn_1 => bc_mux_out_1
(7 * i +
6 downto 7 * i
),
216 bcn_2 => bc_mux_out_2
(7 * i +
6 downto 7 * i
),
217 bcn_3 => bc_mux_out_3
(7 * i +
6 downto 7 * i
),
223 cntr_ch0 => bc_mux_tmp_0
(7 * i +
6 downto 7 * i
),
224 cntr_ch1 => bc_mux_tmp_1
(7 * i +
6 downto 7 * i
),
225 cntr_ch2 => bc_mux_tmp_2
(7 * i +
6 downto 7 * i
),
226 cntr_ch3 => bc_mux_tmp_3
(7 * i +
6 downto 7 * i
)
228 end generate bc_alignment_after_mux;
230 bcn_after_mux :
process(TTC_clk)
232 if rising_edge(TTC_clk) then
233 if sel_bcn_or_bc_cnt = '1' then
234 bc_mux_cntr_0 <= bc_mux_out_0;
235 bc_mux_cntr_1 <= bc_mux_out_1;
236 bc_mux_cntr_2 <= bc_mux_out_2;
237 bc_mux_cntr_3 <= bc_mux_out_3;
239 bc_mux_cntr_0 <= bc_mux_tmp_0;
240 bc_mux_cntr_1 <= bc_mux_tmp_1;
241 bc_mux_cntr_2 <= bc_mux_tmp_2;
242 bc_mux_cntr_3 <= bc_mux_tmp_3;
253 bcn => bc_mux_out_0
(4 downto 0),
260 start_pulse_40 :
process(TTC_clk)
262 if TTC_clk'event and TTC_clk = '1' then
266 start_40 <= temp1 and not temp2;
269 start_pulse_rst <= start_40;
274 synch_gen : for i in 0 to (n_channels - 1) generate
282 reg_sel => sel_reg
(i +
3 +
3 * i
downto i +
3 * i
),
283 mux_sel => sel_mux
(i +
3 +
3 * i
downto i +
3 * i
),
284 start => start_pulse_280,
289 delay_num => delay_num
(i +
3 +
3 * i
downto i +
3 * i
),
295 data_out => dataout_after_mux_i
(i
)(223 downto 0),
308 enable_mgt => enable_mgt
(i
),
314 ram_data_int(i) <= ram_data(i);
315 data_in_int(i) <= MGT_data(i);
316 MGT_Commadet_i(i) <= MGT_Commadet(i);
318 end generate synch_gen;
320 crc_error_chan <= crc_error_chan_i;
321 sel_reg <= BC_Reg_sel;
325 start_pulse :
process(clk280)
327 if rising_edge(clk280) then
331 start_pulse_280 <= reg2 and not reg3;
335 dataout_after_mux <= ram_data_int when sel_data_in ='1' else dataout_after_mux_i ;
342 generic map(FPGA_NUMBER => FPGA_NUMBER
)
External data-types and functions.
in clk std_logic
MGT rx clock.
in mgt_commdet std_logic
MGT commadet.
in rxdata std_logic_vector( 31 downto 0)
MGT rx data.
out crc_error std_logic
crc error crc error in 40MHz clock domain
in eFEXPosition std_logic_vector( 31 downto 0)
Geographical position of eFEX module for dynamic mapping.
eFEX Fibre mapping module
out DataToAlg_out Algoinput
output to algorithm block
in MGT_data_in mgt_data_out
data in from MGT
in eFEXPosition_in std_logic_vector( 31 downto 0)
Geographical position of eFEX module for dynamic mapping.
out RAW_data_out RAW_data_227_type
datata out to readout block
in clk std_logic
ttc clock
in bcn std_logic_vector( 4 downto 0)
5 lsb of the bcn kn the data
out pseudo_orbit std_logic
pseudo orbit pulse generated
out cntr_ch2 std_logic_vector( 6 downto 0)
counter value of channel 2
out aeqb_ch1 std_logic
two counter equal in channel 1
out aeqb_ch2 std_logic
two counter equal in channel 2
in bcn_2 std_logic_vector( 6 downto 0)
bunch crossing number of channel 2
in clk std_logic
TTC 40MHz clock.
in bcn_0 std_logic_vector( 6 downto 0)
bunch crossing number of channel 1
out aeqb_ch0 std_logic
two counter equal in channel 0
out aeqb_ch3 std_logic
two counter equal in channel 3
in bcn_1 std_logic_vector( 6 downto 0)
bunch crossing number of channel 3
in bcn_3 std_logic_vector( 6 downto 0)
bunch crossing number of channel 3
out cntr_ch0 std_logic_vector( 6 downto 0)
counter value of channel 0
in start std_logic
start pulse
out cntr_ch1 std_logic_vector( 6 downto 0)
counter value of channel 1
out cntr_ch3 std_logic_vector( 6 downto 0)
counter value of channel 3
in ref_orbit std_logic
orbit reference signal
in rx_clk280 std_logic
rx clock of the mgt
out delay_num std_logic_vector( 3 downto 0)
first stage dealy counter value
in reset std_logic
reset active high
out crc_error_out std_logic
crc_error to the error counter
in rx_resetdone std_logic
rx reset done of the MGT
in MGT_Commadet std_logic
comma detected for incoming data
out delay_latch std_logic
delay latch
in mux_sel std_logic_vector( 3 downto 0)
setting BC mux
in align_frame std_logic
bit indicating if data is an alignment frame or not
in notable_error std_logic
notable channel error
in disperr_error std_logic
disperr channel error
in data_in std_logic_vector( 31 downto 0)
rx data in
in start std_logic
start pulse for the calibration to start
out reg224_latch std_logic
latch enable
in crc_error_in std_logic
crc channel error
in enable_mgt std_logic
enable mgt rx register
out disp_notable_error std_logic_vector( 1 downto 0)
combined disperr and notable errors
out ttc_pipe std_logic
ttc pipe
out data_out_reg224 std_logic_vector( 223 downto 0) :=( others => '0')
data before mux
out align_frame_out std_logic
align frame output
in TTC_clk std_logic
ttc clk of 40MHz
out bcn_synch std_logic
bcn synch
out data_out std_logic_vector( 223 downto 0)
data out of 224 bits
in reg_sel std_logic_vector( 3 downto 0)
setting the first stage mux