From 3f0efdea1ae7d8172bff27e1be436a17d257aa00 Mon Sep 17 00:00:00 2001 From: hadeshyp Date: Tue, 5 Oct 2010 14:48:00 +0000 Subject: [PATCH] *** empty log message *** --- media_interfaces/trb_net16_med_ecp_fot.vhd | 1 + .../trb_net16_rx_comma_handler.vhd | 67 +++++++++++++++++-- .../trb_net16_rx_full_packets.vhd | 2 +- media_interfaces/trb_net16_tx_control.vhd | 21 +++--- 4 files changed, 74 insertions(+), 17 deletions(-) diff --git a/media_interfaces/trb_net16_med_ecp_fot.vhd b/media_interfaces/trb_net16_med_ecp_fot.vhd index 6be346e..b43d050 100644 --- a/media_interfaces/trb_net16_med_ecp_fot.vhd +++ b/media_interfaces/trb_net16_med_ecp_fot.vhd @@ -248,6 +248,7 @@ begin RESET_IN => tx_lane_reset, TX_DATA_IN => MED_DATA_IN, + TX_PACKET_NUMBER_IN => MED_PACKET_NUM_IN, TX_WRITE_IN => MED_DATAREADY_IN, TX_READ_OUT => MED_READ_OUT, diff --git a/media_interfaces/trb_net16_rx_comma_handler.vhd b/media_interfaces/trb_net16_rx_comma_handler.vhd index 2eb4361..707fbe4 100644 --- a/media_interfaces/trb_net16_rx_comma_handler.vhd +++ b/media_interfaces/trb_net16_rx_comma_handler.vhd @@ -4,7 +4,7 @@ use ieee.numeric_std.all; library work; use work.trb_net_std.all; ---use work.trb_net_components.all; +use work.trb_net_components.all; entity trb_net16_rx_comma_handler is port( @@ -58,6 +58,7 @@ signal buf_cv : std_logic_vector(1 downto 0); signal buf_disperr : std_logic_vector(1 downto 0); signal data_valid_x : std_logic; +signal data_valid : std_logic; signal comma_valid_x : std_logic; signal c_idle_x : std_logic; @@ -68,6 +69,9 @@ signal c_error_x : std_logic; signal c_error : std_logic; -- 0xF7 signal c_stx_x : std_logic; signal c_stx : std_logic; -- 0xFB +signal c_crc_x : std_logic; +signal c_crc : std_logic; -- 0xFD +signal c_invalid_k_x : std_logic; signal comma_idle : std_logic; -- correct IDLE comma (/I1/ or /I2/) received signal comma_idle_x : std_logic; @@ -75,6 +79,11 @@ signal comma_stx : std_logic; -- correct StartOfTransmission comma re signal comma_stx_x : std_logic; signal comma_error : std_logic; -- correct ErrorDetected comma received signal comma_error_x : std_logic; +signal comma_crc : std_logic; -- correct CRC comma received +signal comma_crc_x : std_logic; +signal comma_crc_q : std_logic; +signal comma_crc_qq : std_logic; + signal comma_toggle : std_logic; signal rst_toggle : std_logic; @@ -86,6 +95,7 @@ signal comma_locked : std_logic; signal fifo_wr_x : std_logic; signal fifo_wr : std_logic; +signal buf_fifo_wr : std_logic; signal ld_rx_position : std_logic; signal rx_position : std_logic_vector(7 downto 0); @@ -100,6 +110,11 @@ signal send_reset_words : std_logic; signal make_trbnet_reset : std_logic; signal reset_word_cnt : unsigned(4 downto 0); +signal crc_enable : std_logic; +signal crc_active : std_logic; +signal crc_match : std_logic; +signal crc_reset : std_logic; + begin ---------------------------------------------------------------------- @@ -147,11 +162,16 @@ begin c_reset <= c_reset_x; c_error <= c_error_x; c_stx <= c_stx_x; + c_crc <= c_crc_x; comma_idle <= comma_idle_x; comma_stx <= comma_stx_x; comma_error <= comma_error_x; comma_locked <= comma_locked_x; + comma_crc <= comma_crc_x; + comma_crc_q <= comma_crc; + data_valid <= data_valid_x; fifo_wr <= fifo_wr_x; + buf_fifo_wr <= fifo_wr; ld_rx_position <= comma_stx; ld_start_position <= comma_error; if( comma_toggle = '1' ) then @@ -163,6 +183,12 @@ begin if( comma_error = '1' ) then start_position <= buf_data(7 downto 0); end if; + + if RESET_IN = '1' then + crc_active <= '0'; + elsif( comma_crc = '1') then + crc_active <= '1'; + end if; end if; end process THE_SYNC_PROC; @@ -171,9 +197,13 @@ c_idle_x <= '1' when ( (buf_rx_k = '1') and (buf_rx_data = x"bc") ) else '0 c_reset_x <= '1' when ( (buf_rx_k = '1') and (buf_rx_data = x"fe") ) else '0'; c_error_x <= '1' when ( (buf_rx_k = '1') and (buf_rx_data = x"f7") ) else '0'; c_stx_x <= '1' when ( (buf_rx_k = '1') and (buf_rx_data = x"fb") ) else '0'; +c_crc_x <= '1' when ( (buf_rx_k = '1') and (buf_rx_data = x"fd") ) else '0'; + +c_invalid_k_x <= '1' when buf_rx_k = '1' and + (c_idle_x = '0' and c_reset_x = '0' and c_error_x = '0' and c_stx_x = '0' and c_crc_x = '0') else '0'; -- Comma recognition part II: data part of comma --- IDLE is allows any time +-- IDLE is allowed any time comma_idle_x <= '1' when ( (c_idle = '1') and (buf_rx_k = '0') and ((buf_rx_data = x"50") or (buf_rx_data = x"c5")) ) else '0'; @@ -183,6 +213,10 @@ comma_stx_x <= '1' when ( (c_stx = '1') and (buf_rx_k = '0') and (comma_lock -- ErrorDetected is only accepted in LOCKED state comma_error_x <= '1' when ( (c_error = '1') and (buf_rx_k = '0') and (comma_locked_x = '1') ) else '0'; +-- CRC found is only accepted in LOCKED state +comma_crc_x <= '1' when ( (c_crc = '1') and (buf_rx_k = '0') and (comma_locked_x = '1') ) else '0'; + + -- reset toggle bit in case of mismatch during locking phase rst_toggle <= '1' when ( ((comma_idle = '1') and (comma_toggle = '0') and (comma_locked_x = '0')) or ((comma_idle = '0') and (comma_toggle = '1') and (comma_locked_x = '0')) or @@ -223,7 +257,7 @@ comma_locked_x <= '1' when (comma_ctr = x"f") else '0'; -- check for correct data / comma values ---------------------------------------------------------------------- -comma_valid_x <= comma_locked and (comma_idle or comma_error or comma_stx) +comma_valid_x <= comma_locked and (comma_idle or comma_error or comma_stx or comma_crc) and not buf_cv(1) and not buf_cv(0) ; --and not buf_disperr(0) and not buf_disperr(1); data_valid_x <= comma_locked and not buf_k(1) and not buf_k(0) @@ -233,15 +267,34 @@ fifo_wr_x <= comma_toggle and data_valid_x and not fifo_inhibit; THE_FIFO_INHIBIT_PROC: process( CLK_IN ) begin - if( rising_edge(CLK_IN) ) then + if( rising_edge(CLK_IN) ) then if ( (RESET_IN = '1') or (comma_stx = '1') or ENABLE_CORRECTION_IN = '0') then fifo_inhibit <= '0'; - elsif( (comma_locked = '1') and (comma_toggle = '1') and (comma_valid_x = '0') and (data_valid_x = '0') and c_reset_x = '0' ) then + elsif( (comma_locked = '1') and (comma_toggle = '1') and (comma_valid_x = '0') and (data_valid_x = '0') and c_reset_x = '0' ) + or (crc_match = '0' and comma_crc_x = '1' and crc_active = '1') + or c_invalid_k_x = '1' then fifo_inhibit <= '1'; end if; end if; end process THE_FIFO_INHIBIT_PROC; +---------------------------------------------------------------------- +-- CRC +---------------------------------------------------------------------- +THE_CRC : trb_net_CRC8 + port map( + CLK => CLK_IN, + RESET => crc_reset, + CLK_EN => crc_enable, + DATA_IN => buf_rx_data, + CRC_OUT => open, + CRC_match => crc_match + ); + + crc_reset <= RESET_IN or (fifo_inhibit and not comma_stx) or (not crc_active and not comma_crc); + crc_enable <= (not buf_rx_k and not (comma_idle_x or comma_error_x or comma_stx_x or comma_crc_x)) or comma_crc_x; + + ---------------------------------------------------------------------- -- Debug signals ---------------------------------------------------------------------- @@ -255,14 +308,14 @@ debug(10 downto 0) <= (others => '0'); STAT_REG_OUT(4 downto 0) <= std_logic_vector(reset_word_cnt); STAT_REG_OUT(5) <= fifo_inhibit; STAT_REG_OUT(6) <= comma_locked; -STAT_REG_OUT(7) <= '0'; +STAT_REG_OUT(7) <= comma_crc; STAT_REG_OUT(15 downto 8)<= (others => '0'); ---------------------------------------------------------------------- -- Output signals ---------------------------------------------------------------------- FIFO_DATA_OUT <= buf2_data; -FIFO_WR_OUT <= fifo_wr; +FIFO_WR_OUT <= buf_fifo_wr; FIFO_INHIBIT_OUT <= fifo_inhibit; LD_START_POSITION_OUT <= ld_start_position; diff --git a/media_interfaces/trb_net16_rx_full_packets.vhd b/media_interfaces/trb_net16_rx_full_packets.vhd index 81d494e..8372c93 100644 --- a/media_interfaces/trb_net16_rx_full_packets.vhd +++ b/media_interfaces/trb_net16_rx_full_packets.vhd @@ -374,7 +374,7 @@ begin end if; end process THE_TOC_PROC; -toc_done_x <= '1' when ( timeout_ctr(6 downto 2) = b"111_11" and ENABLE_CORRECTION_IN = '1') else '0'; +toc_done_x <= '1' when ( timeout_ctr(5 downto 2) = b"11_11" and ENABLE_CORRECTION_IN = '1') else '0'; ---------------------------------------------------------------------- -- Debug signals diff --git a/media_interfaces/trb_net16_tx_control.vhd b/media_interfaces/trb_net16_tx_control.vhd index 5b68020..49deb70 100644 --- a/media_interfaces/trb_net16_tx_control.vhd +++ b/media_interfaces/trb_net16_tx_control.vhd @@ -135,9 +135,7 @@ begin RdEn => ct_fifo_read, Reset => ct_fifo_reset, RPReset => ct_fifo_reset, - Q(15 downto 0) => tx_data_25_i, - Q(16) => load_sop, - Q(17) => load_eop, + Q(17 downto 0) => tx_data_25_i, Empty => ct_fifo_empty, Full => ct_fifo_full, AlmostFull => ct_fifo_afull @@ -157,8 +155,8 @@ ct_fifo_write<= buf_tx_read_out and TX_WRITE_IN; ct_fifo_read <= tx_allow_qtx and not ram_afull and not ct_fifo_empty; -- gk 05.10.10 -save_sop <= '1' when (TX_PACKET_NUMBER_IN = b"100") else '0'; -save_eop <= '1' when (TX_PACKET_NUMBER_IN = b"011") else '0'; +save_sop <= '1' when (TX_PACKET_NUMBER_IN = c_H0) else '0'; +save_eop <= '1' when (TX_PACKET_NUMBER_IN = c_F3) else '0'; ---------------------------------------------------------------------- -- RAM @@ -255,6 +253,8 @@ save_eop <= '1' when (TX_PACKET_NUMBER_IN = b"011") else '0'; when SEND_DATA_L => TX_DATA_OUT <= ram_dout(7 downto 0); + load_sop <= ram_dout(16); + load_eop <= ram_dout(17); TX_K_OUT <= '0'; current_state <= SEND_DATA_H; @@ -267,13 +267,15 @@ save_eop <= '1' when (TX_PACKET_NUMBER_IN = b"011") else '0'; when SEND_CHKSUM_L => TX_DATA_OUT <= x"FD"; TX_K_OUT <= '1'; + load_sop <= '0'; + load_eop <= '0'; current_state <= SEND_CHKSUM_H; -- gk 05.10.10 when SEND_CHKSUM_H => TX_DATA_OUT <= crc_q; - TX_K_OUT <= '1'; - current_state <= SEND_IDLE_L; + TX_K_OUT <= '0'; +-- current_state <= SEND_IDLE_L; when SEND_IDLE_L => TX_DATA_OUT <= x"BC"; @@ -320,6 +322,7 @@ save_eop <= '1' when (TX_PACKET_NUMBER_IN = b"011") else '0'; current_state = SEND_IDLE_H or current_state = SEND_DATA_H or current_state = SEND_REQUEST_H or + current_state = SEND_CHKSUM_H or current_state = SLEEP then if tx_allow_qtx = '0' then current_state <= SEND_IDLE_L; @@ -456,9 +459,9 @@ save_eop <= '1' when (TX_PACKET_NUMBER_IN = b"011") else '0'; load_read_pointer_i <= '1' when current_state = SEND_START_L else '0'; -- gk 05.10.10 - crc_reset <= '1' when ((RESET_IN = '1') or (current_state = SEND_IDLE_L)) else '0'; + crc_reset <= '1' when ((RESET_IN = '1') or (current_state = SEND_CHKSUM_H) or (current_state = SEND_START_H)) else '0'; crc_en <= '1' when ((current_state = SEND_DATA_L) or (current_state = SEND_DATA_H)) else '0'; - crc_data <= ram_dout(15 downto 8) when (current_state = SEND_IDLE_H) else ram_dout(7 downto 0); + crc_data <= ram_dout(15 downto 8) when (current_state = SEND_DATA_H) else ram_dout(7 downto 0); -- gk 05.10.10 CRC_CALC : trb_net_CRC8 -- 2.43.0