From 5d6df0219be2bc1a4bfab8b2c106f4ba25e9f4d3 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Sat, 28 Aug 2021 14:22:28 +0200 Subject: [PATCH] phy: rx: Introduce simple glitch filter --- trashernet/trashernet_phy.vhd | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) 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