23 use IEEE.STD_LOGIC_1164.
ALL;
27 use work.ipbus_decode_L1CaloHubRodBackplaneRegisters.
all;
32 use IEEE.STD_LOGIC_UNSIGNED.
ALL;
41 ipb_clk: in std_logic;
42 ipb_rst: in std_logic;
44 ipb_out: out ipb_rbus;
46 pp_clock : in std_logic;
47 clk_40 : in std_logic;
48 clk_160 : in std_logic;
49 clk_125 : in std_logic;
50 rt_clk : in std_logic;
51 ck_pll_lock : in std_logic;
52 timer_reset : in std_logic;
55 CK_INT : in STD_LOGIC;
56 SMBALERT_B : in STD_LOGIC;
57 T_WRN_B : in STD_LOGIC;
60 channel_up : in STD_LOGIC_VECTOR (23 downto 0);
61 chan_enable : out STD_LOGIC_VECTOR (23 downto 0);
62 first_chan : out STD_LOGIC_vector(4 downto 0);
63 last_chan : out STD_LOGIC_vector(4 downto 0);
64 ro_status : in STD_LOGIC_VECTOR (7 downto 0);
66 time_count : out STD_LOGIC_VECTOR (31 downto 0);
67 tob_fifo_busy_threshold : out STD_LOGIC_VECTOR (31 downto 0);
68 bulk_fifo_busy_threshold : out STD_LOGIC_VECTOR (31 downto 0);
69 tob_fifo_xoff_threshold : out STD_LOGIC_VECTOR (31 downto 0);
70 bulk_fifo_xoff_threshold : out STD_LOGIC_VECTOR (31 downto 0);
71 backplane_control : out STD_LOGIC_VECTOR (31 downto 0);
73 chan_disable : out STD_LOGIC_VECTOR (31 downto 0);
74 combined_busy : in std_logic;
75 ro_user_clock : in std_logic
82 chan_ena :
in STD_LOGIC_VECTOR (
23 downto 0);
84 first_chan :
out STD_LOGIC_vector(
4 downto 0);
85 last_chan :
out STD_LOGIC_vector(
4 downto 0)
92 COUNTER_WIDTH_40 :
integer :=
8;
93 reset_count :
std_logic_vector(
15 downto 0) := x"
03ff";
94 count_40_term :
std_logic_vector(
7 downto 0) := x"
45";
95 count_160_term :
std_logic_vector(
7 downto 0) := x"
45"
104 clock_40 :
in STD_LOGIC;
105 clock_160 :
in STD_LOGIC;
106 clock_125 :
in STD_LOGIC;
107 reset :
in STD_LOGIC;
108 clock_160_lock :
in STD_LOGIC;
109 clk_40_good :
out std_logic;
110 clk_160_good :
out std_logic;
111 count_40 :
out std_logic_vector(counter_width_40
-1 downto 0);
112 count_160 :
out std_logic_vector(counter_width_40
-1 downto 0);
113 count_125 :
out std_logic_vector(counter_width_40
-1 downto 0)
120 signal ipbw: ipb_wbus_array(N_SLAVES - 1 downto 0);
121 signal ipbr: ipb_rbus_array(N_SLAVES - 1 downto 0);
122 signal time_counter : STD_LOGIC_VECTOR (31 downto 0);
123 signal time_count_reg : std_logic_vector( 31 downto 0);
125 signal backplane_control_reg_rst : std_logic;
126 signal backplane_control_reg_stb : std_logic;
128 signal first_chan_i : STD_LOGIC_vector(4 downto 0);
129 signal last_chan_i : STD_LOGIC_vector(4 downto 0);
130 signal first_last : STD_LOGIC_vector(31 downto 0);
132 signal chan_ena : STD_LOGIC_vector(23 downto 0);
133 signal chan_dis : STD_LOGIC_vector(31 downto 0);
134 signal ro_status_32 : STD_LOGIC_vector(31 downto 0);
136 signal count_40 : STD_LOGIC_vector(7 downto 0);
137 signal count_160 : STD_LOGIC_vector(7 downto 0);
138 signal count_125 : STD_LOGIC_vector(7 downto 0);
139 signal clk_40_good : STD_LOGIC;
140 signal clk_160_good : STD_LOGIC;
142 signal clock_status_32 : STD_LOGIC_vector(31 downto 0);
144 signal backplane_control_two : STD_LOGIC_vector(31 downto 0);
145 signal backplane_control_i : STD_LOGIC_vector(31 downto 0);
147 signal clk_test_reset : STD_LOGIC;
149 signal SMBALERT : STD_LOGIC;
150 signal T_WARN : STD_LOGIC;
152 signal busy_active_time : STD_LOGIC_vector(31 downto 0);
153 signal busy_active_time_reset : STD_LOGIC;
155 signal ro_cpll_lock : STD_LOGIC;
156 signal ro_cpll_lock_delay_1 : STD_LOGIC;
157 signal ro_cpll_lock_delay_2 : STD_LOGIC;
158 signal ro_cpll_lock_lost : STD_LOGIC;
160 signal CK_INT_delay_1 : STD_LOGIC;
161 signal CK_INT_delay_2 : STD_LOGIC;
162 signal silab_ck_int_sticky : STD_LOGIC;
165 attribute ASYNC_REG : string;
166 signal chan_enable_r1 : STD_LOGIC_vector(23 downto 0);
167 attribute ASYNC_REG of chan_enable_r1 : signal is "TRUE";
168 signal chan_enable_r2 : STD_LOGIC_vector(23 downto 0);
169 attribute ASYNC_REG of chan_enable_r2 : signal is "TRUE";
175 fabric:
entity work.ipbus_fabric_sel
178 SEL_WIDTH => IPBUS_SEL_WIDTH
)
186 sel => ipbus_sel_L1CaloHubRodBackplaneRegisters
(ipb_in.ipb_addr
),
187 ipb_to_slaves => ipbw,
188 ipb_from_slaves => ipbr
195 Time_count_value:
entity work.ipbus_syncreg_v
205 ipb_in => ipbw
(N_SLV_TIME_COUNT_VALUE
),
206 ipb_out => ipbr
(N_SLV_TIME_COUNT_VALUE
),
208 d
(0) => time_count_reg,
209 qmask =>
(others =>
(others => '1'
)),
216 Tob_fifo_busy_threshold_reg:
entity work.ipbus_reg_v
222 ipbus_in => ipbw
(N_SLV_TOB_FIFO_BUSY_THRESHOLD
),
223 ipbus_out => ipbr
(N_SLV_TOB_FIFO_BUSY_THRESHOLD
),
224 q
(0) => TOB_FIFO_BUSY_THRESHOLD
228 Tob_fifo_xoff_threshold_reg:
entity work.ipbus_reg_v
234 ipbus_in => ipbw
(N_SLV_TOB_FIFO_XOFF_THRESHOLD
),
235 ipbus_out => ipbr
(N_SLV_TOB_FIFO_XOFF_THRESHOLD
),
236 q
(0) => tob_fifo_xoff_threshold
241 Bulk_fifo_busy_threshold_reg:
entity work.ipbus_reg_v
247 ipbus_in => ipbw
(N_SLV_BULK_FIFO_BUSY_THRESHOLD
),
248 ipbus_out => ipbr
(N_SLV_BULK_FIFO_BUSY_THRESHOLD
),
249 q
(0) => bulk_fifo_busy_threshold
255 Bulk_fifo_xoff_threshold_reg:
entity work.ipbus_reg_v
261 ipbus_in => ipbw
(N_SLV_BULK_FIFO_XOFF_THRESHOLD
),
262 ipbus_out => ipbr
(N_SLV_BULK_FIFO_XOFF_THRESHOLD
),
263 q
(0) => bulk_fifo_xoff_threshold
278 backplane_control_reg:
entity work.ipbus_reg_v
281 reset => backplane_control_reg_rst,
284 ipbus_in => ipbw
(N_SLV_BACKPLANE_CONTROL
),
285 ipbus_out => ipbr
(N_SLV_BACKPLANE_CONTROL
),
286 stb
(0) => backplane_control_reg_stb,
287 q
(0) => backplane_control_i
289 backplane_control_reg_rst <= backplane_control_reg_stb or ipb_rst;
290 backplane_control(28 downto 0) <= backplane_control_i(28 downto 0);
292 Backplane_control_reg_2_reg:
entity work.ipbus_reg_v
296 ipbus_in => ipbw
(N_SLV_BACKPLANE_CONTROL_2
),
297 ipbus_out => ipbr
(N_SLV_BACKPLANE_CONTROL_2
),
298 q
(0) => backplane_control_two
301 backplane_control(31) <= backplane_control_two(0);
303 backplane_control(30) <= '1';
304 backplane_control(29) <= backplane_control_two(1);
319 channel_map:
entity work.ipbus_syncreg_v
329 ipb_in => ipbw
(N_SLV_CHANNEL_MAP
),
330 ipb_out => ipbr
(N_SLV_CHANNEL_MAP
),
332 d
(0) => x"00" & chan_ena ,
333 qmask =>
(others =>
(others => '1'
)),
339 channel_disable:
entity work.ipbus_reg_v
345 ipbus_in => ipbw
(N_SLV_CHAN_DISABLE
),
346 ipbus_out => ipbr
(N_SLV_CHAN_DISABLE
),
351 chan_disable <= chan_dis;
354 first_last_chan:
entity work.ipbus_syncreg_v
364 ipb_in => ipbw
(N_SLV_FIRST_LAST_CHAN
),
365 ipb_out => ipbr
(N_SLV_FIRST_LAST_CHAN
),
368 qmask =>
(others =>
(others => '1'
)),
374 ro_ctrl_status :
entity work.ipbus_syncreg_v
384 ipb_in => ipbw
(N_SLV_RO_CTRL_LINK_STAT
),
385 ipb_out => ipbr
(N_SLV_RO_CTRL_LINK_STAT
),
387 d
(0) => ro_status_32,
388 qmask =>
(others =>
(others => '1'
)),
394 ro_status_32 <= (x"000000" & "00" & ro_cpll_lock_lost & ro_status(4 downto 0));
398 ro_cpll_lock <= ro_status(3);
400 process (clk_125)
begin
401 if rising_edge (clk_125) then
402 ro_cpll_lock_delay_1 <= ro_cpll_lock;
403 ro_cpll_lock_delay_2 <= ro_cpll_lock_delay_1;
408 process (clk_125)
begin
409 if rising_edge (clk_125) then
410 if (backplane_control(3) = '1') then
411 ro_cpll_lock_lost <= '0';
412 elsif (ro_cpll_lock_delay_1 = '0') and (ro_cpll_lock_delay_2 = '1') then
413 ro_cpll_lock_lost <= '1';
415 ro_cpll_lock_lost <= ro_cpll_lock_lost;
423 clock_status :
entity work.ipbus_syncreg_v
433 ipb_in => ipbw
(N_SLV_CLOCK_STATUS
),
434 ipb_out => ipbr
(N_SLV_CLOCK_STATUS
),
436 d
(0) => clock_status_32,
437 qmask =>
(others =>
(others => '1'
)),
443 clock_status_32(31 downto 24) <= count_125;
444 clock_status_32(23 downto 16) <= count_40;
445 clock_status_32(15 downto 8) <= count_160;
447 clock_status_32(6) <= silab_ck_int_sticky;
448 clock_status_32(5) <= SMBALERT;
449 clock_status_32(4) <= T_WARN;
450 clock_status_32(3) <= CK_INT;
451 clock_status_32(2) <= clk_40_good;
452 clock_status_32(1) <= clk_160_good;
453 clock_status_32(0) <= ck_pll_lock;
455 T_WARN <= not T_WRN_B;
456 SMBALERT <= not SMBALERT_B;
459 process (clk_125)
begin
460 if rising_edge (clk_125) then
461 CK_INT_delay_1 <= CK_INT;
462 CK_INT_delay_2 <= CK_INT_delay_1;
466 process (clk_125)
begin
467 if rising_edge (clk_125) then
468 if (backplane_control(9) = '1') then
469 silab_ck_int_sticky <= '0';
470 elsif (CK_INT_delay_1 = '0') and (CK_INT_delay_2 = '1') then
471 silab_ck_int_sticky <= '1';
473 silab_ck_int_sticky <= silab_ck_int_sticky;
482 process(channel_up, chan_dis)
484 for i in 23 downto 0 loop
485 chan_ena(i) <= channel_up(i) AND NOT chan_dis(i);
491 process (pp_clock)
begin
492 if rising_edge (pp_clock) then
493 chan_enable_r1 <= chan_ena;
494 chan_enable_r2 <= chan_enable_r1;
498 chan_enable <= chan_enable_r2;
515 process(rt_clk, timer_reset, backplane_control(
2))
517 if (timer_reset = '1') or (backplane_control(2) = '1') then
518 time_counter <= (others => '0');
519 elsif rising_edge(rt_clk) then
520 time_counter <= (time_counter + 1);
525 time_count <= time_counter(31 downto 0);
526 time_count_reg <= time_counter(31 downto 0);
530 chan_ena => chan_ena,
532 first_chan => first_chan_i,
533 last_chan => last_chan_i
536 first_chan <= first_chan_i;
537 last_chan <= last_chan_i;
538 first_last <= x"00" & "000" & last_chan_i & x"00" & "000" & first_chan_i;
546 reset_count => x"03ff",
547 count_40_term => x"45",
548 count_160_term => x"45"
555 clock_160 => clk_160,
556 clock_125 => clk_125,
557 reset => clk_test_reset,
558 clock_160_lock => ck_pll_lock,
559 clk_40_good => clk_40_good,
560 clk_160_good => clk_160_good,
561 count_40 => count_40,
562 count_160 => count_160,
563 count_125 => count_125
566 clk_test_reset <= backplane_control(7) ;
569 busy_active_time_reg :
entity work.ipbus_syncreg_v
577 ipb_in => ipbw
(N_SLV_Busy_Active_TIME
),
578 ipb_out => ipbr
(N_SLV_Busy_Active_TIME
),
580 d
(0) => busy_active_time,
581 qmask =>
(others =>
(others => '1'
)),
586 busy_active_time_reset <= backplane_control_i(8);
589 process(rt_clk, ipb_rst, busy_active_time_reset)
591 if (ipb_rst or busy_active_time_reset) = '1' then
592 busy_active_time <= (others => '0');
593 elsif rising_edge(rt_clk) then
594 if (combined_busy = '1') and (busy_active_time < x"ffffffff") then
595 busy_active_time <= (busy_active_time + 1);
597 busy_active_time <= busy_active_time;