URL
https://opencores.org/ocsvn/udp_ip_stack/udp_ip_stack/trunk
Subversion Repositories udp_ip_stack
Compare Revisions
- This comparison shows the changes necessary to convert path
/udp_ip_stack/trunk
- from Rev 4 to Rev 6
- ↔ Reverse comparison
Rev 4 → Rev 6
/bench/vhdl/IPv4_RX_tb.vhd
187,6 → 187,7
assert ip_rx.hdr.src_ip_addr = x"c0a80501" report "T1: ip_rx.hdr.src_ip_addr not set correctly"; |
assert ip_rx.hdr.num_frame_errors = x"00" report "T1: ip_rx.hdr.num_frame_errors not set correctly"; |
assert ip_rx.hdr.last_error_code = x"0" report "T1: ip_rx.hdr.last_error_code not set correctly"; |
assert ip_rx.hdr.is_broadcast = '0' report "T1: ip_rx.hdr.is_broadcast should not be set"; |
assert ip_rx_start = '1' report "T1: ip_rx_start not set"; |
assert ip_rx.data.data_in_valid = '1' report "T1: ip_rx.data.data_in_valid not set"; |
|
272,6 → 273,7
assert ip_rx.hdr.data_length = x"0004" report "T2: ip_rx.hdr.data_length not set correctly"; |
assert ip_rx.hdr.src_ip_addr = x"c0a80502" report "T2: ip_rx.hdr.src_ip_addr not set correctly"; |
assert ip_rx.hdr.num_frame_errors = x"00" report "T2: ip_rx.hdr.num_frame_errors not set correctly"; |
assert ip_rx.hdr.is_broadcast = '0' report "T2: ip_rx.hdr.is_broadcast should not be set"; |
assert ip_rx.hdr.last_error_code = x"0" report "T2: ip_rx.hdr.last_error_code not set correctly"; |
assert ip_rx_start = '0' report "T2: ip_rx_start set when pkt not for us"; |
assert ip_rx.data.data_in_valid = '0' report "T2: ip_rx.data.data_in_valid set when pkt not for us"; |
293,6 → 295,94
assert ip_rx.hdr.last_error_code = x"0" report "T2: ip_rx.hdr.last_error_code indicates error at end of test"; |
assert ip_rx_start = '0' report "T2: ip_rx_start not cleared"; |
|
wait for clk_period*20; |
|
|
------------ |
-- TEST 3 -- RX Broadcast pkt |
------------ |
|
report "T3: Send an eth frame with IP pkt dst ip_address = BC, dst mac = BC"; |
|
mac_data_in_valid <= '1'; |
-- dst MAC (bc) |
mac_data_in <= x"ff"; wait for clk_period; |
mac_data_in <= x"ff"; wait for clk_period; |
mac_data_in <= x"ff"; wait for clk_period; |
mac_data_in <= x"ff"; wait for clk_period; |
mac_data_in <= x"ff"; wait for clk_period; |
mac_data_in <= x"ff"; wait for clk_period; |
-- src MAC |
mac_data_in <= x"00"; wait for clk_period; |
mac_data_in <= x"23"; wait for clk_period; |
mac_data_in <= x"18"; wait for clk_period; |
mac_data_in <= x"29"; wait for clk_period; |
mac_data_in <= x"26"; wait for clk_period; |
mac_data_in <= x"7c"; wait for clk_period; |
-- type |
mac_data_in <= x"08"; wait for clk_period; -- IP pkt |
mac_data_in <= x"00"; wait for clk_period; |
-- ver & HL / service type |
mac_data_in <= x"45"; wait for clk_period; |
mac_data_in <= x"00"; wait for clk_period; |
-- total len |
mac_data_in <= x"00"; wait for clk_period; |
mac_data_in <= x"18"; wait for clk_period; |
-- ID |
mac_data_in <= x"00"; wait for clk_period; |
mac_data_in <= x"00"; wait for clk_period; |
-- flags & frag |
mac_data_in <= x"00"; wait for clk_period; |
mac_data_in <= x"00"; wait for clk_period; |
-- TTL |
mac_data_in <= x"00"; wait for clk_period; |
-- Protocol |
mac_data_in <= x"11"; wait for clk_period; |
-- Header CKS |
mac_data_in <= x"00"; wait for clk_period; |
mac_data_in <= x"00"; wait for clk_period; |
-- SRC IP |
mac_data_in <= x"c0"; wait for clk_period; |
mac_data_in <= x"a8"; wait for clk_period; |
mac_data_in <= x"05"; wait for clk_period; |
mac_data_in <= x"01"; wait for clk_period; |
-- DST IP |
mac_data_in <= x"ff"; wait for clk_period; |
mac_data_in <= x"ff"; wait for clk_period; |
mac_data_in <= x"ff"; wait for clk_period; |
mac_data_in <= x"ff"; wait for clk_period; |
|
-- user data |
mac_data_in <= x"24"; wait for clk_period; |
|
assert ip_rx.hdr.is_valid = '1' report "T3: ip_rx.hdr.is_valid not set"; |
assert ip_rx.hdr.protocol = x"11" report "T3: ip_rx.hdr.protocol not set correctly"; |
assert ip_rx.hdr.data_length = x"0004" report "T3: ip_rx.hdr.data_length not set correctly"; |
assert ip_rx.hdr.src_ip_addr = x"c0a80501" report "T3: ip_rx.hdr.src_ip_addr not set correctly"; |
assert ip_rx.hdr.num_frame_errors = x"00" report "T3: ip_rx.hdr.num_frame_errors not set correctly"; |
assert ip_rx.hdr.is_broadcast = '1' report "T3: ip_rx.hdr.is_broadcast not set"; |
assert ip_rx.hdr.last_error_code = x"0" report "T3: ip_rx.hdr.last_error_code not set correctly"; |
assert ip_rx_start = '1' report "T3: ip_rx_start not set"; |
assert ip_rx.data.data_in_valid = '1' report "T3: ip_rx.data.data_in_valid not set"; |
|
mac_data_in <= x"25"; wait for clk_period; |
mac_data_in <= x"26"; wait for clk_period; |
mac_data_in <= x"27"; mac_data_in_last <= '1';wait for clk_period; |
|
assert ip_rx.data.data_in_last = '1' report "T3: ip_rx.data.data_in_last not set"; |
|
mac_data_in <= x"00"; |
mac_data_in_last <= '0'; |
mac_data_in_valid <= '0'; |
wait for clk_period; |
|
assert ip_rx.data.data_in_valid = '0' report "T3: ip_rx.data.data_in_valid not cleared"; |
assert ip_rx.data.data_in_last = '0' report "T3: ip_rx.data.data_in_last not cleared"; |
assert ip_rx.hdr.num_frame_errors = x"00" report "T3: ip_rx.hdr.num_frame_errors non zero at end of test"; |
assert ip_rx.hdr.last_error_code = x"0" report "T3: ip_rx.hdr.last_error_code indicates error at end of test"; |
assert ip_rx_start = '0' report "T3: ip_rx_start not cleared"; |
|
|
report "--- end of tests ---"; |
|
wait; |
/bench/vhdl/IPv4_TX_tb.vhd
16,6 → 16,7
-- |
-- Revision: |
-- Revision 0.01 - File Created |
-- Revision 0.02 - Added test for IP broadcast tx |
-- Additional Comments: |
-- |
-- Notes: |
255,8 → 256,8
ip_tx_start <= '0'; wait for clk_period; |
arp_req_rslt.got_mac <= '0'; |
|
assert arp_req_req.lookup_req = '1' report "T1: lookup_req not set on tx start"; |
assert ip_tx_result = IPTX_RESULT_SENDING report "T1: result should be IPTX_RESULT_SENDING"; |
assert arp_req_req.lookup_req = '1' report "T2: lookup_req not set on tx start"; |
assert ip_tx_result = IPTX_RESULT_SENDING report "T2: result should be IPTX_RESULT_SENDING"; |
|
wait for clk_period; -- simulate arp lookup time |
arp_req_rslt.mac <= x"050423271016"; |
264,8 → 265,8
|
wait for clk_period*2; |
|
assert arp_req_req.lookup_req = '0' report "T1: lookup_req not clear after setting"; |
assert mac_tx_req = '1' report "T1: mac_tx_req not set after getting mac"; |
assert arp_req_req.lookup_req = '0' report "T2: lookup_req not clear after setting"; |
assert mac_tx_req = '1' report "T2: mac_tx_req not set after getting mac"; |
|
wait for clk_period; -- simulate mac chn access time |
mac_tx_granted <= '1'; |
272,7 → 273,7
wait for clk_period*2; |
mac_data_out_ready <= '1'; |
|
assert ip_tx_data_out_ready = '0' report "T1: IP data out ready asserted too early"; |
assert ip_tx_data_out_ready = '0' report "T2: IP data out ready asserted too early"; |
|
wait until ip_tx_data_out_ready = '1'; |
|
288,7 → 289,7
ip_tx.data.data_out_last <= '1'; |
wait for clk_period; |
|
assert mac_data_out_last = '1' report "T1: mac_datda_out_last not set on last byte"; |
assert mac_data_out_last = '1' report "T2: mac_datda_out_last not set on last byte"; |
|
|
ip_tx.data.data_out_valid <= '0'; |
295,12 → 296,64
ip_tx.data.data_out_last <= '0'; |
wait for clk_period*2; |
|
assert ip_tx_result = IPTX_RESULT_SENT report "T1: result should be IPTX_RESULT_SENT"; |
assert mac_tx_req = '0' report "T1: mac_tx_req held on too long after TX"; |
assert ip_tx_result = IPTX_RESULT_SENT report "T2: result should be IPTX_RESULT_SENT"; |
assert mac_tx_req = '0' report "T2: mac_tx_req held on too long after TX"; |
|
mac_tx_granted <= '0'; |
wait for clk_period*2; |
|
------------ |
-- TEST 3 -- tx test for IP broadcast, should be no arp req |
------------ |
|
report "T3: tx test for IP broadcast, should be no arp req"; |
|
ip_tx.hdr.protocol <= x"11"; |
ip_tx.hdr.data_length <= x"0006"; |
ip_tx.hdr.dst_ip_addr <= x"ffffffff"; |
ip_tx_start <= '1'; |
wait for clk_period; |
ip_tx_start <= '0'; wait for clk_period; |
arp_req_rslt.got_mac <= '0'; |
|
assert arp_req_req.lookup_req = '0' report "T3: its trying to do an ARP req tx start"; |
assert ip_tx_result = IPTX_RESULT_SENDING report "T3: result should be IPTX_RESULT_SENDING"; |
|
wait for clk_period; -- simulate mac chn access time |
mac_tx_granted <= '1'; |
wait for clk_period*2; |
mac_data_out_ready <= '1'; |
|
assert ip_tx_data_out_ready = '0' report "T3: IP data out ready asserted too early"; |
|
wait until ip_tx_data_out_ready = '1'; |
|
-- start to tx IP data |
ip_tx.data.data_out_valid <= '1'; |
ip_tx.data.data_out <= x"c1"; wait for clk_period; |
ip_tx.data.data_out <= x"c2"; wait for clk_period; |
ip_tx.data.data_out <= x"c3"; wait for clk_period; |
ip_tx.data.data_out <= x"c4"; wait for clk_period; |
ip_tx.data.data_out <= x"c5"; wait for clk_period; |
|
ip_tx.data.data_out <= x"c6"; |
ip_tx.data.data_out_last <= '1'; |
wait for clk_period; |
|
assert mac_data_out_last = '1' report "T3: mac_datda_out_last not set on last byte"; |
|
|
ip_tx.data.data_out_valid <= '0'; |
ip_tx.data.data_out_last <= '0'; |
wait for clk_period*2; |
|
assert ip_tx_result = IPTX_RESULT_SENT report "T3: result should be IPTX_RESULT_SENT"; |
assert mac_tx_req = '0' report "T3: mac_tx_req held on too long after TX"; |
|
mac_tx_granted <= '0'; |
wait for clk_period*2; |
|
|
report "--- end of tests ---"; |
|
wait; |
/bench/vhdl/UDP_complete_nomac_tb.vhd
16,6 → 16,7
-- |
-- Revision: |
-- Revision 0.01 - File Created |
-- Revision 0.02 - Added test for IP broadcast tx |
-- Additional Comments: |
-- |
-- Notes: |
126,7 → 127,6
signal set_count : count_mode_type; |
signal set_hdr : std_logic; |
signal set_tx_start : set_clr_type; |
signal tx_data : std_logic_vector (7 downto 0); |
signal set_last : std_logic; |
signal set_tx_started : set_clr_type; |
signal set_tx_fin : set_clr_type; |
512,11 → 512,360
assert ip_rx_hdr.last_error_code = x"0" report "T3: ip_rx_hdr.last_error_code indicates error at end of test"; |
assert ip_pkt_count = x"02" report "T3: ip pkt cnt incorrect"; |
|
|
|
|
|
------------ |
-- TEST 4 -- send UDP pkt with src=bc addr to force a broadcast tx in reply |
------------ |
|
report "T4: Send UDP IP pkt dst ip_address c0a80509, from port f49a to port 2694"; |
|
mac_rx_tvalid <= '1'; |
-- dst MAC (bc) |
mac_rx_tdata <= x"00"; wait for clk_period; |
mac_rx_tdata <= x"23"; wait for clk_period; |
mac_rx_tdata <= x"20"; wait for clk_period; |
mac_rx_tdata <= x"21"; wait for clk_period; |
mac_rx_tdata <= x"22"; wait for clk_period; |
mac_rx_tdata <= x"23"; wait for clk_period; |
-- src MAC |
mac_rx_tdata <= x"00"; wait for clk_period; |
mac_rx_tdata <= x"23"; wait for clk_period; |
mac_rx_tdata <= x"18"; wait for clk_period; |
mac_rx_tdata <= x"29"; wait for clk_period; |
mac_rx_tdata <= x"26"; wait for clk_period; |
mac_rx_tdata <= x"7c"; wait for clk_period; |
-- type |
mac_rx_tdata <= x"08"; wait for clk_period; -- IP pkt |
mac_rx_tdata <= x"00"; wait for clk_period; |
-- ver & HL / service type |
mac_rx_tdata <= x"45"; wait for clk_period; |
mac_rx_tdata <= x"00"; wait for clk_period; |
-- total len |
mac_rx_tdata <= x"00"; wait for clk_period; |
mac_rx_tdata <= x"21"; wait for clk_period; |
-- ID |
mac_rx_tdata <= x"00"; wait for clk_period; |
mac_rx_tdata <= x"7a"; wait for clk_period; |
-- flags & frag |
mac_rx_tdata <= x"00"; wait for clk_period; |
mac_rx_tdata <= x"00"; wait for clk_period; |
-- TTL |
mac_rx_tdata <= x"80"; wait for clk_period; |
-- Protocol |
mac_rx_tdata <= x"11"; wait for clk_period; |
-- Header CKS |
mac_rx_tdata <= x"00"; wait for clk_period; |
mac_rx_tdata <= x"00"; wait for clk_period; |
-- SRC IP |
mac_rx_tdata <= x"ff"; wait for clk_period; |
mac_rx_tdata <= x"ff"; wait for clk_period; |
mac_rx_tdata <= x"ff"; wait for clk_period; |
mac_rx_tdata <= x"ff"; wait for clk_period; |
-- DST IP |
mac_rx_tdata <= x"c0"; wait for clk_period; |
mac_rx_tdata <= x"a8"; wait for clk_period; |
mac_rx_tdata <= x"05"; wait for clk_period; |
mac_rx_tdata <= x"09"; wait for clk_period; |
-- SRC port |
mac_rx_tdata <= x"f4"; wait for clk_period; |
mac_rx_tdata <= x"9a"; wait for clk_period; |
-- DST port |
mac_rx_tdata <= x"26"; wait for clk_period; |
mac_rx_tdata <= x"94"; wait for clk_period; |
-- length |
mac_rx_tdata <= x"00"; wait for clk_period; |
mac_rx_tdata <= x"0d"; wait for clk_period; |
-- cks |
mac_rx_tdata <= x"8b"; wait for clk_period; |
mac_rx_tdata <= x"79"; wait for clk_period; |
-- user data |
mac_rx_tdata <= x"68"; wait for clk_period; |
|
-- since we are up to the user data stage, the header should be valid and the data_in_valid should be set |
assert udp_rx_int.hdr.is_valid = '1' report "T4: udp_rx_int.hdr.is_valid not set"; |
assert udp_rx_int.hdr.data_length = x"0005" report "T4: udp_rx_int.hdr.data_length not set correctly"; |
assert udp_rx_int.hdr.src_ip_addr = x"ffffffff" report "T4: udp_rx_int.hdr.src_ip_addr not set correctly"; |
assert udp_rx_int.hdr.src_port = x"f49a" report "T4: udp_rx_int.hdr.src_port not set correctly"; |
assert udp_rx_int.hdr.dst_port = x"2694" report "T4: udp_rx_int.hdr.dst_port not set correctly"; |
|
assert udp_rx_start_int = '1' report "T4: udp_rx_start not set"; |
assert udp_rx_int.data.data_in_valid = '1' report "T4: udp_rx_int.data.data_in_valid not set"; |
|
assert ip_rx_hdr.is_valid = '1' report "T4: ip_rx_hdr.is_valid not set"; |
assert ip_rx_hdr.protocol = x"11" report "T4: ip_rx_hdr.protocol not set correctly"; |
assert ip_rx_hdr.src_ip_addr = x"ffffffff" report "T4: ip_rx.hdr.src_ip_addr not set correctly"; |
assert ip_rx_hdr.num_frame_errors = x"00" report "T4: ip_rx.hdr.num_frame_errors not set correctly"; |
assert ip_rx_hdr.last_error_code = x"0" report "T4: ip_rx.hdr.last_error_code not set correctly"; |
|
-- put the rest of the user data |
mac_rx_tdata <= x"65"; wait for clk_period; |
mac_rx_tdata <= x"6c"; wait for clk_period; |
mac_rx_tdata <= x"6c"; wait for clk_period; |
mac_rx_tdata <= x"6f"; mac_rx_tlast <= '1'; wait for clk_period; |
|
assert udp_rx_int.data.data_in_last = '1' report "T4: udp_rx_int.data.data_in_last not set"; |
|
mac_rx_tdata <= x"00"; |
mac_rx_tlast <= '0'; |
mac_rx_tvalid <= '0'; |
wait for clk_period; |
|
report "T4: waiting for mac data tx"; |
wait until mac_tx_tvalid = '1'; |
report "T4: starting mac data tx"; |
wait for clk_period; |
|
-- check the mac data being transmitted |
assert mac_tx_tdata = x"ff" report "T4: incorrect dst mac 0"; wait for clk_period; |
assert mac_tx_tdata = x"ff" report "T4: incorrect dst mac 1"; wait for clk_period; |
assert mac_tx_tdata = x"ff" report "T4: incorrect dst mac 2"; wait for clk_period; |
assert mac_tx_tdata = x"ff" report "T4: incorrect dst mac 3"; wait for clk_period; |
assert mac_tx_tdata = x"ff" report "T4: incorrect dst mac 4"; wait for clk_period; |
assert mac_tx_tdata = x"ff" report "T4: incorrect dst mac 5"; wait for clk_period; |
|
assert mac_tx_tdata = x"00" report "T4: incorrect src mac 0"; wait for clk_period; |
assert mac_tx_tdata = x"23" report "T4: incorrect src mac 1"; wait for clk_period; |
assert mac_tx_tdata = x"20" report "T4: incorrect src mac 2"; wait for clk_period; |
assert mac_tx_tdata = x"21" report "T4: incorrect src mac 3"; wait for clk_period; |
assert mac_tx_tdata = x"22" report "T4: incorrect src mac 4"; wait for clk_period; |
assert mac_tx_tdata = x"23" report "T4: incorrect src mac 5"; wait for clk_period; |
|
assert mac_tx_tdata = x"08" report "T4: incorrect pkt_type 0"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T4: incorrect pkt type 1"; wait for clk_period; |
|
assert mac_tx_tdata = x"45" report "T4: incorrect ver.hlen"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T4: incorrect srv type"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T4: incorrect len 0"; wait for clk_period; |
assert mac_tx_tdata = x"20" report "T4: incorrect len 1"; wait for clk_period; |
|
assert mac_tx_tdata = x"00" report "T4: incorrect ident 0"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T4: incorrect ident 1"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T4: incorrect flag&frag 0"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T4: incorrect flag&frag 1"; wait for clk_period; |
|
assert mac_tx_tdata = x"80" report "T4: incorrect TTL"; wait for clk_period; |
assert mac_tx_tdata = x"11" report "T4: incorrect protocol"; wait for clk_period; |
assert mac_tx_tdata = x"75" report "T4: incorrect hdr.cks 0"; wait for clk_period; |
assert mac_tx_tdata = x"1c" report "T4: incorrect hdr.cks 1"; wait for clk_period; |
|
assert mac_tx_tdata = x"c0" report "T4: incorrect src ip 0"; wait for clk_period; |
assert mac_tx_tdata = x"a8" report "T4: incorrect src ip 1"; wait for clk_period; |
assert mac_tx_tdata = x"05" report "T4: incorrect src ip 2"; wait for clk_period; |
assert mac_tx_tdata = x"09" report "T4: incorrect src ip 3"; wait for clk_period; |
|
assert mac_tx_tdata = x"ff" report "T4: incorrect dst ip 0"; wait for clk_period; |
assert mac_tx_tdata = x"ff" report "T4: incorrect dst ip 1"; wait for clk_period; |
assert mac_tx_tdata = x"ff" report "T4: incorrect dst ip 2"; wait for clk_period; |
assert mac_tx_tdata = x"ff" report "T4: incorrect dst ip 3"; wait for clk_period; |
|
assert mac_tx_tdata = x"26" report "T4: incorrect src port 0"; wait for clk_period; |
assert mac_tx_tdata = x"94" report "T4: incorrect src port 1"; wait for clk_period; |
assert mac_tx_tdata = x"f4" report "T4: incorrect dst port 0"; wait for clk_period; |
assert mac_tx_tdata = x"9a" report "T4: incorrect dst port 1"; wait for clk_period; |
|
assert mac_tx_tdata = x"00" report "T4: incorrect udp len 0"; wait for clk_period; |
assert mac_tx_tdata = x"0c" report "T4: incorrect udp len 1"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T4: incorrect udp cks 0"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T4: incorrect udp cks 1"; wait for clk_period; |
|
assert mac_tx_tdata = x"40" report "T4: incorrect udp data 0"; wait for clk_period; |
assert mac_tx_tdata = x"41" report "T4: incorrect udp data 1"; wait for clk_period; |
|
assert mac_tx_tdata = x"42" report "T4: incorrect udp data 2"; |
assert mac_tx_tlast = '0' report "T4: tlast asserted too soon"; wait for clk_period; |
assert mac_tx_tdata = x"43" report "T4: incorrect udp data 3"; |
assert mac_tx_tlast = '1' report "T4: tlast not asserted"; wait for clk_period; |
|
assert udp_tx_result = IPTX_RESULT_SENT report "T4: TX did not complete"; |
|
assert udp_rx_int.data.data_in_valid = '0' report "T4: udp_rx_int.data.data_in_valid not cleared"; |
assert udp_rx_int.data.data_in_last = '0' report "T4: udp_rx_int.data.data_in_last not cleared"; |
assert udp_rx_start_int = '0' report "T4: udp_rx_start not cleared"; |
assert ip_rx_hdr.num_frame_errors = x"00" report "T4: ip_rx_hdr.num_frame_errors non zero at end of test"; |
assert ip_rx_hdr.last_error_code = x"0" report "T4: ip_rx_hdr.last_error_code indicates error at end of test"; |
assert ip_pkt_count = x"03" report "T4: ip pkt cnt incorrect"; |
|
------------ |
-- TEST 5 -- send UDP pkt with dst=bc addr to ensure we can receive broadcast tx |
------------ |
|
report "T5: Send UDP IP pkt dst ip_address bc, from port f49a to port 2694"; |
|
mac_rx_tvalid <= '1'; |
-- dst MAC (bc) |
mac_rx_tdata <= x"ff"; wait for clk_period; |
mac_rx_tdata <= x"ff"; wait for clk_period; |
mac_rx_tdata <= x"ff"; wait for clk_period; |
mac_rx_tdata <= x"ff"; wait for clk_period; |
mac_rx_tdata <= x"ff"; wait for clk_period; |
mac_rx_tdata <= x"ff"; wait for clk_period; |
-- src MAC |
mac_rx_tdata <= x"00"; wait for clk_period; |
mac_rx_tdata <= x"23"; wait for clk_period; |
mac_rx_tdata <= x"18"; wait for clk_period; |
mac_rx_tdata <= x"29"; wait for clk_period; |
mac_rx_tdata <= x"26"; wait for clk_period; |
mac_rx_tdata <= x"7c"; wait for clk_period; |
-- type |
mac_rx_tdata <= x"08"; wait for clk_period; -- IP pkt |
mac_rx_tdata <= x"00"; wait for clk_period; |
-- ver & HL / service type |
mac_rx_tdata <= x"45"; wait for clk_period; |
mac_rx_tdata <= x"00"; wait for clk_period; |
-- total len |
mac_rx_tdata <= x"00"; wait for clk_period; |
mac_rx_tdata <= x"21"; wait for clk_period; |
-- ID |
mac_rx_tdata <= x"00"; wait for clk_period; |
mac_rx_tdata <= x"7a"; wait for clk_period; |
-- flags & frag |
mac_rx_tdata <= x"00"; wait for clk_period; |
mac_rx_tdata <= x"00"; wait for clk_period; |
-- TTL |
mac_rx_tdata <= x"80"; wait for clk_period; |
-- Protocol |
mac_rx_tdata <= x"11"; wait for clk_period; |
-- Header CKS |
mac_rx_tdata <= x"00"; wait for clk_period; |
mac_rx_tdata <= x"00"; wait for clk_period; |
-- SRC IP |
mac_rx_tdata <= x"c0"; wait for clk_period; |
mac_rx_tdata <= x"a8"; wait for clk_period; |
mac_rx_tdata <= x"05"; wait for clk_period; |
mac_rx_tdata <= x"01"; wait for clk_period; |
-- DST IP |
mac_rx_tdata <= x"ff"; wait for clk_period; |
mac_rx_tdata <= x"ff"; wait for clk_period; |
mac_rx_tdata <= x"ff"; wait for clk_period; |
mac_rx_tdata <= x"ff"; wait for clk_period; |
-- SRC port |
mac_rx_tdata <= x"f4"; wait for clk_period; |
mac_rx_tdata <= x"9a"; wait for clk_period; |
-- DST port |
mac_rx_tdata <= x"26"; wait for clk_period; |
mac_rx_tdata <= x"94"; wait for clk_period; |
-- length |
mac_rx_tdata <= x"00"; wait for clk_period; |
mac_rx_tdata <= x"0d"; wait for clk_period; |
-- cks |
mac_rx_tdata <= x"8b"; wait for clk_period; |
mac_rx_tdata <= x"79"; wait for clk_period; |
-- user data |
mac_rx_tdata <= x"68"; wait for clk_period; |
|
-- since we are up to the user data stage, the header should be valid and the data_in_valid should be set |
assert udp_rx_int.hdr.is_valid = '1' report "T5: udp_rx_int.hdr.is_valid not set"; |
assert udp_rx_int.hdr.data_length = x"0005" report "T5: udp_rx_int.hdr.data_length not set correctly"; |
assert udp_rx_int.hdr.src_ip_addr = x"c0a80501" report "T5: udp_rx_int.hdr.src_ip_addr not set correctly"; |
assert udp_rx_int.hdr.src_port = x"f49a" report "T5: udp_rx_int.hdr.src_port not set correctly"; |
assert udp_rx_int.hdr.dst_port = x"2694" report "T5: udp_rx_int.hdr.dst_port not set correctly"; |
|
assert udp_rx_start_int = '1' report "T5: udp_rx_start not set"; |
assert udp_rx_int.data.data_in_valid = '1' report "T5: udp_rx_int.data.data_in_valid not set"; |
|
assert ip_rx_hdr.is_valid = '1' report "T5: ip_rx_hdr.is_valid not set"; |
assert ip_rx_hdr.protocol = x"11" report "T5: ip_rx_hdr.protocol not set correctly"; |
assert ip_rx_hdr.src_ip_addr = x"c0a80501" report "T5: ip_rx.hdr.src_ip_addr not set correctly"; |
assert ip_rx_hdr.num_frame_errors = x"00" report "T5: ip_rx.hdr.num_frame_errors not set correctly"; |
assert ip_rx_hdr.last_error_code = x"0" report "T5: ip_rx.hdr.last_error_code not set correctly"; |
|
-- put the rest of the user data |
mac_rx_tdata <= x"65"; wait for clk_period; |
mac_rx_tdata <= x"6c"; wait for clk_period; |
mac_rx_tdata <= x"6c"; wait for clk_period; |
mac_rx_tdata <= x"6f"; mac_rx_tlast <= '1'; wait for clk_period; |
|
assert udp_rx_int.data.data_in_last = '1' report "T5: udp_rx_int.data.data_in_last not set"; |
|
mac_rx_tdata <= x"00"; |
mac_rx_tlast <= '0'; |
mac_rx_tvalid <= '0'; |
|
report "T5: waiting for mac data tx"; |
if mac_tx_tvalid = '0' then |
wait until mac_tx_tvalid = '1'; |
wait for clk_period; |
end if; |
report "T5: starting mac data tx"; |
|
-- check the mac data being transmitted |
assert mac_tx_tdata = x"00" report "T5: incorrect dst mac 0"; wait for clk_period; |
assert mac_tx_tdata = x"23" report "T5: incorrect dst mac 1"; wait for clk_period; |
assert mac_tx_tdata = x"18" report "T5: incorrect dst mac 2"; wait for clk_period; |
assert mac_tx_tdata = x"29" report "T5: incorrect dst mac 3"; wait for clk_period; |
assert mac_tx_tdata = x"26" report "T5: incorrect dst mac 4"; wait for clk_period; |
assert mac_tx_tdata = x"7c" report "T5: incorrect dst mac 5"; wait for clk_period; |
|
assert mac_tx_tdata = x"00" report "T5: incorrect src mac 0"; wait for clk_period; |
assert mac_tx_tdata = x"23" report "T5: incorrect src mac 1"; wait for clk_period; |
assert mac_tx_tdata = x"20" report "T5: incorrect src mac 2"; wait for clk_period; |
assert mac_tx_tdata = x"21" report "T5: incorrect src mac 3"; wait for clk_period; |
assert mac_tx_tdata = x"22" report "T5: incorrect src mac 4"; wait for clk_period; |
assert mac_tx_tdata = x"23" report "T5: incorrect src mac 5"; wait for clk_period; |
|
assert mac_tx_tdata = x"08" report "T5: incorrect pkt_type 0"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T5: incorrect pkt type 1"; wait for clk_period; |
|
assert mac_tx_tdata = x"45" report "T5: incorrect ver.hlen"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T5: incorrect srv type"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T5: incorrect len 0"; wait for clk_period; |
assert mac_tx_tdata = x"20" report "T5: incorrect len 1"; wait for clk_period; |
|
assert mac_tx_tdata = x"00" report "T5: incorrect ident 0"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T5: incorrect ident 1"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T5: incorrect flag&frag 0"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T5: incorrect flag&frag 1"; wait for clk_period; |
|
assert mac_tx_tdata = x"80" report "T5: incorrect TTL"; wait for clk_period; |
assert mac_tx_tdata = x"11" report "T5: incorrect protocol"; wait for clk_period; |
assert mac_tx_tdata = x"af" report "T5: incorrect hdr.cks 0"; wait for clk_period; |
assert mac_tx_tdata = x"72" report "T5: incorrect hdr.cks 1"; wait for clk_period; |
|
assert mac_tx_tdata = x"c0" report "T5: incorrect src ip 0"; wait for clk_period; |
assert mac_tx_tdata = x"a8" report "T5: incorrect src ip 1"; wait for clk_period; |
assert mac_tx_tdata = x"05" report "T5: incorrect src ip 2"; wait for clk_period; |
assert mac_tx_tdata = x"09" report "T5: incorrect src ip 3"; wait for clk_period; |
|
assert mac_tx_tdata = x"c0" report "T5: incorrect dst ip 0"; wait for clk_period; |
assert mac_tx_tdata = x"a8" report "T5: incorrect dst ip 1"; wait for clk_period; |
assert mac_tx_tdata = x"05" report "T5: incorrect dst ip 2"; wait for clk_period; |
assert mac_tx_tdata = x"01" report "T5: incorrect dst ip 3"; wait for clk_period; |
|
assert mac_tx_tdata = x"26" report "T5: incorrect src port 0"; wait for clk_period; |
assert mac_tx_tdata = x"94" report "T5: incorrect src port 1"; wait for clk_period; |
assert mac_tx_tdata = x"f4" report "T5: incorrect dst port 0"; wait for clk_period; |
assert mac_tx_tdata = x"9a" report "T5: incorrect dst port 1"; wait for clk_period; |
|
assert mac_tx_tdata = x"00" report "T5: incorrect udp len 0"; wait for clk_period; |
assert mac_tx_tdata = x"0c" report "T5: incorrect udp len 1"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T5: incorrect udp cks 0"; wait for clk_period; |
assert mac_tx_tdata = x"00" report "T5: incorrect udp cks 1"; wait for clk_period; |
|
assert mac_tx_tdata = x"50" report "T5: incorrect udp data 0"; wait for clk_period; |
assert mac_tx_tdata = x"51" report "T5: incorrect udp data 1"; wait for clk_period; |
|
assert mac_tx_tdata = x"52" report "T5: incorrect udp data 2"; |
assert mac_tx_tlast = '0' report "T5: tlast asserted too soon"; wait for clk_period; |
assert mac_tx_tdata = x"53" report "T5: incorrect udp data 3"; |
assert mac_tx_tlast = '1' report "T5: tlast not asserted"; wait for clk_period; |
|
assert udp_tx_result = IPTX_RESULT_SENT report "T5: TX did not complete"; |
|
assert udp_rx_int.data.data_in_valid = '0' report "T5: udp_rx_int.data.data_in_valid not cleared"; |
assert udp_rx_int.data.data_in_last = '0' report "T5: udp_rx_int.data.data_in_last not cleared"; |
assert udp_rx_start_int = '0' report "T5: udp_rx_start not cleared"; |
assert ip_rx_hdr.num_frame_errors = x"00" report "T5: ip_rx_hdr.num_frame_errors non zero at end of test"; |
assert ip_rx_hdr.last_error_code = x"0" report "T5: ip_rx_hdr.last_error_code indicates error at end of test"; |
assert ip_pkt_count = x"04" report "T5: ip pkt cnt incorrect"; |
|
report "--- end of tests ---"; |
wait; |
end process; |
|
-- AUTO TX process - on receipt of any UDP pkt, send a response |
-- AUTO TX process - on receipt of any UDP pkt, send a response. data sent is modified if a broadcast was received. |
|
-- TX response process - COMB |
tx_proc_combinatorial: process( |
561,7 → 910,11
end if; |
|
when DATA_OUT => |
udp_tx_int.data.data_out <= std_logic_vector(count) or x"40"; |
if ip_rx_hdr.is_broadcast = '1' then |
udp_tx_int.data.data_out <= std_logic_vector(count) or x"50"; |
else |
udp_tx_int.data.data_out <= std_logic_vector(count) or x"40"; |
end if; |
udp_tx_int.data.data_out_valid <= udp_tx_data_out_ready_int; |
if udp_tx_data_out_ready_int = '1' then |
set_tx_start <= CLR; |
/bench/vhdl/UDP_RX_tb.vhd
102,6 → 102,7
ip_rx.hdr.protocol <= (others => '0'); |
ip_rx.hdr.num_frame_errors <= (others => '0'); |
ip_rx.hdr.last_error_code <= (others => '0'); |
ip_rx.hdr.is_broadcast <= '0'; |
|
reset <= '1'; |
wait for clk_period*10; |
/rtl/vhdl/arp.vhd
193,6 → 193,9
if arp_req_req.lookup_req = '1' and arp_req_req.ip = arp_entry.ip and arp_entry.is_valid = '1' then |
arp_req_rslt.got_mac <= '1'; |
arp_req_rslt.mac <= arp_entry.mac; |
elsif arp_req_req.lookup_req = '1' then |
arp_req_rslt.got_mac <= '0'; -- hold off got_mac while req is there as arp_entry will not be correct yet |
arp_req_rslt.mac <= arp_entry.mac; |
else |
arp_req_rslt.got_mac <= mac_addr_valid_reg; |
arp_req_rslt.mac <= mac_addr_found; |
/rtl/vhdl/ml605/UDP_integration_example.vhd
141,6 → 141,7
signal set_tx_started : set_clr_type; |
signal set_tx_fin : set_clr_type; |
signal set_udp_rx_start_reg : set_clr_type; |
signal first_byte_rx : STD_LOGIC_VECTOR(7 downto 0); |
|
begin |
|
171,17 → 172,18
|
end process; |
|
-- AUTO TX process - on receipt of any UDP pkt, send a response |
-- AUTO TX process - on receipt of any UDP pkt, send a response, |
|
-- TX response process - COMB |
tx_proc_combinatorial: process( |
-- inputs |
udp_rx_start_int, udp_tx_data_out_ready_int, udp_tx_int.data.data_out_valid, PBTX, reset_leds, |
udp_rx_start_int, udp_tx_data_out_ready_int, udp_tx_int.data.data_out_valid, |
udp_rx_int, PBTX, reset_leds, |
-- state |
state, count, tx_hdr, tx_start_reg, tx_started_reg, tx_fin_reg, udp_rx_start_reg, |
-- controls |
next_state, set_state, set_count, set_hdr, set_tx_start, set_last, |
set_tx_started, set_tx_fin, set_udp_rx_start_reg |
set_tx_started, set_tx_fin, set_udp_rx_start_reg, first_byte_rx |
) |
begin |
-- set output_followers |
199,6 → 201,7
set_tx_started <= HOLD; |
set_tx_fin <= HOLD; |
set_udp_rx_start_reg <= HOLD; |
first_byte_rx <= (others => '0'); |
|
-- FSM |
case state is |
207,6 → 210,11
udp_tx_int.data.data_out <= (others => '0'); |
udp_tx_int.data.data_out_valid <= '0'; |
if udp_rx_start_int = '1' or PBTX = '1' then |
if udp_rx_start_int = '1' then |
first_byte_rx <= udp_rx_int.data.data_in; |
else |
first_byte_rx <= x"00"; |
end if; |
set_udp_rx_start_reg <= SET; |
set_tx_started <= SET; |
set_hdr <= '1'; |
278,7 → 286,12
|
-- set tx hdr |
if set_hdr = '1' then |
tx_hdr.dst_ip_addr <= udp_rx_int.hdr.src_ip_addr; |
-- if the first byte of the rx pkt is 'B' then send to broadcast, otherwise send to reply IP |
if first_byte_rx = x"42" then |
tx_hdr.dst_ip_addr <= IP_BC_ADDR; |
else |
tx_hdr.dst_ip_addr <= udp_rx_int.hdr.src_ip_addr; |
end if; |
tx_hdr.dst_port <= udp_rx_int.hdr.src_port; |
tx_hdr.src_port <= udp_rx_int.hdr.dst_port; |
tx_hdr.data_length <= x"0004"; |
/rtl/vhdl/ipv4_types.vhd
9,6 → 9,9
|
package ipv4_types is |
|
constant IP_BC_ADDR : std_logic_vector (31 downto 0) := x"ffffffff"; |
constant MAC_BC_ADDR : std_logic_vector (47 downto 0) := x"ffffffffffff"; |
|
-------------- |
-- IPv4 TX -- |
-------------- |
48,6 → 51,7
src_ip_addr : STD_LOGIC_VECTOR (31 downto 0); |
num_frame_errors : std_logic_vector (7 downto 0); |
last_error_code : std_logic_vector (3 downto 0); -- see RX_EC_xxx constants |
is_broadcast : std_logic; -- set if the msg received is a broadcast |
end record; |
|
type ipv4_rx_type is record |
/rtl/vhdl/IPv4_RX.vhd
19,6 → 19,7
-- Revision: |
-- Revision 0.01 - File Created |
-- Revision 0.02 - Improved error handling |
-- Revision 0.03 - Added handling of broadcast address |
-- Additional Comments: |
-- |
---------------------------------------------------------------------------------- |
60,6 → 61,8
signal rx_state : rx_state_type; |
signal rx_count : unsigned (15 downto 0); |
signal src_ip : std_logic_vector (31 downto 0); -- src IP captured from input |
signal dst_ip : std_logic_vector (23 downto 0); -- 1st 3 bytes of dst IP captured from input |
signal is_broadcast_reg : std_logic; |
signal protocol : std_logic_vector (7 downto 0); -- src protocol captured from input |
signal data_len : std_logic_vector (15 downto 0); -- src data length captured from input |
signal ip_rx_start_reg : std_logic; -- indicates start of user data |
66,7 → 69,7
signal hdr_valid_reg : std_logic; -- indicates that hdr data is valid |
signal frame_err_cnt : unsigned (7 downto 0); -- number of frame errors |
signal error_code_reg : std_logic_vector (3 downto 0); |
signal rx_pkt_counter : unsigned (7 downto 0); -- number of rx frames received for us |
signal rx_pkt_counter : unsigned (7 downto 0); -- number of rx frames received for us |
|
-- rx control signals |
signal next_rx_state : rx_state_type; |
73,6 → 76,9
signal set_rx_state : std_logic; |
signal rx_event : rx_event_type; |
signal rx_count_mode : settable_count_mode_type; |
signal set_dst_ip3 : std_logic; |
signal set_dst_ip2 : std_logic; |
signal set_dst_ip1 : std_logic; |
signal set_ip3 : std_logic; |
signal set_ip2 : std_logic; |
signal set_ip1 : std_logic; |
89,6 → 95,8
signal error_code_val : std_logic_vector (3 downto 0); |
signal set_pkt_cnt : count_mode_type; |
signal set_data_last : std_logic; |
signal dst_ip_rx : std_logic_vector (31 downto 0); |
signal set_is_broadcast : set_clr_type; |
|
|
-- IP datagram header format |
132,12 → 140,14
-- input signals |
mac_data_in, mac_data_in_valid, mac_data_in_last, our_ip_address, |
-- state variables |
rx_state, rx_count, src_ip, protocol, data_len, ip_rx_start_reg, hdr_valid_reg, frame_err_cnt, error_code_reg, rx_pkt_counter, |
rx_state, rx_count, src_ip, dst_ip, protocol, data_len, ip_rx_start_reg, hdr_valid_reg, |
frame_err_cnt, error_code_reg, rx_pkt_counter, is_broadcast_reg, |
-- control signals |
next_rx_state, set_rx_state, rx_event, rx_count_mode, |
set_ip3, set_ip2, set_ip1, set_ip0, set_protocol, set_len_H, set_len_L, |
set_dst_ip3, set_dst_ip2, set_dst_ip1, |
set_ip_rx_start, set_hdr_valid, set_frame_err_cnt, dataval, rx_count_val, |
set_error_code, error_code_val, set_pkt_cnt, set_data_last |
set_error_code, error_code_val, set_pkt_cnt, set_data_last, dst_ip_rx, set_is_broadcast |
) |
begin |
-- set output followers |
148,6 → 158,7
ip_rx.hdr.src_ip_addr <= src_ip; |
ip_rx.hdr.num_frame_errors <= std_logic_vector(frame_err_cnt); |
ip_rx.hdr.last_error_code <= error_code_reg; |
ip_rx.hdr.is_broadcast <= is_broadcast_reg; |
rx_pkt_count <= STD_LOGIC_VECTOR(rx_pkt_counter); |
|
-- transfer data upstream if in user data phase |
170,6 → 181,9
set_ip2 <= '0'; |
set_ip1 <= '0'; |
set_ip0 <= '0'; |
set_dst_ip3 <= '0'; |
set_dst_ip2 <= '0'; |
set_dst_ip1 <= '0'; |
set_protocol <= '0'; |
set_len_H <= '0'; |
set_len_L <= '0'; |
182,6 → 196,8
set_pkt_cnt <= HOLD; |
dataval <= (others => '0'); |
set_data_last <= '0'; |
dst_ip_rx <= (others => '0'); |
set_is_broadcast <= HOLD; |
|
-- determine event (if any) |
if mac_data_in_valid = '1' then |
289,37 → 305,32
when x"000c" => set_ip3 <= '1'; |
when x"000d" => set_ip2 <= '1'; |
when x"000e" => set_ip1 <= '1'; |
when x"000f" => set_ip0 <= '1'; set_hdr_valid <= SET; -- header values are now valid, although the pkt may not be for us |
when x"000f" => set_ip0 <= '1'; |
|
when x"0010" => |
if mac_data_in /= our_ip_address(31 downto 24) then -- ignore pkts that are not addressed to us |
next_rx_state <= WAIT_END; |
set_rx_state <= '1'; |
end if; |
|
when x"0011" => |
if mac_data_in /= our_ip_address(23 downto 16) then -- ignore pkts that are not addressed to us |
next_rx_state <= WAIT_END; |
set_rx_state <= '1'; |
end if; |
|
when x"0012" => |
if mac_data_in /= our_ip_address(15 downto 8) then -- ignore pkts that are not addressed to us |
next_rx_state <= WAIT_END; |
set_rx_state <= '1'; |
end if; |
|
when x"0010" => set_dst_ip3 <= '1'; |
when x"0011" => set_dst_ip2 <= '1'; |
when x"0012" => set_dst_ip1 <= '1'; |
|
when x"0013" => |
if mac_data_in /= our_ip_address(7 downto 0) then -- ignore pkts that are not addressed to us |
next_rx_state <= WAIT_END; |
set_rx_state <= '1'; |
-- now have the dst IP addr |
dst_ip_rx <= dst_ip & mac_data_in; |
if dst_ip_rx = IP_BC_ADDR then |
set_is_broadcast <= SET; |
else |
set_is_broadcast <= CLR; |
end if; |
set_hdr_valid <= SET; -- header values are now valid, although the pkt may not be for us |
|
if dst_ip_rx = our_ip_address or dst_ip_rx = IP_BC_ADDR then |
next_rx_state <= USER_DATA; |
set_pkt_cnt <= INCR; -- count another pkt |
set_pkt_cnt <= INCR; -- count another pkt received |
set_rx_state <= '1'; |
set_ip_rx_start <= SET; |
else |
next_rx_state <= WAIT_END; |
set_rx_state <= '1'; |
end if; |
|
|
when others => -- ignore other bytes in ip header |
end case; |
end if; |
397,10 → 408,12
rx_state <= IDLE; |
rx_count <= x"0000"; |
src_ip <= (others => '0'); |
dst_ip <= (others => '0'); |
protocol <= (others => '0'); |
data_len <= (others => '0'); |
ip_rx_start_reg <= '0'; |
hdr_valid_reg <= '0'; |
is_broadcast_reg <= '0'; |
frame_err_cnt <= (others => '0'); |
error_code_reg <= RX_EC_NONE; |
rx_pkt_counter <= x"00"; |
441,6 → 454,11
if (set_ip1 = '1') then src_ip(15 downto 8) <= dataval; end if; |
if (set_ip0 = '1') then src_ip(7 downto 0) <= dataval; end if; |
|
-- dst ip capture |
if (set_dst_ip3 = '1') then dst_ip(23 downto 16) <= dataval; end if; |
if (set_dst_ip2 = '1') then dst_ip(15 downto 8) <= dataval; end if; |
if (set_dst_ip1 = '1') then dst_ip(7 downto 0) <= dataval; end if; |
|
if (set_protocol = '1') then |
protocol <= dataval; |
else |
462,6 → 480,12
when CLR => ip_rx_start_reg <= '0'; |
when HOLD => ip_rx_start_reg <= ip_rx_start_reg; |
end case; |
|
case set_is_broadcast is |
when SET => is_broadcast_reg <= '1'; |
when CLR => is_broadcast_reg <= '0'; |
when HOLD => is_broadcast_reg <= is_broadcast_reg; |
end case; |
|
case set_hdr_valid is |
when SET => hdr_valid_reg <= '1'; |
/rtl/vhdl/IPv4_TX.vhd
19,6 → 19,7
-- Revision 0.01 - File Created |
-- Revision 0.02 - fixed up setting of tx_result control defaults |
-- Revision 0.03 - Added data_out_first |
-- Revision 0.04 - Added handling of broadcast address |
-- Additional Comments: |
-- |
---------------------------------------------------------------------------------- |
75,7 → 76,7
|
-- Configuration |
|
constant IP_TTL : std_logic_vector (7 downto 0) := x"80"; |
constant IP_TTL : std_logic_vector (7 downto 0) := x"80"; |
|
-- TX state variables |
signal tx_state : tx_state_type; |
94,6 → 95,7
signal set_tx_state : std_logic; |
signal next_tx_result : std_logic_vector (1 downto 0); |
signal set_tx_result : std_logic; |
signal tx_mac_value : std_logic_vector (47 downto 0); |
signal set_tx_mac : std_logic; |
signal tx_count_val : unsigned (11 downto 0); |
signal tx_count_mode : settable_cnt_type; |
163,7 → 165,7
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, |
-- 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_valid, tx_count_val |
) |
208,6 → 210,7
next_tx_result <= IPTX_RESULT_NONE; |
set_tx_result <= '0'; |
tx_count_val <= (others => '0'); |
tx_mac_value <= (others => '0'); |
|
-- set temp signals |
total_length <= std_logic_vector(unsigned(ip_tx.hdr.data_length) + 20); -- total length = user data length + header length (bytes) |
224,14 → 227,23
next_tx_result <= IPTX_RESULT_ERR; |
set_tx_result <= '1'; |
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 |
|
-- req the mac address for this ip |
set_mac_lku_req <= SET; |
next_tx_result <= IPTX_RESULT_SENDING; |
set_tx_result <= '1'; |
next_tx_state <= WAIT_MAC; |
set_tx_state <= '1'; |
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; |
next_tx_state <= WAIT_MAC; |
set_tx_state <= '1'; |
end if; |
end if; |
else |
set_mac_lku_req <= CLR; |
241,6 → 253,7
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 |
-- save the MAC we got back from the ARP lookup |
tx_mac_value <= arp_req_rslt.mac; |
set_tx_mac <= '1'; |
set_chn_reqd <= SET; |
set_mac_lku_req <= CLR; |
425,7 → 438,7
|
-- save MAC |
if set_tx_mac = '1' then |
tx_mac <= arp_req_rslt.mac; |
tx_mac <= tx_mac_value; |
else |
tx_mac <= tx_mac; |
end if; |
/doc/release_notes.txt
1,3 → 1,9
V1.2 - Added handling for receipt of IP pkts with broadcast address ff.ff.ff.ff. Added is_broadcast flag |
to IP RX hdr. |
- Added ability to transmit IP pkts to broadcast address. |
Migration Notes: V1.1 to V1.2 - IP_RX_HDR has an additional output signal to indicate the IP pkt |
was received on the broadcast address. |
|
V1.1 - Added mac_tx_tfirst output to assist coupling to MAC layers that require a start of frame indication. |
Migration Notes: V1.0 to V1.1 |
- The entity declaration for UDP_Complete_nomac and IP_Complete_nomac have changed. |
/doc/src/UDP_IP_Stack.pptx
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/doc/UDP_IP_Stack.pdf
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream