diff --git a/trashernet/trashernet_phy.vhd b/trashernet/trashernet_phy.vhd index 2e085f2..d5c2293 100644 --- a/trashernet/trashernet_phy.vhd +++ b/trashernet/trashernet_phy.vhd @@ -37,9 +37,10 @@ begin receiver : block -- Signal conditioning - signal rx : std_logic; - signal rx_last : std_logic; - signal rx_edge : std_logic; + signal rx : std_logic; + signal rx_last : std_logic; + signal rx_last_static : std_logic; + signal rx_edge : std_logic; -- Bit recovery signal bit_value : std_logic; @@ -61,11 +62,23 @@ begin data_out => rx ); - -- Edge detector for RX - rx_last <= '0' when rst - else rx when rising_edge(clk) - ; - rx_edge <= rx_last xor rx; + -- Edge detector for RX (+glitch filter) + edgedet : process(clk, rst) is + begin + if rst then + rx_last <= '0'; + rx_last_static <= '0'; + rx_edge <= '0'; + + elsif rising_edge(clk) then + rx_edge <= '0'; + if (rx_last = rx) then + rx_edge <= rx_last_static xor rx; + rx_last_static <= rx; + end if; + rx_last <= rx; + end if; + end process edgedet; demanchestizer : block -- Transition detector