From: hadeshyp Date: Thu, 2 Apr 2009 13:31:46 +0000 (+0000) Subject: fixed ipudata X-Git-Tag: oldGBE~466 X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=141393b53f0584975d09401d387ae33a9d7fb4b8;p=trbnet.git fixed ipudata --- diff --git a/trb_net16_ipudata.vhd b/trb_net16_ipudata.vhd index 3197aad..7495192 100644 --- a/trb_net16_ipudata.vhd +++ b/trb_net16_ipudata.vhd @@ -78,12 +78,15 @@ architecture trb_net16_ipudata_arch of trb_net16_ipudata is signal state_bits : std_logic_vector(2 downto 0); signal dhdr_counter : std_logic_vector(1 downto 0); signal first_ipu_read : std_logic; - + signal ipu_read_before : std_logic; + signal second_word_waiting : std_logic; + signal last_second_word_waiting : std_logic; begin IPU_NUMBER_OUT <= buf_NUMBER; IPU_START_READOUT_OUT <= buf_START_READOUT; + IPU_READ_OUT <= buf_IPU_READ; IPU_INFORMATION_OUT <= buf_INFORMATION; PROC_STATE_MACHINE : process(CLK) @@ -96,11 +99,9 @@ begin update_buffers <= '0'; waiting_word <= '0'; buf_API_DATAREADY_OUT <= '0'; - buf_IPU_READ <= '0'; first_ipu_read <= '0'; else buf_API_READ_OUT <= '1'; - buf_API_DATAREADY_OUT <= '0'; first_ipu_read <= '0'; case state is when START => @@ -122,14 +123,14 @@ begin when WAITING => if IPU_DATAREADY_IN = '1' and API_READ_IN = '1' then - first_ipu_read <= '1'; - update_buffers <= '1'; + first_ipu_read <= '1'; -- read signal for DHDR + update_buffers <= '1'; -- store length and error pattern on separate ports state <= MAKE_DHDR; dhdr_counter <= (others => '0'); buf_API_DATA_OUT <= IPU_DATA_IN(31 downto 16); end if; - when MAKE_DHDR => + when MAKE_DHDR => -- send DHDR packet update_buffers <= '0'; buf_API_SEND_OUT <= '1'; buf_API_DATAREADY_OUT <= '1'; @@ -152,11 +153,29 @@ begin when READING => + buf_API_DATAREADY_OUT <= IPU_DATAREADY_IN or waiting_word or ipu_read_before or second_word_waiting; + if API_READ_IN = '1' then + ipu_read_before <= '0'; + end if; + + if buf_API_DATAREADY_OUT = '1' and API_READ_IN = '1' then + waiting_word <= '0'; + end if; - --end of readout - if saved_IPU_READOUT_FINISHED_IN = '1' and select_word = '0' and buf_API_DATAREADY_OUT = '0' - and buf_IPU_READ = '1' and IPU_DATAREADY_IN = '0' then + if IPU_DATAREADY_IN = '1' and waiting_word = '0' and buf_IPU_READ = '1' then + buf_API_DATA_OUT <= IPU_DATA_IN(31 downto 16); + waiting_word <= '1'; + ipu_read_before <= '1'; + elsif ipu_read_before = '1' and API_READ_IN = '0' then + buf_API_DATA_OUT <= reg_IPU_DATA_high; + else + buf_API_DATA_OUT <= reg_IPU_DATA; + end if; + + + + if saved_IPU_READOUT_FINISHED_IN = '1' and waiting_word = '0' and IPU_DATAREADY_IN = '0' and buf_API_DATAREADY_OUT = '0' then state <= START; end if; if saved_IPU_READOUT_FINISHED_IN = '1' or IPU_READOUT_FINISHED_IN = '1' then @@ -169,8 +188,31 @@ begin end if; end process; + buf_IPU_READ <= '1' when API_READ_IN = '1' and waiting_word = '0' and second_word_waiting = '0' and (state = READING or first_ipu_read = '1') else '0'; +-- + PROC_second_word : process(waiting_word, buf_API_DATAREADY_OUT, API_READ_IN, last_second_word_waiting, RESET) + begin + if RESET = '1' then + second_word_waiting <= '0'; + elsif waiting_word = '1' then + second_word_waiting <= '1'; + elsif buf_API_DATAREADY_OUT = '1' and API_READ_IN = '1' then + second_word_waiting <= '0'; + else + second_word_waiting <= last_second_word_waiting; + end if; + end process; - + PROC_last_second_word : process(CLK) + begin + if rising_edge(CLK) then + if RESET = '1' then + last_second_word_waiting <= '0'; + else + last_second_word_waiting <= second_word_waiting; + end if; + end if; + end process; PROC_buffer_inputs : process(CLK) begin @@ -226,11 +268,13 @@ begin API_ERROR_PATTERN_OUT <= buf_IPU_ERROR_PATTERN_IN; API_LENGTH_OUT <= buf_IPU_LENGTH_IN+2; API_READ_OUT <= buf_API_READ_OUT; + API_DATAREADY_OUT <= buf_API_DATAREADY_OUT; + API_DATA_OUT <= buf_API_DATA_OUT; API_PACKET_NUM_OUT <= packet_number; API_SEND_OUT <= buf_API_SEND_OUT; API_SHORT_TRANSFER_OUT<= '0'; API_DTYPE_OUT <= buf_TYPE; - API_DATAREADY_OUT <= buf_API_DATAREADY_OUT; + STAT_DEBUG <= (others => '0');