parent
9f0f8c2775
commit
e6c98b8643
@ -168,6 +168,9 @@ begin
|
||||
checksum_ones <= checksum(15 downto 0) + checksum(checksum'high downto 16);
|
||||
|
||||
tx_fsm : process(clk, rst) is
|
||||
variable gateway_masked : std_logic_vector(31 downto 0);
|
||||
variable ip_masked : std_logic_vector(31 downto 0);
|
||||
|
||||
begin
|
||||
if rst then
|
||||
state <= IDLE;
|
||||
@ -194,6 +197,14 @@ begin
|
||||
if ipv4_in.tx_en then
|
||||
arp_in.arp_query_stb <= '1';
|
||||
state <= ARP;
|
||||
|
||||
gateway_masked := to_std_logic_vector(ipv4_config.gateway) and to_std_logic_vector(ipv4_config.subnet_mask);
|
||||
ip_masked := to_std_logic_vector(arp_in.arp_ip) and to_std_logic_vector(ipv4_config.subnet_mask);
|
||||
if ip_masked = gateway_masked then
|
||||
arp_in.arp_ip <= ipv4_in.tx_ip_address;
|
||||
else
|
||||
arp_in.arp_ip <= ipv4_config.gateway;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
when ARP =>
|
||||
@ -244,9 +255,6 @@ begin
|
||||
|
||||
ethernet_ii_in.tx_data <= sr(sr'low);
|
||||
ethernet_ii_in.tx_en <= '1' when (state = HEADER) or (state = PAYLOAD) else '0';
|
||||
|
||||
arp_in.arp_ip <= ipv4_in.tx_ip_address;
|
||||
|
||||
end block tx;
|
||||
|
||||
end architecture rtl;
|
||||
|
@ -32,6 +32,7 @@ package trashernet_pkg is
|
||||
-- IP specific types
|
||||
subtype ip_addr_t is byte_vector(0 to 3);
|
||||
function ip_to_string(constant ip_address : in ip_addr_t) return string;
|
||||
function to_std_logic_vector(ip_address : ip_addr_t) return std_logic_vector;
|
||||
|
||||
-- Configuration interface
|
||||
type configuration_t is record
|
||||
@ -262,6 +263,11 @@ package body trashernet_pkg is
|
||||
;
|
||||
end function ip_to_string;
|
||||
|
||||
function to_std_logic_vector(ip_address : ip_addr_t) return std_logic_vector is
|
||||
begin
|
||||
return ip_address(0) & ip_address(1) & ip_address(2) & ip_address(3);
|
||||
end function to_std_logic_vector;
|
||||
|
||||
function to_std_logic(constant bool : boolean) return std_logic is
|
||||
variable ret : std_logic;
|
||||
begin
|
||||
|
Loading…
x
Reference in New Issue
Block a user