2 use IEEE.STD_LOGIC_1164.
ALL;
3 use IEEE.NUMERIC_STD.
ALL;
4 use IEEE.STD_LOGIC_MISC.
ALL;
5 use IEEE.STD_LOGIC_UNSIGNED.
ALL;
34 -- state machine input parameters 35 win_samp_start_asic : in slv14(4 downto 0) := (others => (others=>'0'));
36 -- samp_start : in slv5(4 downto 0) := (others => "00000"); 37 asic_mask : in (4 downto 0) := (others=>'0');
38 first_dig_win : in (8 downto 0);
39 last_dig_win : in (8 downto 0);
41 -- wires to ThresholdCheck 42 sample_data : out slv12(14 downto 0) := (others=>"000000000000");
43 samples_valid : out := '0';
-- samplesel & valid flag 44 -- samples_sel : out std_logic_vector(4 downto 0) := (others=>'0'); 45 current_asic : out (4 downto 0) := "00001";
48 ramp_length : in (11 downto 6);
49 -- force_test_pattern : in std_logic := '0'; 50 t_samp_addr_settle : in (3 downto 0) := "0110";
-- 6 51 t_setup_ss_any : in (3 downto 0) := "0110";
-- 6 52 t_strobe_settle : in (3 downto 0) := "0100";
-- 4 53 t_sr_clk_high : in (3 downto 0) := "0010";
-- 2 54 t_sr_clk_low : in (3 downto 0) := "0010";
-- 2 55 t_sr_clk_strobe : in (3 downto 0) := "0110";
-- 6 56 N_readout_samples : in (7 downto 0);
59 ShiftOutWinBusy : out := '0';
60 ShiftOutSampBusy : out := '0';
63 ---- digitization control 64 BUS_RD_ENA : out := '0';
66 BUS_RAMP : out := '0';
67 BUS_RD_WINSEL : out (8 downto 0) := (others=>'0');
69 ---- shift register data and control 70 BUS_DO : in (14 downto 0) := (others=>'0');
72 SR_CLK : out (4 downto 0) := (others=>'0');
74 SAMPLESEL : out (4 downto 0) := (others=>'0');
75 SAMPLESEL_ANY : out (4 downto 0) := (others=>'0') 77 end DigitizeAndShiftOutData;
83 type digitize_and_shift_out_window_data is ( 85 WAIT_DIG_BUSY_TO_COME_UP, -- next_state = (WAIT_DIG_BUSY_TO_COME_UP) or (IDLE) 87 WAIT_SHIFT_BUSY_TO_COME_UP, 88 WAIT_SHIFT_OUT ---- next_state = WAIT_DIG_BUSY_TO_COME_UP 90 signal digNshift_state : digitize_and_shift_out_window_data := IDLE;
92 -- internal state machine signals 93 signal ena_i : := '0';
94 -- signal count : std_logic_vector(7 downto 0) := "00000000"; 95 -- signal earliest_win_samp : std_logic_vector(8 downto 0) := (others=>'0'); 96 signal first_dig_win_i : (8 downto 0) := (others=>'0');
97 signal BUS_RD_WINSEL_i : (8 downto 0) := (others=>'0');
98 signal i_win_samp_start_asic : slv14(4 downto 0) := (others => (others=>'0'));
100 -- ShiftOutWindow signals 101 signal shift_ena : := '0';
102 signal shift_asic_mask : (4 downto 0);
103 signal shift_samp_start : slv5(4 downto 0) := (others=>(others=>'0'));
104 signal shift_samp_stop : slv5(4 downto 0) := (others=>(others=>'1'));
105 signal shift_busy : := '0';
108 -- DigitizingLgcTX signals 109 signal dig_ena : := '0';
110 signal dig_busy : := '0';
112 ---------------------------------------- 115 BUS_RD_WINSEL <= BUS_RD_WINSEL_i;
116 ShiftOutWinBusy <= shift_busy;
127 -- force_test_pattern => force_test_pattern, 128 ramp_length => ramp_length,
131 BUS_RD_ENA => BUS_RD_ENA,
143 -- force_test_pattern => force_test_pattern, 144 t_samp_addr_settle => t_samp_addr_settle,
145 t_setup_ss_any => t_setup_ss_any,
146 t_strobe_settle => t_strobe_settle,
147 t_sr_clk_high => t_sr_clk_high ,
148 t_sr_clk_low => t_sr_clk_low ,
149 t_sr_clk_strobe => t_sr_clk_strobe ,
150 ShiftOutSampBusy => ShiftOutSampBusy,
151 asic_mask => shift_asic_mask,
152 samp_start_asic => shift_samp_start,
153 samp_stop_asic => shift_samp_stop,
154 samples_valid => samples_valid,
155 -- sample_sel => sample_sel, 156 sample_data => sample_data,
157 current_asic => current_asic,
162 SAMPLESEL => SAMPLESEL,
163 SAMPLESEL_ANY => SAMPLESEL_ANY
167 --detect start rising edge 170 if rising_edge(clk) then 176 process (clk, first_dig_win)
178 if rising_edge(clk) then 179 first_dig_win_i <= first_dig_win;
185 process(clk, ena_i, ena, first_dig_win_i, win_samp_start_asic, asic_mask,
186 dig_busy, BUS_RD_WINSEL_i, i_win_samp_start_asic, shift_busy, last_dig_win)
187 variable i_asic_mask : (4 downto 0);
189 if rising_edge(clk) then 191 digNshift_state <= IDLE;
193 Case digNshift_state is 196 shift_asic_mask <= (others=>'0');
197 shift_samp_stop <= (others=>"11111");
198 if ( ena_i = '0' and ena = '1' ) then 200 BUS_RD_WINSEL_i <= first_dig_win_i;
-- set initial window address 201 -- count <= "00100000" - ("000" & samp_start); -- num samps shifted out in first win 202 i_win_samp_start_asic <= win_samp_start_asic;
203 -- samp_start_asic <= samp_start; 205 i_asic_mask := asic_mask;
206 digNshift_state <= WAIT_DIG_BUSY_TO_COME_UP;
208 -- count <= (others=>'0'); 209 i_win_samp_start_asic <= (others=>(others=>'0'));
210 BUS_RD_WINSEL_i <= (others=>'0');
214 digNshift_state <= IDLE;
217 When WAIT_DIG_BUSY_TO_COME_UP => 219 if dig_busy = '1' then 220 digNshift_state <= WAIT_DIG_WINDOW;
222 digNshift_state <= WAIT_DIG_BUSY_TO_COME_UP;
225 When WAIT_DIG_WINDOW => 227 if dig_busy = '1' then 228 digNshift_state <= WAIT_DIG_WINDOW;
230 digNshift_state <= WAIT_SHIFT_BUSY_TO_COME_UP;
233 if i_asic_mask(i) = '1' then 235 if BUS_RD_WINSEL_i & "11111" - i_win_samp_start_asic(i) < N_readout_samples then 236 shift_asic_mask(i) <= '1';
238 shift_asic_mask(i) <= '0';
241 if BUS_RD_WINSEL_i = i_win_samp_start_asic(i)(13 downto 5) then 242 shift_samp_start(i) <= i_win_samp_start_asic(i)(4 downto 0);
244 shift_samp_start(i) <= "00000";
247 if BUS_RD_WINSEL_i = i_win_samp_start_asic(i)(13 downto 5) + "000000" & N_readout_samples(7 downto 5) then 248 shift_samp_stop(i) <= "11111" - i_win_samp_start_asic(i)(4 downto 0);
250 shift_samp_stop(i) <= "11111";
257 When WAIT_SHIFT_BUSY_TO_COME_UP => 259 if shift_busy = '1' then 260 digNshift_state <= WAIT_SHIFT_OUT;
262 digNshift_state <= WAIT_SHIFT_BUSY_TO_COME_UP;
265 When WAIT_SHIFT_OUT => 267 if shift_busy = '1' then 268 digNshift_state <= WAIT_SHIFT_OUT;
270 BUS_RD_WINSEL_i <= BUS_RD_WINSEL_i + "000000001";
-- automatically rolls over at window 512 271 -- shift_samp_start <= "00000"; 272 if BUS_RD_WINSEL_i /= last_dig_win then 274 digNshift_state <= WAIT_DIG_BUSY_TO_COME_UP;
278 digNshift_state <= IDLE;
284 digNshift_state <= IDLE;