]> jspc29.x-matter.uni-frankfurt.de Git - trbnet.git/commitdiff
XCKU media interface: Reset RX on errors
authorThomas Gessler <Thomas.Gessler@exp2.physik.uni-giessen.de>
Thu, 8 Oct 2020 19:13:29 +0000 (21:13 +0200)
committerThomas Gessler <Thomas.Gessler@exp2.physik.uni-giessen.de>
Thu, 8 Oct 2020 19:13:29 +0000 (21:13 +0200)
In some cases the downlink RX logic did not come up correctly after a
reset. This is solved by checking RX data validity after a reset and
applying an RX PMA reset in case of errors.

media_interfaces/med_xcku_sfp_sync.vhd

index 0a0d743c56ccc95b1b3fbcfd529e7cf92f869f98..5851651032e67bdc82c31df25fc213094cee1c8b 100644 (file)
@@ -1,5 +1,6 @@
 library ieee;
 use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
 
 library xpm;
 use xpm.vcomponents.all;
@@ -86,9 +87,11 @@ architecture med_xcku_sfp_sync_arch of med_xcku_sfp_sync is
     signal rx_cdr_lol : std_logic;
     signal tx_lol : std_logic;
 
-    signal rxpmaresetdone_i : std_logic;
+    signal rxresetdone : std_logic;
     signal txpmaresetdone_i : std_logic;
 
+    signal rx_data_valid_count : unsigned(7 downto 0) := (others => '0');
+
     signal debug_rx_control_i : std_logic_vector(31 downto 0);
     signal debug_tx_control_i : std_logic_vector(31 downto 0);
 
@@ -147,9 +150,9 @@ begin
         TXPMARESET      => '0',
         TXPCSRESET      => '0',
         INIT_DONE       => open,
-        RXRESETDONE     => open,
+        RXRESETDONE     => rxresetdone,
         TXRESETDONE     => open,
-        RXPMARESETDONE  => rxpmaresetdone_i,
+        RXPMARESETDONE  => RXPMARESETDONE,
         TXPMARESETDONE  => txpmaresetdone_i,
         RXBYTEISALIGNED => open,
         RXN             => RXN,
@@ -181,9 +184,26 @@ begin
     );
 
     tx_lol <= not txpmaresetdone_i;
-    rx_cdr_lol <= not rxpmaresetdone_i;
 
-    RXPMARESETDONE <= rxpmaresetdone_i;
+    process (RXUSRCLK_DOUBLE) is
+    begin
+        if rising_edge(RXUSRCLK_DOUBLE) then
+            if rxresetdone = '0' then
+                rx_cdr_lol <= '1';
+            else
+                if rxnotintable = '1' then
+                    rx_data_valid_count <= (others => '0');
+                    rx_cdr_lol <= '1';
+                else
+                    rx_data_valid_count <= rx_data_valid_count + 1;
+                    if rx_data_valid_count(rx_data_valid_count'left) = '1' then
+                        rx_cdr_lol <= '0';
+                    end if;
+                end if;
+            end if;
+        end if;
+    end process;
+
     TXPMARESETDONE <= txpmaresetdone_i;
 
     THE_MED_CONTROL : entity work.med_sync_control