From 4d41635f19309141c9a2450921466631503b133e Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Sun, 4 Apr 2010 09:54:27 +0000 Subject: [PATCH] - added MAC own address register - added MAC check and promiscious mode - added new flags 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@852 cc03376c-175c-47c8-b038-4cd826a8556b --- lib/emac/src/emac_top_jb.vhd | 39 +++++++++++++++++++++++++++++------- lib/emac/src/emac_types.vhd | 5 +++++ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/lib/emac/src/emac_top_jb.vhd b/lib/emac/src/emac_top_jb.vhd index 050b2a7..ea67bc9 100644 --- a/lib/emac/src/emac_top_jb.vhd +++ b/lib/emac/src/emac_top_jb.vhd @@ -84,10 +84,12 @@ registers_write: rx_ctrl_in.pkt_req_en <= '0'; rx_ctrl_in.reset <= '0'; if RST_I = '1' then - rx_int_en <= '0'; - tx_int_en <= '0'; - tx_ctrl_in.tx_er <= '0'; - tx_ctrl_in.tx_size <= (others => '0'); + rx_int_en <= '0'; + tx_int_en <= '0'; + tx_ctrl_in.tx_er <= '0'; + tx_ctrl_in.tx_size <= (others => '0'); + rx_ctrl_in.mac_addr <= (X"03", X"02", X"01", X"00", X"07", X"06"); + rx_ctrl_in.promiscious <= '1'; elsif (STB_I and CYC_I and WE_I) = '1' then case ADDR_I(5 downto 2) is @@ -101,6 +103,7 @@ registers_write: rx_ctrl_in.pkt_req_en <= DAT_I(16); tx_int_en <= DAT_I(5); rx_int_en <= DAT_I(4); + rx_ctrl_in.promiscious <= DAT_I(3); when "0001" => tx_ctrl_in.tx_size <= DAT_I(31 downto 16); @@ -109,6 +112,16 @@ registers_write: tx_din_vld <= '1'; tx_din <= DAT_I; + when "0100" => + rx_ctrl_in.mac_addr(0) <= DAT_I(31 downto 24); + rx_ctrl_in.mac_addr(1) <= DAT_I(23 downto 16); + rx_ctrl_in.mac_addr(2) <= DAT_I(15 downto 8); + rx_ctrl_in.mac_addr(3) <= DAT_I(7 downto 0); + + when "0101" => + rx_ctrl_in.mac_addr(4) <= DAT_I(31 downto 24); + rx_ctrl_in.mac_addr(5) <= DAT_I(23 downto 16); + when others => null; end case; end if; @@ -129,18 +142,22 @@ registers_read: ACK_O <= ready; DAT_O <= (others => '0'); DAT_O(31) <= tx_ctrl_in.tx_er; - DAT_O(30) <= mii_rx_er; - DAT_O(29) <= mii_col; - DAT_O(28) <= mii_crs; + DAT_O(30) <= mii_rx_er; -- remove that + DAT_O(29) <= mii_col; -- remove that + DAT_O(28) <= mii_crs; -- remove that DAT_O(27) <= tx_ctrl_out.reset_busy; DAT_O(26) <= tx_ctrl_out.pkt_done; DAT_O(25) <= tx_ctrl_out.pkt_alloc_req; DAT_O(24) <= tx_ctrl_out.pkt_armed; DAT_O(23) <= rx_ctrl_out.reset_busy; + DAT_O(19) <= rx_ctrl_out.pkt_bcast; + DAT_O(18) <= rx_ctrl_out.pkt_mac_match; DAT_O(17) <= rx_ctrl_out.pkt_lost; DAT_O(16) <= rx_ctrl_out.pkt_avail; DAT_O(5) <= tx_int_en; DAT_O(4) <= rx_int_en; + DAT_O(3) <= rx_ctrl_in.promiscious; + when "0001" => ACK_O <= '1'; DAT_O <= tx_ctrl_out.tx_size & rx_ctrl_out.rx_size; @@ -148,6 +165,14 @@ registers_read: when "0010" => rx_ctrl_in.pkt_read_en <= '1'; + when "0100" => + ACK_O <= '1'; + DAT_O <= rx_ctrl_in.mac_addr(0) & rx_ctrl_in.mac_addr(1) & rx_ctrl_in.mac_addr(2) & rx_ctrl_in.mac_addr(3); + + when "0101" => + ACK_O <= '1'; + DAT_O <= rx_ctrl_in.mac_addr(4) & rx_ctrl_in.mac_addr(5) & X"0000"; + when others => null; end case; end if; diff --git a/lib/emac/src/emac_types.vhd b/lib/emac/src/emac_types.vhd index 42d1e9b..fbbc558 100644 --- a/lib/emac/src/emac_types.vhd +++ b/lib/emac/src/emac_types.vhd @@ -12,6 +12,7 @@ use IEEE.MATH_REAL.ALL; package emac_types is -- Constants + type mac_addr_t is array (0 to 5) of unsigned (7 downto 0); -- Types type tx_ctrl_in_t is record @@ -35,12 +36,16 @@ package emac_types is pkt_read_en : std_logic; pkt_req_en : std_logic; pkt_free_en : std_logic; + mac_addr : mac_addr_t; + promiscious : std_logic; end record; type rx_ctrl_out_t is record rx_er : std_logic; pkt_avail : std_logic; pkt_lost : std_logic; + pkt_bcast : std_logic; + pkt_mac_match : std_logic; rx_size : unsigned(15 downto 0); reset_busy : std_logic; end record;