11 USE ieee.std_logic_1164.
all;
12 use ieee.numeric_std.
all;
17 DELAY_DEPTH : Integer range 0 to 255 := 3
22 clk_320 : in std_logic;
24 rst_ttc : in std_logic;
25 ttc_wr_en : in std_logic;
26 ttc_rd_en : in std_logic;
27 ttc_din : in std_logic_vector(49 DOWNTO 0);
29 ttc_rd_en_A : in std_logic;
30 ttc_empty_A : out std_logic;
31 ttc_dout_A : out std_logic_vector(49 DOWNTO 0);
32 ttc_rd_en_B : in std_logic;
33 ttc_empty_B : out std_logic;
34 ttc_dout_B : out std_logic_vector(49 DOWNTO 0);
36 destination_enable : in std_logic_vector(1 downto 0) := (Others => '0');
37 readout_delay : in std_logic_vector(7 downto 0)
46 INIT :
std_logic_vector(
31 downto 0) := (
Others => '
0')
52 A :
in std_logic_vector(
4 downto 0);
56 end COMPONENT SRLC32E;
58 COMPONENT fifo_40M_160M
is
61 wr_clk :
IN STD_LOGIC;
62 rd_clk :
IN STD_LOGIC;
63 din :
IN STD_LOGIC_VECTOR(
49 DOWNTO 0);
66 dout :
OUT STD_LOGIC_VECTOR(
49 DOWNTO 0);
70 END COMPONENT fifo_40M_160M;
72 signal ttc_delay_d: std_logic_vector(49 DOWNTO 0);
73 signal ttc_delay_q: std_logic_vector(49 DOWNTO 0);
74 signal ttc_fifo_rd, ttc_fifo_wr, ttc_fifo_wait: std_logic;
75 signal ttc_delay_wr_A, ttc_delay_wr_B: std_logic;
76 signal ttc_fifo_rd_A, ttc_fifo_rd_B: std_logic;
77 signal ttc_fifo_empty_A, ttc_fifo_empty_B: std_logic;
78 signal ttc_veto_clk40, ttc_veto_clk320: std_logic := '1';
79 signal q_i: std_logic_vector(DELAY_DEPTH DOWNTO 0);
80 signal actual_delay: integer range 0 to 255;
85 actual_delay_block:
process(clk_320)
86 variable input_delay: integer range 0 to 255;
88 if rising_edge(clk_320) then
89 input_delay := to_integer(unsigned(readout_delay));
90 if (input_delay > DELAY_DEPTH) then
91 input_delay := DELAY_DEPTH;
93 actual_delay <= input_delay;
95 end process actual_delay_block;
98 ttc_veto_block_clk40 :
process(clk40)
99 Variable stretch: std_logic_vector(15 downto 0) := (Others => '1');
101 if rising_edge(clk40) then
102 if (rst_ttc /= '0') then
103 stretch := (Others => '1');
104 ttc_veto_clk40 <= '1';
106 stretch := stretch(14 downto 0) & "0";
107 ttc_veto_clk40 <= stretch(15);
110 end process ttc_veto_block_clk40;
113 ttc_veto_block_clk320 :
process(clk_320)
115 if rising_edge(clk_320) then
116 if (rst_ttc /= '0') or (ttc_veto_clk40 /= '0') then
117 ttc_veto_clk320 <= '1';
119 ttc_veto_clk320 <= '0';
122 end process ttc_veto_block_clk320;
124 q_i(0) <= ttc_rd_en when ttc_veto_clk40 = '0' else '0';
125 ttc_fifo_wr <= ttc_wr_en when ttc_veto_clk40 = '0' else '0';
126 ttc_fifo_rd_A <= ttc_rd_en_A when ttc_veto_clk320 = '0' else '0';
127 ttc_fifo_rd_B <= ttc_rd_en_B when ttc_veto_clk320 = '0' else '0';
128 ttc_empty_A <= ttc_fifo_empty_A when ttc_veto_clk320 = '0' else '1';
129 ttc_empty_B <= ttc_fifo_empty_B when ttc_veto_clk320 = '0' else '1';
131 ttc_delay_strobe : for i in 0 to DELAY_DEPTH - 1 generate
132 SRLC32E_delay_strobe : SRLC32E
138 A =>
(Others => '1'
),
143 end generate ttc_delay_strobe;
145 ttc_fifo_delay: fifo_40M_160M
151 wr_en => ttc_fifo_wr,
152 rd_en => ttc_fifo_rd,
158 ttc_fifo_A: fifo_40M_160M
164 wr_en => ttc_delay_wr_A,
165 rd_en => ttc_fifo_rd_A,
168 empty => ttc_fifo_empty_A
171 ttc_fifo_B: fifo_40M_160M
177 wr_en => ttc_delay_wr_B,
178 rd_en => ttc_fifo_rd_B,
181 empty => ttc_fifo_empty_B
184 ttc_fifo_connect:
process(clk40)
186 if rising_edge(clk40) then
187 ttc_fifo_rd <= q_i(actual_delay) and not ttc_veto_clk40
192 ttc_fifo_wait <= ttc_fifo_rd and not ttc_veto_clk40
197 ttc_delay_d <= ttc_delay_q
202 case destination_enable is
204 ttc_delay_wr_A <= ttc_fifo_wait and not ttc_veto_clk40
209 ttc_delay_wr_B <= '0'
215 ttc_delay_wr_A <= '0'
220 ttc_delay_wr_B <= ttc_fifo_wait and not ttc_veto_clk40
227 ttc_delay_wr_A <= ttc_fifo_wait and ttc_delay_q(12) and not ttc_veto_clk40
232 ttc_delay_wr_B <= ttc_fifo_wait and not ttc_delay_q(12) and not ttc_veto_clk40
238 ttc_delay_wr_A <= '0'
243 ttc_delay_wr_B <= '0'
250 End process ttc_fifo_connect;
252 END Architecture rtl;
Switch TTC FIFO data to correct stream depending on destination_enable...
Switch TTC FIFO data to correct stream depending on destination_enable...