9 use IEEE.STD_LOGIC_1164.
ALL;
10 use ieee.numeric_std.
all;
12 use ipbus_lib.ipbus.
all;
13 use ipbus_lib.ipbus_reg_types.
all;
14 library infrastructure_lib;
37 aurora_1_gt0_txctl : out std_logic_vector(23 downto 0);
38 aurora_1_gt1_txctl : out std_logic_vector(23 downto 0);
39 aurora_1_gt2_txctl : out std_logic_vector(23 downto 0);
40 aurora_1_gt3_txctl : out std_logic_vector(23 downto 0);
43 aurora_2_gt0_txctl : out std_logic_vector(23 downto 0);
44 aurora_2_gt1_txctl : out std_logic_vector(23 downto 0);
45 aurora_2_gt2_txctl : out std_logic_vector(23 downto 0);
46 aurora_2_gt3_txctl : out std_logic_vector(23 downto 0);
49 control_busy_bus : in std_logic_vector(7 downto 0);
50 processor_busy_bus : in std_logic_vector(7 downto 0);
60 type integer_array is array(natural range <>) of integer range 0 to N_SLAVES;
63 signal ipbw: ipb_wbus_array(N_SLAVES-1 downto 0);
64 signal ipbr: ipb_rbus_array(N_SLAVES-1 downto 0);
65 signal aurora_status_bus: mgt_data_array(1 downto 0);
66 signal aurora_gt_txctl_bus: mgt_data_array(7 downto 0);
67 signal counter_control, bc_count, bc_count_ipb: std_logic_vector(31 downto 0);
68 signal update_counter_reg_1, update_counter_reg_2, update_counter_reg_3, update_counter_bcr, update_counter_reg: std_logic;
69 signal err_cntr_rst, status_cntr_rst, xoff_cntr_rst: std_logic;
71 signal ttc_bits: std_logic_vector(3 downto 0);
72 signal ttc_counters, ttc_counters_ipb: mgt_data_array(3 downto 0);
73 signal last_l1id, input_data_l1id, last_l1id_ipb, input_data_l1id_ipb: std_logic_vector(31 downto 0);
75 signal rod_status, last_rod_status, rod_pulse: std_logic_vector(7 downto 0);
76 signal rod1_tx_reset, rod2_tx_reset: std_logic_vector(1 downto 0);
77 signal rod_counters, rod_counters_ipb: mgt_data_array(7 downto 0);
79 signal control_xoff_reg, control_busy_reg, processor_busy_reg: std_logic_vector(15 downto 0);
80 signal busy_xoff_bus_a, busy_xoff_bus_b, busy_xoff_bus_c, busy_xoff_reset_bus, busy_xoff_count_bus, busy_xoff_assert_bus: std_logic_vector(27 downto 0);
81 signal busy_xoff_total_counter_bus, busy_xoff_active_counter_bus, busy_xoff_total_counter_bus_ipb, busy_xoff_active_counter_bus_ipb: mgt_data_array(27 downto 0);
82 signal busy_xoff_assert_counter_bus, busy_xoff_assert_counter_bus_ipb: mgt_data_array(27 downto 0);
84 constant aurora_status_slv_bus: integer_array(1 downto 0) := (N_SLV_AURORA_STATUS_2, N_SLV_AURORA_STATUS_1);
85 constant aurora_gt_txctl_slv_bus: integer_array(7 downto 0) := (
86 N_SLV_AURORA2_GT3_TXCTRL, N_SLV_AURORA2_GT2_TXCTRL, N_SLV_AURORA2_GT1_TXCTRL, N_SLV_AURORA2_GT0_TXCTRL,
87 N_SLV_AURORA1_GT3_TXCTRL, N_SLV_AURORA1_GT2_TXCTRL, N_SLV_AURORA1_GT1_TXCTRL, N_SLV_AURORA1_GT0_TXCTRL);
88 constant rod_link_status_slv_bus: integer_array(1 downto 0) := (N_SLV_ROD_LINK_STATUS_ROD1, N_SLV_ROD_LINK_STATUS_ROD0);
89 constant busy_xoff_slv_bus: integer_array(13 downto 0) := (
90 N_SLV_PROCESSOR_BUSY_STATUS_P3, N_SLV_PROCESSOR_BUSY_STATUS_P2, N_SLV_PROCESSOR_BUSY_STATUS_P1, N_SLV_PROCESSOR_BUSY_STATUS_P0,
91 N_SLV_CONTROL_BUSY_STATUS_P3, N_SLV_CONTROL_BUSY_STATUS_P2, N_SLV_CONTROL_BUSY_STATUS_P1, N_SLV_CONTROL_BUSY_STATUS_P0,
92 N_SLV_CONTROL_XOFF_STATUS_P3, N_SLV_CONTROL_XOFF_STATUS_P2, N_SLV_CONTROL_XOFF_STATUS_P1, N_SLV_CONTROL_XOFF_STATUS_P0,
93 N_SLV_BACKPLANE_XOFF_STATUS_ROD1, N_SLV_BACKPLANE_XOFF_STATUS_ROD0);
95 attribute ASYNC_REG: string;
96 attribute ASYNC_REG of rod1_tx_reset: signal is "TRUE";
97 attribute ASYNC_REG of rod2_tx_reset: signal is "TRUE";
98 attribute ASYNC_REG of control_xoff_reg: signal is "TRUE";
99 attribute ASYNC_REG of control_busy_reg: signal is "TRUE";
100 attribute ASYNC_REG of processor_busy_reg: signal is "TRUE";
106 aurora_1_gt0_txctl<= aurora_gt_txctl_bus(0)(23 downto 0);
107 aurora_1_gt1_txctl<= aurora_gt_txctl_bus(1)(23 downto 0);
108 aurora_1_gt2_txctl<= aurora_gt_txctl_bus(2)(23 downto 0);
109 aurora_1_gt3_txctl<= aurora_gt_txctl_bus(3)(23 downto 0);
111 aurora_2_gt0_txctl<= aurora_gt_txctl_bus(4)(23 downto 0);
112 aurora_2_gt1_txctl<= aurora_gt_txctl_bus(5)(23 downto 0);
113 aurora_2_gt2_txctl<= aurora_gt_txctl_bus(6)(23 downto 0);
114 aurora_2_gt3_txctl<= aurora_gt_txctl_bus(7)(23 downto 0);
116 fabric_cntrl_backplane:
entity ipbus_lib.ipbus_fabric_sel
117 generic map(NSLV => N_SLAVES, SEL_WIDTH => IPBUS_SEL_WIDTH
)
121 sel => ipbus_sel_efex_cntrl_backplane
(ipb_in.ipb_addr
),
122 ipb_to_slaves => ipbw,
123 ipb_from_slaves => ipbr
126 control:
entity ipbus_lib.ipbus_ctrlreg_v
127 generic map (N_CTRL =>
2, N_STAT =>
1)
131 ipbus_in => ipbw
(N_SLV_CONTROL
),
132 ipbus_out => ipbr
(N_SLV_CONTROL
),
134 q
(1) => counter_control,
135 d
(0) => bc_count_ipb,
136 ctrl_default
(0) => x"0000c802",
137 ctrl_default
(1) => x"002bd702",
141 ttc_status:
entity ipbus_lib.ipbus_ctrlreg_v
142 generic map (N_CTRL =>
0, N_STAT =>
6)
146 ipbus_in => ipbw
(N_SLV_TTC_STATUS
),
147 ipbus_out => ipbr
(N_SLV_TTC_STATUS
),
149 d
(0) => ttc_counters_ipb
(0),
150 d
(1) => ttc_counters_ipb
(3),
151 d
(2) => ttc_counters_ipb
(1),
152 d
(3) => ttc_counters_ipb
(2),
153 d
(4) => last_l1id_ipb,
154 d
(5) => input_data_l1id_ipb,
158 aurora_status_generate_block: for i in 0 to 1 generate
159 aurora_status:
entity ipbus_lib.ipbus_ctrlreg_v
160 generic map(N_CTRL =>
0, N_STAT =>
1)
164 ipbus_in => ipbw
(aurora_status_slv_bus
(i
)),
165 ipbus_out => ipbr
(aurora_status_slv_bus
(i
)),
166 d
(0) => aurora_status_bus
(i
),
170 end generate aurora_status_generate_block;
172 aurora_gt_txctl_generate_block: for i in 0 to 7 generate
173 aurora_gt_txctl:
entity ipbus_lib.ipbus_ctrlreg_v
174 generic map(N_CTRL =>
1, N_STAT =>
0)
178 ipbus_in => ipbw
(aurora_gt_txctl_slv_bus
(i
)),
179 ipbus_out => ipbr
(aurora_gt_txctl_slv_bus
(i
)),
180 d =>
(others =>
(others => '0'
)),
181 ctrl_default
(0) => x"00000c07",
182 q
(0) => aurora_gt_txctl_bus
(i
),
185 end generate aurora_gt_txctl_generate_block;
187 rod_link_status_generate_block: for i in 0 to 1 generate
188 rod_link_status:
entity ipbus_lib.ipbus_ctrlreg_v
189 generic map (N_CTRL =>
0, N_STAT =>
4)
193 ipbus_in => ipbw
(rod_link_status_slv_bus
(i
)),
194 ipbus_out => ipbr
(rod_link_status_slv_bus
(i
)),
196 d
(0) => rod_counters_ipb
(i*4 +
2),
197 d
(1) => rod_counters_ipb
(i*4 +
1),
198 d
(2) => rod_counters_ipb
(i*4
),
199 d
(3) => rod_counters_ipb
(i*4 +
3),
202 end generate rod_link_status_generate_block;
204 busy_xoff_status_generate_block: for i in 0 to 13 generate
205 busy_xoff_status:
entity ipbus_lib.ipbus_ctrlreg_v
206 generic map (N_CTRL =>
0, N_STAT =>
6)
210 ipbus_in => ipbw
(busy_xoff_slv_bus
(i
)),
211 ipbus_out => ipbr
(busy_xoff_slv_bus
(i
)),
213 d
(0) => busy_xoff_total_counter_bus_ipb
(2*i
),
214 d
(1) => busy_xoff_active_counter_bus_ipb
(2*i
),
215 d
(2) => busy_xoff_assert_counter_bus_ipb
(2*i
),
216 d
(3) => busy_xoff_total_counter_bus_ipb
(2*i +
1),
217 d
(4) => busy_xoff_active_counter_bus_ipb
(2*i +
1),
218 d
(5) => busy_xoff_assert_counter_bus_ipb
(2*i +
1),
221 end generate busy_xoff_status_generate_block;
223 update_counter_bcr_block:
process(
clk)
224 variable bcr_counter, bcr_match: unsigned(23 downto 0) := (Others => '0');
226 if rising_edge(clk) then
227 bcr_match := unsigned(counter_control(31 downto 8));
229 update_counter_bcr <= '0';
230 bcr_counter := (Others => '0');
232 if (bcr_counter >= bcr_match) then
233 update_counter_bcr <= counter_control(1);
234 bcr_counter := (Others => '0');
236 update_counter_bcr <= '0';
237 bcr_counter := bcr_counter + 1;
240 update_counter_bcr <= '0';
243 end process update_counter_bcr_block;
245 register_update_control:
process(
clk)
247 if rising_edge(clk) then
248 update_counter_reg_1 <= counter_control(0);
249 update_counter_reg_2 <= update_counter_reg_1;
250 update_counter_reg_3 <= counter_control(2);
251 if (update_counter_reg_1 = '1' and update_counter_reg_2 = '0') or (update_counter_reg_3 = '1') or (update_counter_bcr = '1') then
252 update_counter_reg <= '1';
254 update_counter_reg <= '0';
257 end process register_update_control;
259 register_update:
process(
clk)
261 if rising_edge(clk) then
262 if update_counter_reg = '1' then
263 ttc_counters_ipb <= ttc_counters;
264 last_l1id_ipb <= last_l1id;
265 input_data_l1id_ipb <= input_data_l1id;
266 rod_counters_ipb <= rod_counters;
267 bc_count_ipb <= bc_count;
268 busy_xoff_total_counter_bus_ipb <= busy_xoff_total_counter_bus;
269 busy_xoff_active_counter_bus_ipb <= busy_xoff_active_counter_bus;
270 busy_xoff_assert_counter_bus_ipb <= busy_xoff_assert_counter_bus;
273 end process register_update;
275 reset_control:
process(
clk)
277 if rising_edge(clk) then
278 if (rst = '1') or (counter_control(4) = '1') then
283 if (rst = '1') or (counter_control(5) = '1') then
284 status_cntr_rst <= '1';
286 status_cntr_rst <= '0';
288 if (rst = '1') or (counter_control(6) = '1') then
289 xoff_cntr_rst <= '1';
291 xoff_cntr_rst <= '0';
294 end process reset_control;
296 ttc_registers:
process(
clk)
298 if rising_edge(clk) then
299 if (status_cntr_rst = '1') then
300 last_l1id <= (Others => '0');
301 input_data_l1id <= (Others => '0');
308 ttc_bits(2 downto 0) <= ttc_info(2 downto 0);
315 end process ttc_registers;
317 ttc_counter_generate_block: for i in 0 to 3 generate
318 ttc_counter_block :
entity infrastructure_lib.
cntr_generic
319 generic map (width =>
32, WRAPAROUND => False
)
323 RST => status_cntr_rst,
324 Q => ttc_counters
(i
));
325 end generate ttc_counter_generate_block;
327 rod1_tx_reset_block:
process(
clk)
329 if rising_edge(clk) then
332 end process rod1_tx_reset_block;
334 rod2_tx_reset_block:
process(
clk)
336 if rising_edge(clk) then
339 end process rod2_tx_reset_block;
341 rod_registers:
process(
clk)
343 if rising_edge(clk) then
344 if (status_cntr_rst = '1') then
345 rod_status <= (Others => '0');
346 last_rod_status <= (Others => '0');
347 rod_pulse <= (Others => '0');
352 rod_status(2 downto 0) <= rod_status(2 downto 0);
354 rod_status(3) <= rod1_tx_reset(1);
358 rod_status(6 downto 4) <= rod_status(6 downto 4);
360 rod_status(7) <= rod2_tx_reset(1);
362 last_rod_status <= rod_status;
363 rod_pulse <= rod_status and not last_rod_status;
365 end process rod_registers;
367 rod_counter_generate_block : for i in 0 to 7 generate
368 rod_counter_block :
entity infrastructure_lib.
cntr_generic
369 generic map (width =>
32, WRAPAROUND => False
)
373 RST => status_cntr_rst,
374 Q => rod_counters
(i
));
375 end generate rod_counter_generate_block;
378 generic map (width =>
32, WRAPAROUND => False
)
382 RST => xoff_cntr_rst,
386 control_xoff_block:
process(
clk)
388 if rising_edge(clk) then
391 end process control_xoff_block;
393 control_busy_block:
process(
clk)
395 if rising_edge(clk) then
396 control_busy_reg <= control_busy_reg(7 downto 0) & control_busy_bus;
398 end process control_busy_block;
400 processor_busy_block:
process(
clk)
402 if rising_edge(clk) then
403 processor_busy_reg <= processor_busy_reg(7 downto 0) & processor_busy_bus;
405 end process processor_busy_block;
407 busy_xoff_registers:
process(
clk)
409 if rising_edge(clk) then
412 busy_xoff_bus_a(11 downto 4) <= control_xoff_reg(15) & control_xoff_reg(11) & control_xoff_reg(14) & control_xoff_reg(10) & control_xoff_reg(13) & control_xoff_reg(9) & control_xoff_reg(12) & control_xoff_reg(8);
413 busy_xoff_bus_a(19 downto 12) <= control_busy_reg(15) & control_busy_reg(11) & control_busy_reg(14) & control_busy_reg(10) & control_busy_reg(13) & control_busy_reg(9) & control_busy_reg(12) & control_busy_reg(8);
414 busy_xoff_bus_a(27 downto 20) <= processor_busy_reg(15) & processor_busy_reg(11) & processor_busy_reg(14) & processor_busy_reg(10) & processor_busy_reg(13) & processor_busy_reg(9) & processor_busy_reg(12) & processor_busy_reg(8);
415 busy_xoff_bus_b <= busy_xoff_bus_a;
416 busy_xoff_bus_c <= busy_xoff_bus_b;
417 busy_xoff_count_bus <= busy_xoff_bus_c;
418 if (xoff_cntr_rst = '1') then
419 busy_xoff_reset_bus <= (Others => '1');
420 busy_xoff_assert_bus <= (Others => '0');
422 busy_xoff_reset_bus <= busy_xoff_bus_a and not busy_xoff_bus_b;
423 busy_xoff_assert_bus <= busy_xoff_bus_a and not busy_xoff_bus_b;
426 end process busy_xoff_registers;
428 busy_xoff_counter_generate_block : for i in 0 to 27 generate
429 total_counter_block :
entity infrastructure_lib.
cntr_generic
430 generic map (width =>
32, WRAPAROUND => False
)
432 CE => busy_xoff_count_bus
(i
),
434 RST => xoff_cntr_rst,
435 Q => busy_xoff_total_counter_bus
(i
));
437 active_counter_block :
entity infrastructure_lib.
cntr_generic
438 generic map (width =>
32, WRAPAROUND => False
)
440 CE => busy_xoff_count_bus
(i
),
442 RST => busy_xoff_reset_bus
(i
),
443 Q => busy_xoff_active_counter_bus
(i
));
445 assert_counter_block :
entity infrastructure_lib.
cntr_generic
446 generic map (width =>
32, WRAPAROUND => False
)
448 CE => busy_xoff_assert_bus
(i
),
450 RST => xoff_cntr_rst,
451 Q => busy_xoff_assert_counter_bus
(i
));
452 end generate busy_xoff_counter_generate_block;
out input_data_readout_control std_logic_vector( 31 downto 0)
Privileged readout control.
in ipb_rst std_logic
ipbus reset
in aurora_status_1 std_logic_vector( 31 downto 0)
aurora status hub1
in clk std_logic
TTC fabric clock.
in control_xoff_bus std_logic_vector( 7 downto 0)
XOff and BUSY.
in aurora_status_2 std_logic_vector( 31 downto 0)
aurora status hub2
in ipb_clk std_logic
ipbus clock
out ipb_out ipb_rbus
IPBus output bus going from slaves to master.
in ipb_in ipb_wbus
IPBus input bus going from master to slaves.
in rst std_logic
fabric reset
in ttc_info std_logic_vector( 35 downto 0)
ttc_L1ID & ttc_ECRID & ttc_pr_rdout & ttc_ECR & ttc_BCR & ttc_L1A
Generic Counter for process FPGA.
in CLK STD_LOGIC
Clock signal input.
in CE STD_LOGIC
Enable signal input.
out Q STD_LOGIC_VECTOR( width- 1 downto 0)
Counter Output signal.
in RST STD_LOGIC
Reset signal input.