diff --git a/libraries/io/eth/src/vhdl/eth_control.vhd b/libraries/io/eth/src/vhdl/eth_control.vhd index c9f05abf52f6ac95e75079241ce81108207231b5..7efb2fa35a64090f2c818feb9785306d92d3b35d 100644 --- a/libraries/io/eth/src/vhdl/eth_control.vhd +++ b/libraries/io/eth/src/vhdl/eth_control.vhd @@ -187,6 +187,8 @@ BEGIN nxt_hdr_response_arr <= func_network_total_header_response_arp( rcv_hdr_words_arr, reg_config.mac_address, reg_config.ip_address); ELSIF rcv_hdr_status.is_icmp='1' THEN nxt_hdr_response_arr <= func_network_total_header_response_icmp(rcv_hdr_words_arr, reg_config.mac_address); + -- Calculate icmp checksum = original checksum + 0x0800. + nxt_hdr_response_arr(9)(c_halfword_w-1 DOWNTO 0) <= TO_UVEC( 2048 + TO_UINT(rcv_hdr_words_arr(9)(c_halfword_w-1 DOWNTO 0)), c_halfword_w); ELSIF rcv_hdr_status.is_udp='1' THEN nxt_hdr_response_arr <= func_network_total_header_response_udp( rcv_hdr_words_arr, reg_config.mac_address); ELSIF rcv_hdr_status.is_ip='1' THEN diff --git a/libraries/io/eth/tb/vhdl/tb_eth.vhd b/libraries/io/eth/tb/vhdl/tb_eth.vhd index 22387c22d9d90beb359e0e2513ef85bd8ef065a2..8274212a952de0465c56fedb596507b4b2148018 100644 --- a/libraries/io/eth/tb/vhdl/tb_eth.vhd +++ b/libraries/io/eth/tb/vhdl/tb_eth.vhd @@ -181,9 +181,13 @@ ARCHITECTURE tb OF tb_eth IS checksum => TO_UVEC(c_network_icmp_checksum, c_network_icmp_checksum_w), -- init value id => TO_UVEC(c_network_icmp_id, c_network_icmp_id_w), sequence => TO_UVEC(c_network_icmp_sequence, c_network_icmp_sequence_w)); + + -- checksum is 0x0800 + original checksum + CONSTANT c_exp_icmp_checksum : STD_LOGIC_VECTOR(c_network_icmp_checksum_w-1 DOWNTO 0) := TO_UVEC( 2048 + TO_UINT(c_tx_icmp_header.checksum), c_network_icmp_checksum_w); + CONSTANT c_exp_icmp_header : t_network_icmp_header := (msg_type => TO_UVEC(c_network_icmp_msg_type_reply, c_network_icmp_msg_type_w), -- ping reply code => c_tx_icmp_header.code, - checksum => c_tx_icmp_header.checksum, -- init value + checksum => c_exp_icmp_checksum, id => c_tx_icmp_header.id, sequence => c_tx_icmp_header.sequence); diff --git a/libraries/io/eth1g/tb/vhdl/tb_eth1g.vhd b/libraries/io/eth1g/tb/vhdl/tb_eth1g.vhd index 956e61a07e4262b35df42a61d4f4eda7dc69a995..ad31f6993c05a73b70d8178512ce05d7e6468c2d 100644 --- a/libraries/io/eth1g/tb/vhdl/tb_eth1g.vhd +++ b/libraries/io/eth1g/tb/vhdl/tb_eth1g.vhd @@ -181,9 +181,13 @@ ARCHITECTURE tb OF tb_eth1g IS checksum => TO_UVEC(c_network_icmp_checksum, c_network_icmp_checksum_w), -- init value id => TO_UVEC(c_network_icmp_id, c_network_icmp_id_w), sequence => TO_UVEC(c_network_icmp_sequence, c_network_icmp_sequence_w)); + + -- checksum is 0x0800 + original checksum + CONSTANT c_exp_icmp_checksum : STD_LOGIC_VECTOR(c_network_icmp_checksum_w-1 DOWNTO 0) := TO_UVEC( 2048 + TO_UINT(c_tx_icmp_header.checksum), c_network_icmp_checksum_w); + CONSTANT c_exp_icmp_header : t_network_icmp_header := (msg_type => TO_UVEC(c_network_icmp_msg_type_reply, c_network_icmp_msg_type_w), -- ping reply code => c_tx_icmp_header.code, - checksum => c_tx_icmp_header.checksum, -- init value + checksum => c_exp_icmp_checksum, id => c_tx_icmp_header.id, sequence => c_tx_icmp_header.sequence);