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

Back to eFEX documentation
mgt_slaves.vhd
Go to the documentation of this file.
1 
21 
24 
25 library IEEE;
26 use IEEE.STD_LOGIC_1164.all;
27 use ieee.numeric_std.all;
28 library work;
29 library ipbus_lib;
30 use ipbus_lib.ipbus.all;
31 use work.ipbus_decode_efex_mgt_top.all;
32 
34 entity mgt_slaves is
35  generic (
37  MGT_QUAD_ENABLE : std_logic_vector(19 downto 0) := x"00000";
39  MGT_USE_OTHER_CLK : std_logic_vector(19 downto 0) := x"00000";
41  MGT_TX_POWER : std_logic_vector(79 downto 0) := (others => '0');
43  MGT_RX_POWER : std_logic_vector(79 downto 0) := (others => '0')
44  );
45  port (
47  clk280_tx : in std_logic_vector(79 downto 0);
49  clk280_rx : in std_logic_vector(79 downto 0);
51  clk280 : in std_logic ;
53  clk40 : in std_logic;
55  BCR_in : in std_logic;
57  ipb_clk : in std_logic;
59  ipb_rst : in std_logic;
61  ipb_in : in ipb_wbus;
63  ipb_out : out ipb_rbus;
65  loopback : out std_logic_vector(59 downto 0); -- 3 bits per quad
67  softreset_tx : out std_logic_vector(19 downto 0);
69  softreset_rx : out std_logic_vector(19 downto 0);
71  mgt_enable : out std_logic_vector(79 downto 0);
73  qpll_lock : in std_logic_vector(19 downto 0);
75  qpll_refclklost : in std_logic_vector(19 downto 0);
77  phase_mux : out std_logic_vector(319 downto 0);
79  bc_cntr_0 : in std_logic_vector(139 downto 0);
81  bc_cntr_1 : in std_logic_vector(139 downto 0);
83  bc_cntr_2 : in std_logic_vector(139 downto 0);
85  bc_cntr_3 : in std_logic_vector(139 downto 0);
87  bc_mux_cntr_0 : in std_logic_vector(139 downto 0);
89  bc_mux_cntr_1 : in std_logic_vector(139 downto 0);
91  bc_mux_cntr_2 : in std_logic_vector(139 downto 0);
93  bc_mux_cntr_3 : in std_logic_vector(139 downto 0);
94 
95  --gt channel
97  delay_cntr : in std_logic_vector (319 downto 0);
99  BC_Reg_sel : out std_logic_vector (319 downto 0);
101  mux_sel : out std_logic_vector (319 downto 0);
103  rx_resetdone : in std_logic_vector (79 downto 0);
105  rx_fsm_resetdone : in std_logic_vector (79 downto 0);
107  rx_byteisaligned : in std_logic_vector (79 downto 0);
109  crc_error_chan : in std_logic_vector (79 downto 0);
111  tx_resetdone : in std_logic_vector (79 downto 0);
113  tx_fsm_resetdone : in std_logic_vector (79 downto 0);
115  tx_bufstatus : in std_logic_vector (159 downto 0);
117  rx_realign : in std_logic_vector (79 downto 0);
119  rx_disperr : in std_logic_vector (319 downto 0);
121  encode_error : in std_logic_vector (319 downto 0);
123  kchar_mgt : out std_logic_vector (79 downto 0);
125  rxdata_mgt0 : in std_logic_vector (639 downto 0);
127  rxdata_mgt1 : in std_logic_vector (639 downto 0);
129  rxdata_mgt2 : in std_logic_vector (639 downto 0);
131  rxdata_mgt3 : in std_logic_vector (639 downto 0);
133  ram_data_mgt0 : out std_logic_vector (4559 downto 0);
134  ---! ram data from all channel 1 in the all channels
135  ram_data_mgt1 : out std_logic_vector (4559 downto 0);
137  ram_data_mgt2 : out std_logic_vector (4559 downto 0);
138  ---! ram data from all channel 3 in the all channels
139  ram_data_mgt3 : out std_logic_vector (4559 downto 0);
141  disperr_error : out std_logic_vector (79 downto 0);
143  notable_error : out std_logic_vector (79 downto 0)
144 
145  );
146 
147 end mgt_slaves;
148 
150 architecture Behavioral of mgt_slaves is
151 
152 --constant NSLV: positive := 16;
153  signal ipbw : ipb_wbus_array(N_SLAVES-1 downto 0);
154  signal ipbr, ipbr_d : ipb_rbus_array(N_SLAVES-1 downto 0);
155  signal clock : std_logic_vector(79 downto 0);
156 
157  -- ipbus number assignment, here we link the constants defined in the IPbus address map with the array used in the for generate
158  -- we should try and keep this the same for every FPGA, but if that it not possible we can define it in a different file and
159  -- make it FPGA dependent
160 
161  type MGT_IPBUS_NUMBER is array(19 downto 0) of integer;
162  constant mgt_n : MGT_IPBUS_NUMBER := (N_SLV_MGT_219, N_SLV_MGT_218, N_SLV_MGT_217, N_SLV_MGT_216, N_SLV_MGT_215,
163  N_SLV_MGT_214, N_SLV_MGT_213, N_SLV_MGT_212, N_SLV_MGT_211, N_SLV_MGT_210,
164  N_SLV_MGT_119, N_SLV_MGT_118, N_SLV_MGT_117, N_SLV_MGT_116, N_SLV_MGT_115,
165  N_SLV_MGT_114, N_SLV_MGT_113, N_SLV_MGT_112, N_SLV_MGT_111, N_SLV_MGT_110);
166 
167 begin
168 
169  mgt_fabric : entity ipbus_lib.ipbus_fabric_sel
170  generic map(NSLV => N_SLAVES, --defined in ipbus_decode_mgt_slvs
171  SEL_WIDTH => ipbus_sel_width)
172  port map(
173  ipb_in => ipb_in,
174  ipb_out => ipb_out,
175  sel => ipbus_sel_efex_mgt_top(ipb_in.ipb_addr),
176  ipb_to_slaves => ipbw,
177  ipb_from_slaves => ipbr
178  );
179 
180  QUAD_FOR : for i in 0 to 19 generate
181 
182  -- Use rx clock in case the MGT is using the other clock and so it is transmitter only
183  -- Maybe this should be done using the rx power instead as the new board will not have any slow MGT
184  clock(i*4+3 downto i*4) <= Clk280_rx(i*4+3 downto i*4) when MGT_USE_OTHER_CLK(i) = '0' else
185  Clk280_tx(i*4+3 downto i*4);
186 
187  quad : entity work.mgt_quad_slaves
188  generic map(ENABLE => MGT_QUAD_ENABLE(i)
189  )
190  port map (
191  rxclk280 => clock(i*4+3 downto i*4),
192  clk280 => clk280,
193  clk40 => clk40,
194  BCR_in => BCR_in,
195  ipb_clk => ipb_clk,
196  ipb_rst => ipb_rst,
197  ipb_in => ipbw(mgt_n(i)),
198  ipb_out => ipbr(mgt_n(i)),
199  tx_pd => MGT_TX_POWER(i*4+3 downto i*4), --79
200  rx_pd => MGT_RX_POWER(i*4+3 downto i*4), --79
201  loopback => loopback(i*3+2 downto i*3), --59
202  -- error_counter => error_counter(i*64+63 downto i*64), --1279
203  bc_reg_sel => bc_reg_sel(i*16+15 downto i*16), --319
204  mux_sel => mux_sel(i*16+15 downto i*16), --319
205  bc_cntr_0 => bc_cntr_0(i*7+6 downto i*7), --99
206  bc_cntr_1 => bc_cntr_1(i*7+6 downto i*7), --99
207  bc_cntr_2 => bc_cntr_2(i*7+6 downto i*7), --99
208  bc_cntr_3 => bc_cntr_3(i*7+6 downto i*7), --99
209  bc_mux_cntr_0 => bc_mux_cntr_0(i*7+6 downto i*7), --99
210  bc_mux_cntr_1 => bc_mux_cntr_1(i*7+6 downto i*7), --99
211  bc_mux_cntr_2 => bc_mux_cntr_2(i*7+6 downto i*7), --99
212  bc_mux_cntr_3 => bc_mux_cntr_3(i*7+6 downto i*7), --99
213  delay_cntr_0 => delay_cntr(i*16+3 downto i*16+0), --319
214  delay_cntr_1 => delay_cntr(i*16+7 downto i*16+4), --319
215  delay_cntr_2 => delay_cntr(i*16+11 downto i*16+8), --319
216  delay_cntr_3 => delay_cntr(i*16+15 downto i*16+12), --319
217  softreset_tx => softreset_tx(i), --19
218  softreset_rx => softreset_rx(i), --19
219  mgt_enable => mgt_enable (i*4+3 downto i*4), --79
220  phase_mux => phase_mux(i*16+15 downto i*16), --319
221  qpll_lock => qpll_lock(i), --19
222  qpll_refclklost => qpll_refclklost(i), --19
223  rx_resetdone => rx_resetdone(i*4+3 downto i*4), --79
224  rx_fsm_resetdone => rx_fsm_resetdone(i*4+3 downto i*4), --79
225  rx_byteisaligned => rx_byteisaligned(i*4+3 downto i*4), --79
226  tx_resetdone => tx_resetdone(i*4+3 downto i*4), --79
227  tx_fsm_resetdone => tx_fsm_resetdone(i*4+3 downto i*4), --79
228  tx_bufstatus => tx_bufstatus(i*8+7 downto i*8),
229  rx_realign => rx_realign(i*4+3 downto i*4), --79
230  crc_error => crc_error_chan(i*4+3 downto i*4), --79
231  rx_disperr => rx_disperr(i*16+15 downto i*16), --319
232  encode_error => encode_error(i*16+15 downto i*16), --319
233  rxdata_gt0 => rxdata_mgt0 (i*32+31 downto i*32), --639
234  rxdata_gt1 => rxdata_mgt1 (i*32+31 downto i*32), --639
235  rxdata_gt2 => rxdata_mgt2 (i*32+31 downto i*32), --639
236  rxdata_gt3 => rxdata_mgt3 (i*32+31 downto i*32), --639
237 
238  ram_data_gt0 => ram_data_mgt0(i*228+227 downto i*228), --639
239  ram_data_gt1 => ram_data_mgt1(i*228+227 downto i*228), --639
240  ram_data_gt2 => ram_data_mgt2(i*228+227 downto i*228), --639
241  ram_data_gt3 => ram_data_mgt3(i*228+227 downto i*228), --639
242 
243  disperr_error => disperr_error (i*4+3 downto i*4),
244  notable_error => notable_error (i*4+3 downto i*4)
245  );
246  end generate;
247 
248 
249 
250 end Behavioral;
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
MGT ipbus control.
Definition: mgt_slaves.vhd:150
MGT ipbus control.
Definition: mgt_slaves.vhd:34
out ram_data_mgt0 std_logic_vector( 4559 downto 0)
ram data from all channel 0 in the all channels
Definition: mgt_slaves.vhd:133
in delay_cntr std_logic_vector( 319 downto 0)
first stage delay counters
Definition: mgt_slaves.vhd:97
out kchar_mgt std_logic_vector( 79 downto 0)
kchar_mgt all MGTs
Definition: mgt_slaves.vhd:123
in rx_fsm_resetdone std_logic_vector( 79 downto 0)
rx_fsm_resetdone for all MGTs
Definition: mgt_slaves.vhd:105
in bc_mux_cntr_2 std_logic_vector( 139 downto 0)
bc_mux_cntr_2 for gt2 of the MGTs
Definition: mgt_slaves.vhd:91
in clk40 std_logic
fabric clock of 40MHz
Definition: mgt_slaves.vhd:53
in ipb_rst std_logic
ipbus reset
Definition: mgt_slaves.vhd:59
in rxdata_mgt1 std_logic_vector( 639 downto 0)
rx data from all gt1 in the all QAUDs
Definition: mgt_slaves.vhd:127
in BCR_in std_logic
BCR from TTC information.
Definition: mgt_slaves.vhd:55
in tx_fsm_resetdone std_logic_vector( 79 downto 0)
tx_fsm_resetdone for all MGTs
Definition: mgt_slaves.vhd:113
in qpll_refclklost std_logic_vector( 19 downto 0)
qpll_refclklost for the quads
Definition: mgt_slaves.vhd:75
in crc_error_chan std_logic_vector( 79 downto 0)
crc errors for all MGTs
Definition: mgt_slaves.vhd:109
in rxdata_mgt0 std_logic_vector( 639 downto 0)
rx data from all gt0 in the all QAUDs
Definition: mgt_slaves.vhd:125
in qpll_lock std_logic_vector( 19 downto 0)
qpllock for the quads
Definition: mgt_slaves.vhd:73
in rxdata_mgt3 std_logic_vector( 639 downto 0)
rx data from all gt3 in the all QAUDs
Definition: mgt_slaves.vhd:131
in clk280_rx std_logic_vector( 79 downto 0)
rx clock of the all the mgts
Definition: mgt_slaves.vhd:49
in rx_realign std_logic_vector( 79 downto 0)
rx_realign for all MGTs
Definition: mgt_slaves.vhd:117
in bc_cntr_3 std_logic_vector( 139 downto 0)
bc cntr for all the gt3 of the MGTs
Definition: mgt_slaves.vhd:85
out softreset_tx std_logic_vector( 19 downto 0)
softreset_tx for all the Quads
Definition: mgt_slaves.vhd:67
in bc_cntr_0 std_logic_vector( 139 downto 0)
bc cntr for all the gt0 of the MGTs
Definition: mgt_slaves.vhd:79
out ram_data_mgt2 std_logic_vector( 4559 downto 0)
ram data from all channel 2 in the all channels
Definition: mgt_slaves.vhd:137
MGT_RX_POWER std_logic_vector( 79 downto 0) :=( others => '0')
power down to rx
Definition: mgt_slaves.vhd:44
in rxdata_mgt2 std_logic_vector( 639 downto 0)
rx data from all gt2 in the all QAUDs
Definition: mgt_slaves.vhd:129
in bc_cntr_1 std_logic_vector( 139 downto 0)
bc cntr for all the gt1 of the MGTs
Definition: mgt_slaves.vhd:81
in bc_mux_cntr_1 std_logic_vector( 139 downto 0)
bc_mux_cntr_1 for gt1 of the MGTs
Definition: mgt_slaves.vhd:89
out loopback std_logic_vector( 59 downto 0)
loopback setting for all the MGTs
Definition: mgt_slaves.vhd:65
in rx_byteisaligned std_logic_vector( 79 downto 0)
rx_byteisaligned for all MGTs
Definition: mgt_slaves.vhd:107
in rx_resetdone std_logic_vector( 79 downto 0)
rx resetdone for all MGTs
Definition: mgt_slaves.vhd:103
in bc_cntr_2 std_logic_vector( 139 downto 0)
bc cntr for all the gt2 of the MGTs
Definition: mgt_slaves.vhd:83
out disperr_error std_logic_vector( 79 downto 0)
disperr_error in all the MGTs
Definition: mgt_slaves.vhd:141
out mgt_enable std_logic_vector( 79 downto 0)
mgt enable for the MGTs
Definition: mgt_slaves.vhd:71
out phase_mux std_logic_vector( 319 downto 0)
phase_mux
Definition: mgt_slaves.vhd:77
in tx_resetdone std_logic_vector( 79 downto 0)
tx resetdone for all MGTs
Definition: mgt_slaves.vhd:111
in tx_bufstatus std_logic_vector( 159 downto 0)
tx_bufstatus for all MGTs
Definition: mgt_slaves.vhd:115
in clk280_tx std_logic_vector( 79 downto 0)
tx clock of the all the mgts
Definition: mgt_slaves.vhd:47
out BC_Reg_sel std_logic_vector( 319 downto 0)
mux setting for BC mux
Definition: mgt_slaves.vhd:99
in clk280 std_logic
fabric clock of clk280MHz
Definition: mgt_slaves.vhd:51
MGT_QUAD_ENABLE std_logic_vector( 19 downto 0) := x"00000"
enable the quad in the design
Definition: mgt_slaves.vhd:37
in ipb_clk std_logic
ipbus clock
Definition: mgt_slaves.vhd:57
in bc_mux_cntr_0 std_logic_vector( 139 downto 0)
bc_mux_cntr_0 for gt0 of the MGTs
Definition: mgt_slaves.vhd:87
out ipb_out ipb_rbus
IPBus output bus going from slaves to master.
Definition: mgt_slaves.vhd:63
out mux_sel std_logic_vector( 319 downto 0)
mux setting for the first stage mux
Definition: mgt_slaves.vhd:101
MGT_USE_OTHER_CLK std_logic_vector( 19 downto 0) := x"00000"
tx or rx clock selection
Definition: mgt_slaves.vhd:39
out notable_error std_logic_vector( 79 downto 0)
d notable_error in all the MGTs
Definition: mgt_slaves.vhd:145
in encode_error std_logic_vector( 319 downto 0)
encode_error for all MGTs
Definition: mgt_slaves.vhd:121
in rx_disperr std_logic_vector( 319 downto 0)
rx_disperr for all MGTs
Definition: mgt_slaves.vhd:119
in bc_mux_cntr_3 std_logic_vector( 139 downto 0)
bc_mux_cntr_3 for gt3 of the MGTs
Definition: mgt_slaves.vhd:93
in ipb_in ipb_wbus
IPBus input bus going from master to slaves.
Definition: mgt_slaves.vhd:61
out softreset_rx std_logic_vector( 19 downto 0)
softreset_rx for all the Quads
Definition: mgt_slaves.vhd:69
MGT_TX_POWER std_logic_vector( 79 downto 0) :=( others => '0')
power down to tx
Definition: mgt_slaves.vhd:41