INIT_TDC_READOUT_IN => init_tdc_readout_i,
DATA_TYPE_SELECT_IN => DATA_TYPE_SELECT_IN,
- -- INIT_TRB_INTERFACE_IN => init_trb_interface_i,
TOKEN_TO_TRB_OUT => token_to_trb_i,
REINIT_ROC1_IN => reinit_roc1_i,
REINIT_ROC1_OUT => reinit_roc1_forwarded_i,
SUCCESFUL_REINIT_ROC1 => succesful_reinit_roc1_i,
STOP_READOUT_IN => stop_readout_i,
- -- DATA_BUS_TO_TRB_OUT => DATA_BUS_TO_TRB_OUT,
- -- DATA_VALID_TO_TRB_OUT => DATA_VALID_TO_TRB_OUT,
+
DEBUG_REGISTER_0 => DEBUG_REGISTER_0_BUS_0,
DEBUG_REGISTER_1 => DEBUG_REGISTER_1_BUS_0,
DEBUG_REGISTER_2 => DEBUG_REGISTER_2_BUS_0,
-- trb interface
--- ACKNOWLEDGE_TRB_INTERFACE_IN => ACKNOWLEDGE_TRB_INTERFACE_IN,
--- INIT_TRB_INTERFACE_OUT => INIT_TRB_INTERFACE_OUT,
--- DATA_OUT => DATA_OUT,
--- READ_FIFO_IN => READ_FIFO_IN,
--- DEBUG_REGISTER_TRB_INTERFACE => DEBUG_REGISTER_TRB_INTERFACE
LVL1_TRG_TYPE_IN => LVL1_TRG_TYPE_IN,
LVL1_TRG_RECEIVED_IN => LVL1_TRG_RECEIVED_IN,
LVL1_TRG_NUMBER_IN => LVL1_TRG_NUMBER_IN,
A_ENR_2 <= '1'; --common stop enable
A_DRB_2 <= '1'; --A_RDM enable
A_DRA <= '0'; --A_ACK enable
--------------------------------------------------------------------------------
-
--- reset_i <= ADO_TTL_IN(0);
+
A_GDE <= a_gde_i;
A_RES <= a_res_i;
A_TOK <= a_tok_i;
a_reserv_i <= A_RESERV; --this is 11 bit of dataword
A_CMS <= a_cms_out_i; --common stop
--- A_RDO_OUT <= token_to_trb_i;
-
end behavioral;
REGISTER_OUTPUT : process (CLK, reg_data_type_select_in)
begin
if rising_edge(CLK) then
- if (RESET = '1' or reg_data_type_select_in = x"1") then
+ if (RESET = '1' or reg_data_type_select_in = x"1" or
+ reg_data_type_select_in = x"2") then
current_state <= idle_state;
reg_data_bus_out <= (others => '0');
reg_data_valid_out <= '0';
-------------------------------------------------------------------------------
-- DATA SELECT MULTIPLEXER
-------------------------------------------------------------------------------
- process (CLK, reg_data_type_select_in)
+ process (CLK, reg_data_type_select_in(3 downto 0))
begin
if (rising_edge(CLK)) then
if (reg_data_type_select_in = x"0") then --debug mode
process (CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') then
+ if (RESET = '1' or reg_data_type_select_in = x"0" or
+ reg_data_type_select_in = x"1") then
current_state_test_data <= idle_state_test_data;
reg_data_bus_out_test_data <= (others => '0');
reg_data_valid_out_test_data <= '0';
-------------------------------------------------------------------------------
process(current_state_test_data, INIT_TDC_READOUT_IN, counter_test_data)
--- variable index : integer range 0 to conv_integer(reg_test_data_maximun_word_number);
---std_logic_vector (19 downto 0);
-
begin
next_data_valid_out_test_data <= '0';
when check_dataword_number_test_data =>
next_debug_register_test_data <= x"3";
next_data_valid_out_test_data <= '0';
- next_data_bus_out_test_data(15 downto 0) <= std_logic_vector(TO_UNSIGNED(conv_integer(counter_test_data), reg_test_data_maximun_word_number'Length));
+ next_data_bus_out_test_data(15 downto 0) <= std_logic_vector(TO_UNSIGNED(conv_integer(counter_test_data), reg_test_data_maximun_word_number'Length));
if (conv_integer(counter_test_data) >= reg_test_data_maximun_word_number) then
next_state_test_data <= send_token_state_test_data;
else
--test in case no data in fifo (ok if I don't buffer many events)
--set the 18th bit if fifo data is empty
- IPU_ERROR_PATTERN_OUT <= x"000" & "0100" & x"0000" when (empty_flag_fee_data_fifo_i = '1') else (others => '0');--reg_ipu_error_pattern;
+ IPU_ERROR_PATTERN_OUT <= x"000" & "0000" & x"0000"; --when (empty_flag_fee_data_fifo_i = '1') else (others => '0');--reg_ipu_error_pattern;
-- Count number of dataword per event
next_ipu_data_ready <= '0';
next_data_to_trb_net <= header_data_fifo_out_i(31 downto 0);
--here I wait only when the first token from the first event is back
---in fiture I need to see there is one event at least in the header fifo
- if (conv_integer(counter_token_back) >= 1) then
- -- push_read_header_data_i <= '1';
+--in future I need to see there is one event at least in the header fifo
+--check if header is in the header fifo
+ if (empty_flag_header_data_fifo_i = '1') then
+ --if (conv_integer(counter_token_back) >= 1) then
next_state_fsm_multiplexer <= dummy_wait_4_fsm_multiplexer;
else
next_state_fsm_multiplexer <= wait_for_complete_event_fsm_multiplexer;
else
next_state_fsm_multiplexer <= send_data_state_fsm_multiplexer;
end if;
+
--stay if no tok back and fifo empty for
when end_of_event_transfer_fsm_multiplexer =>
next_debug_register_fsm_multiplexer <= x"07";
begin
if rising_edge(CLK) then
if RESET = '1' then
- reg_first_header <= (others => '0');
+ reg_first_header<= (others => '0');
else
reg_first_header <= first_header;
end if;