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

Subversion Repositories udp_ip_stack

[/] [udp_ip_stack/] [trunk/] [rtl/] [vhdl/] [IPv4_TX.vhd] - Diff between revs 4 and 6

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 4 Rev 6
Line 17... Line 17...
--
--
-- Revision: 
-- Revision: 
-- Revision 0.01 - File Created
-- Revision 0.01 - File Created
-- Revision 0.02 - fixed up setting of tx_result control defaults
-- Revision 0.02 - fixed up setting of tx_result control defaults
-- Revision 0.03 - Added data_out_first
-- Revision 0.03 - Added data_out_first
 
-- Revision 0.04 - Added handling of broadcast address
-- Additional Comments: 
-- Additional Comments: 
--
--
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
library IEEE;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_1164.ALL;
Line 92... Line 93...
        -- tx control signals
        -- tx control signals
        signal next_tx_state    : tx_state_type;
        signal next_tx_state    : tx_state_type;
        signal set_tx_state             : std_logic;
        signal set_tx_state             : std_logic;
        signal next_tx_result   : std_logic_vector (1 downto 0);
        signal next_tx_result   : std_logic_vector (1 downto 0);
        signal set_tx_result            : std_logic;
        signal set_tx_result            : std_logic;
 
        signal tx_mac_value             : std_logic_vector (47 downto 0);
        signal set_tx_mac                       : std_logic;
        signal set_tx_mac                       : std_logic;
        signal tx_count_val             : unsigned (11 downto 0);
        signal tx_count_val             : unsigned (11 downto 0);
        signal tx_count_mode            : settable_cnt_type;
        signal tx_count_mode            : settable_cnt_type;
        signal tx_data                          : std_logic_vector (7 downto 0);
        signal tx_data                          : std_logic_vector (7 downto 0);
        signal set_last                 : std_logic;
        signal set_last                 : std_logic;
Line 161... Line 163...
                mac_tx_granted, mac_data_out_ready,
                mac_tx_granted, mac_data_out_ready,
                -- state variables
                -- state variables
                tx_state, tx_count, tx_result_reg, tx_mac, tx_mac_chn_reqd,
                tx_state, tx_count, tx_result_reg, tx_mac, tx_mac_chn_reqd,
                mac_lookup_req, tx_hdr_cks, arp_req_ip_reg, mac_data_out_ready_reg,
                mac_lookup_req, tx_hdr_cks, arp_req_ip_reg, mac_data_out_ready_reg,
                -- control signals
                -- control signals
                next_tx_state, set_tx_state, next_tx_result, set_tx_result, set_tx_mac, tx_count_mode,
                next_tx_state, set_tx_state, next_tx_result, set_tx_result, tx_mac_value, set_tx_mac, tx_count_mode,
                tx_data, set_last, set_chn_reqd, set_mac_lku_req, total_length,
                tx_data, set_last, set_chn_reqd, set_mac_lku_req, total_length,
                tx_data_valid, tx_count_val
                tx_data_valid, tx_count_val
                )
                )
        begin
        begin
                -- set output followers
                -- set output followers
Line 206... Line 208...
                set_chn_reqd <= HOLD;
                set_chn_reqd <= HOLD;
                set_mac_lku_req <= HOLD;
                set_mac_lku_req <= HOLD;
                next_tx_result <= IPTX_RESULT_NONE;
                next_tx_result <= IPTX_RESULT_NONE;
                set_tx_result <= '0';
                set_tx_result <= '0';
                tx_count_val <= (others => '0');
                tx_count_val <= (others => '0');
 
                tx_mac_value <= (others => '0');
 
 
                -- set temp signals
                -- set temp signals
                total_length <= std_logic_vector(unsigned(ip_tx.hdr.data_length) + 20);         -- total length = user data length + header length (bytes)
                total_length <= std_logic_vector(unsigned(ip_tx.hdr.data_length) + 20);         -- total length = user data length + header length (bytes)
 
 
                -- TX FSM
                -- TX FSM
Line 222... Line 225...
                                        -- check header count for error if too high
                                        -- check header count for error if too high
                                        if unsigned(ip_tx.hdr.data_length) > 1480 then
                                        if unsigned(ip_tx.hdr.data_length) > 1480 then
                                                next_tx_result <= IPTX_RESULT_ERR;
                                                next_tx_result <= IPTX_RESULT_ERR;
                                                set_tx_result <= '1';
                                                set_tx_result <= '1';
                                        else
                                        else
 
                                                next_tx_result <= IPTX_RESULT_SENDING;
 
                                                set_tx_result <= '1';
 
 
                                                -- TODO - check if we already have the mac addr for this ip, if so, bypass the WAIT_MAC state
                                                -- TODO - check if we already have the mac addr for this ip, if so, bypass the WAIT_MAC state
 
 
                                                -- req the mac address for this ip
                                                if ip_tx.hdr.dst_ip_addr = IP_BC_ADDR then
 
                                                        -- for IP broadcast, dont need to look up the MAC addr
 
                                                        tx_mac_value <= MAC_BC_ADDR;
 
                                                        set_tx_mac <= '1';
 
                                                        next_tx_state <= WAIT_CHN;
 
                                                        set_tx_state <= '1';
 
                                                else
 
                                                        -- need to req the mac address for this ip
                                                set_mac_lku_req <= SET;
                                                set_mac_lku_req <= SET;
                                                next_tx_result <= IPTX_RESULT_SENDING;
 
                                                set_tx_result <= '1';
 
                                                next_tx_state <= WAIT_MAC;
                                                next_tx_state <= WAIT_MAC;
                                                set_tx_state <= '1';
                                                set_tx_state <= '1';
                                        end if;
                                        end if;
 
                                        end if;
                                else
                                else
                                        set_mac_lku_req <= CLR;
                                        set_mac_lku_req <= CLR;
                                end if;
                                end if;
 
 
                        when WAIT_MAC =>
                        when WAIT_MAC =>
                                ip_tx_data_out_ready <= '0';             -- in this state, we are unable to accept user data for tx
                                ip_tx_data_out_ready <= '0';             -- in this state, we are unable to accept user data for tx
                                if arp_req_rslt.got_mac = '1' then
                                if arp_req_rslt.got_mac = '1' then
                                        -- save the MAC we got back from the ARP lookup
                                        -- save the MAC we got back from the ARP lookup
 
                                        tx_mac_value <= arp_req_rslt.mac;
                                        set_tx_mac <= '1';
                                        set_tx_mac <= '1';
                                        set_chn_reqd <= SET;
                                        set_chn_reqd <= SET;
                                        set_mac_lku_req <= CLR;
                                        set_mac_lku_req <= CLR;
                                        -- check for optimise when already have the channel
                                        -- check for optimise when already have the channel
                                        if mac_tx_granted = '1' then
                                        if mac_tx_granted = '1' then
Line 423... Line 436...
                                                arp_req_ip_reg <= arp_req_ip_reg;
                                                arp_req_ip_reg <= arp_req_ip_reg;
                                end case;
                                end case;
 
 
                                -- save MAC
                                -- save MAC
                                if set_tx_mac = '1' then
                                if set_tx_mac = '1' then
                                        tx_mac <= arp_req_rslt.mac;
                                        tx_mac <= tx_mac_value;
                                else
                                else
                                        tx_mac <= tx_mac;
                                        tx_mac <= tx_mac;
                                end if;
                                end if;
 
 
                                -- control access request to mac tx chn
                                -- control access request to mac tx chn

powered by: WebSVN 2.1.0

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