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

Back to eFEX documentation
mgt_quad_slaves.vhd
Go to the documentation of this file.
1 
9 
10 library IEEE;
11 use IEEE.STD_LOGIC_1164.all;
12 use ieee.numeric_std.all;
13 library ipbus_lib;
14 use ipbus_lib.ipbus.all;
15 use work.ipbus_decode_efex_mgt_quad.all;
16 
18 entity mgt_quad_slaves is
19  generic(ENABLE : in std_logic := '1'
20  );
21  port (
23  clk280 : in std_logic;
25  rxclk280 : in std_logic_vector(3 downto 0);
27  clk40 : in std_logic;
29  BCR_in : in std_logic;
31  ipb_clk : in std_logic;
33  ipb_rst : in std_logic;
35  ipb_in : in ipb_wbus;
37  ipb_out : out ipb_rbus;
39  loopback : out std_logic_vector(2 downto 0);
41  bc_reg_sel : out std_logic_vector(15 downto 0);
43  mux_sel : out std_logic_vector(15 downto 0);
45  softreset_tx : out std_logic;
47  softreset_rx : out std_logic;
49  qpll_lock : in std_logic;
51  qpll_refclklost : in std_logic;
53  tx_pd : in std_logic_vector(3 downto 0);
55  rx_pd : in std_logic_vector(3 downto 0);
56 
57  -- error_counter : in std_logic_vector(63 downto 0);
59  bc_cntr_0 : in std_logic_vector(6 downto 0);
61  bc_cntr_1 : in std_logic_vector(6 downto 0);
63  bc_cntr_2 : in std_logic_vector(6 downto 0);
65  bc_cntr_3 : in std_logic_vector(6 downto 0);
67  bc_mux_cntr_0 : in std_logic_vector(6 downto 0);
69  bc_mux_cntr_1 : in std_logic_vector(6 downto 0);
71  bc_mux_cntr_2 : in std_logic_vector(6 downto 0);
73  bc_mux_cntr_3 : in std_logic_vector(6 downto 0);
75  delay_cntr_0 : in std_logic_vector (3 downto 0);
77  delay_cntr_1 : in std_logic_vector (3 downto 0);
79  delay_cntr_2 : in std_logic_vector (3 downto 0);
81  delay_cntr_3 : in std_logic_vector (3 downto 0);
83  crc_error : in std_logic_vector (3 downto 0);
85  mgt_enable : out std_logic_vector(3 downto 0);
86  phase_mux : out std_logic_vector(15 downto 0);
88  rx_resetdone : in std_logic_vector (3 downto 0);
90  rx_fsm_resetdone : in std_logic_vector (3 downto 0);
92  rx_byteisaligned : in std_logic_vector (3 downto 0);
94  tx_resetdone : in std_logic_vector (3 downto 0);
96  tx_fsm_resetdone : in std_logic_vector (3 downto 0);
98  tx_bufstatus : in std_logic_vector (7 downto 0);
100  rx_realign : in std_logic_vector (3 downto 0);
102  rx_disperr : in std_logic_vector (15 downto 0);
104  encode_error : in std_logic_vector (15 downto 0);
106  rxdata_gt0 : in std_logic_vector(31 downto 0);
108  rxdata_gt1 : in std_logic_vector(31 downto 0);
110  rxdata_gt2 : in std_logic_vector(31 downto 0);
112  rxdata_gt3 : in std_logic_vector(31 downto 0);
114  ram_data_gt0 : out std_logic_vector(227 downto 0);
116  ram_data_gt1 : out std_logic_vector(227 downto 0);
118  ram_data_gt2 : out std_logic_vector(227 downto 0);
120  ram_data_gt3 : out std_logic_vector(227 downto 0);
122  disperr_error : out std_logic_vector(3 downto 0);
124  notable_error : out std_logic_vector(3 downto 0)
125 
126 
127  );
128 
129 end mgt_quad_slaves;
130 
132 architecture Behavioral of mgt_quad_slaves is
133 --constant N_SLAVES: positive := 5;
134  signal ipbw : ipb_wbus_array(N_SLAVES-1 downto 0);
135  signal ipbr, ipbr_d : ipb_rbus_array(N_SLAVES-1 downto 0);
136  signal error_counter_reset : std_logic;
137  signal encode_error_int, rx_disperr_int,rdy, mgtdata_enable : std_logic_vector (3 downto 0);
138  signal softreset_rx_int, softreset_tx_int, error_counter_reset_int : std_logic;
139  signal control_reg, synch_reg, pulse_reg, quad_status, phase_reg : std_logic_vector (31 downto 0);
140  signal pulse_reset, softreset_rx_i, error_counter_reset_i, softreset_tx_i : std_logic;
141  signal clr_pulse_reg, cntr_reset,sel_bcn_or_bc_cnt : std_logic;
142 
143 -- ####### Mark signals ########
144  attribute keep : string ;
145  attribute max_fanout : integer;
146  attribute keep of softreset_tx_i : signal is "true" ;
147  attribute max_fanout of softreset_tx_i : signal is 40;
148  attribute keep of softreset_rx_i : signal is "true" ;
149  attribute max_fanout of softreset_rx_i : signal is 40;
150  attribute keep of error_counter_reset_i : signal is "true" ;
151  attribute max_fanout of error_counter_reset_i : signal is 40;
152 -- #######################################
153 
154 begin
155 --- quad fabric decoder
156  ENABLED_QUAD : if ENABLE = '1' generate
157  fabric_quad : entity ipbus_lib.ipbus_fabric_sel
158  generic map(NSLV => N_SLAVES,
159  SEL_WIDTH => ipbus_sel_width)
160  port map(
161  ipb_in => ipb_in,
162  ipb_out => ipb_out,
163  sel => ipbus_sel_efex_mgt_quad(ipb_in.ipb_addr),
164  ipb_to_slaves => ipbw,
165  ipb_from_slaves => ipbr
166  );
167  end generate ENABLED_QUAD;
168 
169  DISABLED_QUAD : if ENABLE = '0' generate
170  fabric_quad : entity ipbus_lib.ipbus_fabric_sel
171  generic map(NSLV => N_SLAVES,
172  SEL_WIDTH => ipbus_sel_width)
173  port map(
174  ipb_in => IPB_WBUS_NULL,
175  ipb_out => open,
176  sel => (others => '0'),
177  ipb_to_slaves => open,
178  ipb_from_slaves => (others => IPB_RBUS_NULL)
179  );
180  ipb_out <= (x"DEADBEEF", '1', '0');
181  end generate DISABLED_QUAD;
182 
183  encode_error_int(0) <= encode_error(0) or encode_error(1) or encode_error(2) or encode_error(3);
184  encode_error_int(1) <= encode_error(4) or encode_error(5) or encode_error(6) or encode_error(7);
185  encode_error_int(2) <= encode_error(8) or encode_error(9) or encode_error(10) or encode_error(11);
186  encode_error_int(3) <= encode_error(12) or encode_error(13) or encode_error(14) or encode_error(15);
187 
188  notable_error <= encode_error_int;
189 
190  disperr_error <= rx_disperr_int;
191 
192  rx_disperr_int(0) <= rx_disperr(0) or rx_disperr(1) or rx_disperr(2) or rx_disperr(3);
193  rx_disperr_int(1) <= rx_disperr(4) or rx_disperr(5) or rx_disperr(6) or rx_disperr(7);
194  rx_disperr_int(2) <= rx_disperr(8) or rx_disperr(9) or rx_disperr(10) or rx_disperr(11);
195  rx_disperr_int(3) <= rx_disperr(12) or rx_disperr(13) or rx_disperr(14) or rx_disperr(15);
196 
197  loopback <= control_reg(2 downto 0); --- loopback signal
198  mgt_enable <= control_reg(7 downto 4); -- mgt enable signals
199  rdy <= control_reg( 11 downto 8); -- rdy for dual state machine
200  mgtdata_enable <= control_reg( 15 downto 12); -- enable the input ram for capturing the rxdata
201  bc_reg_sel <= synch_reg (15 downto 0); -- 2nd stage BC level MUX selector
202  mux_sel <= synch_reg (31 downto 16); -- 1st stage fine tune MUX selector
203  softreset_tx_int <= pulse_reg(0); -- tx reset pulse
204  softreset_rx_int <= pulse_reg(1); -- rxreset pulse
205  error_counter_reset_int <= pulse_reg(2); -- error counter reset pulse
206  quad_status <= x"0000000" & "00" & qpll_refclklost & qpll_lock; --- concatenating the pll status signals
207  softreset_tx <= softreset_tx_i;
208  softreset_rx <= softreset_rx_i;
209  phase_mux <= phase_reg(15 downto 0);
210 
211  softreset_rx_pulse : entity work.led_stretch -- softresetrx pulse generator
212  port map(
213  input => softreset_rx_int,
214  clk => ipb_clk, --clk280(0),
215  output => softreset_rx_i
216  );
217 
218  softreset_tx_pulse : entity work.led_stretch -- softresettx pulse generator
219  port map(
220  input => softreset_tx_int,
221  clk => ipb_clk, --clk280(0),
222  output => softreset_tx_i
223  );
224 
225  error_counter_reset_pulse : entity work.led_stretch -- pulse generator
226  port map(
227  input => error_counter_reset_int,
228  clk => ipb_clk, --clk280(0),
229  output => error_counter_reset_i
230  );
231 
232  cntr_reset <= error_counter_reset_i or softreset_rx_i; -- error counter will be reset when rx is reset
233  pulse_reset <= softreset_rx_i or error_counter_reset_i or softreset_tx_i;
234  clr_pulse_reg <= ipb_rst or pulse_reset; -- reset the pulse register with ipb reset or when it generates one pulse
235 
236 MGT_QUAD_Control : entity ipbus_lib.ipbus_ctrlreg_v --- control register
237  generic map (
238  N_CTRL => 1, --number of control reg
239  N_STAT => 0) --number of status reg
240  port map(
241  clk => ipb_clk,
242  reset => ipb_rst,
243  ipbus_in => ipbw(N_SLV_QUAD_MGT_CONTROL),
244  ipbus_out => ipbr(N_SLV_QUAD_MGT_CONTROL),
245  d => (others => (others => '0')) ,
246  q(0) => control_reg,
247  stb => open);
248 
249 MGT_QUAD_Synch: entity ipbus_lib.ipbus_ctrlreg_v -- reads the module ID register
250  generic map (
251  N_CTRL => 1, --number of control reg
252  N_STAT => 0) --number of status reg
253  port map(
254  clk => ipb_clk,
255  reset => ipb_rst,
256  ipbus_in => ipbw(N_SLV_QUAD_SYNCH_CONTROL),
257  ipbus_out => ipbr(N_SLV_QUAD_SYNCH_CONTROL),
258  d => (others => (others => '0')) ,
259  q(0) => synch_reg,
260  stb => open);
261 
262 MGT_QUAD_Pulse: entity ipbus_lib.ipbus_ctrlreg_v -- reads the module ID register
263  generic map (
264  N_CTRL => 1, --number of control reg
265  N_STAT => 0) --number of status reg
266  port map(
267  clk => ipb_clk,
268  reset => clr_pulse_reg,
269  ipbus_in => ipbw(N_SLV_QUAD_MGT_PULSE),
270  ipbus_out => ipbr(N_SLV_QUAD_MGT_PULSE),
271  d => (others => (others => '0')) ,
272  q(0) => pulse_reg,
273  stb => open);
274 
275 MGT_QUAD_status: entity ipbus_lib.ipbus_ctrlreg_v
276  generic map (
277  N_CTRL => 0, --number of control reg
278  N_STAT => 1) --number of status reg
279  port map(
280  clk => ipb_clk,
281  reset => ipb_rst,
282  ipbus_in => ipbw(N_SLV_QUAD_MGT_STATUS),
283  ipbus_out => ipbr(N_SLV_QUAD_MGT_STATUS),
284  d => (0 => quad_status) ,
285  q => open,
286  stb => open);
287 
288 MGT_QUAD_PHASE: entity ipbus_lib.ipbus_ctrlreg_v -- reads the module ID register
289  generic map (
290  N_CTRL => 1, --number of control reg
291  N_STAT => 0) --number of status reg
292  port map(
293  clk => ipb_clk,
294  reset => ipb_rst,
295  ipbus_in => ipbw(N_SLV_QUAD_PHASE_CONTROL),
296  ipbus_out => ipbr(N_SLV_QUAD_PHASE_CONTROL),
297  d => (others => (others => '0')) ,
298  q(0) => phase_reg,
299  stb => open);
300 
301 
302  MGT_GT0 : entity work.gt_information
303  generic map (addr_width => 8)
304  port map(
305  clk40 => clk40,
306  BCR_in => BCR_in,
307  ipb_clk => ipb_clk,
308  rxclk280 => rxclk280(0),
309  clk280 => clk280,
310  ipb_rst => ipb_rst,
311  reset => cntr_reset,
312  ipb_in => ipbw(N_SLV_GT0),
313  ipb_out => ipbr(N_SLV_GT0),
314  tx_pd => tx_pd(0),
315  rx_pd => rx_pd(0),
316  --error_counter => error_counter(15 downto 0),
317  bc_cntr => bc_cntr_0,
320  not_intable => encode_error_int(0),
326  tx_bufstatus => tx_bufstatus(1 downto 0),
327  rx_realign => rx_realign(0),
328  rx_disperr => rx_disperr_int(0),
329  crc_error => crc_error(0),
330  mgtdata_enable => mgtdata_enable(0),
331  rxdata => rxdata_gt0,
332  rdy => rdy(0) ,
334 
335  );
336 
337  MGT_GT1 : entity work.gt_information
338  generic map (addr_width => 8)
339  port map(
340  clk40 => clk40,
341  BCR_in => BCR_in,
342  ipb_clk => ipb_clk,
343  rxclk280 => rxclk280(1),
344  clk280 => clk280,
345  ipb_rst => ipb_rst,
346  reset => cntr_reset,
347  ipb_in => ipbw(N_SLV_GT1),
348  ipb_out => ipbr(N_SLV_GT1),
349  tx_pd => tx_pd(1),
350  rx_pd => rx_pd(1),
351  --error_counter => error_counter(31 downto 16),
352  bc_cntr => bc_cntr_1,
355  not_intable => encode_error_int(1),
361  tx_bufstatus => tx_bufstatus(3 downto 2),
362  rx_realign => rx_realign(1),
363  rx_disperr => rx_disperr_int(1),
364  crc_error => crc_error(1),
365  mgtdata_enable => mgtdata_enable(1),
366  rxdata => rxdata_gt1,
367  rdy => rdy(1) ,
369 
370  );
371 
372  MGT_GT2 : entity work.gt_information
373  generic map (addr_width => 8)
374  port map(
375  clk40 => clk40,
376  BCR_in => BCR_in,
377  ipb_clk => ipb_clk,
378  rxclk280 => rxclk280(2),
379  clk280 => clk280,
380  ipb_rst => ipb_rst,
381  reset => cntr_reset,
382  ipb_in => ipbw(N_SLV_GT2),
383  ipb_out => ipbr(N_SLV_GT2),
384  tx_pd => tx_pd(2),
385  rx_pd => rx_pd(2),
386  -- error_counter => error_counter(47 downto 32),
387  bc_cntr => bc_cntr_2,
390  not_intable => encode_error_int(2),
396  tx_bufstatus => tx_bufstatus(5 downto 4),
397  rx_realign => rx_realign(2),
398  rx_disperr => rx_disperr_int(2),
399  crc_error => crc_error(2),
400  mgtdata_enable => mgtdata_enable(2),
401  rxdata => rxdata_gt2,
402  rdy => rdy(2) ,
404 
405  );
406 
407  MGT_GT3 : entity work.gt_information
408  generic map (addr_width => 8)
409  port map(
410  clk40 => clk40,
411  BCR_in => BCR_in,
412  ipb_clk => ipb_clk,
413  rxclk280 => rxclk280(3),
414  clk280 => clk280,
415  ipb_rst => ipb_rst,
416  reset => cntr_reset,
417  ipb_in => ipbw(N_SLV_GT3),
418  ipb_out => ipbr(N_SLV_GT3),
419  tx_pd => tx_pd(3),
420  rx_pd => rx_pd(3),
421  --error_counter => error_counter(63 downto 48),
422  bc_cntr => bc_cntr_3,
425  not_intable => encode_error_int(3),
431  tx_bufstatus => tx_bufstatus(7 downto 6),
432  rx_realign => rx_realign(3),
433  rx_disperr => rx_disperr_int(3),
434  crc_error => crc_error(3),
435  mgtdata_enable => mgtdata_enable(3),
436  rxdata => rxdata_gt3,
437  rdy => rdy(3) ,
439 
440  );
441 
442 end Behavioral;
in reset std_logic
reset
in rx_realign std_logic
rx realign status
out ram_data std_logic_vector( 227 downto 0)
kchar generated signal ram_data from the plyback ram gt channel
in clk40 std_logic
fabric clock of 40MHz
in ipb_rst std_logic
ipbus reset
in BCR_in std_logic
BCR from TTC information.
in rx_resetdone std_logic
rx reset done of the gt if high is done
in bc_mux_cntr std_logic_vector( 4 downto 0)
bc value after the mux
in rx_byteisaligned std_logic
rx byte alignment
in rx_disperr std_logic
rx disperr error
in rx_pd std_logic
power control for rx side of the gt
in tx_resetdone std_logic
tx reset done of the gt if high is done
in not_intable std_logic
not in the table
in clk280 std_logic
fabric clock 280MHz
in ipb_clk std_logic
ipbus clock
in rx_fsm_resetdone std_logic
rx fsm reset done of the if high is done
out ipb_out ipb_rbus
IPBus output bus going from slaves to master.
in tx_fsm_resetdone std_logic
tx fsm reset done of the gt if high is done
in tx_bufstatus std_logic_vector( 1 downto 0)
tx buffer status
in tx_pd std_logic
power control for tx side of the gt
in mgtdata_enable std_logic
mgt enable of the channel
in rxclk280 std_logic
mgt rxclk
in ipb_in ipb_wbus
IPBus input bus going from master to slaves.
in rxdata std_logic_vector( 31 downto 0)
rx_data from gt channel
in bc_cntr std_logic_vector( 4 downto 0)
bc cntr value
in crc_error std_logic
crc_error
in delay_cntr std_logic_vector( 3 downto 0)
first stage delay count of gt
in rdy std_logic
ready to trigger the start of state machanie that controls the playback ram
led stretch
Definition: led_stretch.vhd:12
in clk std_logic
clock
Definition: led_stretch.vhd:17
in input std_logic
input
Definition: led_stretch.vhd:15
out output std_logic
output
Definition: led_stretch.vhd:20
MGT quad ipbus control.
MGT quad ipbus control.
in delay_cntr_2 std_logic_vector( 3 downto 0)
first stage delay count of gt2
in qpll_lock std_logic
qpll lock of the MGT if high
out mgt_enable std_logic_vector( 3 downto 0)
mgt enable of the quad
out softreset_rx std_logic
rx soft reset of the quad
in clk40 std_logic
fabric clock of 40MHz
in bc_cntr_1 std_logic_vector( 6 downto 0)
bc value of gt1
in ipb_rst std_logic
ipbus reset
out ram_data_gt0 std_logic_vector( 227 downto 0)
ram_data from the plyback ram gt0
in BCR_in std_logic
BCR from TTC information.
in delay_cntr_1 std_logic_vector( 3 downto 0)
first stage delay count of gt1
in rx_pd std_logic_vector( 3 downto 0)
power control for rx side of the mgt
in tx_resetdone std_logic_vector( 3 downto 0)
tx reset done of the quad if high is done
in rx_realign std_logic_vector( 3 downto 0)
rx realign status
out bc_reg_sel std_logic_vector( 15 downto 0)
BC level mux setting value.
in crc_error std_logic_vector( 3 downto 0)
crc error of the quad
in tx_pd std_logic_vector( 3 downto 0)
power control for tx side of the mgt
in bc_mux_cntr_3 std_logic_vector( 6 downto 0)
bc value after the mux gt3
out loopback std_logic_vector( 2 downto 0)
Loopback Ports.
out ram_data_gt2 std_logic_vector( 227 downto 0)
ram_data from the plyback ram gt2
in rxclk280 std_logic_vector( 3 downto 0)
rxclk
in bc_cntr_0 std_logic_vector( 6 downto 0)
bc value of gt0
in bc_mux_cntr_1 std_logic_vector( 6 downto 0)
bc value after the mux gt1
out mux_sel std_logic_vector( 15 downto 0)
first stage sync mux setting value
in tx_bufstatus std_logic_vector( 7 downto 0)
tx buffer status
in delay_cntr_3 std_logic_vector( 3 downto 0)
first stage delay count of gt3
out ram_data_gt3 std_logic_vector( 227 downto 0)
ram_data from the plyback ram gt3
in rx_resetdone std_logic_vector( 3 downto 0)
rx reset done of the quad if high is done
in tx_fsm_resetdone std_logic_vector( 3 downto 0)
tx fsm reset done of the quad if high is done
in rx_byteisaligned std_logic_vector( 3 downto 0)
RX Byte and Word Alignment.
in delay_cntr_0 std_logic_vector( 3 downto 0)
first stage delay count of gt0
out notable_error std_logic_vector( 3 downto 0)
notable_error
in clk280 std_logic
fabric clock 280MHz
in rx_disperr std_logic_vector( 15 downto 0)
rx disperr error
in ipb_clk std_logic
ipbus clock
in bc_cntr_2 std_logic_vector( 6 downto 0)
bc value of gt2
in rxdata_gt3 std_logic_vector( 31 downto 0)
rx_data from gt3
out ipb_out ipb_rbus
IPBus output bus going from slaves to master.
in rx_fsm_resetdone std_logic_vector( 3 downto 0)
rx fsm reset done of the quad if high is done
in bc_cntr_3 std_logic_vector( 6 downto 0)
bc value of gt3
out disperr_error std_logic_vector( 3 downto 0)
disperr_error
in bc_mux_cntr_0 std_logic_vector( 6 downto 0)
bc value after the mux gt0
in ipb_in ipb_wbus
IPBus input bus going from master to slaves.
in rxdata_gt0 std_logic_vector( 31 downto 0)
rx_data from gt0
in encode_error std_logic_vector( 15 downto 0)
B/10B Decoder error.
in bc_mux_cntr_2 std_logic_vector( 6 downto 0)
bc value after the mux gt2
in qpll_refclklost std_logic
qpll refrence clcok lost if high
in rxdata_gt2 std_logic_vector( 31 downto 0)
rx_data from gt2
out softreset_tx std_logic
tx soft reset of the quad
out ram_data_gt1 std_logic_vector( 227 downto 0)
ram_data from the plyback ram gt1
in rxdata_gt1 std_logic_vector( 31 downto 0)
rx_data from gt1