From 6e616c5f35f9ca645a826564c1601c6b36b989a7 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Tue, 30 Sep 2025 16:12:52 +0200 Subject: [PATCH] ipv4: Only forward rx_ok/error strobes when addressed --- trashernet/trashernet_ipv4.vhd | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/trashernet/trashernet_ipv4.vhd b/trashernet/trashernet_ipv4.vhd index 2ee1f89..83b4128 100644 --- a/trashernet/trashernet_ipv4.vhd +++ b/trashernet/trashernet_ipv4.vhd @@ -59,6 +59,7 @@ begin alias sr_destination_ip is sr(16 to 19); signal header_ok : std_logic; + signal selected : std_logic; signal bytecount : integer range 0 to 65535; signal block_done : std_logic; @@ -82,16 +83,13 @@ begin ipv4_out.rx_error_stb <= '0'; ipv4_out.rx_header_rcv <= '0'; bytecount <= BYTECOUNT_HEADER; + selected <= '0'; elsif rising_edge(clk) then ipv4_out.rx_ok_stb <= '0'; ipv4_out.rx_error_stb <= '0'; ipv4_out.rx_header_rcv <= '0'; - if (ethernet_ii_out.rx_crc_ok or ethernet_ii_out.rx_crc_error) then - ipv4_out.rx_error_stb <= ethernet_ii_out.rx_crc_error or to_std_logic(state = PAYLOAD); - ipv4_out.rx_ok_stb <= ethernet_ii_out.rx_crc_ok and to_std_logic(state = DONE); - end if; if (ethernet_ii_out.rx_data_valid = '1') and (bytecount > 0) then if state = HEADER then sr <= sr(sr'low + 1 to sr'high) & ethernet_ii_out.rx_data; @@ -105,6 +103,7 @@ begin bytecount <= to_integer(unsigned(sr_ihl) - 5) * 4; -- five 32-bit words is the header itself if header_ok then state <= OPT; + selected <= '1'; ipv4_out.rx_header_rcv <= '1'; else state <= DONE; @@ -125,9 +124,14 @@ begin when DONE => -- @suppress "Dead state 'DONE'": Outgoing state transition is outside of case statement null; -- We just wait here until the MAC gives us a CRC OK/error end case; + if selected and (ethernet_ii_out.rx_crc_ok or ethernet_ii_out.rx_crc_error) then + ipv4_out.rx_error_stb <= ethernet_ii_out.rx_crc_error or to_std_logic(state = PAYLOAD); + ipv4_out.rx_ok_stb <= ethernet_ii_out.rx_crc_ok and to_std_logic(state = DONE); + end if; if (ethernet_ii_out.rx_header_rcv) then state <= HEADER; bytecount <= BYTECOUNT_HEADER; + selected <= '0'; end if; end if; end process rx_fsm;