From 6bbe32e93578e8432c560734be2154339cadd4a0 Mon Sep 17 00:00:00 2001 From: Thomas Gessler Date: Wed, 30 Sep 2020 15:03:12 +0200 Subject: [PATCH] Move retransmit sync logic to med_sync_control Retransmit signals are produced with the RXI clock and were previously synchronized to the TXI clock in tx_control, where the RXI clock is not available. The incoming signals were sampled with the unrelated system clock. Moving everything up one level allows for a cleaner CDC. --- media_interfaces/sync/med_sync_control.vhd | 44 ++++++++++++++++++++-- media_interfaces/sync/tx_control.vhd | 44 ++-------------------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/media_interfaces/sync/med_sync_control.vhd b/media_interfaces/sync/med_sync_control.vhd index c91f378..6df14ad 100644 --- a/media_interfaces/sync/med_sync_control.vhd +++ b/media_interfaces/sync/med_sync_control.vhd @@ -70,6 +70,10 @@ signal request_retr_i : std_logic; signal start_retr_i : std_logic; signal request_retr_position_i : std_logic_vector(7 downto 0); signal start_retr_position_i : std_logic_vector(7 downto 0); +signal request_retr_tx : std_logic; +signal start_retr_tx : std_logic; +signal request_retr_position_q : std_logic_vector(7 downto 0); +signal start_retr_position_q : std_logic_vector(7 downto 0); signal rx_dlm_i : std_logic; signal led_ok : std_logic; @@ -237,11 +241,11 @@ THE_TX : tx_control TX_K_OUT => TX_K, TX_CD_OUT => TX_CD, - REQUEST_RETRANSMIT_IN => request_retr_i, --TODO - REQUEST_POSITION_IN => request_retr_position_i, --TODO + REQUEST_RETRANSMIT_IN => request_retr_tx, --TODO + REQUEST_POSITION_IN => request_retr_position_q, --TODO - START_RETRANSMIT_IN => start_retr_i, --TODO - START_POSITION_IN => start_retr_position_i, --TODO + START_RETRANSMIT_IN => start_retr_tx, --TODO + START_POSITION_IN => start_retr_position_q, --TODO SEND_DLM => TX_DLM, SEND_DLM_WORD => TX_DLM_WORD, @@ -295,6 +299,38 @@ THE_RX_CONTROL : rx_control RX_DLM <= rx_dlm_i; MEDIA_MED2INT <= media_med2int_i; +THE_RETRANSMIT_PULSE_SYNC_1 : pulse_sync +port map( + CLK_A_IN => CLK_RXI, + RESET_A_IN => reset_i, + PULSE_A_IN => request_retr_i, + CLK_B_IN => CLK_TXI, + RESET_B_IN => reset_i, + PULSE_B_OUT => request_retr_tx +); + +THE_RETRANSMIT_PULSE_SYNC_2 : pulse_sync +port map( + CLK_A_IN => CLK_RXI, + RESET_A_IN => reset_i, + PULSE_A_IN => start_retr_i, + CLK_B_IN => CLK_TXI, + RESET_B_IN => reset_i, + PULSE_B_OUT => start_retr_tx +); + +THE_POSITION_REG : process(CLK_RXI) +begin + if rising_edge(CLK_RXI) then + if request_retr_i = '1' then + request_retr_position_q <= request_retr_position_i; + end if; + if start_retr_i = '1' then + start_retr_position_q <= start_retr_position_i; + end if; + end if; +end process; + ------------------------------------------------- -- Generate LED signals ------------------------------------------------- diff --git a/media_interfaces/sync/tx_control.vhd b/media_interfaces/sync/tx_control.vhd index 298e8d2..58d6d82 100644 --- a/media_interfaces/sync/tx_control.vhd +++ b/media_interfaces/sync/tx_control.vhd @@ -65,8 +65,6 @@ architecture arch of tx_control is signal ram_empty : std_logic; signal ram_afull : std_logic; - signal request_position_q : std_logic_vector( 7 downto 0); - signal restart_position_q : std_logic_vector( 7 downto 0); signal request_position_i : std_logic_vector( 7 downto 0); signal restart_position_i : std_logic_vector( 7 downto 0); signal make_request_i : std_logic; @@ -74,8 +72,6 @@ architecture arch of tx_control is signal load_read_pointer_i : std_logic; signal send_dlm_in_i : std_logic; signal send_dlm_i : std_logic; - signal start_retransmit_i : std_logic; - signal request_retransmit_i : std_logic; signal buf_tx_read_out : std_logic; signal tx_data_200 : std_logic_vector(17 downto 0); @@ -374,26 +370,6 @@ begin D_OUT(0) => tx_allow_q); - THE_RETRANSMIT_PULSE_SYNC_1 : pulse_sync - port map( - CLK_A_IN => CLK_100, - RESET_A_IN => RESET_IN, - PULSE_A_IN => REQUEST_RETRANSMIT_IN, - CLK_B_IN => CLK_200, - RESET_B_IN => RESET_IN, - PULSE_B_OUT => request_retransmit_i - ); - - THE_RETRANSMIT_PULSE_SYNC_2 : pulse_sync - port map( - CLK_A_IN => CLK_100, - RESET_A_IN => RESET_IN, - PULSE_A_IN => START_RETRANSMIT_IN, - CLK_B_IN => CLK_200, - RESET_B_IN => RESET_IN, - PULSE_B_OUT => start_retransmit_i - ); - -- THE_RETRANSMIT_PULSE_SYNC_3 : pulse_sync -- port map( -- CLK_A_IN => CLK_100, @@ -405,18 +381,6 @@ begin -- ); send_dlm_in_i <= SEND_DLM; - THE_POSITION_REG : process(CLK_100) - begin - if rising_edge(CLK_100) then - if REQUEST_RETRANSMIT_IN = '1' then - request_position_q <= REQUEST_POSITION_IN; - end if; - if START_RETRANSMIT_IN = '1' then - restart_position_q <= START_POSITION_IN; - end if; - end if; - end process; - --Store Request Retransmit position THE_STORE_REQUEST_PROC : process(CLK_200, RESET_IN) @@ -428,9 +392,9 @@ begin if tx_allow_qtx = '0' then make_request_i <= '0'; request_position_i <= (others => '0'); - elsif request_retransmit_i = '1' then + elsif REQUEST_RETRANSMIT_IN = '1' then make_request_i <= '1'; - request_position_i <= request_position_q; + request_position_i <= REQUEST_POSITION_IN; elsif current_state = SEND_REQUEST_L then make_request_i <= '0'; elsif current_state = SEND_REQUEST_H then @@ -450,9 +414,9 @@ begin if tx_allow_qtx = '0' then make_restart_i <= '0'; restart_position_i <= (others => '0'); - elsif start_retransmit_i = '1' then + elsif START_RETRANSMIT_IN = '1' then make_restart_i <= '1'; - restart_position_i <= restart_position_q; + restart_position_i <= START_POSITION_IN; elsif current_state = SEND_START_L then make_restart_i <= '0'; elsif current_state = SEND_START_H then -- 2.43.0