OpenCores
URL https://opencores.org/ocsvn/udp_ip_stack/udp_ip_stack/trunk

Subversion Repositories udp_ip_stack

[/] [udp_ip_stack/] [trunk/] [rtl/] [vhdl/] [arpv2.vhd] - Diff between revs 10 and 18

Show entire file | Details | Blame | View Log

Rev 10 Rev 18
Line 29... Line 29...
-- Revision 0.01 - File Created
-- Revision 0.01 - File Created
-- Additional Comments: 
-- Additional Comments: 
--
--
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
library IEEE;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.ALL;
use IEEE.NUMERIC_STD.all;
use work.arp_types.all;
use work.arp_types.all;
 
 
entity arpv2 is
entity arpv2 is
         generic (
         generic (
 
    no_default_gateway : boolean := true;  -- set to false if communicating with devices accessed
 
                                            -- though a "default gateway or router"
                        CLOCK_FREQ                      : integer := 125000000;                                                 -- freq of data_in_clk -- needed to timout cntr
                        CLOCK_FREQ                      : integer := 125000000;                                                 -- freq of data_in_clk -- needed to timout cntr
                        ARP_TIMEOUT                     : integer := 60;                                                                        -- ARP response timeout (s)
                        ARP_TIMEOUT                     : integer := 60;                                                                        -- ARP response timeout (s)
                        ARP_MAX_PKT_TMO : integer := 5;                                                                 -- # wrong nwk pkts received before set error
                        ARP_MAX_PKT_TMO : integer := 5;                                                                 -- # wrong nwk pkts received before set error
                        MAX_ARP_ENTRIES         : integer := 255                                                                        -- max entries in the arp store
                        MAX_ARP_ENTRIES         : integer := 255                                                                        -- max entries in the arp store
                        );
                        );
    Port (
  port (
                        -- lookup request signals
                        -- lookup request signals
                        arp_req_req                     : in arp_req_req_type;
                        arp_req_req                     : in arp_req_req_type;
                        arp_req_rslt            : out arp_req_rslt_type;
                        arp_req_rslt            : out arp_req_rslt_type;
                        -- MAC layer RX signals
                        -- MAC layer RX signals
                        data_in_clk             : in  STD_LOGIC;
    data_in_clk     : in  std_logic;
                        reset                           : in  STD_LOGIC;
    reset           : in  std_logic;
                        data_in                                 : in  STD_LOGIC_VECTOR (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
    data_in         : in  std_logic_vector (7 downto 0);  -- ethernet frame (from dst mac addr through to last byte of frame)
                        data_in_valid           : in  STD_LOGIC;                                                                        -- indicates data_in valid on clock
    data_in_valid   : in  std_logic;    -- indicates data_in valid on clock
                        data_in_last            : in  STD_LOGIC;                                                                        -- indicates last data in frame
    data_in_last    : in  std_logic;    -- indicates last data in frame
                        -- MAC layer TX signals
                        -- MAC layer TX signals
                        mac_tx_req                      : out std_logic;                                                                        -- indicates that ip wants access to channel (stays up for as long as tx)
                        mac_tx_req                      : out std_logic;                                                                        -- indicates that ip wants access to channel (stays up for as long as tx)
                        mac_tx_granted          : in std_logic;                                                                 -- indicates that access to channel has been granted            
                        mac_tx_granted          : in std_logic;                                                                 -- indicates that access to channel has been granted            
                        data_out_clk            : in std_logic;
                        data_out_clk            : in std_logic;
                        data_out_ready          : in std_logic;                                                                 -- indicates system ready to consume data
                        data_out_ready          : in std_logic;                                                                 -- indicates system ready to consume data
                        data_out_valid          : out std_logic;                                                                        -- indicates data out is valid
                        data_out_valid          : out std_logic;                                                                        -- indicates data out is valid
                        data_out_first          : out std_logic;                                                                        -- with data out valid indicates the first byte of a frame
                        data_out_first          : out std_logic;                                                                        -- with data out valid indicates the first byte of a frame
                        data_out_last           : out std_logic;                                                                        -- with data out valid indicates the last byte of a frame
                        data_out_last           : out std_logic;                                                                        -- with data out valid indicates the last byte of a frame
                        data_out                                : out std_logic_vector (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
                        data_out                                : out std_logic_vector (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
                        -- system signals
                        -- system signals
                        our_mac_address         : in STD_LOGIC_VECTOR (47 downto 0);
    our_mac_address : in  std_logic_vector (47 downto 0);
                        our_ip_address  : in STD_LOGIC_VECTOR (31 downto 0);
    our_ip_address  : in  std_logic_vector (31 downto 0);
 
    nwk_gateway     : in  std_logic_vector (31 downto 0) := (others => '0');  -- IP address of default gateway
 
    nwk_mask        : in  std_logic_vector (31 downto 0) := (others => '0');  -- Net mask
                        control                         : in arp_control_type;
                        control                         : in arp_control_type;
                        req_count                       : out STD_LOGIC_VECTOR(7 downto 0)                       -- count of arp pkts received
    req_count       : out std_logic_vector(7 downto 0)    -- count of arp pkts received
                        );
                        );
end arpv2;
end arpv2;
 
 
architecture structural of arpv2 is
architecture structural of arpv2 is
 
 
    COMPONENT arp_req
  component arp_req
         generic (
         generic (
 
      no_default_gateway : boolean := true;
                        CLOCK_FREQ                       : integer := 125000000;                        -- freq of data_in_clk -- needed to timout cntr
                        CLOCK_FREQ                       : integer := 125000000;                        -- freq of data_in_clk -- needed to timout cntr
                        ARP_TIMEOUT                      : integer := 60;                                               -- ARP response timeout (s)
                        ARP_TIMEOUT                      : integer := 60;                                               -- ARP response timeout (s)
                        ARP_MAX_PKT_TMO  : integer := 5                                         -- # wrong nwk pkts received before set error
                        ARP_MAX_PKT_TMO  : integer := 5                                         -- # wrong nwk pkts received before set error
                        );
                        );
    Port (
    port (
                        -- lookup request signals
                        -- lookup request signals
                        arp_req_req                     : in arp_req_req_type;                          -- request for a translation from IP to MAC
                        arp_req_req                     : in arp_req_req_type;                          -- request for a translation from IP to MAC
                        arp_req_rslt            : out arp_req_rslt_type;                        -- the result
                        arp_req_rslt            : out arp_req_rslt_type;                        -- the result
                        -- external arp store signals
                        -- external arp store signals
                        arp_store_req           : out arp_store_rdrequest_t;            -- requesting a lookup or store
                        arp_store_req           : out arp_store_rdrequest_t;            -- requesting a lookup or store
Line 87... Line 92...
                        -- network request signals
                        -- network request signals
                        arp_nwk_req                     : out arp_nwk_request_t;                        -- requesting resolution via the network
                        arp_nwk_req                     : out arp_nwk_request_t;                        -- requesting resolution via the network
                        arp_nwk_result          : in arp_nwk_result_t;                          -- the result
                        arp_nwk_result          : in arp_nwk_result_t;                          -- the result
                        -- system signals
                        -- system signals
                        clear_cache                     : in std_logic;                                         -- clear the internal cache
                        clear_cache                     : in std_logic;                                         -- clear the internal cache
 
      nwk_gateway      : in  std_logic_vector(31 downto 0);  -- IP address of default gateway
 
      nwk_mask         : in  std_logic_vector(31 downto 0);  -- Net mask
                        clk                                     : in std_logic;
                        clk                                     : in std_logic;
                        reset                           : in  STD_LOGIC
      reset            : in  std_logic
                        );
                        );
    END COMPONENT;
  end component;
 
 
    COMPONENT arp_tx
  component arp_tx
    PORT(
    port(
                        -- control signals
                        -- control signals
                        send_I_have                     : in std_logic;                                                                 -- pulse will be latched
                        send_I_have                     : in std_logic;                                                                 -- pulse will be latched
                        arp_entry                       : in arp_entry_t;                                                                       -- arp target for I_have req (will be latched)
                        arp_entry                       : in arp_entry_t;                                                                       -- arp target for I_have req (will be latched)
                        send_who_has            : in std_logic;                                                                 -- pulse will be latched
                        send_who_has            : in std_logic;                                                                 -- pulse will be latched
                        ip_entry                                : in STD_LOGIC_VECTOR (31 downto 0);             -- ip target for who_has req (will be latched)
      ip_entry        : in  std_logic_vector (31 downto 0);  -- ip target for who_has req (will be latched)
                        -- MAC layer TX signals
                        -- MAC layer TX signals
                        mac_tx_req                      : out std_logic;                                                                        -- indicates that ip wants access to channel (stays up for as long as tx)
                        mac_tx_req                      : out std_logic;                                                                        -- indicates that ip wants access to channel (stays up for as long as tx)
                        mac_tx_granted          : in std_logic;                                                                 -- indicates that access to channel has been granted            
                        mac_tx_granted          : in std_logic;                                                                 -- indicates that access to channel has been granted            
                        data_out_ready          : in std_logic;                                                                 -- indicates system ready to consume data
                        data_out_ready          : in std_logic;                                                                 -- indicates system ready to consume data
                        data_out_valid          : out std_logic;                                                                        -- indicates data out is valid
                        data_out_valid          : out std_logic;                                                                        -- indicates data out is valid
                        data_out_first          : out std_logic;                                                                        -- with data out valid indicates the first byte of a frame
                        data_out_first          : out std_logic;                                                                        -- with data out valid indicates the first byte of a frame
                        data_out_last           : out std_logic;                                                                        -- with data out valid indicates the last byte of a frame
                        data_out_last           : out std_logic;                                                                        -- with data out valid indicates the last byte of a frame
                        data_out                                : out std_logic_vector (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
                        data_out                                : out std_logic_vector (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
                        -- system signals
                        -- system signals
                        our_mac_address         : in STD_LOGIC_VECTOR (47 downto 0);
      our_mac_address : in  std_logic_vector (47 downto 0);
                        our_ip_address  : in STD_LOGIC_VECTOR (31 downto 0);
      our_ip_address  : in  std_logic_vector (31 downto 0);
                        tx_clk                          : in std_logic;
                        tx_clk                          : in std_logic;
                        reset                                   : in std_logic
                        reset                                   : in std_logic
        );
        );
    END COMPONENT;
  end component;
 
 
    COMPONENT arp_rx
  component arp_rx
    PORT(
    port(
                        -- MAC layer RX signals
                        -- MAC layer RX signals
                        data_in                                 : in  STD_LOGIC_VECTOR (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
      data_in               : in  std_logic_vector (7 downto 0);  -- ethernet frame (from dst mac addr through to last byte of frame)
                        data_in_valid           : in  STD_LOGIC;                                                                        -- indicates data_in valid on clock
      data_in_valid         : in  std_logic;    -- indicates data_in valid on clock
                        data_in_last            : in  STD_LOGIC;                                                                        -- indicates last data in frame
      data_in_last          : in  std_logic;    -- indicates last data in frame
                        -- ARP output signals
                        -- ARP output signals
                        recv_who_has            : out std_logic;                                                                        -- pulse will be latched
                        recv_who_has            : out std_logic;                                                                        -- pulse will be latched
                        arp_entry_for_who_has   : out arp_entry_t;                                              -- target for who_has msg (Iie, who to reply to)
                        arp_entry_for_who_has   : out arp_entry_t;                                              -- target for who_has msg (Iie, who to reply to)
                        recv_I_have                     : out std_logic;                                                                        -- pulse will be latched
                        recv_I_have                     : out std_logic;                                                                        -- pulse will be latched
                        arp_entry_for_I_have    : out arp_entry_t;                                                      -- arp target for I_have msg
                        arp_entry_for_I_have    : out arp_entry_t;                                                      -- arp target for I_have msg
                        -- control and status signals
                        -- control and status signals
                        req_count                       : out STD_LOGIC_VECTOR(7 downto 0);                      -- count of arp pkts received
      req_count             : out std_logic_vector(7 downto 0);   -- count of arp pkts received
                        -- system signals
                        -- system signals
                        our_ip_address  : in STD_LOGIC_VECTOR (31 downto 0);
      our_ip_address        : in  std_logic_vector (31 downto 0);
                        rx_clk                          : in std_logic;
                        rx_clk                          : in std_logic;
                        reset                           : in  STD_LOGIC
      reset                 : in  std_logic
        );
        );
    END COMPONENT;
  end component;
 
 
 
 
    COMPONENT arp_store_br
  component arp_store_br
         generic (
         generic (
                        MAX_ARP_ENTRIES : integer := 255                                                        -- max entries in the store
                        MAX_ARP_ENTRIES : integer := 255                                                        -- max entries in the store
                        );
                        );
         Port (
    port (
                        -- read signals
                        -- read signals
                        read_req                                : in arp_store_rdrequest_t;             -- requesting a lookup or store
                        read_req                                : in arp_store_rdrequest_t;             -- requesting a lookup or store
                        read_result                     : out arp_store_result_t;                       -- the result
                        read_result                     : out arp_store_result_t;                       -- the result
                        -- write signals
                        -- write signals
                        write_req                       : in arp_store_wrrequest_t;             -- requesting a lookup or store
                        write_req                       : in arp_store_wrrequest_t;             -- requesting a lookup or store
                        -- control and status signals
                        -- control and status signals
                        clear_store                     : in std_logic;                                         -- erase all entries
                        clear_store                     : in std_logic;                                         -- erase all entries
                        entry_count                     : out unsigned(7 downto 0);              -- how many entries currently in store
                        entry_count                     : out unsigned(7 downto 0);              -- how many entries currently in store
                        -- system signals
                        -- system signals
                        clk                                     : in std_logic;
                        clk                                     : in std_logic;
                        reset                           : in  STD_LOGIC
      reset       : in  std_logic
        );
        );
    END COMPONENT;
  end component;
 
 
    COMPONENT arp_sync
  component arp_sync
         Port (
    port (
                                -- REQ to TX
                                -- REQ to TX
                                arp_nwk_req                                     : in arp_nwk_request_t;                         -- request for a translation from IP to MAC
                                arp_nwk_req                                     : in arp_nwk_request_t;                         -- request for a translation from IP to MAC
                                send_who_has                            : out std_logic;
                                send_who_has                            : out std_logic;
                                ip_entry                                                : out STD_LOGIC_VECTOR (31 downto 0);
      ip_entry              : out std_logic_vector (31 downto 0);
                                -- RX to TX
                                -- RX to TX
                                recv_who_has                            : in std_logic;                                         -- this is for us, we will respond
                                recv_who_has                            : in std_logic;                                         -- this is for us, we will respond
                                arp_entry_for_who_has   : in arp_entry_t;
                                arp_entry_for_who_has   : in arp_entry_t;
                                send_I_have                                     : out std_logic;
                                send_I_have                                     : out std_logic;
                                arp_entry                                       : out arp_entry_t;
                                arp_entry                                       : out arp_entry_t;
Line 174... Line 181...
                                -- System Signals
                                -- System Signals
                                rx_clk                                          : in std_logic;
                                rx_clk                                          : in std_logic;
                                tx_clk                                          : in std_logic;
                                tx_clk                                          : in std_logic;
                                reset                                                   : in std_logic
                                reset                                                   : in std_logic
        );
        );
    END COMPONENT;
  end component;
 
 
 
 
                -- interconnect REQ -> ARP_TX
                -- interconnect REQ -> ARP_TX
                signal arp_nwk_req_int          : arp_nwk_request_t;                    -- tx req from REQ
                signal arp_nwk_req_int          : arp_nwk_request_t;                    -- tx req from REQ
 
 
                signal send_I_have_int          : std_logic;
                signal send_I_have_int          : std_logic;
                signal arp_entry_int                    : arp_entry_t;
                signal arp_entry_int                    : arp_entry_t;
                signal send_who_has_int         : std_logic;
                signal send_who_has_int         : std_logic;
                signal ip_entry_int                     : STD_LOGIC_VECTOR (31 downto 0);
  signal ip_entry_int     : std_logic_vector (31 downto 0);
 
 
                -- interconnect REQ <-> ARP_STORE
                -- interconnect REQ <-> ARP_STORE
                signal arp_store_req_int        : arp_store_rdrequest_t;                -- lookup request
                signal arp_store_req_int        : arp_store_rdrequest_t;                -- lookup request
                signal arp_store_result_int: arp_store_result_t;                        -- lookup result
                signal arp_store_result_int: arp_store_result_t;                        -- lookup result
 
 
Line 206... Line 213...
begin
begin
 
 
 
 
   req : arp_req
   req : arp_req
                        generic map (
                        generic map (
 
      no_default_gateway => no_default_gateway,
                         CLOCK_FREQ                     => CLOCK_FREQ,
                         CLOCK_FREQ                     => CLOCK_FREQ,
                         ARP_TIMEOUT            => ARP_TIMEOUT,
                         ARP_TIMEOUT            => ARP_TIMEOUT,
                         ARP_MAX_PKT_TMO        => ARP_MAX_PKT_TMO
                         ARP_MAX_PKT_TMO        => ARP_MAX_PKT_TMO
                         )
                         )
                        PORT MAP (
    port map (
                        -- lookup request signals
                        -- lookup request signals
          arp_req_req                           => arp_req_req,
          arp_req_req                           => arp_req_req,
          arp_req_rslt                          => arp_req_rslt,
          arp_req_rslt                          => arp_req_rslt,
                        -- external arp store signals
                        -- external arp store signals
          arp_store_req                         => arp_store_req_int,
          arp_store_req                         => arp_store_req_int,
Line 223... Line 231...
          arp_nwk_req                           => arp_nwk_req_int,
          arp_nwk_req                           => arp_nwk_req_int,
          arp_nwk_result.status => nwk_result_status_int,
          arp_nwk_result.status => nwk_result_status_int,
          arp_nwk_result.entry  => arp_entry_for_I_have_int,
          arp_nwk_result.entry  => arp_entry_for_I_have_int,
                        -- system signals
                        -- system signals
                         clear_cache                            => control.clear_cache,
                         clear_cache                            => control.clear_cache,
 
      nwk_gateway           => nwk_gateway,
 
      nwk_mask              => nwk_mask,
          clk                                                   => data_in_clk,
          clk                                                   => data_in_clk,
          reset                                                 => reset
          reset                                                 => reset
        );
        );
 
 
   sync : arp_sync PORT MAP (
  sync : arp_sync port map (
                         -- REQ to TX
                         -- REQ to TX
                         arp_nwk_req                            => arp_nwk_req_int,
                         arp_nwk_req                            => arp_nwk_req_int,
                         send_who_has                           => send_who_has_int,
                         send_who_has                           => send_who_has_int,
                         ip_entry                                       => ip_entry_int,
                         ip_entry                                       => ip_entry_int,
                         -- RX to TX
                         -- RX to TX
Line 246... Line 256...
                         rx_clk                                         => data_in_clk,
                         rx_clk                                         => data_in_clk,
                         tx_clk                                         => data_out_clk,
                         tx_clk                                         => data_out_clk,
                         reset                                          => reset
                         reset                                          => reset
        );
        );
 
 
   tx : arp_tx PORT MAP (
  tx : arp_tx port map (
                        -- control signals
                        -- control signals
          send_I_have                   => send_I_have_int,
          send_I_have                   => send_I_have_int,
          arp_entry                             => arp_entry_int,
          arp_entry                             => arp_entry_int,
          send_who_has                  => send_who_has_int,
          send_who_has                  => send_who_has_int,
          ip_entry                              => ip_entry_int,
          ip_entry                              => ip_entry_int,
Line 267... Line 277...
          our_mac_address               => our_mac_address,
          our_mac_address               => our_mac_address,
          tx_clk                                        => data_out_clk,
          tx_clk                                        => data_out_clk,
          reset                                         => reset
          reset                                         => reset
        );
        );
 
 
   rx : arp_rx PORT MAP (
  rx : arp_rx port map (
                        -- MAC layer RX signals
                        -- MAC layer RX signals
          data_in                                       => data_in,
          data_in                                       => data_in,
          data_in_valid                 => data_in_valid,
          data_in_valid                 => data_in_valid,
          data_in_last                  => data_in_last,
          data_in_last                  => data_in_last,
                        -- ARP output signals
                        -- ARP output signals
Line 289... Line 299...
 
 
   store : arp_store_br
   store : arp_store_br
                        generic map (
                        generic map (
                                MAX_ARP_ENTRIES => MAX_ARP_ENTRIES
                                MAX_ARP_ENTRIES => MAX_ARP_ENTRIES
                        )
                        )
                        PORT MAP (
    port map (
                        -- read signals
                        -- read signals
          read_req                              => arp_store_req_int,
          read_req                              => arp_store_req_int,
          read_result                   => arp_store_result_int,
          read_result                   => arp_store_result_int,
                        -- write signals
                        -- write signals
          write_req.req                 => recv_I_have_int,
          write_req.req                 => recv_I_have_int,

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.