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
/
- from Rev 12 to Rev 11
- ↔ Reverse comparison
Rev 12 → Rev 11
/udp_ip_stack/tags/v2.0/rtl/vhdl/IPv4_TX.vhd
File deleted
/udp_ip_stack/tags/v2.0/rtl/vhdl/arp_TX.vhd
File deleted
/udp_ip_stack/tags/v2.0/rtl/vhdl/UDP_RX.vhd
File deleted
/udp_ip_stack/tags/v2.0/rtl/vhdl/UDP_TX.vhd
File deleted
/udp_ip_stack/tags/v2.0/rtl/vhdl/arp_types.vhd
File deleted
/udp_ip_stack/tags/v2.0/rtl/vhdl/ipv4_types.vhd
File deleted
/udp_ip_stack/tags/v2.0/rtl/vhdl/arp_SYNC.vhd
File deleted
/udp_ip_stack/tags/v2.0/rtl/vhdl/axi.vhd
File deleted
/udp_ip_stack/tags/v2.0/rtl/vhdl/arp_STORE_br.vhd
File deleted
/udp_ip_stack/tags/v2.0/rtl/vhdl/IPv4.vhd
File deleted
/udp_ip_stack/tags/v2.0/rtl/vhdl/arp.vhd
File deleted
/udp_ip_stack/tags/v2.0/rtl/vhdl/tx_arbitrator.vhd
File deleted
/udp_ip_stack/tags/v2.0/rtl/vhdl/arp_REQ.vhd
File deleted
/udp_ip_stack/tags/v2.0/rtl/vhdl/arpv2.vhd
File deleted
/udp_ip_stack/tags/v2.0/rtl/vhdl/IPv4_RX.vhd
File deleted
/udp_ip_stack/tags/v2.0/rtl/vhdl/arp_RX.vhd
File deleted
/udp_ip_stack/tags/v2.0/doc/release_notes.txt
File deleted
/udp_ip_stack/tags/v2.0/doc/src/UDP_IP_Stack.pptx
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
udp_ip_stack/tags/v2.0/doc/src/UDP_IP_Stack.pptx
Property changes :
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: udp_ip_stack/tags/v2.0/doc/src/zero latency receive.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: udp_ip_stack/tags/v2.0/doc/src/zero latency receive.jpg
===================================================================
--- udp_ip_stack/tags/v2.0/doc/src/zero latency receive.jpg (revision 12)
+++ udp_ip_stack/tags/v2.0/doc/src/zero latency receive.jpg (nonexistent)
udp_ip_stack/tags/v2.0/doc/src/zero latency receive.jpg
Property changes :
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: udp_ip_stack/tags/v2.0/doc/UDP_IP_Stack.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: udp_ip_stack/tags/v2.0/doc/UDP_IP_Stack.pdf
===================================================================
--- udp_ip_stack/tags/v2.0/doc/UDP_IP_Stack.pdf (revision 12)
+++ udp_ip_stack/tags/v2.0/doc/UDP_IP_Stack.pdf (nonexistent)
udp_ip_stack/tags/v2.0/doc/UDP_IP_Stack.pdf
Property changes :
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: udp_ip_stack/tags/v2.0/sw/UDPTest.java
===================================================================
--- udp_ip_stack/tags/v2.0/sw/UDPTest.java (revision 12)
+++ udp_ip_stack/tags/v2.0/sw/UDPTest.java (nonexistent)
@@ -1,34 +0,0 @@
-package com.pjf;
-
-import java.io.IOException;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-
-public class UDPTest {
- private UDPCxn cxn;
-
- public UDPTest() throws SocketException, UnknownHostException {
- cxn = new UDPCxn("192.168.5.9");
- }
-
- public void go() throws IOException {
- String fix1 = "1=45~34=201~18=23~";
- cxn.fixSend(fix1, 2000, true);
- byte[] rep = cxn.rcv();
- String reply = new String(rep);
- System.out.println("Got [" + reply + "]");
- }
-
-
- public static void main(String[] args) {
- UDPTest ut;
- try {
- ut = new UDPTest();
- ut.go();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
-
-}
Index: udp_ip_stack/tags/v2.0/sw/test_results/UDPTestStream_console.txt
===================================================================
--- udp_ip_stack/tags/v2.0/sw/test_results/UDPTestStream_console.txt (revision 12)
+++ udp_ip_stack/tags/v2.0/sw/test_results/UDPTestStream_console.txt (nonexistent)
@@ -1,152 +0,0 @@
-Sending price tick 225
-Sending price tick 224
-Sending price tick 223
-Sending price tick 222
-Sending price tick 221
-Sending price tick 220
-Sending price tick 219
-Sending price tick 218
-Sending price tick 217
-Sending price tick 216
-Sending price tick 215
-Sending price tick 214
-Sending price tick 213
-Sending price tick 212
-Sending price tick 211
-Sending price tick 210
-Sending price tick 209
-Sending price tick 208
-Sending price tick 207
-Sending price tick 206
-Sending price tick 205
-Sending price tick 204
-Sending price tick 203
-Sending price tick 202
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Sending price tick 201
-Sending price tick 200
-Sending price tick 199
-Got [@ABC]
-Sending price tick 198
-Sending price tick 197
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Sending price tick 196
-Sending price tick 195
-Got [@ABC]
-Sending price tick 194
-Sending price tick 193
-Got [@ABC]
-Sending price tick 192
-Sending price tick 191
-Got [@ABC]
-Sending price tick 190
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Sending price tick 189
-Sending price tick 188
-Sending price tick 187
-Got [@ABC]
-Got [@ABC]
-Sending price tick 186
-Got [@ABC]
-Sending price tick 185
-Sending price tick 184
-Got [@ABC]
-Sending price tick 183
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Sending price tick 182
-Sending price tick 181
-Got [@ABC]
-Sending price tick 180
-Got [@ABC]
-Sending price tick 179
-Got [@ABC]
-Sending price tick 178
-Sending price tick 177
-Got [@ABC]
-Sending price tick 176
-Got [@ABC]
-Sending price tick 175
-Got [@ABC]
-Got [@ABC]
-Sending price tick 174
-Sending price tick 173
-Got [@ABC]
-Sending price tick 172
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Sending price tick 171
-Sending price tick 170
-Got [@ABC]
-Sending price tick 169
-Sending price tick 168
-Got [@ABC]
-Sending price tick 167
-Sending price tick 166
-Got [@ABC]
-Sending price tick 165
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Sending price tick 164
-Got [@ABC]
-Sending price tick 163
-Sending price tick 162
-Got [@ABC]
-Sending price tick 161
-Got [@ABC]
-Sending price tick 160
-Got [@ABC]
-Sending price tick 159
-Sending price tick 158
-Got [@ABC]
-Sending price tick 157
-Sending price tick 156
-Got [@ABC]
-Sending price tick 155
-Got [@ABC]
-Sending price tick 154
-Got [@ABC]
-Sending price tick 153
-Got [@ABC]
-Sending price tick 152
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Got [@ABC]
-Sending price tick 151
-Sending price tick 150
-Got [@ABC]
-Got [@ABC]
Index: udp_ip_stack/tags/v2.0/sw/test_results/UDPTestStream_wireshark.pcap
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: udp_ip_stack/tags/v2.0/sw/test_results/UDPTestStream_wireshark.pcap
===================================================================
--- udp_ip_stack/tags/v2.0/sw/test_results/UDPTestStream_wireshark.pcap (revision 12)
+++ udp_ip_stack/tags/v2.0/sw/test_results/UDPTestStream_wireshark.pcap (nonexistent)
udp_ip_stack/tags/v2.0/sw/test_results/UDPTestStream_wireshark.pcap
Property changes :
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: udp_ip_stack/tags/v2.0/sw/test_results/UDPTest_console.txt
===================================================================
--- udp_ip_stack/tags/v2.0/sw/test_results/UDPTest_console.txt (revision 12)
+++ udp_ip_stack/tags/v2.0/sw/test_results/UDPTest_console.txt (nonexistent)
@@ -1,2 +0,0 @@
-Sending packet: 1=45~34=201~18=23~ on port 2000
-Got [@ABC]
Index: udp_ip_stack/tags/v2.0/sw/test_results/UDPTest_wireshark.pcap
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: udp_ip_stack/tags/v2.0/sw/test_results/UDPTest_wireshark.pcap
===================================================================
--- udp_ip_stack/tags/v2.0/sw/test_results/UDPTest_wireshark.pcap (revision 12)
+++ udp_ip_stack/tags/v2.0/sw/test_results/UDPTest_wireshark.pcap (nonexistent)
udp_ip_stack/tags/v2.0/sw/test_results/UDPTest_wireshark.pcap
Property changes :
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: udp_ip_stack/tags/v2.0/sw/UDPCxn.java
===================================================================
--- udp_ip_stack/tags/v2.0/sw/UDPCxn.java (revision 12)
+++ udp_ip_stack/tags/v2.0/sw/UDPCxn.java (nonexistent)
@@ -1,72 +0,0 @@
-package com.pjf;
-
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-
-
-public class UDPCxn {
- private DatagramSocket skt;
- private InetAddress dstIP;
-
- public UDPCxn(long dstIPadr) throws SocketException, UnknownHostException {
- skt = new DatagramSocket();
- byte[] target = new byte[4];
- target[0] = (byte) ((dstIPadr >> 24) & 0xff);
- target[1] = (byte) ((dstIPadr >> 16) & 0xff);
- target[2] = (byte) ((dstIPadr >> 8) & 0xff);
- target[3] = (byte) (dstIPadr & 0xff);
- dstIP = InetAddress.getByAddress(target);
- }
-
- public UDPCxn(String dstIPadr) throws SocketException, UnknownHostException {
- skt = new DatagramSocket();
- String[] parts = dstIPadr.split("[.]");
- if (parts.length != 4) {
- throw new UnknownHostException("ip addr must have 4 parts");
- }
- byte[] target = new byte[4];
- for (int i = 0; i<4; i++) {
- target[i] = (byte) Integer.parseInt(parts[i]);
- }
- dstIP = InetAddress.getByAddress(target);
- }
-
- public void send(byte[] data, int port) throws IOException {
- DatagramPacket pkt = new DatagramPacket(data, data.length, dstIP, port);
- System.out.println("Sending packet");
- skt.send(pkt);
- }
-
- public void fixSend(String str, int port, boolean print) throws IOException {
- String s1 = str.replace('~','\001');
- byte[] data = s1.getBytes();
- DatagramPacket pkt = new DatagramPacket(data, data.length, dstIP, port);
- if (print) {
- System.out.println("Sending packet: " + str + " on port " + port);
- }
- skt.send(pkt);
- }
-
-
- public byte[] rcv() throws IOException {
- byte[] buf = new byte[1024];
- DatagramPacket pkt = new DatagramPacket(buf, buf.length);
-// System.out.println("waiting to receive ...");
- skt.receive(pkt);
- int len = pkt.getLength();
- byte[] rd = pkt.getData();
- byte[] data = new byte[len];
- for (int i=0; i=150; price--) {
- StringBuffer fixmsg = new StringBuffer(fix1);
- fixmsg.append(Integer.toString(price));
- fixmsg.append(fix2);
- System.out.println("Sending price tick " + price);
- cxn.fixSend(fixmsg.toString(), 2000, false);
- }
- Thread.sleep(2000);
- }
-
-
- public static void main(String[] args) {
- UDPTestStream ut;
- try {
- ut = new UDPTestStream();
- ut.go();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
-
-}
Index: udp_ip_stack/tags/v2.0/bench/vhdl/UDP_complete_nomac_tb.vhd
===================================================================
--- udp_ip_stack/tags/v2.0/bench/vhdl/UDP_complete_nomac_tb.vhd (revision 12)
+++ udp_ip_stack/tags/v2.0/bench/vhdl/UDP_complete_nomac_tb.vhd (nonexistent)
@@ -1,1546 +0,0 @@
---------------------------------------------------------------------------------
--- Company:
--- Engineer:
---
--- Create Date: 09:57:01 06/13/2011
--- Design Name:
--- Module Name: C:/Users/pjf/Documents/projects/fpga/xilinx/Network/udp1/UDP_complete_nomac_tb.vhd
--- Project Name: udp1
--- Target Device:
--- Tool versions:
--- Description:
---
--- VHDL Test Bench Created by ISE for module: UDP_Complete_nomac
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Revision 0.02 - Added test for IP broadcast tx
--- Revision 0.03 - Added tests for ARP timeout
--- Additional Comments:
---
--- Notes:
--- This testbench has been automatically generated using types std_logic and
--- std_logic_vector for the ports of the unit under test. Xilinx recommends
--- that these types always be used for the top-level I/O of a design in order
--- to guarantee that the testbench will bind correctly to the post-implementation
--- simulation model.
---------------------------------------------------------------------------------
-library IEEE;
-use IEEE.STD_LOGIC_1164.ALL;
-use IEEE.NUMERIC_STD.ALL;
-use work.axi.all;
-use work.ipv4_types.all;
-use work.arp_types.all;
-
-ENTITY UDP_complete_nomac_tb IS
-END UDP_complete_nomac_tb;
-
-ARCHITECTURE behavior OF UDP_complete_nomac_tb IS
-
- -- Component Declaration for the Unit Under Test (UUT)
-
- COMPONENT UDP_Complete_nomac
- generic (
- CLOCK_FREQ : integer := 125000000; -- freq of data_in_clk -- needed to timout cntr
- ARP_TIMEOUT : integer := 60 -- ARP response timeout (s)
- );
- Port (
- -- UDP TX signals
- udp_tx_start : in std_logic; -- indicates req to tx UDP
- udp_txi : in udp_tx_type; -- UDP tx cxns
- udp_tx_result : out std_logic_vector (1 downto 0);-- tx status (changes during transmission)
- udp_tx_data_out_ready: out std_logic; -- indicates udp_tx is ready to take data
- -- UDP RX signals
- udp_rx_start : out std_logic; -- indicates receipt of udp header
- udp_rxo : out udp_rx_type;
- -- IP RX signals
- ip_rx_hdr : out ipv4_rx_header_type;
- -- system signals
- rx_clk : in STD_LOGIC;
- tx_clk : in STD_LOGIC;
- reset : in STD_LOGIC;
- our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
- our_mac_address : in std_logic_vector (47 downto 0);
- control : in udp_control_type;
- -- status signals
- arp_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- count of arp pkts received
- ip_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- number of IP pkts received for us
- -- MAC Transmitter
- mac_tx_tdata : out std_logic_vector(7 downto 0); -- data byte to tx
- mac_tx_tvalid : out std_logic; -- tdata is valid
- mac_tx_tready : in std_logic; -- mac is ready to accept data
- mac_tx_tfirst : out std_logic; -- indicates first byte of frame
- mac_tx_tlast : out std_logic; -- indicates last byte of frame
- -- MAC Receiver
- mac_rx_tdata : in std_logic_vector(7 downto 0); -- data byte received
- mac_rx_tvalid : in std_logic; -- indicates tdata is valid
- mac_rx_tready : out std_logic; -- tells mac that we are ready to take data
- mac_rx_tlast : in std_logic -- indicates last byte of the trame
- );
- END COMPONENT;
-
-
-
- type state_type is (IDLE, WAIT_RX_DONE, DATA_OUT);
- type count_mode_type is (RST, INCR, HOLD);
- type set_clr_type is (SET, CLR, HOLD);
-
-
- --Inputs
- signal udp_tx_start_int : std_logic := '0';
- signal udp_tx_int : udp_tx_type;
- signal clk_int : std_logic := '0';
- signal reset : std_logic := '0';
- signal our_ip_address : std_logic_vector(31 downto 0) := (others => '0');
- signal our_mac_address : std_logic_vector(47 downto 0) := (others => '0');
- signal mac_tx_tready : std_logic := '0';
- signal mac_rx_tdata : std_logic_vector(7 downto 0) := (others => '0');
- signal mac_rx_tvalid : std_logic := '0';
- signal mac_rx_tlast : std_logic := '0';
- signal control : udp_control_type;
-
- --Outputs
- signal udp_rx_start_int : std_logic;
- signal udp_rx_int : udp_rx_type;
- signal ip_rx_hdr : ipv4_rx_header_type;
- signal udp_tx_result : std_logic_vector (1 downto 0);
- signal udp_tx_data_out_ready_int: std_logic;
-
- signal arp_pkt_count : std_logic_vector(7 downto 0);
- signal ip_pkt_count : std_logic_vector(7 downto 0);
- signal mac_tx_tdata : std_logic_vector(7 downto 0);
- signal mac_tx_tvalid : std_logic;
- signal mac_tx_tfirst : std_logic;
- signal mac_tx_tlast : std_logic;
- signal mac_rx_tready : std_logic;
-
- signal pbtx_led : std_logic;
- signal pbtx : std_logic := '0';
-
- -- state signals
- signal state : state_type;
- signal count : unsigned (7 downto 0);
- signal tx_hdr : udp_tx_header_type;
- signal tx_start_reg : std_logic;
- signal tx_started_reg : std_logic;
- signal tx_fin_reg : std_logic;
-
-
- -- control signals
- signal next_state : state_type;
- signal set_state : std_logic;
- signal set_count : count_mode_type;
- signal set_hdr : std_logic;
- signal set_tx_start : set_clr_type;
- signal set_last : std_logic;
- signal set_tx_started : set_clr_type;
- signal set_tx_fin : set_clr_type;
- signal first_byte_rx : STD_LOGIC_VECTOR(7 downto 0);
-
-
-
- -- Clock period definitions
- constant clk_period : time := 8 ns;
-
-BEGIN
-
- -- Instantiate the Unit Under Test (UUT)
- uut: UDP_Complete_nomac
- generic map (
- CLOCK_FREQ => 10, -- artificially low count to enable pragmatic testing
- ARP_TIMEOUT => 20
- )
- PORT MAP (
- udp_tx_start => udp_tx_start_int,
- udp_txi => udp_tx_int,
- udp_tx_result => udp_tx_result,
- udp_tx_data_out_ready => udp_tx_data_out_ready_int,
- udp_rx_start => udp_rx_start_int,
- udp_rxo => udp_rx_int,
- ip_rx_hdr => ip_rx_hdr,
- rx_clk => clk_int,
- tx_clk => clk_int,
- reset => reset,
- our_ip_address => our_ip_address,
- our_mac_address => our_mac_address,
- control => control,
- arp_pkt_count => arp_pkt_count,
- ip_pkt_count => ip_pkt_count,
- mac_tx_tdata => mac_tx_tdata,
- mac_tx_tvalid => mac_tx_tvalid,
- mac_tx_tready => mac_tx_tready,
- mac_tx_tfirst => mac_tx_tfirst,
- mac_tx_tlast => mac_tx_tlast,
- mac_rx_tdata => mac_rx_tdata,
- mac_rx_tvalid => mac_rx_tvalid,
- mac_rx_tready => mac_rx_tready,
- mac_rx_tlast => mac_rx_tlast
- );
-
- -- Clock process definitions
- clk_process :process
- begin
- clk_int <= '0';
- wait for clk_period/2;
- clk_int <= '1';
- wait for clk_period/2;
- end process;
-
-
- -- Stimulus process
- stim_proc: process
- begin
- -- hold reset state for 100 ns.
- wait for 100 ns;
-
- our_ip_address <= x"c0a80509"; -- 192.168.5.9
- our_mac_address <= x"002320212223";
- control.ip_controls.arp_controls.clear_cache <= '0';
- mac_tx_tready <= '0';
-
- reset <= '1';
- wait for clk_period*10;
- reset <= '0';
- wait for clk_period*5;
-
- -- check reset conditions
- assert udp_tx_result = UDPTX_RESULT_NONE report "udp_tx_result not initialised correctly on reset";
- assert udp_tx_data_out_ready_int = '0' report "ip_udp_txitx.data.data_out_ready not initialised correctly on reset";
- assert mac_tx_tvalid = '0' report "mac_tx_tvalid not initialised correctly on reset";
- assert mac_tx_tlast = '0' report "mac_tx_tlast not initialised correctly on reset";
- assert arp_pkt_count = x"00" report "arp_pkt_count not initialised correctly on reset";
- assert ip_pkt_count = x"00" report "ip_pkt_count not initialised correctly on reset";
- assert udp_rx_start_int = '0' report "udp_rx_start not initialised correctly on reset";
- assert udp_rx_int.hdr.is_valid = '0' report "udp_rx_int.hdr.is_valid not initialised correctly on reset";
- assert udp_rx_int.hdr.data_length = x"0000" report "udp_rx_int.hdr.data_length not initialised correctly on reset";
- assert udp_rx_int.hdr.src_ip_addr = x"00000000" report "udp_rx_int.hdr.src_ip_addr not initialised correctly on reset";
- assert udp_rx_int.hdr.src_port = x"0000" report "udp_rx_int.hdr.src_port not initialised correctly on reset";
- assert udp_rx_int.hdr.dst_port = x"0000" report "udp_rx_int.hdr.dst_port not initialised correctly on reset";
- assert udp_rx_int.data.data_in = x"00" report "udp_rx_start.data.data_in not initialised correctly on reset";
- assert udp_rx_int.data.data_in_valid = '0' report "udp_rx_start.data.data_in_valid not initialised correctly on reset";
- assert udp_rx_int.data.data_in_last = '0' report "udp_rx_start.data.data_in_last not initialised correctly on reset";
- assert ip_rx_hdr.is_valid = '0' report "ip_rx_hdr.is_valid not initialised correctly on reset";
- assert ip_rx_hdr.protocol = x"00" report "ip_rx_hdr.protocol not initialised correctly on reset";
- assert ip_rx_hdr.data_length = x"0000" report "ip_rx_hdr.data_length not initialised correctly on reset";
- assert ip_rx_hdr.src_ip_addr = x"00000000" report "ip_rx_hdr.src_ip_addr not initialised correctly on reset";
- assert ip_rx_hdr.num_frame_errors = x"00" report "ip_rx_hdr.num_frame_errors not initialised correctly on reset";
-
-
- -- insert stimulus here
-
- ------------
- -- TEST 1 -- send ARP request
- ------------
-
- report "T1: Send an ARP request: who has 192.168.5.9? Tell 192.168.5.1";
-
- mac_tx_tready <= '1';
-
- 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;
- mac_rx_tdata <= x"06"; wait for clk_period;
- -- HW type
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"01"; wait for clk_period;
- -- Protocol type
- mac_rx_tdata <= x"08"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- -- HW size
- mac_rx_tdata <= x"06"; wait for clk_period;
- -- protocol size
- mac_rx_tdata <= x"04"; wait for clk_period;
- -- Opcode
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"01"; wait for clk_period;
- -- Sender 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;
- -- Sender 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;
- -- Target MAC
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- -- Target 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;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tlast <= '1';
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tlast <= '0';
- mac_rx_tvalid <= '0';
-
- -- check we got the ARP pkt
- assert arp_pkt_count = x"01" report "T1: arp_pkt_count wrong value";
- assert ip_pkt_count = x"00" report "T1: ip_pkt_count wrong value";
- assert udp_tx_result = UDPTX_RESULT_NONE report "T1: udp_tx_result wrong value";
- assert udp_tx_data_out_ready_int = '0' report "T1: ip_udp_txitx.data.data_out_ready wrong value";
- assert udp_rx_start_int = '0' report "T1: udp_rx_start wrong value";
- assert udp_rx_int.hdr.is_valid = '0' report "T1: udp_rx_int.hdr.is_valid wrong value";
- assert ip_rx_hdr.is_valid = '0' report "T1: ip_rx_hdr.is_valid wrong value";
-
- -- check we tx a response
-
- wait for clk_period*25;
- assert mac_tx_tvalid = '1' report "T1: not transmitting a response";
- wait for clk_period*25;
- assert mac_tx_tvalid = '0' report "T1: tx held on for too long";
-
- ------------
- -- TEST 2 -- send UDP pkt (same as sample from Java program)
- ------------
-
- report "T2: 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"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"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 "T2: udp_rx_int.hdr.is_valid not set";
- assert udp_rx_int.hdr.data_length = x"0005" report "T2: udp_rx_int.hdr.data_length not set correctly";
- assert udp_rx_int.hdr.src_ip_addr = x"c0a80501" report "T2: udp_rx_int.hdr.src_ip_addr not set correctly";
- assert udp_rx_int.hdr.src_port = x"f49a" report "T2: udp_rx_int.hdr.src_port not set correctly";
- assert udp_rx_int.hdr.dst_port = x"2694" report "T2: udp_rx_int.hdr.dst_port not set correctly";
-
- assert udp_rx_start_int = '1' report "T2: udp_rx_start not set";
- assert udp_rx_int.data.data_in_valid = '1' report "T2: udp_rx_int.data.data_in_valid not set";
-
- assert ip_rx_hdr.is_valid = '1' report "T2: ip_rx_hdr.is_valid not set";
- assert ip_rx_hdr.protocol = x"11" report "T2: ip_rx_hdr.protocol not set correctly";
- assert ip_rx_hdr.src_ip_addr = x"c0a80501" 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.last_error_code = x"0" report "T2: 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 "T2: 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;
-
- assert udp_rx_int.data.data_in_valid = '0' report "T2: udp_rx_int.data.data_in_valid not cleared";
- assert udp_rx_int.data.data_in_last = '0' report "T2: udp_rx_int.data.data_in_last not cleared";
- assert udp_rx_start_int = '0' report "T2: udp_rx_start not cleared";
- assert ip_rx_hdr.num_frame_errors = x"00" report "T2: ip_rx_hdr.num_frame_errors non zero at end of test";
- 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_pkt_count = x"01" report "T2: ip pkt cnt incorrect";
-
- wait for clk_period*20;
-
- ------------
- -- TEST 3 -- send UDP pkt again (same as sample from Java program)
- ------------
-
- report "T3: 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"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"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 "T3: udp_rx_int.hdr.is_valid not set";
- assert udp_rx_int.hdr.data_length = x"0005" report "T3: udp_rx_int.hdr.data_length not set correctly";
- assert udp_rx_int.hdr.src_ip_addr = x"c0a80501" report "T3: udp_rx_int.hdr.src_ip_addr not set correctly";
- assert udp_rx_int.hdr.src_port = x"f49a" report "T3: udp_rx_int.hdr.src_port not set correctly";
- assert udp_rx_int.hdr.dst_port = x"2694" report "T3: udp_rx_int.hdr.dst_port not set correctly";
-
- assert udp_rx_start_int = '1' report "T3: udp_rx_start not set";
- assert udp_rx_int.data.data_in_valid = '1' report "T3: udp_rx_int.data.data_in_valid not set";
-
- 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.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.last_error_code = x"0" report "T3: 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 "T3: 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;
-
- assert udp_rx_int.data.data_in_valid = '0' report "T3: udp_rx_int.data.data_in_valid not cleared";
- assert udp_rx_int.data.data_in_last = '0' report "T3: udp_rx_int.data.data_in_last not cleared";
- assert udp_rx_start_int = '0' report "T3: udp_rx_start 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_pkt_count = x"02" report "T3: ip pkt cnt incorrect";
-
- wait for clk_period*50;
-
- ------------
- -- TEST 4 -- send UDP pkt with specific UDP data 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"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"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"42"; wait for clk_period; -- First byte 'B' triggers a reply to broadcast addr
-
- -- 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"c0a80501" 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"c0a80501" 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";
-
-
- ------------
- -- TEST 6 -- send UDP pkt with data to trigger the sending of a pkt to unknown IP addr to force an ARP timeout
- ------------
-
- report "T6: Send UDP IP pkt dst ip_address c0a80509, from port f49a to port 2694 with data x43 to trig tx to unknown IP";
-
- 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"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"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"43"; wait for clk_period; -- First byte 'C' triggers a reply to unknown addr
-
- -- 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 "T6: udp_rx_int.hdr.is_valid not set";
- assert udp_rx_int.hdr.data_length = x"0005" report "T6: udp_rx_int.hdr.data_length not set correctly";
- assert udp_rx_int.hdr.src_ip_addr = x"c0a80501" report "T6: udp_rx_int.hdr.src_ip_addr not set correctly";
- assert udp_rx_int.hdr.src_port = x"f49a" report "T6: udp_rx_int.hdr.src_port not set correctly";
- assert udp_rx_int.hdr.dst_port = x"2694" report "T6: udp_rx_int.hdr.dst_port not set correctly";
-
- assert udp_rx_start_int = '1' report "T6: udp_rx_start not set";
- assert udp_rx_int.data.data_in_valid = '1' report "T6: udp_rx_int.data.data_in_valid not set";
-
- assert ip_rx_hdr.is_valid = '1' report "T6: ip_rx_hdr.is_valid not set";
- assert ip_rx_hdr.protocol = x"11" report "T6: ip_rx_hdr.protocol not set correctly";
- assert ip_rx_hdr.src_ip_addr = x"c0a80501" report "T6: ip_rx.hdr.src_ip_addr not set correctly";
- assert ip_rx_hdr.num_frame_errors = x"00" report "T6: ip_rx.hdr.num_frame_errors not set correctly";
- assert ip_rx_hdr.last_error_code = x"0" report "T6: 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 "T6: 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 "T6: waiting for mac data tx";
- wait until mac_tx_tvalid = '1';
- report "T6: starting mac data tx";
- wait for clk_period;
-
- -- check the mac data being transmitted is valid ARP request
- assert mac_tx_tdata = x"ff" report "T6: incorrect dst mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"ff" report "T6: incorrect dst mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"ff" report "T6: incorrect dst mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"ff" report "T6: incorrect dst mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"ff" report "T6: incorrect dst mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"ff" report "T6: incorrect dst mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T6: incorrect src mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T6: incorrect src mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"20" report "T6: incorrect src mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"21" report "T6: incorrect src mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"22" report "T6: incorrect src mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T6: incorrect src mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"08" report "T6: incorrect pkt_type 0"; wait for clk_period;
- assert mac_tx_tdata = x"06" report "T6: incorrect pkt type 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T6: incorrect HW type.0"; wait for clk_period;
- assert mac_tx_tdata = x"01" report "T6: incorrect HW type.1"; wait for clk_period;
- assert mac_tx_tdata = x"08" report "T6: incorrect prot.0"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T6: incorrect prot.1"; wait for clk_period;
- assert mac_tx_tdata = x"06" report "T6: incorrect HW size"; wait for clk_period;
- assert mac_tx_tdata = x"04" report "T6: incorrect prot size"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T6: incorrect opcode.0"; wait for clk_period;
- assert mac_tx_tdata = x"01" report "T6: incorrect opcode.1"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T6: incorrect sndr mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T6: incorrect sndr mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"20" report "T6: incorrect sndr mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"21" report "T6: incorrect sndr mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"22" report "T6: incorrect sndr mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T6: incorrect sndr mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"c0" report "T6: incorrect sndr ip 0"; wait for clk_period;
- assert mac_tx_tdata = x"a8" report "T6: incorrect sndr ip 1"; wait for clk_period;
- assert mac_tx_tdata = x"05" report "T6: incorrect sndr ip 2"; wait for clk_period;
- assert mac_tx_tdata = x"09" report "T6: incorrect sndr ip 3"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T6: incorrect trg mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T6: incorrect trg mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T6: incorrect trg mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T6: incorrect trg mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T6: incorrect trg mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T6: incorrect trg mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"c0" report "T6: incorrect trg ip 0"; wait for clk_period;
- assert mac_tx_tdata = x"bb" report "T6: incorrect trg ip 1"; wait for clk_period;
- assert mac_tx_tdata = x"cc" report "T6: incorrect trg ip 2";
- assert mac_tx_tlast = '0' report "T6: tlast asserted too soon";
- wait for clk_period;
-
- assert mac_tx_tdata = x"dd" report "T6: incorrect trg ip 3";
- assert mac_tx_tlast = '1' report "T6: tlast should be set";
- wait for clk_period;
-
- assert udp_tx_result = IPTX_RESULT_SENDING report "T6: TX should still be in sending phase";
-
- assert udp_rx_int.data.data_in_valid = '0' report "T6: udp_rx_int.data.data_in_valid not cleared";
- assert udp_rx_int.data.data_in_last = '0' report "T6: udp_rx_int.data.data_in_last not cleared";
- assert udp_rx_start_int = '0' report "T6: udp_rx_start not cleared";
- assert ip_rx_hdr.num_frame_errors = x"00" report "T6: ip_rx_hdr.num_frame_errors non zero at end of test";
- assert ip_rx_hdr.last_error_code = x"0" report "T6: ip_rx_hdr.last_error_code indicates error at end of test";
- assert ip_pkt_count = x"05" report "T6: ip pkt cnt incorrect";
-
- -- check for error on tx as a result of ARP timeout
-
- wait for clk_period*10*20;
- assert udp_tx_result = IPTX_RESULT_ERR report "T6: TX should resulkt in error (arp timeout)";
-
- wait for clk_period*10;
-
- ------------
- -- TEST 7 -- send UDP pkt again to ensure that we can rx a pkt and tx after a timeout
- ------------
-
- report "T7: 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"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"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 "T7: udp_rx_int.hdr.is_valid not set";
- assert udp_rx_int.hdr.data_length = x"0005" report "T7: udp_rx_int.hdr.data_length not set correctly";
- assert udp_rx_int.hdr.src_ip_addr = x"c0a80501" report "T7: udp_rx_int.hdr.src_ip_addr not set correctly";
- assert udp_rx_int.hdr.src_port = x"f49a" report "T7: udp_rx_int.hdr.src_port not set correctly";
- assert udp_rx_int.hdr.dst_port = x"2694" report "T7: udp_rx_int.hdr.dst_port not set correctly";
-
- assert udp_rx_start_int = '1' report "T7: udp_rx_start not set";
- assert udp_rx_int.data.data_in_valid = '1' report "T7: udp_rx_int.data.data_in_valid not set";
-
- assert ip_rx_hdr.is_valid = '1' report "T7: ip_rx_hdr.is_valid not set";
- assert ip_rx_hdr.protocol = x"11" report "T7: ip_rx_hdr.protocol not set correctly";
- assert ip_rx_hdr.src_ip_addr = x"c0a80501" report "T7: ip_rx.hdr.src_ip_addr not set correctly";
- assert ip_rx_hdr.num_frame_errors = x"00" report "T7: ip_rx.hdr.num_frame_errors not set correctly";
- assert ip_rx_hdr.last_error_code = x"0" report "T7: 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 "T7: 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 "T7: waiting for mac ARP REQ data tx";
- if mac_tx_tvalid = '0' then
- wait until mac_tx_tvalid = '1';
- wait for clk_period;
- end if;
- report "T7: starting mac ARP REQ data tx";
-
- -- check the ARP REQ mac data being transmitted
- assert mac_tx_tdata = x"ff" report "T7: arp incorrect dst mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"ff" report "T7: arp incorrect dst mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"ff" report "T7: arp incorrect dst mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"ff" report "T7: arp incorrect dst mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"ff" report "T7: arp incorrect dst mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"ff" report "T7: arp incorrect dst mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T7: arp incorrect src mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T7: arp incorrect src mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"20" report "T7: arp incorrect src mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"21" report "T7: arp incorrect src mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"22" report "T7: arp incorrect src mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T7: arp incorrect src mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"08" report "T7: arp incorrect pkt_type 0"; wait for clk_period;
- assert mac_tx_tdata = x"06" report "T7: arp incorrect pkt type 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T7: arp incorrect HW type.0"; wait for clk_period;
- assert mac_tx_tdata = x"01" report "T7: arp incorrect HW type.1"; wait for clk_period;
- assert mac_tx_tdata = x"08" report "T7: arp incorrect prot.0"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: arp incorrect prot.1"; wait for clk_period;
- assert mac_tx_tdata = x"06" report "T7: arp incorrect HW size"; wait for clk_period;
- assert mac_tx_tdata = x"04" report "T7: arp incorrect prot size"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: arp incorrect opcode.0"; wait for clk_period;
- assert mac_tx_tdata = x"01" report "T7: arp incorrect opcode.1"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T7: arp incorrect sndr mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T7: arp incorrect sndr mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"20" report "T7: arp incorrect sndr mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"21" report "T7: arp incorrect sndr mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"22" report "T7: arp incorrect sndr mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T7: arp incorrect sndr mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"c0" report "T7: arp incorrect sndr ip 0"; wait for clk_period;
- assert mac_tx_tdata = x"a8" report "T7: arp incorrect sndr ip 1"; wait for clk_period;
- assert mac_tx_tdata = x"05" report "T7: arp incorrect sndr ip 2"; wait for clk_period;
- assert mac_tx_tdata = x"09" report "T7: arp incorrect sndr ip 3"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T7: arp incorrect trg mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: arp incorrect trg mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: arp incorrect trg mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: arp incorrect trg mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: arp incorrect trg mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: arp incorrect trg mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"c0" report "T7: arp incorrect trg ip 0"; wait for clk_period;
- assert mac_tx_tdata = x"a8" report "T7: arp incorrect trg ip 1"; wait for clk_period;
- assert mac_tx_tdata = x"05" report "T7: arp incorrect trg ip 2";
- assert mac_tx_tlast = '0' report "T7: arp tlast asserted too soon";
- wait for clk_period;
-
- assert mac_tx_tdata = x"01" report "T7: arp incorrect trg ip 3";
- assert mac_tx_tlast = '1' report "T7: arp tlast should be set";
- wait for clk_period;
-
- assert udp_tx_result = IPTX_RESULT_SENDING report "T7: arp TX should still be in sending phase";
-
- wait for clk_period*5;
-
- report "T7: feeding in an arp reply: I have c0180501 at mac 021503230454";
-
- 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"02"; wait for clk_period;
- mac_rx_tdata <= x"15"; wait for clk_period;
- mac_rx_tdata <= x"03"; wait for clk_period;
- mac_rx_tdata <= x"23"; wait for clk_period;
- mac_rx_tdata <= x"04"; wait for clk_period;
- mac_rx_tdata <= x"54"; wait for clk_period;
- -- type
- mac_rx_tdata <= x"08"; wait for clk_period;
- mac_rx_tdata <= x"06"; wait for clk_period;
- -- HW type
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"01"; wait for clk_period;
- -- Protocol type
- mac_rx_tdata <= x"08"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- -- HW size
- mac_rx_tdata <= x"06"; wait for clk_period;
- -- protocol size
- mac_rx_tdata <= x"04"; wait for clk_period;
- -- Opcode
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"02"; wait for clk_period;
- -- Sender MAC
- mac_rx_tdata <= x"02"; wait for clk_period;
- mac_rx_tdata <= x"15"; wait for clk_period;
- mac_rx_tdata <= x"03"; wait for clk_period;
- mac_rx_tdata <= x"23"; wait for clk_period;
- mac_rx_tdata <= x"04"; wait for clk_period;
- mac_rx_tdata <= x"54"; wait for clk_period;
- -- Sender 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;
- -- Target MAC
- 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;
- -- Target 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;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tlast <= '1';
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tlast <= '0';
- mac_rx_tvalid <= '0';
- wait for clk_period;
-
- assert udp_tx_result = IPTX_RESULT_SENDING report "T7: TX should still be sending";
-
- report "T7: waiting for mac data tx";
- if mac_tx_tvalid = '0' then
- wait until mac_tx_tvalid = '1';
- wait for clk_period;
- end if;
- report "T7: starting mac data tx";
-
- -- check the mac data being transmitted
- assert mac_tx_tdata = x"02" report "T7: incorrect dst mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"15" report "T7: incorrect dst mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"03" report "T7: incorrect dst mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T7: incorrect dst mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"04" report "T7: incorrect dst mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"54" report "T7: incorrect dst mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T7: incorrect src mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T7: incorrect src mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"20" report "T7: incorrect src mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"21" report "T7: incorrect src mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"22" report "T7: incorrect src mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T7: incorrect src mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"08" report "T7: incorrect pkt_type 0"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect pkt type 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"45" report "T7: incorrect ver.hlen"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect srv type"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect len 0"; wait for clk_period;
- assert mac_tx_tdata = x"20" report "T7: incorrect len 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T7: incorrect ident 0"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect ident 1"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect flag&frag 0"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect flag&frag 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"80" report "T7: incorrect TTL"; wait for clk_period;
- assert mac_tx_tdata = x"11" report "T7: incorrect protocol"; wait for clk_period;
- assert mac_tx_tdata = x"af" report "T7: incorrect hdr.cks 0"; wait for clk_period;
- assert mac_tx_tdata = x"72" report "T7: incorrect hdr.cks 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"c0" report "T7: incorrect src ip 0"; wait for clk_period;
- assert mac_tx_tdata = x"a8" report "T7: incorrect src ip 1"; wait for clk_period;
- assert mac_tx_tdata = x"05" report "T7: incorrect src ip 2"; wait for clk_period;
- assert mac_tx_tdata = x"09" report "T7: incorrect src ip 3"; wait for clk_period;
-
- assert mac_tx_tdata = x"c0" report "T7: incorrect dst ip 0"; wait for clk_period;
- assert mac_tx_tdata = x"a8" report "T7: incorrect dst ip 1"; wait for clk_period;
- assert mac_tx_tdata = x"05" report "T7: incorrect dst ip 2"; wait for clk_period;
- assert mac_tx_tdata = x"01" report "T7: incorrect dst ip 3"; wait for clk_period;
-
- assert mac_tx_tdata = x"26" report "T7: incorrect src port 0"; wait for clk_period;
- assert mac_tx_tdata = x"94" report "T7: incorrect src port 1"; wait for clk_period;
- assert mac_tx_tdata = x"f4" report "T7: incorrect dst port 0"; wait for clk_period;
- assert mac_tx_tdata = x"9a" report "T7: incorrect dst port 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T7: incorrect udp len 0"; wait for clk_period;
- assert mac_tx_tdata = x"0c" report "T7: incorrect udp len 1"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect udp cks 0"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect udp cks 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"40" report "T7: incorrect udp data 0"; wait for clk_period;
- assert mac_tx_tdata = x"41" report "T7: incorrect udp data 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"42" report "T7: incorrect udp data 2";
- assert mac_tx_tlast = '0' report "T7: tlast asserted too soon"; wait for clk_period;
- assert mac_tx_tdata = x"43" report "T7: incorrect udp data 3";
- assert mac_tx_tlast = '1' report "T7: tlast not asserted"; wait for clk_period;
-
- assert udp_tx_result = IPTX_RESULT_SENT report "T7: TX did not complete";
-
- assert udp_rx_int.data.data_in_valid = '0' report "T7: udp_rx_int.data.data_in_valid not cleared";
- assert udp_rx_int.data.data_in_last = '0' report "T7: udp_rx_int.data.data_in_last not cleared";
- assert udp_rx_start_int = '0' report "T7: udp_rx_start not cleared";
- assert ip_rx_hdr.num_frame_errors = x"00" report "T7: ip_rx_hdr.num_frame_errors non zero at end of test";
- assert ip_rx_hdr.last_error_code = x"0" report "T7: ip_rx_hdr.last_error_code indicates error at end of test";
- assert ip_pkt_count = x"06" report "T7: ip pkt cnt incorrect";
-
-
- report "--- end of tests ---";
- wait;
- end process;
-
- -- 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(
- -- inputs
- udp_rx_start_int, udp_rx_int, udp_tx_data_out_ready_int, udp_tx_result, ip_rx_hdr,
- udp_tx_int.data.data_out_valid, PBTX,
- -- state
- state, count, tx_hdr, tx_start_reg, tx_started_reg, tx_fin_reg,
- -- controls
- next_state, set_state, set_count, set_hdr, set_tx_start, set_last,
- set_tx_started, set_tx_fin, first_byte_rx
- )
- begin
- -- set output_followers
- udp_tx_int.hdr <= tx_hdr;
- udp_tx_int.data.data_out_last <= set_last;
- udp_tx_start_int <= tx_start_reg;
-
- -- set control signal defaults
- next_state <= IDLE;
- set_state <= '0';
- set_count <= HOLD;
- set_hdr <= '0';
- set_tx_start <= HOLD;
- set_last <= '0';
- set_tx_started <= HOLD;
- set_tx_fin <= HOLD;
- first_byte_rx <= (others => '0');
-
- -- FSM
- case state is
-
- when IDLE =>
- 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_tx_fin <= CLR;
- set_count <= RST;
- set_hdr <= '1';
- if udp_rx_int.data.data_in_last = '1' then
- set_tx_started <= SET;
- set_tx_start <= SET;
- next_state <= DATA_OUT;
- set_state <= '1';
- else
- next_state <= WAIT_RX_DONE;
- set_state <= '1';
- end if;
- end if;
-
- when WAIT_RX_DONE =>
- -- wait until RX pkt fully received
- if udp_rx_int.data.data_in_last = '1' then
- set_tx_started <= SET;
- set_tx_start <= SET;
- next_state <= DATA_OUT;
- set_state <= '1';
- end if;
-
- when DATA_OUT =>
- if udp_tx_result = UDPTX_RESULT_ERR then
- -- have an error from the IP TX layer, clear down the TX
- set_tx_start <= CLR;
- set_tx_fin <= SET;
- set_tx_started <= CLR;
- next_state <= IDLE;
- set_state <= '1';
- else
- if udp_tx_result = UDPTX_RESULT_SENDING then
- set_tx_start <= CLR; -- reset out start req as soon as we know we are sending
- end if;
- 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
- if unsigned(count) = x"03" then
- set_last <= '1';
- set_tx_fin <= SET;
- set_tx_started <= CLR;
- next_state <= IDLE;
- set_state <= '1';
- else
- set_count <= INCR;
- end if;
- end if;
- end if;
-
- end case;
- end process;
-
-
-
- -- TX response process - SEQ
- tx_proc_sequential: process(clk_int)
- begin
- if rising_edge(clk_int) then
- if reset = '1' then
- -- reset state variables
- state <= IDLE;
- count <= x"00";
- tx_start_reg <= '0';
- tx_hdr.dst_ip_addr <= (others => '0');
- tx_hdr.dst_port <= (others => '0');
- tx_hdr.src_port <= (others => '0');
- tx_hdr.data_length <= (others => '0');
- tx_hdr.checksum <= (others => '0');
- tx_started_reg <= '0';
- tx_fin_reg <= '0';
- PBTX_LED <= '0';
- else
- PBTX_LED <= PBTX;
-
- -- Next rx_state processing
- if set_state = '1' then
- state <= next_state;
- else
- state <= state;
- end if;
-
- -- count processing
- case set_count is
- when RST => count <= x"00";
- when INCR => count <= count + 1;
- when HOLD => count <= count;
- end case;
-
- -- set tx hdr
- if set_hdr = '1' then
- -- 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; -- send to Broadcast addr
- elsif first_byte_rx = x"43" then
- tx_hdr.dst_ip_addr <= x"c0bbccdd"; -- set dst unknown so get ARP timeout
- else
- tx_hdr.dst_ip_addr <= udp_rx_int.hdr.src_ip_addr; -- reply to sender
- 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";
- tx_hdr.checksum <= x"0000";
- else
- tx_hdr <= tx_hdr;
- end if;
-
- -- set tx start signal
- case set_tx_start is
- when SET => tx_start_reg <= '1';
- when CLR => tx_start_reg <= '0';
- when HOLD => tx_start_reg <= tx_start_reg;
- end case;
-
- -- set tx started signal
- case set_tx_started is
- when SET => tx_started_reg <= '1';
- when CLR => tx_started_reg <= '0';
- when HOLD => tx_started_reg <= tx_started_reg;
- end case;
-
- -- set tx finished signal
- case set_tx_fin is
- when SET => tx_fin_reg <= '1';
- when CLR => tx_fin_reg <= '0';
- when HOLD => tx_fin_reg <= tx_fin_reg;
- end case;
-
-
- end if;
- end if;
-
- end process;
-
-END;
Index: udp_ip_stack/tags/v2.0/bench/vhdl/IPv4_TX_tb.vhd
===================================================================
--- udp_ip_stack/tags/v2.0/bench/vhdl/IPv4_TX_tb.vhd (revision 12)
+++ udp_ip_stack/tags/v2.0/bench/vhdl/IPv4_TX_tb.vhd (nonexistent)
@@ -1,363 +0,0 @@
---------------------------------------------------------------------------------
--- Company:
--- Engineer:
---
--- Create Date: 09:35:58 06/03/2011
--- Design Name:
--- Module Name: C:/Users/pjf/Documents/projects/fpga/xilinx/Network/ip1/IPv4_TX_tb.vhd
--- Project Name: ip1
--- Target Device:
--- Tool versions:
--- Description:
---
--- VHDL Test Bench Created by ISE for module: IPv4_TX
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Revision 0.02 - Added test for IP broadcast tx
--- Additional Comments:
---
--- Notes:
--- This testbench has been automatically generated using types std_logic and
--- std_logic_vector for the ports of the unit under test. Xilinx recommends
--- that these types always be used for the top-level I/O of a design in order
--- to guarantee that the testbench will bind correctly to the post-implementation
--- simulation model.
---------------------------------------------------------------------------------
-LIBRARY ieee;
-USE ieee.std_logic_1164.ALL;
-use IEEE.NUMERIC_STD.ALL;
-use work.axi.all;
-use work.ipv4_types.all;
-use work.arp_types.all;
-
-
-ENTITY IPv4_TX_tb IS
-END IPv4_TX_tb;
-
-ARCHITECTURE behavior OF IPv4_TX_tb IS
-
- -- Component Declaration for the Unit Under Test (UUT)
-
- COMPONENT IPv4_TX
- PORT(
- -- IP Layer signals
- ip_tx_start : in std_logic;
- ip_tx : in ipv4_tx_type; -- IP tx cxns
- ip_tx_result : out std_logic_vector (1 downto 0); -- tx status (changes during transmission)
- ip_tx_data_out_ready : out std_logic; -- indicates IP TX is ready to take data
-
- -- system signals
- clk : in STD_LOGIC; -- same clock used to clock mac data and ip data
- reset : in STD_LOGIC;
- our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
- our_mac_address : in std_logic_vector (47 downto 0);
- -- ARP lookup signals
- arp_req_req : out arp_req_req_type;
- arp_req_rslt : in arp_req_rslt_type;
- -- 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_granted : in std_logic; -- indicates that access to channel has been granted
- mac_data_out_ready : in std_logic; -- indicates system ready to consume data
- mac_data_out_valid : out std_logic; -- indicates data out is valid
- mac_data_out_first : out std_logic; -- with data out valid indicates the first byte of a frame
- mac_data_out_last : out std_logic; -- with data out valid indicates the last byte of a frame
- mac_data_out : out std_logic_vector (7 downto 0) -- ethernet frame (from dst mac addr through to last byte of frame)
- );
- END COMPONENT;
-
-
- --Inputs
- signal ip_tx_start : std_logic := '0';
- signal ip_tx : ipv4_tx_type;
- signal clk : std_logic := '0';
- signal reset : std_logic := '0';
- signal our_ip_address : std_logic_vector(31 downto 0) := (others => '0');
- signal our_mac_address : std_logic_vector(47 downto 0) := (others => '0');
- signal mac_tx_granted : std_logic := '0';
- signal mac_data_out_ready : std_logic := '0';
- signal arp_req_rslt : arp_req_rslt_type;
-
- --Outputs
- signal ip_tx_result : std_logic_vector (1 downto 0); -- tx status (changes during transmission)
- signal ip_tx_data_out_ready : std_logic; -- indicates IP TX is ready to take data
- signal mac_tx_req : std_logic;
- signal mac_data_out_valid : std_logic;
- signal mac_data_out_last : std_logic;
- signal mac_data_out_first : std_logic;
- signal mac_data_out : std_logic_vector(7 downto 0);
- signal arp_req_req : arp_req_req_type;
-
- -- Clock period definitions
- constant clk_period : time := 8 ns;
-
-BEGIN
-
- -- Instantiate the Unit Under Test (UUT)
- uut: IPv4_TX PORT MAP (
- ip_tx_start => ip_tx_start,
- ip_tx => ip_tx,
- ip_tx_result => ip_tx_result,
- ip_tx_data_out_ready => ip_tx_data_out_ready,
- clk => clk,
- reset => reset,
- our_ip_address => our_ip_address,
- our_mac_address => our_mac_address,
- arp_req_req => arp_req_req,
- arp_req_rslt => arp_req_rslt,
- mac_tx_req => mac_tx_req,
- mac_tx_granted => mac_tx_granted,
- mac_data_out_ready => mac_data_out_ready,
- mac_data_out_valid => mac_data_out_valid,
- mac_data_out_first => mac_data_out_first,
- mac_data_out_last => mac_data_out_last,
- mac_data_out => mac_data_out
- );
-
- -- Clock process definitions
- clk_process :process
- begin
- clk <= '0';
- wait for clk_period/2;
- clk <= '1';
- wait for clk_period/2;
- end process;
-
-
- -- Stimulus process
- stim_proc: process
- begin
- our_ip_address <= x"c0a80509"; -- 192.168.5.9
- our_mac_address <= x"002320212223";
- ip_tx_start <= '0';
- mac_tx_granted <= '0';
- mac_data_out_ready <= '0';
- ip_tx.data.data_out_valid <= '0';
- ip_tx.data.data_out_last <= '0';
- arp_req_rslt.got_mac <= '0';
- arp_req_rslt.got_err <= '0';
- arp_req_rslt.mac <= (others => '0');
-
- reset <= '1';
- wait for clk_period*10;
- reset <= '0';
- wait for clk_period*5;
-
- -- check reset conditions
- assert arp_req_req.lookup_req = '0' report "arp_req_req.lookup_req not initialised correctly on reset";
- assert ip_tx_result = IPTX_RESULT_NONE report "ip_tx_result not initialised correctly on reset";
- assert ip_tx_data_out_ready = '0' report "ip_tx_data_out_ready not initialised correctly on reset";
- assert mac_tx_req = '0' report "mac_tx_req not initialised correctly on reset";
- assert mac_data_out_valid = '0' report "mac_data_out_valid not initialised correctly on reset";
- assert mac_data_out_last = '0' report "mac_data_out_last not initialised correctly on reset";
-
- -- insert stimulus here
-
- ------------
- -- TEST 1 -- basic functional tx test with some delays for arp and chn access
- ------------
-
- report "T1: basic functional tx test with some delays for arp and chn access";
-
- ip_tx.hdr.protocol <= x"35";
- ip_tx.hdr.data_length <= x"0008";
- ip_tx.hdr.dst_ip_addr <= x"c0123478";
- ip_tx_start <= '1';
- wait for clk_period;
- ip_tx_start <= '0';
- arp_req_rslt.got_mac <= '0';
- arp_req_rslt.got_err <= '0';
-
- assert arp_req_req.lookup_req = '1' report "T1: lookup_req not set on tx start";
- wait for clk_period;
- assert ip_tx_result = IPTX_RESULT_SENDING report "T1: result should be IPTX_RESULT_SENDING";
-
- wait for clk_period*10; -- simulate arp lookup time
- arp_req_rslt.mac <= x"050423271016";
- arp_req_rslt.got_mac <= '1';
-
- 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";
-
- wait for clk_period*10; -- simulate mac chn access time
- mac_tx_granted <= '1';
- wait for clk_period*2;
- mac_data_out_ready <= '1';
- assert mac_data_out_valid = '0' report "T1: mac_data_out_valid asserted too early";
-
- wait for clk_period;
-
- assert ip_tx_data_out_ready = '0' report "T1: IP data out ready asserted too early";
- wait for clk_period;
- assert mac_data_out_valid = '1' report "T1: mac_data_out_valid not asserted";
-
- -- wait until in eth hdr
- wait for clk_period*3;
- -- go mac not ready for 2 clocks
- mac_data_out_ready <= '0';
- wait for clk_period*2;
- mac_data_out_ready <= '1';
-
-
- 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"56"; wait for clk_period;
- -- delay data in for 1 clk cycle
- ip_tx.data.data_out_valid <= '0';
- ip_tx.data.data_out <= x"57"; wait for clk_period;
- ip_tx.data.data_out_valid <= '1'; wait for clk_period;
- ip_tx.data.data_out <= x"58"; wait for clk_period;
- ip_tx.data.data_out <= x"59"; wait for clk_period;
-
- -- delay mac ready for 2 clk cycles
- mac_data_out_ready <= '0';
- ip_tx.data.data_out <= x"5a"; wait for clk_period;
- assert ip_tx_data_out_ready = '0' report "T1: ip_tx_data_out_ready not cleared when mac not ready";
-
- ip_tx.data.data_out <= x"5a"; wait for clk_period;
- mac_data_out_ready <= '1';
- wait until ip_tx_data_out_ready = '1';
- wait for clk_period;
- assert ip_tx_data_out_ready = '1' report "T1: ip_tx_data_out_ready not set when mac ready";
- ip_tx.data.data_out <= x"5b"; wait for clk_period;
- ip_tx.data.data_out <= x"5c"; wait for clk_period;
-
- ip_tx.data.data_out <= x"5d";
- 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";
-
- 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 "T1: result should be IPTX_RESULT_SENT";
- assert mac_tx_req = '0' report "T1: mac_tx_req held on too long after TX";
-
- mac_tx_granted <= '0';
- wait for clk_period*2;
-
- ------------
- -- TEST 2 -- basic functional tx test with no delays for arp and chn access
- ------------
-
- report "T2: basic functional tx test with no delays for arp and chn access";
-
- ip_tx.hdr.protocol <= x"11";
- ip_tx.hdr.data_length <= x"0006";
- ip_tx.hdr.dst_ip_addr <= x"c0123478";
- 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 = '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";
- arp_req_rslt.got_mac <= '1';
-
- wait for clk_period*2;
-
- 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';
- wait for clk_period*2;
- mac_data_out_ready <= '1';
-
- assert ip_tx_data_out_ready = '0' report "T2: 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 "T2: 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 "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;
- end process;
-
-END;
Index: udp_ip_stack/tags/v2.0/bench/vhdl/IP_complete_nomac_tb.vhd
===================================================================
--- udp_ip_stack/tags/v2.0/bench/vhdl/IP_complete_nomac_tb.vhd (revision 12)
+++ udp_ip_stack/tags/v2.0/bench/vhdl/IP_complete_nomac_tb.vhd (nonexistent)
@@ -1,438 +0,0 @@
---------------------------------------------------------------------------------
--- Company:
--- Engineer:
---
--- Create Date: 13:54:32 06/04/2011
--- Design Name:
--- Module Name: C:/Users/pjf/Documents/projects/fpga/xilinx/Network/ip1/IP_complete_nomac_tb.vhd
--- Project Name: ip1
--- Target Device:
--- Tool versions:
--- Description:
---
--- VHDL Test Bench Created by ISE for module: IP_complete_nomac
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Additional Comments:
---
--- Notes:
--- This testbench has been automatically generated using types std_logic and
--- std_logic_vector for the ports of the unit under test. Xilinx recommends
--- that these types always be used for the top-level I/O of a design in order
--- to guarantee that the testbench will bind correctly to the post-implementation
--- simulation model.
---------------------------------------------------------------------------------
-LIBRARY ieee;
-USE ieee.std_logic_1164.ALL;
-use IEEE.NUMERIC_STD.ALL;
-use work.axi.all;
-use work.ipv4_types.all;
-use work.arp_types.all;
-
-ENTITY IP_complete_nomac_tb IS
-END IP_complete_nomac_tb;
-
-ARCHITECTURE behavior OF IP_complete_nomac_tb IS
-
- -- Component Declaration for the Unit Under Test (UUT)
-
- COMPONENT IP_complete_nomac
- generic (
- CLOCK_FREQ : integer := 125000000; -- freq of data_in_clk -- needed to timout cntr
- ARP_TIMEOUT : integer := 60 -- ARP response timeout (s)
- );
- Port (
- -- IP Layer signals
- ip_tx_start : in std_logic;
- ip_tx : in ipv4_tx_type; -- IP tx cxns
- ip_tx_result : out std_logic_vector (1 downto 0); -- tx status (changes during transmission)
- ip_tx_data_out_ready : out std_logic; -- indicates IP TX is ready to take data
- ip_rx_start : out std_logic; -- indicates receipt of ip frame.
- ip_rx : out ipv4_rx_type;
- -- system signals
- rx_clk : in STD_LOGIC;
- tx_clk : in STD_LOGIC;
- reset : in STD_LOGIC;
- our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
- our_mac_address : in std_logic_vector (47 downto 0);
- control : in ip_control_type;
- -- status signals
- arp_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- count of arp pkts received
- ip_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- number of IP pkts received for us
- -- MAC Transmitter
- mac_tx_tdata : out std_logic_vector(7 downto 0); -- data byte to tx
- mac_tx_tvalid : out std_logic; -- tdata is valid
- mac_tx_tready : in std_logic; -- mac is ready to accept data
- mac_tx_tfirst : out std_logic; -- indicates first byte of frame
- mac_tx_tlast : out std_logic; -- indicates last byte of frame
- -- MAC Receiver
- mac_rx_tdata : in std_logic_vector(7 downto 0); -- data byte received
- mac_rx_tvalid : in std_logic; -- indicates tdata is valid
- mac_rx_tready : out std_logic; -- tells mac that we are ready to take data
- mac_rx_tlast : in std_logic -- indicates last byte of the trame
- );
- END COMPONENT;
-
-
- --Inputs
- signal ip_tx_start : std_logic := '0';
- signal ip_tx : ipv4_tx_type;
-
- signal clk : std_logic := '0';
- signal reset : std_logic := '0';
- signal our_ip_address : std_logic_vector(31 downto 0) := (others => '0');
- signal our_mac_address : std_logic_vector(47 downto 0) := (others => '0');
- signal mac_tx_tready : std_logic := '0';
- signal mac_rx_tdata : std_logic_vector(7 downto 0) := (others => '0');
- signal mac_rx_tvalid : std_logic := '0';
- signal mac_rx_tlast : std_logic := '0';
- signal control : ip_control_type;
-
- --Outputs
- signal ip_tx_result : std_logic_vector (1 downto 0); -- tx status (changes during transmission)
- signal ip_tx_data_out_ready : std_logic; -- indicates IP TX is ready to take data
- signal ip_rx_start : std_logic;
- signal ip_rx : ipv4_rx_type;
- signal arp_pkt_count : std_logic_vector(7 downto 0);
- signal mac_tx_tdata : std_logic_vector(7 downto 0);
- signal mac_tx_tvalid : std_logic;
- signal mac_tx_tfirst : std_logic;
- signal mac_tx_tlast : std_logic;
- signal mac_rx_tready : std_logic;
-
- -- Clock period definitions
- constant clk_period : time := 8 ns;
-
-BEGIN
-
- -- Instantiate the Unit Under Test (UUT)
- uut: IP_complete_nomac PORT MAP (
- ip_tx_start => ip_tx_start,
- ip_tx => ip_tx,
- ip_tx_result => ip_tx_result,
- ip_tx_data_out_ready => ip_tx_data_out_ready,
- ip_rx_start => ip_rx_start,
- ip_rx => ip_rx,
- rx_clk => clk,
- tx_clk => clk,
- reset => reset,
- our_ip_address => our_ip_address,
- our_mac_address => our_mac_address,
- control => control,
- arp_pkt_count => arp_pkt_count,
- mac_tx_tdata => mac_tx_tdata,
- mac_tx_tvalid => mac_tx_tvalid,
- mac_tx_tready => mac_tx_tready,
- mac_tx_tfirst => mac_tx_tfirst,
- mac_tx_tlast => mac_tx_tlast,
- mac_rx_tdata => mac_rx_tdata,
- mac_rx_tvalid => mac_rx_tvalid,
- mac_rx_tready => mac_rx_tready,
- mac_rx_tlast => mac_rx_tlast
- );
-
- -- Clock process definitions
- clk_process :process
- begin
- clk <= '1';
- wait for clk_period/2;
- clk <= '0';
- wait for clk_period/2;
- end process;
-
-
- -- Stimulus process
- stim_proc: process
- begin
- -- hold reset state for 100 ns.
- wait for 80 ns;
-
- our_ip_address <= x"c0a80509"; -- 192.168.5.9
- our_mac_address <= x"002320212223";
- control.arp_controls.clear_cache <= '0';
- ip_tx_start <= '0';
- mac_tx_tready <= '0';
-
- reset <= '1';
- wait for clk_period*10;
- reset <= '0';
- wait for clk_period*5;
-
- -- check reset conditions
- assert ip_tx_result = IPTX_RESULT_NONE report "ip_tx_result not initialised correctly on reset";
- assert ip_tx_data_out_ready = '0' report "ip_tx_data_out_ready not initialised correctly on reset";
- assert mac_tx_tvalid = '0' report "mac_tx_tvalid not initialised correctly on reset";
- assert mac_tx_tlast = '0' report " mac_tx_tlast not initialised correctly on reset";
- assert arp_pkt_count = x"00" report " arp_pkt_count not initialised correctly on reset";
- assert ip_rx_start = '0' report "ip_rx_start not initialised correctly on reset";
- assert ip_rx.hdr.is_valid = '0' report "ip_rx.hdr.is_valid not initialised correctly on reset";
- assert ip_rx.hdr.protocol = x"00" report "ip_rx.hdr.protocol not initialised correctly on reset";
- assert ip_rx.hdr.data_length = x"0000" report "ip_rx.hdr.data_length not initialised correctly on reset";
- assert ip_rx.hdr.src_ip_addr = x"00000000" report "ip_rx.hdr.src_ip_addr not initialised correctly on reset";
- assert ip_rx.hdr.num_frame_errors = x"00" report "ip_rx.hdr.num_frame_errors not initialised correctly on reset";
- assert ip_rx.data.data_in = x"00" report "ip_rx.data.data_in not initialised correctly on reset";
- assert ip_rx.data.data_in_valid = '0' report "ip_rx.data.data_in_valid not initialised correctly on reset";
- assert ip_rx.data.data_in_last = '0' report "ip_rx.data.data_in_last not initialised correctly on reset";
-
- -- insert stimulus here
-
- ------------
- -- TEST 1 -- basic functional rx test with received ip pkt
- ------------
-
- report "T1: Send an eth frame with IP pkt dst ip_address c0a80509, dst mac 002320212223";
-
- mac_tx_tready <= '1';
- 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"18"; wait for clk_period;
- -- ID
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; 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"00"; 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"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;
-
- -- user data
- mac_rx_tdata <= x"24"; 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 ip_rx.hdr.is_valid = '1' report "T1: ip_rx.hdr.is_valid not set";
- assert ip_rx.hdr.protocol = x"11" report "T1: ip_rx.hdr.protocol not set correctly";
- assert ip_rx.hdr.data_length = x"0004" report "T1: ip_rx.hdr.data_length not set correctly";
- 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_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";
-
- mac_rx_tdata <= x"25"; wait for clk_period;
- mac_rx_tdata <= x"26"; wait for clk_period;
- mac_rx_tdata <= x"27"; mac_rx_tlast <= '1'; wait for clk_period;
-
- assert ip_rx.data.data_in_last = '1' report "T1: ip_rx.data.data_in_last not set";
-
-
- mac_rx_tdata <= x"00";
- mac_rx_tlast <= '0';
- mac_rx_tvalid <= '0';
- wait for clk_period;
-
- assert ip_rx.data.data_in_valid = '0' report "T1: ip_rx.data.data_in_valid not cleared";
- assert ip_rx.data.data_in_last = '0' report "T1: ip_rx.data.data_in_last not cleared";
- assert ip_rx.hdr.num_frame_errors = x"00" report "T1: ip_rx.hdr.num_frame_errors non zero at end of test";
- assert ip_rx.hdr.last_error_code = x"0" report "T1: ip_rx.hdr.last_error_code indicates error at end of test";
- assert ip_rx_start = '0' report "T1: ip_rx_start not cleared";
-
- ------------
- -- TEST 2 -- respond with IP TX
- ------------
-
- report "T2: respond with IP TX";
-
- ip_tx.hdr.protocol <= x"35";
- ip_tx.hdr.data_length <= x"0006";
- ip_tx.hdr.dst_ip_addr <= x"c0123478";
- ip_tx.data.data_out_valid <= '0';
- ip_tx.data.data_out_last <= '0';
- wait for clk_period;
-
- ip_tx_start <= '1'; wait for clk_period;
-
- ip_tx_start <= '0'; wait for clk_period;
-
- assert ip_tx_result = IPTX_RESULT_SENDING report "T2: result should be IPTX_RESULT_SENDING";
-
- wait for clk_period*2;
-
- assert ip_tx_data_out_ready = '0' report "T2: IP data out ready asserted too early";
-
- -- need to wait for ARP tx to complete
-
- wait for clk_period*50;
-
- assert mac_tx_tvalid = '0' report "T2: mac_tx_tvalid not cleared after ARP tx";
- assert mac_tx_tlast = '0' report "T2: mac_tx_tlast not cleared after ARP tx";
-
- -- now create the ARP response (rx)
-
- -- Send the reply
- -- Send an ARP reply: x"c0123478" has mac 02:12:03:23:04:54
- 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"02"; wait for clk_period;
- mac_rx_tdata <= x"12"; wait for clk_period;
- mac_rx_tdata <= x"03"; wait for clk_period;
- mac_rx_tdata <= x"23"; wait for clk_period;
- mac_rx_tdata <= x"04"; wait for clk_period;
- mac_rx_tdata <= x"54"; wait for clk_period;
- -- type
- mac_rx_tdata <= x"08"; wait for clk_period;
- mac_rx_tdata <= x"06"; wait for clk_period;
- -- HW type
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"01"; wait for clk_period;
- -- Protocol type
- mac_rx_tdata <= x"08"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- -- HW size
- mac_rx_tdata <= x"06"; wait for clk_period;
- -- protocol size
- mac_rx_tdata <= x"04"; wait for clk_period;
- -- Opcode
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"02"; wait for clk_period;
- -- Sender MAC
- mac_rx_tdata <= x"02"; wait for clk_period;
- mac_rx_tdata <= x"12"; wait for clk_period;
- mac_rx_tdata <= x"03"; wait for clk_period;
- mac_rx_tdata <= x"23"; wait for clk_period;
- mac_rx_tdata <= x"04"; wait for clk_period;
- mac_rx_tdata <= x"54"; wait for clk_period;
- -- Sender IP
- mac_rx_tdata <= x"c0"; wait for clk_period;
- mac_rx_tdata <= x"12"; wait for clk_period;
- mac_rx_tdata <= x"34"; wait for clk_period;
- mac_rx_tdata <= x"78"; wait for clk_period;
- -- Target MAC
- 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;
- -- Target 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;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tlast <= '1';
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tlast <= '0';
- mac_rx_tvalid <= '0';
-
- 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"56"; wait for clk_period;
- ip_tx.data.data_out <= x"57"; wait for clk_period;
- ip_tx.data.data_out <= x"58"; wait for clk_period;
- ip_tx.data.data_out <= x"59"; wait for clk_period;
- ip_tx.data.data_out <= x"5a"; wait for clk_period;
-
- ip_tx.data.data_out <= x"5b";
- ip_tx.data.data_out_last <= '1';
- wait for clk_period;
-
- assert mac_tx_tlast = '1' report "T2: mac_tx_tlast not set on last byte";
-
- wait for clk_period;
-
- 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 "T2: result should be SENT";
- wait for clk_period*10;
-
- ------------
- -- TEST 3 -- Check that sending to the same IP addr doesnt cause an ARP req as the addr is cached
- ------------
-
- report "T3: Send 2nd IP TX to same IP addr - should not need to do ARP tx/rx";
- ip_tx.hdr.protocol <= x"35";
- ip_tx.hdr.data_length <= x"0006";
- ip_tx.hdr.dst_ip_addr <= x"c0123478";
- ip_tx.data.data_out_valid <= '0';
- ip_tx.data.data_out_last <= '0';
- wait for clk_period;
- ip_tx_start <= '1'; wait for clk_period;
- ip_tx_start <= '0'; wait for clk_period;
- assert ip_tx_result = IPTX_RESULT_SENDING report "T3: result should be IPTX_RESULT_SENDING";
- wait for clk_period*2;
- 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"81"; wait for clk_period;
- ip_tx.data.data_out <= x"83"; wait for clk_period;
- ip_tx.data.data_out <= x"85"; wait for clk_period;
- ip_tx.data.data_out <= x"87"; wait for clk_period;
- ip_tx.data.data_out <= x"89"; wait for clk_period;
-
- ip_tx.data.data_out <= x"8b";
- ip_tx.data.data_out_last <= '1';
- wait for clk_period;
-
- assert mac_tx_tlast = '1' report "T3: mac_tx_tlast not set on last byte";
-
- wait for clk_period;
-
- 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 SENT";
- wait for clk_period*2;
-
-
-
- report "-- end of tests --";
-
- wait;
- end process;
-
-END;
Index: udp_ip_stack/tags/v2.0/bench/vhdl/arp_STORE_tb.vhd
===================================================================
--- udp_ip_stack/tags/v2.0/bench/vhdl/arp_STORE_tb.vhd (revision 12)
+++ udp_ip_stack/tags/v2.0/bench/vhdl/arp_STORE_tb.vhd (nonexistent)
@@ -1,384 +0,0 @@
---------------------------------------------------------------------------------
--- Company:
--- Engineer:
---
--- Create Date: 07:38:43 02/13/2012
--- Design Name:
--- Module Name: arp_STORE_tb.vhd
--- Project Name: udp3
--- Target Device:
--- Tool versions:
--- Description:
---
--- VHDL Test Bench Created by ISE for module: arp_STORE_br
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Additional Comments:
---
--- Notes:
--- This testbench has been automatically generated using types std_logic and
--- std_logic_vector for the ports of the unit under test. Xilinx recommends
--- that these types always be used for the top-level I/O of a design in order
--- to guarantee that the testbench will bind correctly to the post-implementation
--- simulation model.
---------------------------------------------------------------------------------
-library IEEE;
-use IEEE.STD_LOGIC_1164.ALL;
-use IEEE.NUMERIC_STD.ALL;
-use ieee.std_logic_unsigned.all;
-use work.arp_types.all;
-
-ENTITY arp_STORE_tb IS
-END arp_STORE_tb;
-
-ARCHITECTURE behavior OF arp_STORE_tb IS
-
- -- Component Declaration for the Unit Under Test (UUT)
-
- COMPONENT arp_STORE_br
- generic (
- MAX_ARP_ENTRIES : integer := 256 -- max entries in the store
- );
- PORT(
- -- read signals
- read_req : in arp_store_rdrequest_t; -- requesting a '1' or store
- read_result : out arp_store_result_t; -- the result
- -- write signals
- write_req : in arp_store_wrrequest_t; -- requesting a '1' or store
- -- control and status signals
- clear_store : in std_logic; -- erase all entries
- entry_count : out unsigned(7 downto 0); -- how many entries currently in store
- -- system signals
- clk : in std_logic;
- reset : in STD_LOGIC
- );
- END COMPONENT;
-
-
- --Inputs
- signal read_req : arp_store_rdrequest_t;
- signal write_req : arp_store_wrrequest_t;
- signal clear_store : std_logic := '0';
- signal clk : std_logic := '0';
- signal reset : std_logic := '0';
-
- --Outputs
- signal read_result : arp_store_result_t;
- signal entry_count : unsigned(7 downto 0); -- how many entries currently in store
-
- -- Clock period definitions
- constant clk_period : time := 8 ns;
-
-BEGIN
-
- -- Instantiate the Unit Under Test (UUT)
- uut: arp_STORE_br
- generic map (
- MAX_ARP_ENTRIES => 4
- )
- PORT MAP (
- read_req => read_req,
- read_result => read_result,
- write_req => write_req,
- clear_store => clear_store,
- entry_count => entry_count,
- clk => clk,
- reset => reset
- );
-
- -- Clock process definitions
- clk_process :process
- begin
- clk <= '0';
- wait for clk_period/2;
- clk <= '1';
- wait for clk_period/2;
- end process;
-
-
- -- Stimulus process
- stim_proc: process
- begin
- read_req.req <= '0';
- read_req.ip <= (others => '0');
- write_req.req <= '0';
- write_req.entry.ip <= (others => '0');
- write_req.entry.mac <= (others => '0');
- reset <= '1';
- -- hold reset state
- wait for clk_period*10;
- reset <= '0';
-
- -- insert stimulus here
- report "T1 - look for something when store is empty";
- read_req.ip <= x"12345678";
- read_req.req <= '1';
- wait for clk_period*4;
- assert read_result.status = NOT_FOUND report "T1: expected NOT_FOUND";
- wait for clk_period;
- read_req.req <= '0';
- wait for clk_period;
- assert read_result.status = IDLE report "T1: expected IDLE";
- assert entry_count = x"00" report "T1: wrong entry count";
-
- report "T2 - insert first entry into store";
- write_req.entry.ip <= x"12345678";
- write_req.entry.mac <= x"002398127645";
- write_req.req <= '1';
- wait for clk_period;
- write_req.req <= '0';
- wait until read_result.status = IDLE;
- wait for clk_period;
- assert entry_count = x"01" report "T2: wrong entry count";
-
- report "T3 - check if can find this single entry";
- read_req.ip <= x"12345678";
- read_req.req <= '1';
- wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
- wait for clk_period;
- assert read_result.status = FOUND report "T3: expected FOUND";
- assert read_result.entry.ip = x"12345678" report "T3: wrong ip addr";
- assert read_result.entry.mac = x"002398127645" report "T3: wrong mac addr";
- wait for clk_period;
- read_req.req <= '0';
- wait for clk_period*2;
- assert read_result.status = IDLE report "T3: expected IDLE";
-
- report "T4 - check unable to find missing entry with one entry in store";
- read_req.ip <= x"12345679";
- read_req.req <= '1';
- wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
- wait for clk_period;
- assert read_result.status = NOT_FOUND report "T4: expected NOT_FOUND";
- wait for clk_period;
- read_req.req <= '0';
- wait for clk_period*2;
- assert read_result.status = IDLE report "T4: expected IDLE";
-
- report "T5 - insert 2nd entry into store and check can find both entries";
- write_req.entry.ip <= x"12345679";
- write_req.entry.mac <= x"101202303404";
- write_req.req <= '1';
- wait for clk_period;
- write_req.req <= '0';
- wait until read_result.status = IDLE;
- wait for clk_period;
- assert entry_count = x"02" report "T4: wrong entry count";
- read_req.ip <= x"12345678";
- read_req.req <= '1';
- wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
- wait for clk_period;
- assert read_result.status = FOUND report "T5.1: expected FOUND";
- assert read_result.entry.ip = x"12345678" report "T5.1: wrong ip addr";
- assert read_result.entry.mac = x"002398127645" report "T5.1: wrong mac addr";
- read_req.req <= '0';
- wait for clk_period*2;
- assert read_result.status = IDLE report "T5.1: expected IDLE";
- read_req.ip <= x"12345679";
- read_req.req <= '1';
- wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
- wait for clk_period;
- assert read_result.status = FOUND report "T5.2: expected FOUND";
- assert read_result.entry.ip = x"12345679" report "T5.2: wrong ip addr";
- assert read_result.entry.mac = x"101202303404" report "T5.2: wrong mac addr";
- read_req.req <= '0';
- wait for clk_period*2;
- assert read_result.status = IDLE report "T5.2: expected IDLE";
-
- report "T6 - insert 2 more entries so that the store is full. check can find all";
- write_req.entry.ip <= x"1234567a";
- write_req.entry.mac <= x"10120230340a";
- write_req.req <= '1';
- wait for clk_period;
- write_req.req <= '0';
- wait until read_result.status = IDLE;
- wait for clk_period;
- write_req.entry.ip <= x"1234567b";
- write_req.entry.mac <= x"10120230340b";
- write_req.req <= '1';
- wait for clk_period;
- write_req.req <= '0';
- wait until read_result.status = IDLE;
- wait for clk_period;
- assert entry_count = x"04" report "T6: wrong entry count";
- read_req.ip <= x"12345678";
- read_req.req <= '1';
- wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
- wait for clk_period;
- assert read_result.status = FOUND report "T6.1: expected FOUND";
- assert read_result.entry.ip = x"12345678" report "T6.1: wrong ip addr";
- assert read_result.entry.mac = x"002398127645" report "T6.1: wrong mac addr";
- read_req.req <= '0';
- wait for clk_period*2;
- assert read_result.status = IDLE report "T6.1: expected IDLE";
- read_req.ip <= x"12345679";
- read_req.req <= '1';
- wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
- wait for clk_period;
- assert read_result.status = FOUND report "T6.2: expected FOUND";
- assert read_result.entry.ip = x"12345679" report "T6.2: wrong ip addr";
- assert read_result.entry.mac = x"101202303404" report "T6.2: wrong mac addr";
- read_req.req <= '0';
- wait for clk_period*2;
- assert read_result.status = IDLE report "T6.2: expected IDLE";
- read_req.ip <= x"1234567a";
- read_req.req <= '1';
- wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
- wait for clk_period;
- assert read_result.status = FOUND report "T6.3: expected FOUND";
- assert read_result.entry.ip = x"1234567a" report "T6.3: wrong ip addr";
- assert read_result.entry.mac = x"10120230340a" report "T6.3: wrong mac addr";
- read_req.req <= '0';
- wait for clk_period*2;
- assert read_result.status = IDLE report "T6.3: expected IDLE";
- read_req.ip <= x"1234567b";
- read_req.req <= '1';
- wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
- wait for clk_period;
- assert read_result.status = FOUND report "T6.4: expected FOUND";
- assert read_result.entry.ip = x"1234567b" report "T6.4: wrong ip addr";
- assert read_result.entry.mac = x"10120230340b" report "T6.4: wrong mac addr";
- read_req.req <= '0';
- wait for clk_period*2;
- assert read_result.status = IDLE report "T6.4: expected IDLE";
-
- report "T7 - with store full, check that we dont find missing item";
- read_req.ip <= x"1233367b";
- read_req.req <= '1';
- wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
- wait for clk_period;
- assert read_result.status = NOT_FOUND report "T7: expected NOT_FOUND";
- read_req.req <= '0';
- wait for clk_period*2;
- assert read_result.status = IDLE report "T7: expected IDLE";
-
- report "T8 - insert additional entry into store - will erase one of the others";
- write_req.entry.ip <= x"12345699";
- write_req.entry.mac <= x"992398127699";
- write_req.req <= '1';
- wait for clk_period;
- write_req.req <= '0';
- wait until read_result.status = IDLE;
- wait for clk_period;
- assert entry_count = x"04" report "T8: wrong entry count";
- read_req.ip <= x"12345699";
- read_req.req <= '1';
- wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
- wait for clk_period;
- assert read_result.status = FOUND report "T8: expected FOUND";
- assert read_result.entry.ip = x"12345699" report "T8: wrong ip addr";
- assert read_result.entry.mac = x"992398127699" report "T8: wrong mac addr";
- read_req.req <= '0';
- wait for clk_period*2;
- assert read_result.status = IDLE report "T8: expected IDLE";
-
- report "T9 - clear the store and ensure cant find something that was there";
- clear_store <= '1';
- wait for clk_period;
- clear_store <= '0';
- wait for clk_period;
- assert entry_count = x"00" report "T9: wrong entry count";
- read_req.ip <= x"12345699";
- read_req.req <= '1';
- wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
- wait for clk_period;
- assert read_result.status = NOT_FOUND report "T9: expected NOT_FOUND";
- read_req.req <= '0';
- wait for clk_period*2;
- assert read_result.status = IDLE report "T9: expected IDLE";
-
- report "T10 - refill the store with three entries";
- write_req.entry.ip <= x"12345675";
- write_req.entry.mac <= x"10120230340a";
- write_req.req <= '1';
- wait for clk_period;
- write_req.req <= '0';
- wait until read_result.status = IDLE;
- wait for clk_period;
- write_req.entry.ip <= x"12345676";
- write_req.entry.mac <= x"10120230340b";
- write_req.req <= '1';
- wait for clk_period;
- write_req.req <= '0';
- wait until read_result.status = IDLE;
- wait for clk_period;
- write_req.entry.ip <= x"12345677";
- write_req.entry.mac <= x"10120230340c";
- write_req.req <= '1';
- wait for clk_period;
- write_req.req <= '0';
- wait until read_result.status = IDLE;
- wait for clk_period;
- assert entry_count = x"03" report "T10: wrong entry count";
-
- report "T11 - check middle entry, then change it and check again";
- read_req.ip <= x"12345676";
- read_req.req <= '1';
- wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
- wait for clk_period;
- assert read_result.status = FOUND report "T11.1: expected FOUND";
- assert read_result.entry.ip = x"12345676" report "T11.1: wrong ip addr";
- assert read_result.entry.mac = x"10120230340b" report "T11.1: wrong mac addr";
- read_req.req <= '0';
- wait for clk_period*2;
- assert read_result.status = IDLE report "T11.1: expected IDLE";
- write_req.entry.ip <= x"12345676";
- write_req.entry.mac <= x"10120990340b";
- write_req.req <= '1';
- wait for clk_period;
- write_req.req <= '0';
- wait for clk_period;
- assert entry_count = x"03" report "T11: wrong entry count";
- read_req.ip <= x"12345676";
- read_req.req <= '1';
- wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
- wait for clk_period;
- assert read_result.status = FOUND report "T11.2: expected FOUND";
- assert read_result.entry.ip = x"12345676" report "T11.2: wrong ip addr";
- assert read_result.entry.mac = x"10120990340b" report "T11.2: wrong mac addr";
- read_req.req <= '0';
- wait for clk_period*2;
- assert read_result.status = IDLE report "T11.2: expected IDLE";
-
- report "T12 - check 2nd write at beginning";
- -- clear store, write 1st entry, overwrite the entry, and check
- clear_store <= '1';
- wait for clk_period;
- clear_store <= '0';
- wait for clk_period;
- assert entry_count = x"00" report "T12.1: wrong entry count";
- write_req.entry.ip <= x"12345678";
- write_req.entry.mac <= x"002398127645";
- write_req.req <= '1';
- wait for clk_period;
- write_req.req <= '0';
- wait until read_result.status = IDLE;
- wait for clk_period;
- assert entry_count = x"01" report "T12.2: wrong entry count";
- write_req.entry.ip <= x"12345678";
- write_req.entry.mac <= x"002398127647";
- write_req.req <= '1';
- wait for clk_period;
- write_req.req <= '0';
- wait until read_result.status = IDLE;
- wait for clk_period;
- assert entry_count = x"01" report "T12.3: wrong entry count";
- read_req.ip <= x"12345678";
- read_req.req <= '1';
- wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
- wait for clk_period;
- assert read_result.status = FOUND report "T12.4: expected FOUND";
- assert read_result.entry.ip = x"12345678" report "T12.4: wrong ip addr";
- assert read_result.entry.mac = x"002398127647" report "T12.4: wrong mac addr";
- read_req.req <= '0';
- wait for clk_period*2;
- assert read_result.status = IDLE report "T12.5: expected IDLE";
-
- report "--- end of tests ---";
- wait;
- end process;
-
-END;
Index: udp_ip_stack/tags/v2.0/bench/vhdl/UDP_RX_tb.vhd
===================================================================
--- udp_ip_stack/tags/v2.0/bench/vhdl/UDP_RX_tb.vhd (revision 12)
+++ udp_ip_stack/tags/v2.0/bench/vhdl/UDP_RX_tb.vhd (nonexistent)
@@ -1,325 +0,0 @@
---------------------------------------------------------------------------------
--- Company:
--- Engineer:
---
--- Create Date: 16:53:03 06/10/2011
--- Design Name:
--- Module Name: C:/Users/pjf/Documents/projects/fpga/xilinx/Network/ip1/UDP_RX_tb.vhd
--- Project Name: ip1
--- Target Device:
--- Tool versions:
--- Description:
---
--- VHDL Test Bench Created by ISE for module: UDP_RX
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Additional Comments:
---
--- Notes:
--- This testbench has been automatically generated using types std_logic and
--- std_logic_vector for the ports of the unit under test. Xilinx recommends
--- that these types always be used for the top-level I/O of a design in order
--- to guarantee that the testbench will bind correctly to the post-implementation
--- simulation model.
---------------------------------------------------------------------------------
-library IEEE;
-use IEEE.STD_LOGIC_1164.ALL;
-use IEEE.NUMERIC_STD.ALL;
-use work.axi.all;
-use work.ipv4_types.all;
-
-ENTITY UDP_RX_tb IS
-END UDP_RX_tb;
-
-ARCHITECTURE behavior OF UDP_RX_tb IS
-
- -- Component Declaration for the Unit Under Test (UUT)
-
- COMPONENT UDP_RX
- PORT(
- -- UDP Layer signals
- udp_rxo : inout udp_rx_type;
- udp_rx_start : out std_logic; -- indicates receipt of udp header
- -- system signals
- clk : in STD_LOGIC;
- reset : in STD_LOGIC;
- -- IP layer RX signals
- ip_rx_start : in std_logic; -- indicates receipt of ip header
- ip_rx : inout ipv4_rx_type
- );
- END COMPONENT;
-
-
- --Inputs
- signal clk : std_logic := '0';
- signal reset : std_logic := '0';
- signal ip_rx_start : std_logic := '0';
-
- --BiDirs
- signal udp_rxo : udp_rx_type;
- signal ip_rx : ipv4_rx_type;
-
- --Outputs
- signal udp_rx_start : std_logic;
-
- -- Clock period definitions
- constant clk_period : time := 8 ns;
-
-BEGIN
-
- -- Instantiate the Unit Under Test (UUT)
- uut: UDP_RX PORT MAP (
- udp_rxo => udp_rxo,
- udp_rx_start => udp_rx_start,
- clk => clk,
- reset => reset,
- ip_rx_start => ip_rx_start,
- ip_rx => ip_rx
- );
-
- -- Clock process definitions
- clk_process :process
- begin
- clk <= '0';
- wait for clk_period/2;
- clk <= '1';
- wait for clk_period/2;
- end process;
-
-
- -- Stimulus process
- stim_proc: process
- begin
- -- hold reset state for 100 ns.
- wait for 100 ns;
- ip_rx_start <= '0';
- ip_rx.data.data_in_valid <= '0';
- ip_rx.data.data_in_last <= '0';
- ip_rx.hdr.is_valid <= '0';
- 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;
- reset <= '0';
- wait for clk_period*5;
- reset <= '0';
-
- -- check reset conditions
- assert udp_rx_start = '0' report "udp_rx_start not initialised correctly on reset";
- assert udp_rxo.hdr.is_valid = '0' report "udp_rxo.hdr.is_valid not initialised correctly on reset";
- assert udp_rxo.data.data_in = x"00" report "udp_rxo.data.data_in not initialised correctly on reset";
- assert udp_rxo.data.data_in_valid = '0' report "udp_rxo.data.data_in_valid not initialised correctly on reset";
- assert udp_rxo.data.data_in_last = '0' report "udp_rxo.data.data_in_last not initialised correctly on reset";
-
- -- insert stimulus here
-
- ------------
- -- TEST 1 -- basic functional rx test with received ip pkt
- ------------
-
- report "T1: Send an ip frame with IP src ip_address c0a80501, udp protocol from port x1498 to port x8724 and 3 bytes data";
-
- ip_rx_start <= '1';
- ip_rx.data.data_in_valid <= '0';
- ip_rx.data.data_in_last <= '0';
- ip_rx.hdr.is_valid <= '1';
- ip_rx.hdr.protocol <= x"11"; -- UDP
- ip_rx.hdr.data_length <= x"000b";
- ip_rx.hdr.src_ip_addr<= x"c0a80501";
- wait for clk_period*3;
- -- now send the data
- ip_rx.data.data_in_valid <= '1';
- ip_rx.data.data_in <= x"14"; wait for clk_period; -- src port
- ip_rx.data.data_in <= x"98"; wait for clk_period;
- ip_rx.data.data_in <= x"87"; wait for clk_period; -- dst port
- ip_rx.data.data_in <= x"24"; wait for clk_period;
- ip_rx.data.data_in <= x"00"; wait for clk_period; -- len (hdr + data)
- ip_rx.data.data_in <= x"0b"; wait for clk_period;
- ip_rx.data.data_in <= x"00"; wait for clk_period; -- mty cks
- ip_rx.data.data_in <= x"00"; wait for clk_period;
- -- udp hdr should be valid
- assert udp_rxo.hdr.is_valid = '1' report "T1: udp_rxo.hdr.is_valid not set";
-
- ip_rx.data.data_in <= x"41"; wait for clk_period; -- data
-
- assert udp_rxo.hdr.src_ip_addr = x"c0a80501" report "T1: udp_rxo.hdr.src_ip_addr not set correctly";
- assert udp_rxo.hdr.src_port = x"1498" report "T1: udp_rxo.hdr.src_port not set correctly";
- assert udp_rxo.hdr.dst_port = x"8724" report "T1: udp_rxo.hdr.dst_port not set correctly";
- assert udp_rxo.hdr.data_length = x"0003" report "T1: udp_rxo.hdr.data_length not set correctly";
- assert udp_rx_start = '1' report "T1: udp_rx_start not set";
- assert udp_rxo.data.data_in_valid = '1' report "T1: udp_rxo.data.data_in_valid not set";
-
- ip_rx.data.data_in <= x"45"; wait for clk_period; -- data
- ip_rx.data.data_in <= x"49"; ip_rx.data.data_in_last <= '1'; wait for clk_period;
- assert udp_rxo.data.data_in_last = '1' report "T1: udp_rxo.data.data_in_last not set";
- ip_rx_start <= '0';
- ip_rx.data.data_in_valid <= '0';
- ip_rx.data.data_in_last <= '0';
- ip_rx.hdr.is_valid <= '0';
- wait for clk_period;
- assert udp_rxo.data.data_in = x"00" report "T1: udp_rxo.data.data_in not cleared";
- assert udp_rxo.data.data_in_valid = '0' report "T1: udp_rxo.data.data_in_valid not cleared";
- assert udp_rxo.data.data_in_last = '0' report "T1: udp_rxo.data.data_in_last not cleared";
-
- wait for clk_period;
-
- ------------
- -- TEST 2 -- ability to receive 2nd ip pkt
- ------------
-
- report "T2: Send an ip frame with IP src ip_address c0a80501, udp protocol from port x7623 to port x0365 and 5 bytes data";
-
- ip_rx_start <= '1';
- ip_rx.data.data_in_valid <= '0';
- ip_rx.data.data_in_last <= '0';
- ip_rx.hdr.is_valid <= '1';
- ip_rx.hdr.protocol <= x"11"; -- UDP
- ip_rx.hdr.data_length <= x"000b";
- ip_rx.hdr.src_ip_addr<= x"c0a80501";
- wait for clk_period*3;
- -- now send the data
- ip_rx.data.data_in_valid <= '1';
- ip_rx.data.data_in <= x"76"; wait for clk_period; -- src port
- ip_rx.data.data_in <= x"23"; wait for clk_period;
- ip_rx.data.data_in <= x"03"; wait for clk_period; -- dst port
- ip_rx.data.data_in <= x"65"; wait for clk_period;
- ip_rx.data.data_in <= x"00"; wait for clk_period; -- len (hdr + data)
- ip_rx.data.data_in <= x"0d"; wait for clk_period;
- ip_rx.data.data_in <= x"00"; wait for clk_period; -- mty cks
- ip_rx.data.data_in <= x"00"; wait for clk_period;
- -- udp hdr should be valid
- assert udp_rxo.hdr.is_valid = '1' report "T2: udp_rxo.hdr.is_valid not set";
-
- ip_rx.data.data_in <= x"17"; wait for clk_period; -- data
-
- assert udp_rxo.hdr.src_ip_addr = x"c0a80501" report "T2: udp_rxo.hdr.src_ip_addr not set correctly";
- assert udp_rxo.hdr.src_port = x"7623" report "T2: udp_rxo.hdr.src_port not set correctly";
- assert udp_rxo.hdr.dst_port = x"0365" report "T2: udp_rxo.hdr.dst_port not set correctly";
- assert udp_rxo.hdr.data_length = x"0005" report "T2: udp_rxo.hdr.data_length not set correctly";
- assert udp_rx_start = '1' report "T2: udp_rx_start not set";
- assert udp_rxo.data.data_in_valid = '1' report "T2: udp_rxo.data.data_in_valid not set";
-
- ip_rx.data.data_in <= x"37"; wait for clk_period; -- data
- ip_rx.data.data_in <= x"57"; wait for clk_period; -- data
- ip_rx.data.data_in <= x"73"; wait for clk_period; -- data
- ip_rx.data.data_in <= x"f9"; ip_rx.data.data_in_last <= '1'; wait for clk_period;
- assert udp_rxo.data.data_in_last = '1' report "T2: udp_rxo.data.data_in_last not set";
- ip_rx_start <= '0';
- ip_rx.data.data_in_valid <= '0';
- ip_rx.data.data_in_last <= '0';
- ip_rx.hdr.is_valid <= '0';
- wait for clk_period;
- assert udp_rxo.data.data_in = x"00" report "T2: udp_rxo.data.data_in not cleared";
- assert udp_rxo.data.data_in_valid = '0' report "T2: udp_rxo.data.data_in_valid not cleared";
- assert udp_rxo.data.data_in_last = '0' report "T2: udp_rxo.data.data_in_last not cleared";
-
- ------------
- -- TEST 3 -- ability to reject non-udp protocols
- ------------
-
- report "T3: Send an ip frame with IP src ip_address c0a80501, protocol x12 from port x7623 to port x0365 and 5 bytes data";
-
- ip_rx_start <= '1';
- ip_rx.data.data_in_valid <= '0';
- ip_rx.data.data_in_last <= '0';
- ip_rx.hdr.is_valid <= '1';
- ip_rx.hdr.protocol <= x"12"; -- non-UDP
- ip_rx.hdr.data_length <= x"000b";
- ip_rx.hdr.src_ip_addr<= x"c0a80501";
- wait for clk_period*3;
- -- now send the data
- ip_rx.data.data_in_valid <= '1';
- ip_rx.data.data_in <= x"76"; wait for clk_period; -- src port
- ip_rx.data.data_in <= x"23"; wait for clk_period;
- ip_rx.data.data_in <= x"03"; wait for clk_period; -- dst port
- ip_rx.data.data_in <= x"65"; wait for clk_period;
- ip_rx.data.data_in <= x"00"; wait for clk_period; -- len (hdr + data)
- ip_rx.data.data_in <= x"0d"; wait for clk_period;
- ip_rx.data.data_in <= x"00"; wait for clk_period; -- mty cks
- ip_rx.data.data_in <= x"00"; wait for clk_period;
- -- udp hdr should be valid
- assert udp_rxo.hdr.is_valid = '0' report "T3: udp_rxo.hdr.is_valid incorrectly set";
-
- ip_rx.data.data_in <= x"17"; wait for clk_period; -- data
-
- assert udp_rx_start = '0' report "T3: udp_rx_start incorrectly set";
- assert udp_rxo.data.data_in_valid = '0' report "T3: udp_rxo.data.data_in_valid not set";
-
- ip_rx.data.data_in <= x"37"; wait for clk_period; -- data
- ip_rx.data.data_in <= x"57"; wait for clk_period; -- data
- ip_rx.data.data_in <= x"73"; wait for clk_period; -- data
- ip_rx.data.data_in <= x"f9"; ip_rx.data.data_in_last <= '1'; wait for clk_period;
- assert udp_rxo.data.data_in_last = '0' report "T3: udp_rxo.data.data_in_last incorrectly set";
- ip_rx_start <= '0';
- ip_rx.data.data_in_valid <= '0';
- ip_rx.data.data_in_last <= '0';
- ip_rx.hdr.is_valid <= '0';
- wait for clk_period;
- assert udp_rxo.data.data_in = x"00" report "T3: udp_rxo.data.data_in not cleared";
- assert udp_rxo.data.data_in_valid = '0' report "T3: udp_rxo.data.data_in_valid not cleared";
- assert udp_rxo.data.data_in_last = '0' report "T3: udp_rxo.data.data_in_last not cleared";
-
- wait for clk_period;
-
- ------------
- -- TEST 4 -- Ability to receive UDP pkt after non-UDP pkt
- ------------
-
- report "T4: Send an ip frame with IP src ip_address c0a80501, udp protocol from port x1498 to port x8724 and 3 bytes data";
-
- ip_rx_start <= '1';
- ip_rx.data.data_in_valid <= '0';
- ip_rx.data.data_in_last <= '0';
- ip_rx.hdr.is_valid <= '1';
- ip_rx.hdr.protocol <= x"11"; -- UDP
- ip_rx.hdr.data_length <= x"000b";
- ip_rx.hdr.src_ip_addr<= x"c0a80501";
- wait for clk_period*3;
- -- now send the data
- ip_rx.data.data_in_valid <= '1';
- ip_rx.data.data_in <= x"14"; wait for clk_period; -- src port
- ip_rx.data.data_in <= x"98"; wait for clk_period;
- ip_rx.data.data_in <= x"87"; wait for clk_period; -- dst port
- ip_rx.data.data_in <= x"24"; wait for clk_period;
- ip_rx.data.data_in <= x"00"; wait for clk_period; -- len (hdr + data)
- ip_rx.data.data_in <= x"0b"; wait for clk_period;
- ip_rx.data.data_in <= x"00"; wait for clk_period; -- mty cks
- ip_rx.data.data_in <= x"00"; wait for clk_period;
- -- udp hdr should be valid
- assert udp_rxo.hdr.is_valid = '1' report "T4: udp_rxo.hdr.is_valid not set";
-
- ip_rx.data.data_in <= x"41"; wait for clk_period; -- data
-
- assert udp_rxo.hdr.src_ip_addr = x"c0a80501" report "T4: udp_rxo.hdr.src_ip_addr not set correctly";
- assert udp_rxo.hdr.src_port = x"1498" report "T4: udp_rxo.hdr.src_port not set correctly";
- assert udp_rxo.hdr.dst_port = x"8724" report "T4: udp_rxo.hdr.dst_port not set correctly";
- assert udp_rxo.hdr.data_length = x"0003" report "T4: udp_rxo.hdr.data_length not set correctly";
- assert udp_rx_start = '1' report "T4: udp_rx_start not set";
- assert udp_rxo.data.data_in_valid = '1' report "T4: udp_rxo.data.data_in_valid not set";
-
- ip_rx.data.data_in <= x"45"; wait for clk_period; -- data
- ip_rx.data.data_in <= x"49"; ip_rx.data.data_in_last <= '1'; wait for clk_period;
- assert udp_rxo.data.data_in_last = '1' report "T4: udp_rxo.data.data_in_last not set";
- ip_rx_start <= '0';
- ip_rx.data.data_in_valid <= '0';
- ip_rx.data.data_in_last <= '0';
- ip_rx.hdr.is_valid <= '0';
- wait for clk_period;
- assert udp_rxo.data.data_in = x"00" report "T4: udp_rxo.data.data_in not cleared";
- assert udp_rxo.data.data_in_valid = '0' report "T4: udp_rxo.data.data_in_valid not cleared";
- assert udp_rxo.data.data_in_last = '0' report "T4: udp_rxo.data.data_in_last not cleared";
-
- wait for clk_period;
-
- report "--- end of tests ---";
-
- wait;
- end process;
-
-END;
Index: udp_ip_stack/tags/v2.0/bench/vhdl/arp_tb.vhd
===================================================================
--- udp_ip_stack/tags/v2.0/bench/vhdl/arp_tb.vhd (revision 12)
+++ udp_ip_stack/tags/v2.0/bench/vhdl/arp_tb.vhd (nonexistent)
@@ -1,601 +0,0 @@
---------------------------------------------------------------------------------
--- Company:
--- Engineer:
---
--- Create Date: 12:35:50 05/31/2011
--- Design Name:
--- Module Name: C:/Users/pjf/Documents/projects/fpga/xilinx/Network/arp1/arp_tb.vhd
--- Project Name: arp1
--- Target Device:
--- Tool versions:
--- Description:
---
--- VHDL Test Bench Created by ISE for module: arp
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Revision 0.02 - Added tests for ARP timeout
--- Additional Comments:
---
--- Notes:
--- This testbench has been automatically generated using types std_logic and
--- std_logic_vector for the ports of the unit under test. Xilinx recommends
--- that these types always be used for the top-level I/O of a design in order
--- to guarantee that the testbench will bind correctly to the post-implementation
--- simulation model.
---------------------------------------------------------------------------------
-LIBRARY ieee;
-USE ieee.std_logic_1164.ALL;
-USE ieee.numeric_std.ALL;
-use work.arp_types.all;
-
-ENTITY arp_tb IS
-END arp_tb;
-
-ARCHITECTURE behavior OF arp_tb IS
-
- -- Component Declaration for the Unit Under Test (UUT)
-
- COMPONENT arp
- generic (
- CLOCK_FREQ : integer := 125000000; -- freq of data_in_clk -- needed to timout cntr
- ARP_TIMEOUT : integer := 60 -- ARP response timeout (s)
- );
- Port (
- -- lookup request signals
- arp_req_req : in arp_req_req_type;
- arp_req_rslt : out arp_req_rslt_type;
- -- MAC layer RX signals
- data_in_clk : 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_valid : in STD_LOGIC; -- indicates data_in valid on clock
- data_in_last : in STD_LOGIC; -- indicates last data in frame
- -- 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_granted : in std_logic; -- indicates that access to channel has been granted
- data_out_clk : in std_logic;
- 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_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 : out std_logic_vector (7 downto 0); -- ethernet frame (from dst mac addr through to last byte of frame)
- -- system signals
- our_mac_address : in STD_LOGIC_VECTOR (47 downto 0);
- our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
- control : in arp_control_type;
- req_count : out STD_LOGIC_VECTOR(7 downto 0) -- count of arp pkts received
- );
- END COMPONENT;
-
-
- --Inputs
- signal clk : std_logic := '0';
- signal reset : std_logic := '0';
- signal data_in : std_logic_vector(7 downto 0) := (others => '0');
- signal data_in_valid : std_logic := '0';
- signal data_in_last : std_logic := '0';
- signal our_mac_address : std_logic_vector(47 downto 0) := (others => '0');
- signal our_ip_address : std_logic_vector(31 downto 0) := (others => '0');
- signal data_out_ready : std_logic;
- signal data_out_valid : std_logic;
- signal data_out_first : std_logic;
- signal data_out_last : std_logic;
- signal data_out : std_logic_vector (7 downto 0);
- signal req_count : STD_LOGIC_VECTOR(7 downto 0);
- signal arp_req_req : arp_req_req_type;
- signal arp_req_rslt : arp_req_rslt_type;
- signal mac_tx_req : std_logic;
- signal mac_tx_granted : std_logic;
- signal control : arp_control_type;
-
-
- -- Clock period definitions
- constant clk_period : time := 8 ns;
-
-BEGIN
-
- -- Instantiate the Unit Under Test (UUT)
- uut: arp generic map (
- CLOCK_FREQ => 10, -- artificially low count to enable pragmatic testing
- ARP_TIMEOUT => 20
- )
- PORT MAP (
- -- lookup request mappings
- arp_req_req => arp_req_req,
- arp_req_rslt => arp_req_rslt,
- -- rx mappings
- data_in_clk => clk,
- reset => reset,
- data_in => data_in,
- data_in_valid => data_in_valid,
- data_in_last => data_in_last,
- -- tx mappings
- mac_tx_req => mac_tx_req,
- mac_tx_granted => mac_tx_granted,
- data_out_clk => clk,
- data_out_ready => data_out_ready,
- data_out_valid => data_out_valid,
- data_out_first => data_out_first,
- data_out_last => data_out_last,
- data_out => data_out,
- -- system mappings
- our_mac_address => our_mac_address,
- our_ip_address => our_ip_address,
- control => control,
- req_count => req_count
- );
-
- -- Clock process definitions
- clk_process :process
- begin
- clk <= '0';
- wait for clk_period/2;
- clk <= '1';
- wait for clk_period/2;
- end process;
-
-
- -- Stimulus process
- stim_proc: process
- begin
- -- hold reset state for 100 ns.
- wait for 100 ns;
-
- our_ip_address <= x"c0a80509"; -- 192.168.5.9
- our_mac_address <= x"002320212223";
- mac_tx_granted <= '1'; -- FIXME 0
- control.clear_cache <= '0';
-
- reset <= '1';
- wait for clk_period*10;
- reset <= '0';
- wait for clk_period*5;
-
- assert mac_tx_req = '0' report "mac_tx_req asserted on reset";
-
- -- insert stimulus here
- arp_req_req.lookup_req <= '0';
- arp_req_req.ip <= (others => '0');
- data_out_ready <= '1';
-
- report "T1: Send an ARP request: who has 192.168.5.9? Tell 192.168.5.1";
- data_in_valid <= '1';
- -- dst MAC (bc)
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- -- src MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"18"; wait for clk_period;
- data_in <= x"29"; wait for clk_period;
- data_in <= x"26"; wait for clk_period;
- data_in <= x"7c"; wait for clk_period;
- -- type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"06"; wait for clk_period;
- -- HW type
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Protocol type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- HW size
- data_in <= x"06"; wait for clk_period;
- -- protocol size
- data_in <= x"04"; wait for clk_period;
- -- Opcode
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Sender MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"18"; wait for clk_period;
- data_in <= x"29"; wait for clk_period;
- data_in <= x"26"; wait for clk_period;
- data_in <= x"7c"; wait for clk_period;
- -- Sender IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Target MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- Target IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"09"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '1';
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '0';
- data_in_valid <= '0';
-
- -- check tx arbitration signals
-
- assert mac_tx_req = '1' report "T1: mac_tx_req not set";
-
- -- ready to tx
- data_out_ready <= '1';
- mac_tx_granted <= '1';
- wait for clk_period*10;
- data_out_ready <= '0';
- wait for clk_period*2;
- data_out_ready <= '1';
- wait for clk_period*50;
-
- report "T2: Send another ARP request: who has 192.168.5.9? Tell 192.168.5.1, holding off transmitter";
- data_out_ready <= '0';
- data_in_valid <= '1';
- -- dst MAC (bc)
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- -- src MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"18"; wait for clk_period;
- data_in <= x"29"; wait for clk_period;
- data_in <= x"26"; wait for clk_period;
- data_in <= x"7c"; wait for clk_period;
- -- type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"06"; wait for clk_period;
- -- HW type
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Protocol type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- HW size
- data_in <= x"06"; wait for clk_period;
- -- protocol size
- data_in <= x"04"; wait for clk_period;
- -- Opcode
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Sender MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"18"; wait for clk_period;
- data_in <= x"29"; wait for clk_period;
- data_in <= x"26"; wait for clk_period;
- data_in <= x"7c"; wait for clk_period;
- -- Sender IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Target MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- Target IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"09"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '1';
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '0';
- data_in_valid <= '0';
-
- -- ready to tx
- wait for clk_period*10;
- data_out_ready <= '1';
-
- wait for clk_period*50;
-
- report "T3 Send a request for the IP that is already cached";
- arp_req_req.ip <= x"c0a80501";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- assert arp_req_rslt.got_mac = '1' report "T3: should have got mac";
- assert arp_req_rslt.mac = x"00231829267c" report "T3: incorrect mac";
- assert arp_req_rslt.got_err = '0' report "T3: should not have got err";
- arp_req_req.lookup_req <= '0';
- wait for clk_period;
- wait for clk_period*10;
-
- wait for clk_period*20;
- assert mac_tx_req = '0' report "T3: should not be requesting TX channel";
-
- report "T4: Request 192.168.5.3 (not cached= and Send an ARP reply: 192.168.5.3 has mac 02:12:03:23:04:54";
- arp_req_req.ip <= x"c0a80503";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- arp_req_req.lookup_req <= '0';
- wait for clk_period*20;
- assert mac_tx_req = '1' report "T4: should be requesting TX channel";
- wait for clk_period*50;
- -- Send the reply
- data_out_ready <= '1';
-
- data_in_valid <= '1';
- -- dst MAC (bc)
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- -- src MAC
- data_in <= x"02"; wait for clk_period;
- data_in <= x"12"; wait for clk_period;
- data_in <= x"03"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"04"; wait for clk_period;
- data_in <= x"54"; wait for clk_period;
- -- type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"06"; wait for clk_period;
- -- HW type
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Protocol type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- HW size
- data_in <= x"06"; wait for clk_period;
- -- protocol size
- data_in <= x"04"; wait for clk_period;
- -- Opcode
- data_in <= x"00"; wait for clk_period;
- data_in <= x"02"; wait for clk_period;
- -- Sender MAC
- data_in <= x"02"; wait for clk_period;
- data_in <= x"12"; wait for clk_period;
- data_in <= x"03"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"04"; wait for clk_period;
- data_in <= x"54"; wait for clk_period;
- -- Sender IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"03"; wait for clk_period;
- -- Target MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"20"; wait for clk_period;
- data_in <= x"21"; wait for clk_period;
- data_in <= x"22"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- -- Target IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"09"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '1';
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '0';
- data_in_valid <= '0';
- wait for clk_period;
- assert arp_req_rslt.got_mac = '1' report "T4: should have got mac";
- assert arp_req_rslt.mac = x"021203230454" report "T4: incorrect mac";
- assert arp_req_rslt.got_err = '0' report "T4: should not have got err";
- wait for clk_period*10;
-
- report "T5: Request 192.168.5.4 (not cached), dont send a reply and wait for timeout";
- arp_req_req.ip <= x"c0a80504";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- arp_req_req.lookup_req <= '0';
- wait for clk_period*20;
- assert mac_tx_req = '1' report "T5: should be requesting TX channel";
- wait for clk_period*200;
- assert arp_req_rslt.got_mac = '0' report "T5: should not have got mac";
- assert arp_req_rslt.got_err = '1' report "T5: should have got err";
-
- report "T6: Request 192.168.5.7 (not cached= and Send an ARP reply: 192.168.5.7 has mac 02:15:03:23:04:54";
- arp_req_req.ip <= x"c0a80507";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- assert arp_req_rslt.got_mac = '0' report "T6: should not yet have mac";
- assert arp_req_rslt.got_err = '0' report "T6: should not have got err";
-
- arp_req_req.lookup_req <= '0';
- wait for clk_period*20;
- assert mac_tx_req = '1' report "T6: should be requesting TX channel";
- wait for clk_period*50;
- -- Send the reply
- data_out_ready <= '1';
-
- data_in_valid <= '1';
- -- dst MAC (bc)
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- -- src MAC
- data_in <= x"02"; wait for clk_period;
- data_in <= x"15"; wait for clk_period;
- data_in <= x"03"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"04"; wait for clk_period;
- data_in <= x"54"; wait for clk_period;
- -- type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"06"; wait for clk_period;
- -- HW type
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Protocol type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- HW size
- data_in <= x"06"; wait for clk_period;
- -- protocol size
- data_in <= x"04"; wait for clk_period;
- -- Opcode
- data_in <= x"00"; wait for clk_period;
- data_in <= x"02"; wait for clk_period;
- -- Sender MAC
- data_in <= x"02"; wait for clk_period;
- data_in <= x"15"; wait for clk_period;
- data_in <= x"03"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"04"; wait for clk_period;
- data_in <= x"54"; wait for clk_period;
- -- Sender IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"07"; wait for clk_period;
- -- Target MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"20"; wait for clk_period;
- data_in <= x"21"; wait for clk_period;
- data_in <= x"22"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- -- Target IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"09"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '1';
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '0';
- data_in_valid <= '0';
- wait for clk_period;
- assert arp_req_rslt.got_mac = '1' report "T6: should have got mac";
- assert arp_req_rslt.mac = x"021503230454" report "T6: incorrect mac";
- assert arp_req_rslt.got_err = '0' report "T6: should not have got err";
- wait for clk_period*10;
-
- report "T7: Request 192.168.5.7 again an expect it to be in the cache";
- arp_req_req.ip <= x"c0a80507";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- assert arp_req_rslt.got_mac = '1' report "T7: should have mac";
- assert arp_req_rslt.got_err = '0' report "T7: should not have got err";
-
- arp_req_req.lookup_req <= '0';
- wait for clk_period*20;
-
- report "T8: Clear the cache, Request 192.168.5.7 again an expect a 'who has' to be sent";
- control.clear_cache <= '1';
- wait for clk_period;
- control.clear_cache <= '0';
- wait for clk_period;
-
- arp_req_req.ip <= x"c0a80507";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- assert arp_req_rslt.got_mac = '0' report "T8: should not yet have mac";
- assert arp_req_rslt.got_err = '0' report "T8: should not have got err";
-
- arp_req_req.lookup_req <= '0';
- wait for clk_period*20;
-
-
- assert mac_tx_req = '1' report "T8: should be requesting TX channel";
- wait for clk_period*50;
- -- Send the reply
- data_out_ready <= '1';
-
- data_in_valid <= '1';
- -- dst MAC (bc)
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- -- src MAC
- data_in <= x"02"; wait for clk_period;
- data_in <= x"15"; wait for clk_period;
- data_in <= x"03"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"04"; wait for clk_period;
- data_in <= x"54"; wait for clk_period;
- -- type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"06"; wait for clk_period;
- -- HW type
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Protocol type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- HW size
- data_in <= x"06"; wait for clk_period;
- -- protocol size
- data_in <= x"04"; wait for clk_period;
- -- Opcode
- data_in <= x"00"; wait for clk_period;
- data_in <= x"02"; wait for clk_period;
- -- Sender MAC
- data_in <= x"02"; wait for clk_period;
- data_in <= x"15"; wait for clk_period;
- data_in <= x"03"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"55"; wait for clk_period;
- data_in <= x"54"; wait for clk_period;
- -- Sender IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"07"; wait for clk_period;
- -- Target MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"20"; wait for clk_period;
- data_in <= x"21"; wait for clk_period;
- data_in <= x"22"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- -- Target IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"09"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '1';
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '0';
- data_in_valid <= '0';
- wait for clk_period;
- assert arp_req_rslt.got_mac = '1' report "T8: should have got mac";
- assert arp_req_rslt.mac = x"021503235554" report "T8: incorrect mac";
- assert arp_req_rslt.got_err = '0' report "T8: should not have got err";
- wait for clk_period*10;
-
- report "--- end of tests ---";
- wait;
- end process;
-
-END;
Index: udp_ip_stack/tags/v2.0/bench/vhdl/UDP_TX_tb.vhd
===================================================================
--- udp_ip_stack/tags/v2.0/bench/vhdl/UDP_TX_tb.vhd (revision 12)
+++ udp_ip_stack/tags/v2.0/bench/vhdl/UDP_TX_tb.vhd (nonexistent)
@@ -1,219 +0,0 @@
---------------------------------------------------------------------------------
--- Company:
--- Engineer:
---
--- Create Date: 18:43:49 06/10/2011
--- Design Name:
--- Module Name: C:/Users/pjf/Documents/projects/fpga/xilinx/Network/ip1/UDP_TX_tb.vhd
--- Project Name: ip1
--- Target Device:
--- Tool versions:
--- Description:
---
--- VHDL Test Bench Created by ISE for module: UDP_TX
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Additional Comments:
---
--- Notes:
--- This testbench has been automatically generated using types std_logic and
--- std_logic_vector for the ports of the unit under test. Xilinx recommends
--- that these types always be used for the top-level I/O of a design in order
--- to guarantee that the testbench will bind correctly to the post-implementation
--- simulation model.
---------------------------------------------------------------------------------
-library IEEE;
-use IEEE.STD_LOGIC_1164.ALL;
-use IEEE.NUMERIC_STD.ALL;
-use work.axi.all;
-use work.ipv4_types.all;
-
-ENTITY UDP_TX_tb IS
-END UDP_TX_tb;
-
-ARCHITECTURE behavior OF UDP_TX_tb IS
-
- -- Component Declaration for the Unit Under Test (UUT)
-
- COMPONENT UDP_TX
- PORT(
- -- UDP Layer signals
- udp_tx_start : in std_logic; -- indicates req to tx UDP
- udp_txi : in udp_tx_type; -- UDP tx cxns
- udp_tx_result : out std_logic_vector (1 downto 0);-- tx status (changes during transmission)
- udp_tx_data_out_ready: out std_logic; -- indicates udp_tx is ready to take data
- -- system signals
- clk : in STD_LOGIC; -- same clock used to clock mac data and ip data
- reset : in STD_LOGIC;
- -- IP layer TX signals
- ip_tx_start : out std_logic;
- ip_tx : out ipv4_tx_type; -- IP tx cxns
- ip_tx_result : in std_logic_vector (1 downto 0); -- tx status (changes during transmission)
- ip_tx_data_out_ready : in std_logic -- indicates IP TX is ready to take data
- );
- END COMPONENT;
-
-
- --Inputs
- signal udp_tx_start : std_logic := '0';
- signal clk : std_logic := '0';
- signal reset : std_logic := '0';
- signal udp_txi : udp_tx_type;
- signal ip_tx_result : std_logic_vector (1 downto 0); -- tx status (changes during transmission)
- signal ip_tx_data_out_ready : std_logic; -- indicates IP TX is ready to take data
-
- --Outputs
- signal ip_tx_start : std_logic := '0';
- signal ip_tx : ipv4_tx_type;
- signal udp_tx_result : std_logic_vector (1 downto 0);
- signal udp_tx_data_out_ready : std_logic;
-
- -- Clock period definitions
- constant clk_period : time := 8 ns;
-
-BEGIN
-
- -- Instantiate the Unit Under Test (UUT)
- uut: UDP_TX PORT MAP (
- udp_tx_start => udp_tx_start,
- udp_txi => udp_txi,
- udp_tx_result => udp_tx_result,
- udp_tx_data_out_ready => udp_tx_data_out_ready,
- clk => clk,
- reset => reset,
- ip_tx_start => ip_tx_start,
- ip_tx => ip_tx,
- ip_tx_result => ip_tx_result,
- ip_tx_data_out_ready => ip_tx_data_out_ready
- );
-
-
- -- Clock process definitions
- clk_process :process
- begin
- clk <= '0';
- wait for clk_period/2;
- clk <= '1';
- wait for clk_period/2;
- end process;
-
-
- -- Stimulus process
- stim_proc: process
- begin
- -- hold reset state for 100 ns.
- wait for 100 ns;
-
- udp_tx_start <= '0';
-
- udp_txi.hdr.dst_ip_addr <= (others => '0');
- udp_txi.hdr.dst_port <= (others => '0');
- udp_txi.hdr.src_port <= (others => '0');
- udp_txi.hdr.data_length <= (others => '0');
- udp_txi.hdr.checksum <= (others => '0');
- udp_txi.data.data_out_last <= '0';
-
- reset <= '1';
- wait for clk_period*10;
- reset <= '0';
- wait for clk_period*5;
-
- -- check reset conditions
-
- assert ip_tx_start = '0' report "ip_tx_start not initialised correctly on reset";
- assert ip_tx.data.data_out_valid = '0' report "ip_tx.data.data_out_valid not initialised correctly on reset";
- assert ip_tx.data.data_out_last = '0' report "ip_tx.data.data_out_last not initialised correctly on reset";
- assert udp_tx_result = UDPTX_RESULT_NONE report "udp_tx_result not initialised correctly on reset";
-
- -- insert stimulus here
-
- wait for clk_period*5;
-
- ------------
- -- TEST 1 -- basic functional tx test
- ------------
-
- report "T1: basic functional tx test - send 56, 57, 58 to port 8532";
-
- udp_txi.hdr.dst_ip_addr <= x"c0123478";
- udp_txi.hdr.dst_port <= x"1467";
- udp_txi.hdr.src_port <= x"8532";
- udp_txi.hdr.data_length <= x"0003";
-
- udp_tx_start <= '1';
- ip_tx_data_out_ready <= '1'; -- IP layer can accept data
- wait for clk_period;
- udp_tx_start <= '0'; wait for clk_period;
- ip_tx_result <= IPTX_RESULT_NONE;
-
- assert udp_tx_result = UDPTX_RESULT_SENDING report "T1: result should be UDPTX_RESULT_SENDING";
-
- wait until udp_tx_data_out_ready = '1';
-
- -- start to tx IP data
- udp_txi.data.data_out_valid <= '1';
- udp_txi.data.data_out <= x"56"; wait for clk_period;
- udp_txi.data.data_out <= x"57"; wait for clk_period;
-
- udp_txi.data.data_out <= x"58";
- udp_txi.data.data_out_last <= '1';
- wait for clk_period;
-
- assert ip_tx.data.data_out_last = '1' report "T1: ip_tx.datda_out_last not set on last byte";
-
- udp_txi.data.data_out_valid <= '0';
- udp_txi.data.data_out_last <= '0';
- wait for clk_period*2;
- ip_tx_result <= IPTX_RESULT_SENT;
-
- assert udp_tx_result = UDPTX_RESULT_SENT report "T1: result should be UDPTX_RESULT_SENT";
- wait for clk_period*2;
-
- ------------
- -- TEST 2 -- 2nd pkt
- ------------
-
- report "T2: send a second pkt - 56,57,58,59 to port 8532";
-
- udp_txi.hdr.dst_ip_addr <= x"c0123475";
- udp_txi.hdr.dst_port <= x"1467";
- udp_txi.hdr.src_port <= x"8532";
- udp_txi.hdr.data_length <= x"0005";
-
- udp_tx_start <= '1';
- ip_tx_data_out_ready <= '1'; -- IP layer can accept data
- wait for clk_period;
- udp_tx_start <= '0'; wait for clk_period;
-
- assert udp_tx_result = UDPTX_RESULT_SENDING report "T1: result should be UDPTX_RESULT_SENDING";
-
- wait until udp_tx_data_out_ready = '1';
-
- -- start to tx IP data
- udp_txi.data.data_out_valid <= '1';
- udp_txi.data.data_out <= x"56"; wait for clk_period;
- udp_txi.data.data_out <= x"57"; wait for clk_period;
- udp_txi.data.data_out <= x"58"; wait for clk_period;
- udp_txi.data.data_out <= x"59"; wait for clk_period;
-
- udp_txi.data.data_out <= x"5a";
- udp_txi.data.data_out_last <= '1';
- wait for clk_period;
- assert ip_tx.data.data_out_last = '1' report "T1: ip_tx.datda_out_last not set on last byte";
-
- udp_txi.data.data_out_valid <= '0';
- udp_txi.data.data_out_last <= '0';
- wait for clk_period*2;
-
- assert udp_tx_result = UDPTX_RESULT_SENT report "T1: result should be UDPTX_RESULT_SENT";
- wait for clk_period*2;
-
- report "--- end of tests ---";
-
- wait;
- end process;
-
-END;
Index: udp_ip_stack/tags/v2.0/bench/vhdl/IP_av2_complete_nomac_tb .vhd
===================================================================
--- udp_ip_stack/tags/v2.0/bench/vhdl/IP_av2_complete_nomac_tb .vhd (revision 12)
+++ udp_ip_stack/tags/v2.0/bench/vhdl/IP_av2_complete_nomac_tb .vhd (nonexistent)
@@ -1,451 +0,0 @@
---------------------------------------------------------------------------------
--- Company:
--- Engineer:
---
--- Create Date: 13:54:32 06/04/2011
--- Design Name:
--- Module Name: C:/Users/pjf/Documents/projects/fpga/xilinx/Network/ip1/IP_complete_nomac_tb.vhd
--- Project Name: ip1
--- Target Device:
--- Tool versions:
--- Description:
---
--- VHDL Test Bench Created by ISE for module: IP_complete_nomac
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Additional Comments:
---
--- Notes:
--- This testbench has been automatically generated using types std_logic and
--- std_logic_vector for the ports of the unit under test. Xilinx recommends
--- that these types always be used for the top-level I/O of a design in order
--- to guarantee that the testbench will bind correctly to the post-implementation
--- simulation model.
---------------------------------------------------------------------------------
-LIBRARY ieee;
-USE ieee.std_logic_1164.ALL;
-use IEEE.NUMERIC_STD.ALL;
-use work.axi.all;
-use work.ipv4_types.all;
-use work.arp_types.all;
-use work.arp;
-use work.arpv2;
-
-
-ENTITY IP_av2_complete_nomac_tb IS
-END IP_av2_complete_nomac_tb;
-
-
-
---configuration main of IP_av2_complete_nomac_tb is
--- for behavior
--- for uut : IP_complete_nomac
--- use configuration work.IP_complete_nomac.multi_slot_arp;
--- end for;
--- end for;
---end main;
-
-ARCHITECTURE behavior OF IP_av2_complete_nomac_tb IS
-
- -- Component Declaration for the Unit Under Test (UUT)
-
- COMPONENT IP_complete_nomac
- generic (
- CLOCK_FREQ : integer := 125000000; -- freq of data_in_clk -- needed to timout cntr
- ARP_TIMEOUT : integer := 60 -- ARP response timeout (s)
- );
- Port (
- -- IP Layer signals
- ip_tx_start : in std_logic;
- ip_tx : in ipv4_tx_type; -- IP tx cxns
- ip_tx_result : out std_logic_vector (1 downto 0); -- tx status (changes during transmission)
- ip_tx_data_out_ready : out std_logic; -- indicates IP TX is ready to take data
- ip_rx_start : out std_logic; -- indicates receipt of ip frame.
- ip_rx : out ipv4_rx_type;
- -- system signals
- rx_clk : in STD_LOGIC;
- tx_clk : in STD_LOGIC;
- reset : in STD_LOGIC;
- our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
- our_mac_address : in std_logic_vector (47 downto 0);
- control : in ip_control_type;
- -- status signals
- arp_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- count of arp pkts received
- ip_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- number of IP pkts received for us
- -- MAC Transmitter
- mac_tx_tdata : out std_logic_vector(7 downto 0); -- data byte to tx
- mac_tx_tvalid : out std_logic; -- tdata is valid
- mac_tx_tready : in std_logic; -- mac is ready to accept data
- mac_tx_tfirst : out std_logic; -- indicates first byte of frame
- mac_tx_tlast : out std_logic; -- indicates last byte of frame
- -- MAC Receiver
- mac_rx_tdata : in std_logic_vector(7 downto 0); -- data byte received
- mac_rx_tvalid : in std_logic; -- indicates tdata is valid
- mac_rx_tready : out std_logic; -- tells mac that we are ready to take data
- mac_rx_tlast : in std_logic -- indicates last byte of the trame
- );
- END COMPONENT;
-
-
- --Inputs
- signal ip_tx_start : std_logic := '0';
- signal ip_tx : ipv4_tx_type;
-
- signal clk : std_logic := '0';
- signal reset : std_logic := '0';
- signal our_ip_address : std_logic_vector(31 downto 0) := (others => '0');
- signal our_mac_address : std_logic_vector(47 downto 0) := (others => '0');
- signal mac_tx_tready : std_logic := '0';
- signal mac_rx_tdata : std_logic_vector(7 downto 0) := (others => '0');
- signal mac_rx_tvalid : std_logic := '0';
- signal mac_rx_tlast : std_logic := '0';
- signal control : ip_control_type;
-
- --Outputs
- signal ip_tx_result : std_logic_vector (1 downto 0); -- tx status (changes during transmission)
- signal ip_tx_data_out_ready : std_logic; -- indicates IP TX is ready to take data
- signal ip_rx_start : std_logic;
- signal ip_rx : ipv4_rx_type;
- signal arp_pkt_count : std_logic_vector(7 downto 0);
- signal mac_tx_tdata : std_logic_vector(7 downto 0);
- signal mac_tx_tvalid : std_logic;
- signal mac_tx_tfirst : std_logic;
- signal mac_tx_tlast : std_logic;
- signal mac_rx_tready : std_logic;
-
- -- Clock period definitions
- constant clk_period : time := 8 ns;
-
-BEGIN
-
- -- Instantiate the Unit Under Test (UUT)
- uut: IP_complete_nomac PORT MAP (
- ip_tx_start => ip_tx_start,
- ip_tx => ip_tx,
- ip_tx_result => ip_tx_result,
- ip_tx_data_out_ready => ip_tx_data_out_ready,
- ip_rx_start => ip_rx_start,
- ip_rx => ip_rx,
- rx_clk => clk,
- tx_clk => clk,
- reset => reset,
- our_ip_address => our_ip_address,
- our_mac_address => our_mac_address,
- control => control,
- arp_pkt_count => arp_pkt_count,
- mac_tx_tdata => mac_tx_tdata,
- mac_tx_tvalid => mac_tx_tvalid,
- mac_tx_tready => mac_tx_tready,
- mac_tx_tfirst => mac_tx_tfirst,
- mac_tx_tlast => mac_tx_tlast,
- mac_rx_tdata => mac_rx_tdata,
- mac_rx_tvalid => mac_rx_tvalid,
- mac_rx_tready => mac_rx_tready,
- mac_rx_tlast => mac_rx_tlast
- );
-
- -- Clock process definitions
- clk_process :process
- begin
- clk <= '1';
- wait for clk_period/2;
- clk <= '0';
- wait for clk_period/2;
- end process;
-
-
- -- Stimulus process
- stim_proc: process
- begin
- -- hold reset state for 100 ns.
- wait for 80 ns;
-
- our_ip_address <= x"c0a80509"; -- 192.168.5.9
- our_mac_address <= x"002320212223";
- control.arp_controls.clear_cache <= '0';
- ip_tx_start <= '0';
- mac_tx_tready <= '0';
-
- reset <= '1';
- wait for clk_period*10;
- reset <= '0';
- wait for clk_period*5;
-
- -- check reset conditions
- assert ip_tx_result = IPTX_RESULT_NONE report "ip_tx_result not initialised correctly on reset";
- assert ip_tx_data_out_ready = '0' report "ip_tx_data_out_ready not initialised correctly on reset";
- assert mac_tx_tvalid = '0' report "mac_tx_tvalid not initialised correctly on reset";
- assert mac_tx_tlast = '0' report " mac_tx_tlast not initialised correctly on reset";
- assert arp_pkt_count = x"00" report " arp_pkt_count not initialised correctly on reset";
- assert ip_rx_start = '0' report "ip_rx_start not initialised correctly on reset";
- assert ip_rx.hdr.is_valid = '0' report "ip_rx.hdr.is_valid not initialised correctly on reset";
- assert ip_rx.hdr.protocol = x"00" report "ip_rx.hdr.protocol not initialised correctly on reset";
- assert ip_rx.hdr.data_length = x"0000" report "ip_rx.hdr.data_length not initialised correctly on reset";
- assert ip_rx.hdr.src_ip_addr = x"00000000" report "ip_rx.hdr.src_ip_addr not initialised correctly on reset";
- assert ip_rx.hdr.num_frame_errors = x"00" report "ip_rx.hdr.num_frame_errors not initialised correctly on reset";
- assert ip_rx.data.data_in = x"00" report "ip_rx.data.data_in not initialised correctly on reset";
- assert ip_rx.data.data_in_valid = '0' report "ip_rx.data.data_in_valid not initialised correctly on reset";
- assert ip_rx.data.data_in_last = '0' report "ip_rx.data.data_in_last not initialised correctly on reset";
-
- -- insert stimulus here
-
- ------------
- -- TEST 1 -- basic functional rx test with received ip pkt
- ------------
-
- report "T1: Send an eth frame with IP pkt dst ip_address c0a80509, dst mac 002320212223";
-
- mac_tx_tready <= '1';
- 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"18"; wait for clk_period;
- -- ID
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; 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"00"; 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"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;
-
- -- user data
- mac_rx_tdata <= x"24"; 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 ip_rx.hdr.is_valid = '1' report "T1: ip_rx.hdr.is_valid not set";
- assert ip_rx.hdr.protocol = x"11" report "T1: ip_rx.hdr.protocol not set correctly";
- assert ip_rx.hdr.data_length = x"0004" report "T1: ip_rx.hdr.data_length not set correctly";
- 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_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";
-
- mac_rx_tdata <= x"25"; wait for clk_period;
- mac_rx_tdata <= x"26"; wait for clk_period;
- mac_rx_tdata <= x"27"; mac_rx_tlast <= '1'; wait for clk_period;
-
- assert ip_rx.data.data_in_last = '1' report "T1: ip_rx.data.data_in_last not set";
-
-
- mac_rx_tdata <= x"00";
- mac_rx_tlast <= '0';
- mac_rx_tvalid <= '0';
- wait for clk_period;
-
- assert ip_rx.data.data_in_valid = '0' report "T1: ip_rx.data.data_in_valid not cleared";
- assert ip_rx.data.data_in_last = '0' report "T1: ip_rx.data.data_in_last not cleared";
- assert ip_rx.hdr.num_frame_errors = x"00" report "T1: ip_rx.hdr.num_frame_errors non zero at end of test";
- assert ip_rx.hdr.last_error_code = x"0" report "T1: ip_rx.hdr.last_error_code indicates error at end of test";
- assert ip_rx_start = '0' report "T1: ip_rx_start not cleared";
-
- ------------
- -- TEST 2 -- respond with IP TX
- ------------
-
- report "T2: respond with IP TX";
-
- ip_tx.hdr.protocol <= x"35";
- ip_tx.hdr.data_length <= x"0006";
- ip_tx.hdr.dst_ip_addr <= x"c0123478";
- ip_tx.data.data_out_valid <= '0';
- ip_tx.data.data_out_last <= '0';
- wait for clk_period;
-
- ip_tx_start <= '1'; wait for clk_period;
-
- ip_tx_start <= '0'; wait for clk_period;
-
- assert ip_tx_result = IPTX_RESULT_SENDING report "T2: result should be IPTX_RESULT_SENDING";
-
- wait for clk_period*2;
-
- assert ip_tx_data_out_ready = '0' report "T2: IP data out ready asserted too early";
-
- -- need to wait for ARP tx to complete
-
- wait for clk_period*50;
-
- assert mac_tx_tvalid = '0' report "T2: mac_tx_tvalid not cleared after ARP tx";
- assert mac_tx_tlast = '0' report "T2: mac_tx_tlast not cleared after ARP tx";
-
- -- now create the ARP response (rx)
-
- -- Send the reply
- -- Send an ARP reply: x"c0123478" has mac 02:12:03:23:04:54
- 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"02"; wait for clk_period;
- mac_rx_tdata <= x"12"; wait for clk_period;
- mac_rx_tdata <= x"03"; wait for clk_period;
- mac_rx_tdata <= x"23"; wait for clk_period;
- mac_rx_tdata <= x"04"; wait for clk_period;
- mac_rx_tdata <= x"54"; wait for clk_period;
- -- type
- mac_rx_tdata <= x"08"; wait for clk_period;
- mac_rx_tdata <= x"06"; wait for clk_period;
- -- HW type
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"01"; wait for clk_period;
- -- Protocol type
- mac_rx_tdata <= x"08"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- -- HW size
- mac_rx_tdata <= x"06"; wait for clk_period;
- -- protocol size
- mac_rx_tdata <= x"04"; wait for clk_period;
- -- Opcode
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"02"; wait for clk_period;
- -- Sender MAC
- mac_rx_tdata <= x"02"; wait for clk_period;
- mac_rx_tdata <= x"12"; wait for clk_period;
- mac_rx_tdata <= x"03"; wait for clk_period;
- mac_rx_tdata <= x"23"; wait for clk_period;
- mac_rx_tdata <= x"04"; wait for clk_period;
- mac_rx_tdata <= x"54"; wait for clk_period;
- -- Sender IP
- mac_rx_tdata <= x"c0"; wait for clk_period;
- mac_rx_tdata <= x"12"; wait for clk_period;
- mac_rx_tdata <= x"34"; wait for clk_period;
- mac_rx_tdata <= x"78"; wait for clk_period;
- -- Target MAC
- 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;
- -- Target 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;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tlast <= '1';
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tlast <= '0';
- mac_rx_tvalid <= '0';
-
- 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"56"; wait for clk_period;
- ip_tx.data.data_out <= x"57"; wait for clk_period;
- ip_tx.data.data_out <= x"58"; wait for clk_period;
- ip_tx.data.data_out <= x"59"; wait for clk_period;
- ip_tx.data.data_out <= x"5a"; wait for clk_period;
-
- ip_tx.data.data_out <= x"5b";
- ip_tx.data.data_out_last <= '1';
- wait for clk_period;
-
- assert mac_tx_tlast = '1' report "T2: mac_tx_tlast not set on last byte";
-
- wait for clk_period;
-
- 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 "T2: result should be SENT";
- wait for clk_period*10;
-
- ------------
- -- TEST 3 -- Check that sending to the same IP addr doesnt cause an ARP req as the addr is cached
- ------------
-
- report "T3: Send 2nd IP TX to same IP addr - should not need to do ARP tx/rx";
- ip_tx.hdr.protocol <= x"35";
- ip_tx.hdr.data_length <= x"0006";
- ip_tx.hdr.dst_ip_addr <= x"c0123478";
- ip_tx.data.data_out_valid <= '0';
- ip_tx.data.data_out_last <= '0';
- wait for clk_period;
- ip_tx_start <= '1'; wait for clk_period;
- ip_tx_start <= '0'; wait for clk_period;
- assert ip_tx_result = IPTX_RESULT_SENDING report "T3: result should be IPTX_RESULT_SENDING";
- wait for clk_period*2;
- 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"81"; wait for clk_period;
- ip_tx.data.data_out <= x"83"; wait for clk_period;
- ip_tx.data.data_out <= x"85"; wait for clk_period;
- ip_tx.data.data_out <= x"87"; wait for clk_period;
- ip_tx.data.data_out <= x"89"; wait for clk_period;
-
- ip_tx.data.data_out <= x"8b";
- ip_tx.data.data_out_last <= '1';
- wait for clk_period;
-
- assert mac_tx_tlast = '1' report "T3: mac_tx_tlast not set on last byte";
-
- wait for clk_period;
-
- 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 SENT";
- wait for clk_period*2;
-
-
-
- report "-- end of tests --";
-
- wait;
- end process;
-
-END;
Index: udp_ip_stack/tags/v2.0/bench/vhdl/UDP_av2_complete_nomac_tb.vhd
===================================================================
--- udp_ip_stack/tags/v2.0/bench/vhdl/UDP_av2_complete_nomac_tb.vhd (revision 12)
+++ udp_ip_stack/tags/v2.0/bench/vhdl/UDP_av2_complete_nomac_tb.vhd (nonexistent)
@@ -1,1415 +0,0 @@
---------------------------------------------------------------------------------
--- Company:
--- Engineer:
---
--- Create Date: 09:57:01 06/13/2011
--- Design Name:
--- Module Name: C:/Users/pjf/Documents/projects/fpga/xilinx/Network/udp1/UDP_complete_nomac_tb.vhd
--- Project Name: udp1
--- Target Device:
--- Tool versions:
--- Description:
---
--- VHDL Test Bench Created by ISE for module: UDP_Complete_nomac
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Revision 0.02 - Added test for IP broadcast tx
--- Revision 0.03 - Added tests for ARP timeout
--- Additional Comments:
---
--- Notes:
--- This testbench has been automatically generated using types std_logic and
--- std_logic_vector for the ports of the unit under test. Xilinx recommends
--- that these types always be used for the top-level I/O of a design in order
--- to guarantee that the testbench will bind correctly to the post-implementation
--- simulation model.
---------------------------------------------------------------------------------
-library IEEE;
-use IEEE.STD_LOGIC_1164.ALL;
-use IEEE.NUMERIC_STD.ALL;
-use work.axi.all;
-use work.ipv4_types.all;
-use work.arp_types.all;
-
-ENTITY UDP_av2_complete_nomac_tb IS
-END UDP_av2_complete_nomac_tb;
-
-ARCHITECTURE behavior OF UDP_av2_complete_nomac_tb IS
-
- -- Component Declaration for the Unit Under Test (UUT)
-
- COMPONENT UDP_Complete_nomac
- generic (
- CLOCK_FREQ : integer := 125000000; -- freq of data_in_clk -- needed to timout cntr
- ARP_TIMEOUT : integer := 60 -- ARP response timeout (s)
- );
- Port (
- -- UDP TX signals
- udp_tx_start : in std_logic; -- indicates req to tx UDP
- udp_txi : in udp_tx_type; -- UDP tx cxns
- udp_tx_result : out std_logic_vector (1 downto 0);-- tx status (changes during transmission)
- udp_tx_data_out_ready: out std_logic; -- indicates udp_tx is ready to take data
- -- UDP RX signals
- udp_rx_start : out std_logic; -- indicates receipt of udp header
- udp_rxo : out udp_rx_type;
- -- IP RX signals
- ip_rx_hdr : out ipv4_rx_header_type;
- -- system signals
- rx_clk : in STD_LOGIC;
- tx_clk : in STD_LOGIC;
- reset : in STD_LOGIC;
- our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
- our_mac_address : in std_logic_vector (47 downto 0);
- control : in udp_control_type;
- -- status signals
- arp_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- count of arp pkts received
- ip_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- number of IP pkts received for us
- -- MAC Transmitter
- mac_tx_tdata : out std_logic_vector(7 downto 0); -- data byte to tx
- mac_tx_tvalid : out std_logic; -- tdata is valid
- mac_tx_tready : in std_logic; -- mac is ready to accept data
- mac_tx_tfirst : out std_logic; -- indicates first byte of frame
- mac_tx_tlast : out std_logic; -- indicates last byte of frame
- -- MAC Receiver
- mac_rx_tdata : in std_logic_vector(7 downto 0); -- data byte received
- mac_rx_tvalid : in std_logic; -- indicates tdata is valid
- mac_rx_tready : out std_logic; -- tells mac that we are ready to take data
- mac_rx_tlast : in std_logic -- indicates last byte of the trame
- );
- END COMPONENT;
-
-
-
- type state_type is (IDLE, WAIT_RX_DONE, DATA_OUT);
- type count_mode_type is (RST, INCR, HOLD);
- type set_clr_type is (SET, CLR, HOLD);
-
-
- --Inputs
- signal udp_tx_start_int : std_logic := '0';
- signal udp_tx_int : udp_tx_type;
- signal clk_int : std_logic := '0';
- signal reset : std_logic := '0';
- signal our_ip_address : std_logic_vector(31 downto 0) := (others => '0');
- signal our_mac_address : std_logic_vector(47 downto 0) := (others => '0');
- signal mac_tx_tready : std_logic := '0';
- signal mac_rx_tdata : std_logic_vector(7 downto 0) := (others => '0');
- signal mac_rx_tvalid : std_logic := '0';
- signal mac_rx_tlast : std_logic := '0';
- signal control : udp_control_type;
-
- --Outputs
- signal udp_rx_start_int : std_logic;
- signal udp_rx_int : udp_rx_type;
- signal ip_rx_hdr : ipv4_rx_header_type;
- signal udp_tx_result : std_logic_vector (1 downto 0);
- signal udp_tx_data_out_ready_int: std_logic;
-
- signal arp_pkt_count : std_logic_vector(7 downto 0);
- signal ip_pkt_count : std_logic_vector(7 downto 0);
- signal mac_tx_tdata : std_logic_vector(7 downto 0);
- signal mac_tx_tvalid : std_logic;
- signal mac_tx_tfirst : std_logic;
- signal mac_tx_tlast : std_logic;
- signal mac_rx_tready : std_logic;
-
- signal pbtx_led : std_logic;
- signal pbtx : std_logic := '0';
-
- -- state signals
- signal state : state_type;
- signal count : unsigned (7 downto 0);
- signal tx_hdr : udp_tx_header_type;
- signal tx_start_reg : std_logic;
- signal tx_started_reg : std_logic;
- signal tx_fin_reg : std_logic;
-
-
- -- control signals
- signal next_state : state_type;
- signal set_state : std_logic;
- signal set_count : count_mode_type;
- signal set_hdr : std_logic;
- signal set_tx_start : set_clr_type;
- signal set_last : std_logic;
- signal set_tx_started : set_clr_type;
- signal set_tx_fin : set_clr_type;
- signal first_byte_rx : STD_LOGIC_VECTOR(7 downto 0);
-
-
-
- -- Clock period definitions
- constant clk_period : time := 8 ns;
-
-BEGIN
-
- -- Instantiate the Unit Under Test (UUT)
- uut: UDP_Complete_nomac
- generic map (
- CLOCK_FREQ => 10, -- artificially low count to enable pragmatic testing
- ARP_TIMEOUT => 20
- )
- PORT MAP (
- udp_tx_start => udp_tx_start_int,
- udp_txi => udp_tx_int,
- udp_tx_result => udp_tx_result,
- udp_tx_data_out_ready => udp_tx_data_out_ready_int,
- udp_rx_start => udp_rx_start_int,
- udp_rxo => udp_rx_int,
- ip_rx_hdr => ip_rx_hdr,
- rx_clk => clk_int,
- tx_clk => clk_int,
- reset => reset,
- our_ip_address => our_ip_address,
- our_mac_address => our_mac_address,
- control => control,
- arp_pkt_count => arp_pkt_count,
- ip_pkt_count => ip_pkt_count,
- mac_tx_tdata => mac_tx_tdata,
- mac_tx_tvalid => mac_tx_tvalid,
- mac_tx_tready => mac_tx_tready,
- mac_tx_tfirst => mac_tx_tfirst,
- mac_tx_tlast => mac_tx_tlast,
- mac_rx_tdata => mac_rx_tdata,
- mac_rx_tvalid => mac_rx_tvalid,
- mac_rx_tready => mac_rx_tready,
- mac_rx_tlast => mac_rx_tlast
- );
-
- -- Clock process definitions
- clk_process :process
- begin
- clk_int <= '0';
- wait for clk_period/2;
- clk_int <= '1';
- wait for clk_period/2;
- end process;
-
-
- -- Stimulus process
- stim_proc: process
- begin
- -- hold reset state for 100 ns.
- wait for 100 ns;
-
- our_ip_address <= x"c0a80509"; -- 192.168.5.9
- our_mac_address <= x"002320212223";
- control.ip_controls.arp_controls.clear_cache <= '0';
- mac_tx_tready <= '0';
-
- reset <= '1';
- wait for clk_period*10;
- reset <= '0';
- wait for clk_period*5;
-
- -- check reset conditions
- assert udp_tx_result = UDPTX_RESULT_NONE report "udp_tx_result not initialised correctly on reset";
- assert udp_tx_data_out_ready_int = '0' report "ip_udp_txitx.data.data_out_ready not initialised correctly on reset";
- assert mac_tx_tvalid = '0' report "mac_tx_tvalid not initialised correctly on reset";
- assert mac_tx_tlast = '0' report "mac_tx_tlast not initialised correctly on reset";
- assert arp_pkt_count = x"00" report "arp_pkt_count not initialised correctly on reset";
- assert ip_pkt_count = x"00" report "ip_pkt_count not initialised correctly on reset";
- assert udp_rx_start_int = '0' report "udp_rx_start not initialised correctly on reset";
- assert udp_rx_int.hdr.is_valid = '0' report "udp_rx_int.hdr.is_valid not initialised correctly on reset";
- assert udp_rx_int.hdr.data_length = x"0000" report "udp_rx_int.hdr.data_length not initialised correctly on reset";
- assert udp_rx_int.hdr.src_ip_addr = x"00000000" report "udp_rx_int.hdr.src_ip_addr not initialised correctly on reset";
- assert udp_rx_int.hdr.src_port = x"0000" report "udp_rx_int.hdr.src_port not initialised correctly on reset";
- assert udp_rx_int.hdr.dst_port = x"0000" report "udp_rx_int.hdr.dst_port not initialised correctly on reset";
- assert udp_rx_int.data.data_in = x"00" report "udp_rx_start.data.data_in not initialised correctly on reset";
- assert udp_rx_int.data.data_in_valid = '0' report "udp_rx_start.data.data_in_valid not initialised correctly on reset";
- assert udp_rx_int.data.data_in_last = '0' report "udp_rx_start.data.data_in_last not initialised correctly on reset";
- assert ip_rx_hdr.is_valid = '0' report "ip_rx_hdr.is_valid not initialised correctly on reset";
- assert ip_rx_hdr.protocol = x"00" report "ip_rx_hdr.protocol not initialised correctly on reset";
- assert ip_rx_hdr.data_length = x"0000" report "ip_rx_hdr.data_length not initialised correctly on reset";
- assert ip_rx_hdr.src_ip_addr = x"00000000" report "ip_rx_hdr.src_ip_addr not initialised correctly on reset";
- assert ip_rx_hdr.num_frame_errors = x"00" report "ip_rx_hdr.num_frame_errors not initialised correctly on reset";
-
-
- -- insert stimulus here
-
- ------------
- -- TEST 1 -- send ARP request
- ------------
-
- report "T1: Send an ARP request: who has 192.168.5.9? Tell 192.168.5.1";
-
- mac_tx_tready <= '1';
-
- 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;
- mac_rx_tdata <= x"06"; wait for clk_period;
- -- HW type
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"01"; wait for clk_period;
- -- Protocol type
- mac_rx_tdata <= x"08"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- -- HW size
- mac_rx_tdata <= x"06"; wait for clk_period;
- -- protocol size
- mac_rx_tdata <= x"04"; wait for clk_period;
- -- Opcode
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"01"; wait for clk_period;
- -- Sender 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;
- -- Sender 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;
- -- Target MAC
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- -- Target 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;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tlast <= '1';
- mac_rx_tdata <= x"00"; wait for clk_period;
- mac_rx_tlast <= '0';
- mac_rx_tvalid <= '0';
-
- -- check we got the ARP pkt
- assert arp_pkt_count = x"01" report "T1: arp_pkt_count wrong value";
- assert ip_pkt_count = x"00" report "T1: ip_pkt_count wrong value";
- assert udp_tx_result = UDPTX_RESULT_NONE report "T1: udp_tx_result wrong value";
- assert udp_tx_data_out_ready_int = '0' report "T1: ip_udp_txitx.data.data_out_ready wrong value";
- assert udp_rx_start_int = '0' report "T1: udp_rx_start wrong value";
- assert udp_rx_int.hdr.is_valid = '0' report "T1: udp_rx_int.hdr.is_valid wrong value";
- assert ip_rx_hdr.is_valid = '0' report "T1: ip_rx_hdr.is_valid wrong value";
-
- -- check we tx a response
-
- wait for clk_period*25;
- assert mac_tx_tvalid = '1' report "T1: not transmitting a response";
- wait for clk_period*25;
- assert mac_tx_tvalid = '0' report "T1: tx held on for too long";
-
- ------------
- -- TEST 2 -- send UDP pkt (same as sample from Java program)
- ------------
-
- report "T2: 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"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"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 "T2: udp_rx_int.hdr.is_valid not set";
- assert udp_rx_int.hdr.data_length = x"0005" report "T2: udp_rx_int.hdr.data_length not set correctly";
- assert udp_rx_int.hdr.src_ip_addr = x"c0a80501" report "T2: udp_rx_int.hdr.src_ip_addr not set correctly";
- assert udp_rx_int.hdr.src_port = x"f49a" report "T2: udp_rx_int.hdr.src_port not set correctly";
- assert udp_rx_int.hdr.dst_port = x"2694" report "T2: udp_rx_int.hdr.dst_port not set correctly";
-
- assert udp_rx_start_int = '1' report "T2: udp_rx_start not set";
- assert udp_rx_int.data.data_in_valid = '1' report "T2: udp_rx_int.data.data_in_valid not set";
-
- assert ip_rx_hdr.is_valid = '1' report "T2: ip_rx_hdr.is_valid not set";
- assert ip_rx_hdr.protocol = x"11" report "T2: ip_rx_hdr.protocol not set correctly";
- assert ip_rx_hdr.src_ip_addr = x"c0a80501" 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.last_error_code = x"0" report "T2: 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 "T2: 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;
-
- assert udp_rx_int.data.data_in_valid = '0' report "T2: udp_rx_int.data.data_in_valid not cleared";
- assert udp_rx_int.data.data_in_last = '0' report "T2: udp_rx_int.data.data_in_last not cleared";
- assert udp_rx_start_int = '0' report "T2: udp_rx_start not cleared";
- assert ip_rx_hdr.num_frame_errors = x"00" report "T2: ip_rx_hdr.num_frame_errors non zero at end of test";
- 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_pkt_count = x"01" report "T2: ip pkt cnt incorrect";
-
- wait for clk_period*20;
-
- ------------
- -- TEST 3 -- send UDP pkt again (same as sample from Java program)
- ------------
-
- report "T3: 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"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"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 "T3: udp_rx_int.hdr.is_valid not set";
- assert udp_rx_int.hdr.data_length = x"0005" report "T3: udp_rx_int.hdr.data_length not set correctly";
- assert udp_rx_int.hdr.src_ip_addr = x"c0a80501" report "T3: udp_rx_int.hdr.src_ip_addr not set correctly";
- assert udp_rx_int.hdr.src_port = x"f49a" report "T3: udp_rx_int.hdr.src_port not set correctly";
- assert udp_rx_int.hdr.dst_port = x"2694" report "T3: udp_rx_int.hdr.dst_port not set correctly";
-
- assert udp_rx_start_int = '1' report "T3: udp_rx_start not set";
- assert udp_rx_int.data.data_in_valid = '1' report "T3: udp_rx_int.data.data_in_valid not set";
-
- 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.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.last_error_code = x"0" report "T3: 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 "T3: 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;
-
- assert udp_rx_int.data.data_in_valid = '0' report "T3: udp_rx_int.data.data_in_valid not cleared";
- assert udp_rx_int.data.data_in_last = '0' report "T3: udp_rx_int.data.data_in_last not cleared";
- assert udp_rx_start_int = '0' report "T3: udp_rx_start 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_pkt_count = x"02" report "T3: ip pkt cnt incorrect";
-
- wait for clk_period*50;
-
- ------------
- -- TEST 4 -- send UDP pkt with specific UDP data 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"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"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"42"; wait for clk_period; -- First byte 'B' triggers a reply to broadcast addr
-
- -- 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"c0a80501" 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"c0a80501" 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";
-
-
- ------------
- -- TEST 6 -- send UDP pkt with data to trigger the sending of a pkt to unknown IP addr to force an ARP timeout
- ------------
-
- report "T6: Send UDP IP pkt dst ip_address c0a80509, from port f49a to port 2694 with data x43 to trig tx to unknown IP";
-
- 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"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"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"43"; wait for clk_period; -- First byte 'C' triggers a reply to unknown addr
-
- -- 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 "T6: udp_rx_int.hdr.is_valid not set";
- assert udp_rx_int.hdr.data_length = x"0005" report "T6: udp_rx_int.hdr.data_length not set correctly";
- assert udp_rx_int.hdr.src_ip_addr = x"c0a80501" report "T6: udp_rx_int.hdr.src_ip_addr not set correctly";
- assert udp_rx_int.hdr.src_port = x"f49a" report "T6: udp_rx_int.hdr.src_port not set correctly";
- assert udp_rx_int.hdr.dst_port = x"2694" report "T6: udp_rx_int.hdr.dst_port not set correctly";
-
- assert udp_rx_start_int = '1' report "T6: udp_rx_start not set";
- assert udp_rx_int.data.data_in_valid = '1' report "T6: udp_rx_int.data.data_in_valid not set";
-
- assert ip_rx_hdr.is_valid = '1' report "T6: ip_rx_hdr.is_valid not set";
- assert ip_rx_hdr.protocol = x"11" report "T6: ip_rx_hdr.protocol not set correctly";
- assert ip_rx_hdr.src_ip_addr = x"c0a80501" report "T6: ip_rx.hdr.src_ip_addr not set correctly";
- assert ip_rx_hdr.num_frame_errors = x"00" report "T6: ip_rx.hdr.num_frame_errors not set correctly";
- assert ip_rx_hdr.last_error_code = x"0" report "T6: 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 "T6: 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 "T6: waiting for mac data tx";
- wait until mac_tx_tvalid = '1';
- report "T6: starting mac data tx";
- wait for clk_period;
-
- -- check the mac data being transmitted is valid ARP request
- assert mac_tx_tdata = x"ff" report "T6: incorrect dst mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"ff" report "T6: incorrect dst mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"ff" report "T6: incorrect dst mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"ff" report "T6: incorrect dst mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"ff" report "T6: incorrect dst mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"ff" report "T6: incorrect dst mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T6: incorrect src mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T6: incorrect src mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"20" report "T6: incorrect src mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"21" report "T6: incorrect src mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"22" report "T6: incorrect src mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T6: incorrect src mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"08" report "T6: incorrect pkt_type 0"; wait for clk_period;
- assert mac_tx_tdata = x"06" report "T6: incorrect pkt type 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T6: incorrect HW type.0"; wait for clk_period;
- assert mac_tx_tdata = x"01" report "T6: incorrect HW type.1"; wait for clk_period;
- assert mac_tx_tdata = x"08" report "T6: incorrect prot.0"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T6: incorrect prot.1"; wait for clk_period;
- assert mac_tx_tdata = x"06" report "T6: incorrect HW size"; wait for clk_period;
- assert mac_tx_tdata = x"04" report "T6: incorrect prot size"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T6: incorrect opcode.0"; wait for clk_period;
- assert mac_tx_tdata = x"01" report "T6: incorrect opcode.1"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T6: incorrect sndr mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T6: incorrect sndr mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"20" report "T6: incorrect sndr mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"21" report "T6: incorrect sndr mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"22" report "T6: incorrect sndr mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T6: incorrect sndr mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"c0" report "T6: incorrect sndr ip 0"; wait for clk_period;
- assert mac_tx_tdata = x"a8" report "T6: incorrect sndr ip 1"; wait for clk_period;
- assert mac_tx_tdata = x"05" report "T6: incorrect sndr ip 2"; wait for clk_period;
- assert mac_tx_tdata = x"09" report "T6: incorrect sndr ip 3"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T6: incorrect trg mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T6: incorrect trg mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T6: incorrect trg mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T6: incorrect trg mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T6: incorrect trg mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T6: incorrect trg mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"c0" report "T6: incorrect trg ip 0"; wait for clk_period;
- assert mac_tx_tdata = x"bb" report "T6: incorrect trg ip 1"; wait for clk_period;
- assert mac_tx_tdata = x"cc" report "T6: incorrect trg ip 2";
- assert mac_tx_tlast = '0' report "T6: tlast asserted too soon";
- wait for clk_period;
-
- assert mac_tx_tdata = x"dd" report "T6: incorrect trg ip 3";
- assert mac_tx_tlast = '1' report "T6: tlast should be set";
- wait for clk_period;
-
- assert udp_tx_result = IPTX_RESULT_SENDING report "T6: TX should still be in sending phase";
-
- assert udp_rx_int.data.data_in_valid = '0' report "T6: udp_rx_int.data.data_in_valid not cleared";
- assert udp_rx_int.data.data_in_last = '0' report "T6: udp_rx_int.data.data_in_last not cleared";
- assert udp_rx_start_int = '0' report "T6: udp_rx_start not cleared";
- assert ip_rx_hdr.num_frame_errors = x"00" report "T6: ip_rx_hdr.num_frame_errors non zero at end of test";
- assert ip_rx_hdr.last_error_code = x"0" report "T6: ip_rx_hdr.last_error_code indicates error at end of test";
- assert ip_pkt_count = x"05" report "T6: ip pkt cnt incorrect";
-
- -- check for error on tx as a result of ARP timeout
-
- wait for clk_period*10*20;
- assert udp_tx_result = IPTX_RESULT_ERR report "T6: TX should resulkt in error (arp timeout)";
-
- wait for clk_period*10;
-
- ------------
- -- TEST 7 -- send UDP pkt again to ensure that we can rx a pkt and tx after a timeout
- ------------
-
- report "T7: 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"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"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 "T7: udp_rx_int.hdr.is_valid not set";
- assert udp_rx_int.hdr.data_length = x"0005" report "T7: udp_rx_int.hdr.data_length not set correctly";
- assert udp_rx_int.hdr.src_ip_addr = x"c0a80501" report "T7: udp_rx_int.hdr.src_ip_addr not set correctly";
- assert udp_rx_int.hdr.src_port = x"f49a" report "T7: udp_rx_int.hdr.src_port not set correctly";
- assert udp_rx_int.hdr.dst_port = x"2694" report "T7: udp_rx_int.hdr.dst_port not set correctly";
-
- assert udp_rx_start_int = '1' report "T7: udp_rx_start not set";
- assert udp_rx_int.data.data_in_valid = '1' report "T7: udp_rx_int.data.data_in_valid not set";
-
- assert ip_rx_hdr.is_valid = '1' report "T7: ip_rx_hdr.is_valid not set";
- assert ip_rx_hdr.protocol = x"11" report "T7: ip_rx_hdr.protocol not set correctly";
- assert ip_rx_hdr.src_ip_addr = x"c0a80501" report "T7: ip_rx.hdr.src_ip_addr not set correctly";
- assert ip_rx_hdr.num_frame_errors = x"00" report "T7: ip_rx.hdr.num_frame_errors not set correctly";
- assert ip_rx_hdr.last_error_code = x"0" report "T7: 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 "T7: 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*2;
-
- -- the mac address will be cached, so udp tx should occur straight away
- assert udp_tx_result = IPTX_RESULT_SENDING report "T7: TX should be sending";
-
- report "T7: waiting for mac data tx";
- if mac_tx_tvalid = '0' then
- wait until mac_tx_tvalid = '1';
- wait for clk_period;
- end if;
- report "T7: starting mac data tx";
-
- -- check the mac data being transmitted
- assert mac_tx_tdata = x"00" report "T7: incorrect dst mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T7: incorrect dst mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"18" report "T7: incorrect dst mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"29" report "T7: incorrect dst mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"26" report "T7: incorrect dst mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"7c" report "T7: incorrect dst mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T7: incorrect src mac 0"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T7: incorrect src mac 1"; wait for clk_period;
- assert mac_tx_tdata = x"20" report "T7: incorrect src mac 2"; wait for clk_period;
- assert mac_tx_tdata = x"21" report "T7: incorrect src mac 3"; wait for clk_period;
- assert mac_tx_tdata = x"22" report "T7: incorrect src mac 4"; wait for clk_period;
- assert mac_tx_tdata = x"23" report "T7: incorrect src mac 5"; wait for clk_period;
-
- assert mac_tx_tdata = x"08" report "T7: incorrect pkt_type 0"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect pkt type 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"45" report "T7: incorrect ver.hlen"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect srv type"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect len 0"; wait for clk_period;
- assert mac_tx_tdata = x"20" report "T7: incorrect len 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T7: incorrect ident 0"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect ident 1"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect flag&frag 0"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect flag&frag 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"80" report "T7: incorrect TTL"; wait for clk_period;
- assert mac_tx_tdata = x"11" report "T7: incorrect protocol"; wait for clk_period;
- assert mac_tx_tdata = x"af" report "T7: incorrect hdr.cks 0"; wait for clk_period;
- assert mac_tx_tdata = x"72" report "T7: incorrect hdr.cks 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"c0" report "T7: incorrect src ip 0"; wait for clk_period;
- assert mac_tx_tdata = x"a8" report "T7: incorrect src ip 1"; wait for clk_period;
- assert mac_tx_tdata = x"05" report "T7: incorrect src ip 2"; wait for clk_period;
- assert mac_tx_tdata = x"09" report "T7: incorrect src ip 3"; wait for clk_period;
-
- assert mac_tx_tdata = x"c0" report "T7: incorrect dst ip 0"; wait for clk_period;
- assert mac_tx_tdata = x"a8" report "T7: incorrect dst ip 1"; wait for clk_period;
- assert mac_tx_tdata = x"05" report "T7: incorrect dst ip 2"; wait for clk_period;
- assert mac_tx_tdata = x"01" report "T7: incorrect dst ip 3"; wait for clk_period;
-
- assert mac_tx_tdata = x"26" report "T7: incorrect src port 0"; wait for clk_period;
- assert mac_tx_tdata = x"94" report "T7: incorrect src port 1"; wait for clk_period;
- assert mac_tx_tdata = x"f4" report "T7: incorrect dst port 0"; wait for clk_period;
- assert mac_tx_tdata = x"9a" report "T7: incorrect dst port 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"00" report "T7: incorrect udp len 0"; wait for clk_period;
- assert mac_tx_tdata = x"0c" report "T7: incorrect udp len 1"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect udp cks 0"; wait for clk_period;
- assert mac_tx_tdata = x"00" report "T7: incorrect udp cks 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"40" report "T7: incorrect udp data 0"; wait for clk_period;
- assert mac_tx_tdata = x"41" report "T7: incorrect udp data 1"; wait for clk_period;
-
- assert mac_tx_tdata = x"42" report "T7: incorrect udp data 2";
- assert mac_tx_tlast = '0' report "T7: tlast asserted too soon"; wait for clk_period;
- assert mac_tx_tdata = x"43" report "T7: incorrect udp data 3";
- assert mac_tx_tlast = '1' report "T7: tlast not asserted"; wait for clk_period;
-
- assert udp_tx_result = IPTX_RESULT_SENT report "T7: TX did not complete";
-
- assert udp_rx_int.data.data_in_valid = '0' report "T7: udp_rx_int.data.data_in_valid not cleared";
- assert udp_rx_int.data.data_in_last = '0' report "T7: udp_rx_int.data.data_in_last not cleared";
- assert udp_rx_start_int = '0' report "T7: udp_rx_start not cleared";
- assert ip_rx_hdr.num_frame_errors = x"00" report "T7: ip_rx_hdr.num_frame_errors non zero at end of test";
- assert ip_rx_hdr.last_error_code = x"0" report "T7: ip_rx_hdr.last_error_code indicates error at end of test";
- assert ip_pkt_count = x"06" report "T7: ip pkt cnt incorrect";
-
-
-
- report "--- end of tests ---";
- wait;
- end process;
-
- -- 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(
- -- inputs
- udp_rx_start_int, udp_rx_int, udp_tx_data_out_ready_int, udp_tx_result, ip_rx_hdr,
- udp_tx_int.data.data_out_valid, PBTX,
- -- state
- state, count, tx_hdr, tx_start_reg, tx_started_reg, tx_fin_reg,
- -- controls
- next_state, set_state, set_count, set_hdr, set_tx_start, set_last,
- set_tx_started, set_tx_fin, first_byte_rx
- )
- begin
- -- set output_followers
- udp_tx_int.hdr <= tx_hdr;
- udp_tx_int.data.data_out_last <= set_last;
- udp_tx_start_int <= tx_start_reg;
-
- -- set control signal defaults
- next_state <= IDLE;
- set_state <= '0';
- set_count <= HOLD;
- set_hdr <= '0';
- set_tx_start <= HOLD;
- set_last <= '0';
- set_tx_started <= HOLD;
- set_tx_fin <= HOLD;
- first_byte_rx <= (others => '0');
-
- -- FSM
- case state is
-
- when IDLE =>
- 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_tx_fin <= CLR;
- set_count <= RST;
- set_hdr <= '1';
- if udp_rx_int.data.data_in_last = '1' then
- set_tx_started <= SET;
- set_tx_start <= SET;
- next_state <= DATA_OUT;
- set_state <= '1';
- else
- next_state <= WAIT_RX_DONE;
- set_state <= '1';
- end if;
- end if;
-
- when WAIT_RX_DONE =>
- -- wait until RX pkt fully received
- if udp_rx_int.data.data_in_last = '1' then
- set_tx_started <= SET;
- set_tx_start <= SET;
- next_state <= DATA_OUT;
- set_state <= '1';
- end if;
-
- when DATA_OUT =>
- if udp_tx_result = UDPTX_RESULT_ERR then
- -- have an error from the IP TX layer, clear down the TX
- set_tx_start <= CLR;
- set_tx_fin <= SET;
- set_tx_started <= CLR;
- next_state <= IDLE;
- set_state <= '1';
- else
- if udp_tx_result = UDPTX_RESULT_SENDING then
- set_tx_start <= CLR; -- reset out start req as soon as we know we are sending
- end if;
- 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
- if unsigned(count) = x"03" then
- set_last <= '1';
- set_tx_fin <= SET;
- set_tx_started <= CLR;
- next_state <= IDLE;
- set_state <= '1';
- else
- set_count <= INCR;
- end if;
- end if;
- end if;
-
- end case;
- end process;
-
-
-
- -- TX response process - SEQ
- tx_proc_sequential: process(clk_int)
- begin
- if rising_edge(clk_int) then
- if reset = '1' then
- -- reset state variables
- state <= IDLE;
- count <= x"00";
- tx_start_reg <= '0';
- tx_hdr.dst_ip_addr <= (others => '0');
- tx_hdr.dst_port <= (others => '0');
- tx_hdr.src_port <= (others => '0');
- tx_hdr.data_length <= (others => '0');
- tx_hdr.checksum <= (others => '0');
- tx_started_reg <= '0';
- tx_fin_reg <= '0';
- PBTX_LED <= '0';
- else
- PBTX_LED <= PBTX;
-
- -- Next rx_state processing
- if set_state = '1' then
- state <= next_state;
- else
- state <= state;
- end if;
-
- -- count processing
- case set_count is
- when RST => count <= x"00";
- when INCR => count <= count + 1;
- when HOLD => count <= count;
- end case;
-
- -- set tx hdr
- if set_hdr = '1' then
- -- 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; -- send to Broadcast addr
- elsif first_byte_rx = x"43" then
- tx_hdr.dst_ip_addr <= x"c0bbccdd"; -- set dst unknown so get ARP timeout
- else
- tx_hdr.dst_ip_addr <= udp_rx_int.hdr.src_ip_addr; -- reply to sender
- 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";
- tx_hdr.checksum <= x"0000";
- else
- tx_hdr <= tx_hdr;
- end if;
-
- -- set tx start signal
- case set_tx_start is
- when SET => tx_start_reg <= '1';
- when CLR => tx_start_reg <= '0';
- when HOLD => tx_start_reg <= tx_start_reg;
- end case;
-
- -- set tx started signal
- case set_tx_started is
- when SET => tx_started_reg <= '1';
- when CLR => tx_started_reg <= '0';
- when HOLD => tx_started_reg <= tx_started_reg;
- end case;
-
- -- set tx finished signal
- case set_tx_fin is
- when SET => tx_fin_reg <= '1';
- when CLR => tx_fin_reg <= '0';
- when HOLD => tx_fin_reg <= tx_fin_reg;
- end case;
-
-
- end if;
- end if;
-
- end process;
-
-END;
Index: udp_ip_stack/tags/v2.0/bench/vhdl/arpv2_tb.vhd
===================================================================
--- udp_ip_stack/tags/v2.0/bench/vhdl/arpv2_tb.vhd (revision 12)
+++ udp_ip_stack/tags/v2.0/bench/vhdl/arpv2_tb.vhd (nonexistent)
@@ -1,956 +0,0 @@
---------------------------------------------------------------------------------
--- Company:
--- Engineer:
---
--- Create Date: 12:35:50 05/31/2011
--- Design Name:
--- Module Name: C:/Users/pjf/Documents/projects/fpga/xilinx/Network/arp1/arp_tb.vhd
--- Project Name: arp1
--- Target Device:
--- Tool versions:
--- Description:
---
--- VHDL Test Bench Created by ISE for module: arp
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Revision 0.02 - Added tests for ARP timeout
--- Additional Comments:
---
--- Notes:
--- This testbench has been automatically generated using types std_logic and
--- std_logic_vector for the ports of the unit under test. Xilinx recommends
--- that these types always be used for the top-level I/O of a design in order
--- to guarantee that the testbench will bind correctly to the post-implementation
--- simulation model.
---------------------------------------------------------------------------------
-LIBRARY ieee;
-USE ieee.std_logic_1164.ALL;
-USE ieee.numeric_std.ALL;
-use work.arp_types.all;
-
-ENTITY arpv2_tb IS
-END arpv2_tb;
-
-ARCHITECTURE behavior OF arpv2_tb IS
-
- -- Component Declaration for the Unit Under Test (UUT)
-
- COMPONENT arpv2
- generic (
- CLOCK_FREQ : integer := 125000000; -- freq of data_in_clk -- needed to timout cntr
- ARP_TIMEOUT : integer := 60; -- ARP response timeout (s)
- MAX_ARP_ENTRIES : integer := 255 -- max entries in the arp store
- );
- Port (
- -- lookup request signals
- arp_req_req : in arp_req_req_type;
- arp_req_rslt : out arp_req_rslt_type;
- -- MAC layer RX signals
- data_in_clk : 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_valid : in STD_LOGIC; -- indicates data_in valid on clock
- data_in_last : in STD_LOGIC; -- indicates last data in frame
- -- 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_granted : in std_logic; -- indicates that access to channel has been granted
- data_out_clk : in std_logic;
- 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_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 : out std_logic_vector (7 downto 0); -- ethernet frame (from dst mac addr through to last byte of frame)
- -- system signals
- our_mac_address : in STD_LOGIC_VECTOR (47 downto 0);
- our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
- control : in arp_control_type;
- req_count : out STD_LOGIC_VECTOR(7 downto 0) -- count of arp pkts received
- );
- END COMPONENT;
-
-
- --Inputs
- signal clk : std_logic := '0';
- signal reset : std_logic := '0';
- signal data_in : std_logic_vector(7 downto 0) := (others => '0');
- signal data_in_valid : std_logic := '0';
- signal data_in_last : std_logic := '0';
- signal our_mac_address : std_logic_vector(47 downto 0) := (others => '0');
- signal our_ip_address : std_logic_vector(31 downto 0) := (others => '0');
- signal data_out_ready : std_logic;
- signal data_out_valid : std_logic;
- signal data_out_first : std_logic;
- signal data_out_last : std_logic;
- signal data_out : std_logic_vector (7 downto 0);
- signal req_count : STD_LOGIC_VECTOR(7 downto 0);
- signal arp_req_req : arp_req_req_type;
- signal arp_req_rslt : arp_req_rslt_type;
- signal mac_tx_req : std_logic;
- signal mac_tx_granted : std_logic;
- signal control : arp_control_type;
-
-
- -- Clock period definitions
- constant clk_period : time := 8 ns;
-
-BEGIN
-
- -- Instantiate the Unit Under Test (UUT)
- uut: arpv2
- generic map (
- CLOCK_FREQ => 10, -- artificially low count to enable pragmatic testing
- ARP_TIMEOUT => 20
- )
- PORT MAP (
- -- lookup request mappings
- arp_req_req => arp_req_req,
- arp_req_rslt => arp_req_rslt,
- -- rx mappings
- data_in_clk => clk,
- reset => reset,
- data_in => data_in,
- data_in_valid => data_in_valid,
- data_in_last => data_in_last,
- -- tx mappings
- mac_tx_req => mac_tx_req,
- mac_tx_granted => mac_tx_granted,
- data_out_clk => clk,
- data_out_ready => data_out_ready,
- data_out_valid => data_out_valid,
- data_out_first => data_out_first,
- data_out_last => data_out_last,
- data_out => data_out,
- -- system mappings
- our_mac_address => our_mac_address,
- our_ip_address => our_ip_address,
- control => control,
- req_count => req_count
- );
-
- -- Clock process definitions
- clk_process :process
- begin
- clk <= '0';
- wait for clk_period/2;
- clk <= '1';
- wait for clk_period/2;
- end process;
-
-
- -- Stimulus process
- stim_proc: process
- begin
- -- hold reset state for 100 ns.
- wait for 100 ns;
-
- our_ip_address <= x"c0a80509"; -- 192.168.5.9
- our_mac_address <= x"002320212223";
- mac_tx_granted <= '1'; -- FIXME 0
- control.clear_cache <= '0';
-
- reset <= '1';
- wait for clk_period*10;
- reset <= '0';
- wait for clk_period*5;
-
- assert mac_tx_req = '0' report "mac_tx_req asserted on reset";
-
- -- insert stimulus here
- arp_req_req.lookup_req <= '0';
- arp_req_req.ip <= (others => '0');
- data_out_ready <= '1';
-
- report "T1: Send an ARP request: who has 192.168.5.9? Tell 192.168.5.1";
- data_in_valid <= '1';
- -- dst MAC (bc)
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- -- src MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"18"; wait for clk_period;
- data_in <= x"29"; wait for clk_period;
- data_in <= x"26"; wait for clk_period;
- data_in <= x"7c"; wait for clk_period;
- -- type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"06"; wait for clk_period;
- -- HW type
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Protocol type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- HW size
- data_in <= x"06"; wait for clk_period;
- -- protocol size
- data_in <= x"04"; wait for clk_period;
- -- Opcode
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Sender MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"18"; wait for clk_period;
- data_in <= x"29"; wait for clk_period;
- data_in <= x"26"; wait for clk_period;
- data_in <= x"7c"; wait for clk_period;
- -- Sender IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Target MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- Target IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"09"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '1';
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '0';
- data_in_valid <= '0';
-
- report "T1: Expect that we send an 'I have 192.168.5.9' msg";
-
- -- check tx arbitration signals
-
- report "T1: waiting for tx req";
- wait until mac_tx_req = '1';
-
- -- ready to tx
- data_out_ready <= '1';
- mac_tx_granted <= '1';
- report "T1: waiting for data_out_valid";
- wait until data_out_valid = '1';
- report "T1: got data_out_valid";
- wait for clk_period*10;
- data_out_ready <= '0';
- wait for clk_period*2;
- data_out_ready <= '1';
- wait for clk_period*12;
- assert data_out = x"02" report "T1: expected opcode = 02 for reply 'I have'";
- -- expect our mac 00 23 20 21 22 23
- wait for clk_period;
- assert data_out = x"00" report "T1: incorrect our mac.0";
- wait for clk_period;
- assert data_out = x"23" report "T1: incorrect our mac.1";
- wait for clk_period;
- assert data_out = x"20" report "T1: incorrect our mac.2";
- wait for clk_period;
- assert data_out = x"21" report "T1: incorrect our mac.3";
- wait for clk_period;
- assert data_out = x"22" report "T1: incorrect our mac.4";
- wait for clk_period;
- assert data_out = x"23" report "T1: incorrect our mac.5";
- -- expect our IP c0 a8 05 05
- wait for clk_period;
- assert data_out = x"c0" report "T1: incorrect our IP.0";
- wait for clk_period;
- assert data_out = x"a8" report "T1: incorrect our IP.1";
- wait for clk_period;
- assert data_out = x"05" report "T1: incorrect our IP.2";
- wait for clk_period;
- assert data_out = x"09" report "T1: incorrect our IP.3";
-
- -- expect target mac 00 23 18 29 26 7c
- wait for clk_period;
- assert data_out = x"00" report "T1: incorrect target mac.0";
- wait for clk_period;
- assert data_out = x"23" report "T1: incorrect target mac.1";
- wait for clk_period;
- assert data_out = x"18" report "T1: incorrect target mac.2";
- wait for clk_period;
- assert data_out = x"29" report "T1: incorrect target mac.3";
- wait for clk_period;
- assert data_out = x"26" report "T1: incorrect target mac.4";
- wait for clk_period;
- assert data_out = x"7c" report "T1: incorrect target mac.5";
- -- expect target IP c0 a8 05 01
- wait for clk_period;
- assert data_out = x"c0" report "T1: incorrect target IP.0";
- wait for clk_period;
- assert data_out = x"a8" report "T1: incorrect target IP.1";
- wait for clk_period;
- assert data_out = x"05" report "T1: incorrect target IP.2";
- assert data_out_last = '0' report "T1: data out last incorrectly set on target IP.2 byte";
- wait for clk_period;
- assert data_out = x"01" report "T1: incorrect target IP.3";
- assert data_out_last = '1' report "T1: data out last should be set";
-
- wait for clk_period*10;
-
- report "T2: Send another ARP request: who has 192.168.5.8? Tell 192.168.5.1, holding off transmitter";
- data_out_ready <= '0';
- data_in_valid <= '1';
- -- dst MAC (bc)
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- -- src MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"18"; wait for clk_period;
- data_in <= x"29"; wait for clk_period;
- data_in <= x"26"; wait for clk_period;
- data_in <= x"7c"; wait for clk_period;
- -- type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"06"; wait for clk_period;
- -- HW type
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Protocol type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- HW size
- data_in <= x"06"; wait for clk_period;
- -- protocol size
- data_in <= x"04"; wait for clk_period;
- -- Opcode
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Sender MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"18"; wait for clk_period;
- data_in <= x"29"; wait for clk_period;
- data_in <= x"26"; wait for clk_period;
- data_in <= x"7c"; wait for clk_period;
- -- Sender IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Target MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- Target IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"09"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '1';
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '0';
- data_in_valid <= '0';
-
- -- ready to tx
- wait for clk_period*10;
- data_out_ready <= '1';
-
- wait for clk_period*50;
-
- report "T3: Send a request for the IP that is already in the store";
- arp_req_req.ip <= x"c0a80501";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- arp_req_req.lookup_req <= '0';
- report "T3: wait for reply from store";
- wait until arp_req_rslt.got_mac = '1' or arp_req_rslt.got_err = '1';
- assert arp_req_rslt.got_mac = '1' report "T3: expected got mac";
- assert arp_req_rslt.got_err = '0' report "T3: expected got err = 0";
- assert arp_req_rslt.mac = x"00231829267c" report "T3: wrong mac value";
- wait for clk_period*2;
-
- -- the entry that was in the store should now be in the cache - check it
- report "T4: Send a request for the IP that is already in the cache";
- arp_req_req.ip <= x"c0a80501";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- arp_req_req.lookup_req <= '0';
- assert arp_req_rslt.got_mac = '1' report "T4: expected got mac";
- assert arp_req_rslt.got_err = '0' report "T4: expected got err = 0";
- assert arp_req_rslt.mac = x"00231829267c" report "T4: wrong mac value";
-
- wait for clk_period*50;
-
- report "T5 - Send a request for the IP that is not cached or in the store";
- arp_req_req.ip <= x"c0a80503";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- arp_req_req.lookup_req <= '0';
- report "T5: waiting for data_out_valid";
- wait until data_out_valid = '1';
- report "T5: got data_out_valid";
- wait for clk_period*10;
- data_out_ready <= '0';
- wait for clk_period*2;
- data_out_ready <= '1';
- wait for clk_period*12;
- assert data_out = x"01" report "T5: expected opcode = 01 for request 'who has'";
- -- expect our mac 00 23 20 21 22 23
- wait for clk_period;
- assert data_out = x"00" report "T5: incorrect our mac.0";
- wait for clk_period;
- assert data_out = x"23" report "T5: incorrect our mac.1";
- wait for clk_period;
- assert data_out = x"20" report "T5: incorrect our mac.2";
- wait for clk_period;
- assert data_out = x"21" report "T5: incorrect our mac.3";
- wait for clk_period;
- assert data_out = x"22" report "T5: incorrect our mac.4";
- wait for clk_period;
- assert data_out = x"23" report "T5: incorrect our mac.5";
- -- expect our IP c0 a8 05 05
- wait for clk_period;
- assert data_out = x"c0" report "T5: incorrect our IP.0";
- wait for clk_period;
- assert data_out = x"a8" report "T5: incorrect our IP.1";
- wait for clk_period;
- assert data_out = x"05" report "T5: incorrect our IP.2";
- wait for clk_period;
- assert data_out = x"09" report "T5: incorrect our IP.3";
-
- -- expect empty target mac
- wait for clk_period;
- assert data_out = x"00" report "T5: incorrect target mac.0";
- wait for clk_period;
- assert data_out = x"00" report "T5: incorrect target mac.1";
- wait for clk_period;
- assert data_out = x"00" report "T5: incorrect target mac.2";
- wait for clk_period;
- assert data_out = x"00" report "T5: incorrect target mac.3";
- wait for clk_period;
- assert data_out = x"00" report "T5: incorrect target mac.4";
- wait for clk_period;
- assert data_out = x"00" report "T5: incorrect target mac.5";
- -- expect target IP c0 a8 05 01
- wait for clk_period;
- assert data_out = x"c0" report "T5: incorrect target IP.0";
- wait for clk_period;
- assert data_out = x"a8" report "T5: incorrect target IP.1";
- wait for clk_period;
- assert data_out = x"05" report "T5: incorrect target IP.2";
- assert data_out_last = '0' report "T5: data out last incorrectly set on target IP.2 byte";
- wait for clk_period;
- assert data_out = x"03" report "T5: incorrect target IP.3";
- assert data_out_last = '1' report "T5: data out last should be set";
-
- wait for clk_period*10;
-
- -- Send the reply
- data_out_ready <= '1';
-
- report "T5.2: Send an ARP reply: 192.168.5.3 has mac 02:12:03:23:04:54";
- data_in_valid <= '1';
- -- dst MAC (bc)
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- -- src MAC
- data_in <= x"02"; wait for clk_period;
- data_in <= x"12"; wait for clk_period;
- data_in <= x"03"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"04"; wait for clk_period;
- data_in <= x"54"; wait for clk_period;
- -- type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"06"; wait for clk_period;
- -- HW type
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Protocol type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- HW size
- data_in <= x"06"; wait for clk_period;
- -- protocol size
- data_in <= x"04"; wait for clk_period;
- -- Opcode
- data_in <= x"00"; wait for clk_period;
- data_in <= x"02"; wait for clk_period;
- -- Sender MAC
- data_in <= x"02"; wait for clk_period;
- data_in <= x"12"; wait for clk_period;
- data_in <= x"03"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"04"; wait for clk_period;
- data_in <= x"54"; wait for clk_period;
- -- Sender IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"03"; wait for clk_period;
- -- Target MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"20"; wait for clk_period;
- data_in <= x"21"; wait for clk_period;
- data_in <= x"22"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- -- Target IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"09"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- assert arp_req_rslt.got_mac = '1' report "T5.2: expected got mac";
- assert arp_req_rslt.got_err = '0' report "T5.2: expected got err = 0";
- assert arp_req_rslt.mac = x"021203230454" report "T5.2: wrong mac value";
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '1';
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '0';
- data_in_valid <= '0';
- wait for clk_period*4;
-
- report "T6: check that both these IPs remain in the store";
- arp_req_req.ip <= x"c0a80501";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- arp_req_req.lookup_req <= '0';
- wait for clk_period;
- report "T6.1: wait for reply from store";
- wait until arp_req_rslt.got_mac = '1' or arp_req_rslt.got_err = '1';
- assert arp_req_rslt.got_mac = '1' report "T6.1: expected got mac";
- assert arp_req_rslt.got_err = '0' report "T6.1: expected got err = 0";
- assert arp_req_rslt.mac = x"00231829267c" report "T6.1: wrong mac value";
- wait for clk_period*2;
-
- arp_req_req.ip <= x"c0a80503";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- arp_req_req.lookup_req <= '0';
- wait for clk_period;
- report "T6.2: wait for reply from store";
- wait until arp_req_rslt.got_mac = '1' or arp_req_rslt.got_err = '1';
- assert arp_req_rslt.got_mac = '1' report "T6.2: expected got mac";
- assert arp_req_rslt.got_err = '0' report "T6.2: expected got err = 0";
- assert arp_req_rslt.mac = x"021203230454" report "T6.2: wrong mac value";
- wait for clk_period*2;
-
- report "T7 - test that receipt of wrong I Have does not satisfy a current req";
- arp_req_req.ip <= x"c0a8050e";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- arp_req_req.lookup_req <= '0';
- report "T7: waiting for data_out_valid";
- wait until data_out_valid = '1';
- report "T7: got data_out_valid";
- wait for clk_period*10;
- data_out_ready <= '0';
- wait for clk_period*2;
- data_out_ready <= '1';
- wait for clk_period*12;
- assert data_out = x"01" report "T7: expected opcode = 01 for request 'who has'";
- -- expect our mac 00 23 20 21 22 23
- wait for clk_period;
- assert data_out = x"00" report "T7: incorrect our mac.0";
- wait for clk_period;
- assert data_out = x"23" report "T7: incorrect our mac.1";
- wait for clk_period;
- assert data_out = x"20" report "T7: incorrect our mac.2";
- wait for clk_period;
- assert data_out = x"21" report "T7: incorrect our mac.3";
- wait for clk_period;
- assert data_out = x"22" report "T7: incorrect our mac.4";
- wait for clk_period;
- assert data_out = x"23" report "T7: incorrect our mac.5";
- -- expect our IP c0 a8 05 05
- wait for clk_period;
- assert data_out = x"c0" report "T7: incorrect our IP.0";
- wait for clk_period;
- assert data_out = x"a8" report "T7: incorrect our IP.1";
- wait for clk_period;
- assert data_out = x"05" report "T7: incorrect our IP.2";
- wait for clk_period;
- assert data_out = x"09" report "T7: incorrect our IP.3";
-
- -- expect empty target mac
- wait for clk_period;
- assert data_out = x"00" report "T7: incorrect target mac.0";
- wait for clk_period;
- assert data_out = x"00" report "T7: incorrect target mac.1";
- wait for clk_period;
- assert data_out = x"00" report "T7: incorrect target mac.2";
- wait for clk_period;
- assert data_out = x"00" report "T7: incorrect target mac.3";
- wait for clk_period;
- assert data_out = x"00" report "T7: incorrect target mac.4";
- wait for clk_period;
- assert data_out = x"00" report "T7: incorrect target mac.5";
- -- expect target IP c0 a8 05 0e
- wait for clk_period;
- assert data_out = x"c0" report "T7: incorrect target IP.0";
- wait for clk_period;
- assert data_out = x"a8" report "T7: incorrect target IP.1";
- wait for clk_period;
- assert data_out = x"05" report "T7: incorrect target IP.2";
- assert data_out_last = '0' report "T7: data out last incorrectly set on target IP.2 byte";
- wait for clk_period;
- assert data_out = x"0e" report "T7: incorrect target IP.3";
- assert data_out_last = '1' report "T7: data out last should be set";
-
- wait for clk_period*10;
-
- -- Send the reply
- data_out_ready <= '1';
-
- report "T7.2: Send an arbitrary unwanted ARP reply: 192.168.7.3 has mac 57:12:34:19:23:9a";
- data_in_valid <= '1';
- -- dst MAC (bc)
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- -- src MAC
- data_in <= x"57"; wait for clk_period;
- data_in <= x"12"; wait for clk_period;
- data_in <= x"34"; wait for clk_period;
- data_in <= x"19"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"9a"; wait for clk_period;
- -- type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"06"; wait for clk_period;
- -- HW type
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Protocol type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- HW size
- data_in <= x"06"; wait for clk_period;
- -- protocol size
- data_in <= x"04"; wait for clk_period;
- -- Opcode
- data_in <= x"00"; wait for clk_period;
- data_in <= x"02"; wait for clk_period;
- -- Sender MAC
- data_in <= x"57"; wait for clk_period;
- data_in <= x"12"; wait for clk_period;
- data_in <= x"34"; wait for clk_period;
- data_in <= x"19"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"9a"; wait for clk_period;
- -- Sender IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"07"; wait for clk_period;
- data_in <= x"03"; wait for clk_period;
- -- Target MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"20"; wait for clk_period;
- data_in <= x"21"; wait for clk_period;
- data_in <= x"22"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- -- Target IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"09"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- assert arp_req_rslt.got_mac = '0' report "T7.2: expected got mac = 0";
- assert arp_req_rslt.got_err = '0' report "T7.2: expected got err = 0";
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '1';
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '0';
- data_in_valid <= '0';
- wait for clk_period*4;
-
- -- Send the reply
- data_out_ready <= '1';
-
- report "T7.3: Send a wanted ARP reply: 192.168.5.e has mac 76:34:98:55:aa:37";
- data_in_valid <= '1';
- -- dst MAC (bc)
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- -- src MAC
- data_in <= x"76"; wait for clk_period;
- data_in <= x"34"; wait for clk_period;
- data_in <= x"98"; wait for clk_period;
- data_in <= x"55"; wait for clk_period;
- data_in <= x"aa"; wait for clk_period;
- data_in <= x"37"; wait for clk_period;
- -- type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"06"; wait for clk_period;
- -- HW type
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Protocol type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- HW size
- data_in <= x"06"; wait for clk_period;
- -- protocol size
- data_in <= x"04"; wait for clk_period;
- -- Opcode
- data_in <= x"00"; wait for clk_period;
- data_in <= x"02"; wait for clk_period;
- -- Sender MAC
- data_in <= x"76"; wait for clk_period;
- data_in <= x"34"; wait for clk_period;
- data_in <= x"98"; wait for clk_period;
- data_in <= x"55"; wait for clk_period;
- data_in <= x"aa"; wait for clk_period;
- data_in <= x"37"; wait for clk_period;
- -- Sender IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"0e"; wait for clk_period;
- -- Target MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"20"; wait for clk_period;
- data_in <= x"21"; wait for clk_period;
- data_in <= x"22"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- -- Target IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"09"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- assert arp_req_rslt.got_mac = '1' report "T7.3: expected got mac";
- assert arp_req_rslt.got_err = '0' report "T7.3: expected got err = 0";
- assert arp_req_rslt.mac = x"76349855aa37" report "T7.3: wrong mac value";
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '1';
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '0';
- data_in_valid <= '0';
- wait for clk_period*4;
-
-
- report "T8: Request 192.168.5.4 (not cached), dont send a reply and wait for timeout";
- arp_req_req.ip <= x"c0a80504";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- arp_req_req.lookup_req <= '0';
- wait for clk_period*20;
- assert mac_tx_req = '1' report "T8: should be requesting TX channel";
- wait for clk_period*220;
- assert arp_req_rslt.got_mac = '0' report "T8: should not have got mac";
- assert arp_req_rslt.got_err = '1' report "T8: should have got err";
-
- report "T9: Request 192.168.5.7 (not cached= and Send an ARP reply: 192.168.5.7 has mac 02:15:03:23:04:54";
- arp_req_req.ip <= x"c0a80507";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- assert arp_req_rslt.got_mac = '0' report "T9: should not yet have mac";
- assert arp_req_rslt.got_err = '0' report "T9: should not have got err";
-
- arp_req_req.lookup_req <= '0';
- wait for clk_period*20;
- assert mac_tx_req = '1' report "T9: should be requesting TX channel";
- wait for clk_period*50;
- -- Send the reply
- data_out_ready <= '1';
-
- data_in_valid <= '1';
- -- dst MAC (bc)
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- -- src MAC
- data_in <= x"02"; wait for clk_period;
- data_in <= x"15"; wait for clk_period;
- data_in <= x"03"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"04"; wait for clk_period;
- data_in <= x"54"; wait for clk_period;
- -- type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"06"; wait for clk_period;
- -- HW type
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Protocol type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- HW size
- data_in <= x"06"; wait for clk_period;
- -- protocol size
- data_in <= x"04"; wait for clk_period;
- -- Opcode
- data_in <= x"00"; wait for clk_period;
- data_in <= x"02"; wait for clk_period;
- -- Sender MAC
- data_in <= x"02"; wait for clk_period;
- data_in <= x"15"; wait for clk_period;
- data_in <= x"03"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"04"; wait for clk_period;
- data_in <= x"54"; wait for clk_period;
- -- Sender IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"07"; wait for clk_period;
- -- Target MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"20"; wait for clk_period;
- data_in <= x"21"; wait for clk_period;
- data_in <= x"22"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- -- Target IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"09"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '1';
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '0';
- data_in_valid <= '0';
- wait for clk_period;
- assert arp_req_rslt.got_mac = '1' report "T9: should have got mac";
- assert arp_req_rslt.mac = x"021503230454" report "T9: incorrect mac";
- assert arp_req_rslt.got_err = '0' report "T9: should not have got err";
- wait for clk_period*10;
-
- report "T10: Request 192.168.5.7 again an expect it to be in the cache";
- arp_req_req.ip <= x"c0a80507";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- assert arp_req_rslt.got_mac = '1' report "T10: should have mac";
- assert arp_req_rslt.got_err = '0' report "T10: should not have got err";
-
- arp_req_req.lookup_req <= '0';
- wait for clk_period*20;
-
- report "T11: Clear the cache, Request 192.168.5.7 again an expect a 'who has' to be sent";
- control.clear_cache <= '1';
- wait for clk_period;
- control.clear_cache <= '0';
- wait for clk_period;
-
- arp_req_req.ip <= x"c0a80507";
- arp_req_req.lookup_req <= '1';
- wait for clk_period;
- assert arp_req_rslt.got_mac = '0' report "T11: should not yet have mac";
- assert arp_req_rslt.got_err = '0' report "T11: should not have got err";
-
- arp_req_req.lookup_req <= '0';
- wait for clk_period*20;
-
-
- assert mac_tx_req = '1' report "T11: should be requesting TX channel";
- wait for clk_period*50;
- -- Send the reply
- data_out_ready <= '1';
-
- data_in_valid <= '1';
- -- dst MAC (bc)
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- data_in <= x"ff"; wait for clk_period;
- -- src MAC
- data_in <= x"02"; wait for clk_period;
- data_in <= x"15"; wait for clk_period;
- data_in <= x"03"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"04"; wait for clk_period;
- data_in <= x"54"; wait for clk_period;
- -- type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"06"; wait for clk_period;
- -- HW type
- data_in <= x"00"; wait for clk_period;
- data_in <= x"01"; wait for clk_period;
- -- Protocol type
- data_in <= x"08"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- -- HW size
- data_in <= x"06"; wait for clk_period;
- -- protocol size
- data_in <= x"04"; wait for clk_period;
- -- Opcode
- data_in <= x"00"; wait for clk_period;
- data_in <= x"02"; wait for clk_period;
- -- Sender MAC
- data_in <= x"02"; wait for clk_period;
- data_in <= x"15"; wait for clk_period;
- data_in <= x"03"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"55"; wait for clk_period;
- data_in <= x"54"; wait for clk_period;
- -- Sender IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"07"; wait for clk_period;
- -- Target MAC
- data_in <= x"00"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- data_in <= x"20"; wait for clk_period;
- data_in <= x"21"; wait for clk_period;
- data_in <= x"22"; wait for clk_period;
- data_in <= x"23"; wait for clk_period;
- -- Target IP
- data_in <= x"c0"; wait for clk_period;
- data_in <= x"a8"; wait for clk_period;
- data_in <= x"05"; wait for clk_period;
- data_in <= x"09"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '1';
- data_in <= x"00"; wait for clk_period;
- data_in_last <= '0';
- data_in_valid <= '0';
- wait for clk_period;
- assert arp_req_rslt.got_mac = '1' report "T11: should have got mac";
- assert arp_req_rslt.mac = x"021503235554" report "T11: incorrect mac";
- assert arp_req_rslt.got_err = '0' report "T11: should not have got err";
- wait for clk_period*10;
-
- report "--- end of tests ---";
- wait;
- end process;
-
-END;
Index: udp_ip_stack/tags/v2.0/bench/vhdl/IPv4_RX_tb.vhd
===================================================================
--- udp_ip_stack/tags/v2.0/bench/vhdl/IPv4_RX_tb.vhd (revision 12)
+++ udp_ip_stack/tags/v2.0/bench/vhdl/IPv4_RX_tb.vhd (nonexistent)
@@ -1,391 +0,0 @@
---------------------------------------------------------------------------------
--- Company:
--- Engineer:
---
--- Create Date: 17:32:02 06/03/2011
--- Design Name:
--- Module Name: C:/Users/pjf/Documents/projects/fpga/xilinx/Network/ip1/IPv4_RX_tb.vhd
--- Project Name: ip1
--- Target Device:
--- Tool versions:
--- Description:
---
--- VHDL Test Bench Created by ISE for module: IPv4_RX
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Additional Comments:
---
--- Notes:
--- This testbench has been automatically generated using types std_logic and
--- std_logic_vector for the ports of the unit under test. Xilinx recommends
--- that these types always be used for the top-level I/O of a design in order
--- to guarantee that the testbench will bind correctly to the post-implementation
--- simulation model.
---------------------------------------------------------------------------------
-library IEEE;
-use IEEE.STD_LOGIC_1164.ALL;
-use IEEE.NUMERIC_STD.ALL;
-use work.axi.all;
-use work.ipv4_types.all;
-use work.arp_types.all;
-
-
-ENTITY IPv4_RX_tb IS
-END IPv4_RX_tb;
-
-ARCHITECTURE behavior OF IPv4_RX_tb IS
-
- -- Component Declaration for the Unit Under Test (UUT)
-
- COMPONENT IPv4_RX
- PORT(
- -- IP Layer signals
- ip_rx : out ipv4_rx_type;
- ip_rx_start : out std_logic; -- indicates receipt of ip frame.
- -- system signals
- clk : in STD_LOGIC; -- same clock used to clock mac data and ip data
- reset : in STD_LOGIC;
- our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
- -- MAC layer RX signals
- mac_data_in : in STD_LOGIC_VECTOR (7 downto 0); -- ethernet frame (from dst mac addr through to last byte of frame)
- mac_data_in_valid : in STD_LOGIC; -- indicates data_in valid on clock
- mac_data_in_last : in STD_LOGIC -- indicates last data in frame
- );
- END COMPONENT;
-
-
- --Inputs
- signal clk : std_logic := '0';
- signal reset : std_logic := '0';
- signal our_ip_address : std_logic_vector(31 downto 0) := (others => '0');
- signal mac_data_in : std_logic_vector(7 downto 0) := (others => '0');
- signal mac_data_in_valid : std_logic := '0';
- signal mac_data_in_last : std_logic := '0';
-
- --Outputs
- signal ip_rx_start : std_logic;
- signal ip_rx : ipv4_rx_type;
-
- -- Clock period definitions
- constant clk_period : time := 8 ns;
-
-BEGIN
-
- -- Instantiate the Unit Under Test (UUT)
- uut: IPv4_RX PORT MAP (
- ip_rx => ip_rx,
- ip_rx_start => ip_rx_start,
- clk => clk,
- reset => reset,
- our_ip_address => our_ip_address,
- mac_data_in => mac_data_in,
- mac_data_in_valid => mac_data_in_valid,
- mac_data_in_last => mac_data_in_last
- );
-
- -- Clock process definitions
- clk_process :process
- begin
- clk <= '0';
- wait for clk_period/2;
- clk <= '1';
- wait for clk_period/2;
- end process;
-
-
- -- Stimulus process
- stim_proc: process
- begin
- -- hold reset state for 100 ns.
- wait for 100 ns;
-
- our_ip_address <= x"c0a80509"; -- 192.168.5.9
- mac_data_in_valid <= '0';
- mac_data_in_last <= '0';
-
- reset <= '1';
- wait for clk_period*10;
- reset <= '0';
- wait for clk_period*5;
-
- -- check reset conditions
- assert ip_rx_start = '0' report "ip_rx_start not initialised correctly on reset";
- assert ip_rx.hdr.is_valid = '0' report "ip_rx.hdr.is_valid not initialised correctly on reset";
- assert ip_rx.hdr.protocol = x"00" report "ip_rx.hdr.protocol not initialised correctly on reset";
- assert ip_rx.hdr.data_length = x"0000" report "ip_rx.hdr.data_length not initialised correctly on reset";
- assert ip_rx.hdr.src_ip_addr = x"00000000" report "ip_rx.hdr.src_ip_addr not initialised correctly on reset";
- assert ip_rx.hdr.num_frame_errors = x"00" report "ip_rx.hdr.num_frame_errors not initialised correctly on reset";
- assert ip_rx.data.data_in = x"00" report "ip_rx.data.data_in not initialised correctly on reset";
- assert ip_rx.data.data_in_valid = '0' report "ip_rx.data.data_in_valid not initialised correctly on reset";
- assert ip_rx.data.data_in_last = '0' report "ip_rx.data.data_in_last not initialised correctly on reset";
-
- -- insert stimulus here
-
- ------------
- -- TEST 1 -- basic functional rx test with received ip pkt
- ------------
-
- report "T1: Send an eth frame with IP pkt dst ip_address c0a80509, dst mac 002320212223";
-
- mac_data_in_valid <= '1';
- -- dst MAC (bc)
- mac_data_in <= x"00"; wait for clk_period;
- mac_data_in <= x"23"; wait for clk_period;
- mac_data_in <= x"20"; wait for clk_period;
- mac_data_in <= x"21"; wait for clk_period;
- mac_data_in <= x"22"; wait for clk_period;
- mac_data_in <= x"23"; 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"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"09"; wait for clk_period;
-
- -- user data
- mac_data_in <= x"24"; wait for clk_period;
-
- assert ip_rx.hdr.is_valid = '1' report "T1: ip_rx.hdr.is_valid not set";
- assert ip_rx.hdr.protocol = x"11" report "T1: ip_rx.hdr.protocol not set correctly";
- assert ip_rx.hdr.data_length = x"0004" report "T1: ip_rx.hdr.data_length not set correctly";
- 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";
-
- 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 "T1: 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 "T1: ip_rx.data.data_in_valid not cleared";
- assert ip_rx.data.data_in_last = '0' report "T1: ip_rx.data.data_in_last not cleared";
- assert ip_rx.hdr.num_frame_errors = x"00" report "T1: ip_rx.hdr.num_frame_errors non zero at end of test";
- assert ip_rx.hdr.last_error_code = x"0" report "T1: ip_rx.hdr.last_error_code indicates error at end of test";
- assert ip_rx_start = '0' report "T1: ip_rx_start not cleared";
-
- ------------
- -- TEST 2 -- basic functional rx test with received ip pkt that is not for us
- ------------
-
- report "T2: Send an eth frame with IP pkt dst ip_address c0a80507, dst mac 002320212223";
-
- mac_data_in_valid <= '1';
- -- dst MAC (bc)
- mac_data_in <= x"00"; wait for clk_period;
- mac_data_in <= x"23"; wait for clk_period;
- mac_data_in <= x"20"; wait for clk_period;
- mac_data_in <= x"21"; wait for clk_period;
- mac_data_in <= x"22"; wait for clk_period;
- mac_data_in <= x"23"; wait for clk_period;
-
- assert ip_rx.hdr.is_valid = '0' report "T2: ip_rx.hdr.is_valid remains set";
-
- -- 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"02"; wait for clk_period;
- -- DST 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"07"; wait for clk_period;
-
- -- user data
- mac_data_in <= x"24"; wait for clk_period;
-
- assert ip_rx.hdr.is_valid = '1' report "T2: ip_rx.hdr.is_valid not set";
- assert ip_rx.hdr.protocol = x"11" report "T2: ip_rx.hdr.protocol not set correctly";
- 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";
-
- 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 = '0' report "T2: ip_rx.data.data_in_last 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 "T2: ip_rx.data.data_in_valid not cleared";
- assert ip_rx.data.data_in_last = '0' report "T2: ip_rx.data.data_in_last not cleared";
- assert ip_rx.hdr.num_frame_errors = x"00" report "T2: ip_rx.hdr.num_frame_errors non zero at end of test";
- 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;
- end process;
-
-END;