From e7f4a5642a529433bbaa4ea9e5126ea37c10e534 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Fri, 9 Apr 2010 09:00:38 +0000 Subject: [PATCH] - added FCS-check (CRC32) - added FCS check enable Committed on the Free edition of March Hare Software CVSNT Server. Upgrade to CVS Suite for more features and support: http://march-hare.com/cvsnt/ git-svn-id: http://moon:8086/svn/vhdl/trunk@895 cc03376c-175c-47c8-b038-4cd826a8556b --- lib/emac/src/emac_rx.vhd | 44 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/lib/emac/src/emac_rx.vhd b/lib/emac/src/emac_rx.vhd index aa26c9c..918635b 100644 --- a/lib/emac/src/emac_rx.vhd +++ b/lib/emac/src/emac_rx.vhd @@ -104,8 +104,15 @@ ARCHITECTURE behavior OF emac_rx IS signal mac_chk_addr : mac_addr_t; signal Gbps_en : std_logic; + signal fcs_chk_en : std_logic; signal rx_en : std_logic; + signal fcs_vld : std_logic; + signal fcs_din_vld : std_logic; + signal fcs_din : unsigned(7 downto 0); + signal fcs : unsigned(31 downto 0); + signal fcs_chk_OK : std_logic; + type host_state_t is (host_init, host_flush, host_idle); signal host_s, host_sn : host_state_t; @@ -143,11 +150,11 @@ begin ram_addr_a <= xfer_ptr; ram_we_a <= xfer_en and sipo32_dout_vld; - xfer_vld <= mac_chk_OK or mac_chk_BC or xfer_promiscious; + xfer_vld <= (mac_chk_OK or mac_chk_BC or xfer_promiscious) and (not fcs_chk_en or fcs_chk_OK); cmd_fifo_we <= commit_en and xfer_vld; cmd_fifo_re <= ctrl_in.pkt_free_en; - cmd_pkt_valid_in <= '1'; + cmd_pkt_valid_in <= fcs_chk_OK; cmd_mac_ok_in <= mac_chk_OK; cmd_bcast_in <= mac_chk_BC; cmd_nbytes_in <= byte_count; @@ -194,6 +201,7 @@ host2xfer_sync_register: if rising_edge(mii_rx_clk) then xfer_promiscious <= ctrl_in.promiscious; Gbps_en <= ctrl_in.Gbps_en; + fcs_chk_en <= ctrl_in.fcs_chk_en; mac_addr <= ctrl_in.mac_addr; xfer_ram_limit <= host_ram_limit; end if; @@ -472,6 +480,38 @@ inst_sipo32 : entity work.sipo ); +inst_fcs: entity work.crc32 + GENERIC MAP + ( + crc32_init => X"00000000" + ) + PORT MAP + ( + rst => byte_count_rst, + clk => mii_rx_clk, + din_vld => fcs_din_vld, + din => fcs_din, + crc32_vld => fcs_vld, + crc32_out => fcs + + ); + + fcs_din <= sipo32_din; + fcs_din_vld <= sipo32_en and sipo32_din_vld; + +fcs_chk_register: + process(mii_rx_clk) + begin + if rising_edge(mii_rx_clk) then + if fcs_vld = '1' then + fcs_chk_OK <= '0'; + if fcs = X"2144DF1C" then + fcs_chk_OK <= '1'; + end if; + end if; + end if; + end process; + mii_input_register: process(mii_rx_clk) begin