| 1 |
2 |
pjf |
--------------------------------------------------------------------------------
|
| 2 |
|
|
-- Company:
|
| 3 |
|
|
-- Engineer:
|
| 4 |
|
|
--
|
| 5 |
|
|
-- Create Date: 18:43:49 06/10/2011
|
| 6 |
|
|
-- Design Name:
|
| 7 |
|
|
-- Module Name: C:/Users/pjf/Documents/projects/fpga/xilinx/Network/ip1/UDP_TX_tb.vhd
|
| 8 |
|
|
-- Project Name: ip1
|
| 9 |
|
|
-- Target Device:
|
| 10 |
|
|
-- Tool versions:
|
| 11 |
|
|
-- Description:
|
| 12 |
|
|
--
|
| 13 |
|
|
-- VHDL Test Bench Created by ISE for module: UDP_TX
|
| 14 |
|
|
--
|
| 15 |
|
|
-- Dependencies:
|
| 16 |
|
|
--
|
| 17 |
|
|
-- Revision:
|
| 18 |
|
|
-- Revision 0.01 - File Created
|
| 19 |
|
|
-- Additional Comments:
|
| 20 |
|
|
--
|
| 21 |
|
|
-- Notes:
|
| 22 |
|
|
-- This testbench has been automatically generated using types std_logic and
|
| 23 |
|
|
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
|
| 24 |
|
|
-- that these types always be used for the top-level I/O of a design in order
|
| 25 |
|
|
-- to guarantee that the testbench will bind correctly to the post-implementation
|
| 26 |
|
|
-- simulation model.
|
| 27 |
|
|
--------------------------------------------------------------------------------
|
| 28 |
|
|
library IEEE;
|
| 29 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
| 30 |
|
|
use IEEE.NUMERIC_STD.ALL;
|
| 31 |
|
|
use work.axi.all;
|
| 32 |
|
|
use work.ipv4_types.all;
|
| 33 |
|
|
|
| 34 |
|
|
ENTITY UDP_TX_tb IS
|
| 35 |
|
|
END UDP_TX_tb;
|
| 36 |
|
|
|
| 37 |
|
|
ARCHITECTURE behavior OF UDP_TX_tb IS
|
| 38 |
|
|
|
| 39 |
|
|
-- Component Declaration for the Unit Under Test (UUT)
|
| 40 |
|
|
|
| 41 |
|
|
COMPONENT UDP_TX
|
| 42 |
|
|
PORT(
|
| 43 |
|
|
-- UDP Layer signals
|
| 44 |
|
|
udp_tx_start : in std_logic; -- indicates req to tx UDP
|
| 45 |
|
|
udp_txi : in udp_tx_type; -- UDP tx cxns
|
| 46 |
|
|
udp_tx_result : out std_logic_vector (1 downto 0);-- tx status (changes during transmission)
|
| 47 |
|
|
udp_tx_data_out_ready: out std_logic; -- indicates udp_tx is ready to take data
|
| 48 |
|
|
-- system signals
|
| 49 |
|
|
clk : in STD_LOGIC; -- same clock used to clock mac data and ip data
|
| 50 |
|
|
reset : in STD_LOGIC;
|
| 51 |
|
|
-- IP layer TX signals
|
| 52 |
|
|
ip_tx_start : out std_logic;
|
| 53 |
|
|
ip_tx : out ipv4_tx_type; -- IP tx cxns
|
| 54 |
|
|
ip_tx_result : in std_logic_vector (1 downto 0); -- tx status (changes during transmission)
|
| 55 |
|
|
ip_tx_data_out_ready : in std_logic -- indicates IP TX is ready to take data
|
| 56 |
|
|
);
|
| 57 |
|
|
END COMPONENT;
|
| 58 |
|
|
|
| 59 |
|
|
|
| 60 |
|
|
--Inputs
|
| 61 |
|
|
signal udp_tx_start : std_logic := '0';
|
| 62 |
|
|
signal clk : std_logic := '0';
|
| 63 |
|
|
signal reset : std_logic := '0';
|
| 64 |
|
|
signal udp_txi : udp_tx_type;
|
| 65 |
|
|
signal ip_tx_result : std_logic_vector (1 downto 0); -- tx status (changes during transmission)
|
| 66 |
|
|
signal ip_tx_data_out_ready : std_logic; -- indicates IP TX is ready to take data
|
| 67 |
|
|
|
| 68 |
|
|
--Outputs
|
| 69 |
|
|
signal ip_tx_start : std_logic := '0';
|
| 70 |
|
|
signal ip_tx : ipv4_tx_type;
|
| 71 |
|
|
signal udp_tx_result : std_logic_vector (1 downto 0);
|
| 72 |
|
|
signal udp_tx_data_out_ready : std_logic;
|
| 73 |
|
|
|
| 74 |
|
|
-- Clock period definitions
|
| 75 |
|
|
constant clk_period : time := 8 ns;
|
| 76 |
|
|
|
| 77 |
|
|
BEGIN
|
| 78 |
|
|
|
| 79 |
|
|
-- Instantiate the Unit Under Test (UUT)
|
| 80 |
|
|
uut: UDP_TX PORT MAP (
|
| 81 |
|
|
udp_tx_start => udp_tx_start,
|
| 82 |
|
|
udp_txi => udp_txi,
|
| 83 |
|
|
udp_tx_result => udp_tx_result,
|
| 84 |
|
|
udp_tx_data_out_ready => udp_tx_data_out_ready,
|
| 85 |
|
|
clk => clk,
|
| 86 |
|
|
reset => reset,
|
| 87 |
|
|
ip_tx_start => ip_tx_start,
|
| 88 |
|
|
ip_tx => ip_tx,
|
| 89 |
|
|
ip_tx_result => ip_tx_result,
|
| 90 |
|
|
ip_tx_data_out_ready => ip_tx_data_out_ready
|
| 91 |
|
|
);
|
| 92 |
|
|
|
| 93 |
|
|
|
| 94 |
|
|
-- Clock process definitions
|
| 95 |
|
|
clk_process :process
|
| 96 |
|
|
begin
|
| 97 |
|
|
clk <= '0';
|
| 98 |
|
|
wait for clk_period/2;
|
| 99 |
|
|
clk <= '1';
|
| 100 |
|
|
wait for clk_period/2;
|
| 101 |
|
|
end process;
|
| 102 |
|
|
|
| 103 |
|
|
|
| 104 |
|
|
-- Stimulus process
|
| 105 |
|
|
stim_proc: process
|
| 106 |
|
|
begin
|
| 107 |
|
|
-- hold reset state for 100 ns.
|
| 108 |
|
|
wait for 100 ns;
|
| 109 |
|
|
|
| 110 |
|
|
udp_tx_start <= '0';
|
| 111 |
|
|
|
| 112 |
|
|
udp_txi.hdr.dst_ip_addr <= (others => '0');
|
| 113 |
|
|
udp_txi.hdr.dst_port <= (others => '0');
|
| 114 |
|
|
udp_txi.hdr.src_port <= (others => '0');
|
| 115 |
|
|
udp_txi.hdr.data_length <= (others => '0');
|
| 116 |
|
|
udp_txi.hdr.checksum <= (others => '0');
|
| 117 |
|
|
udp_txi.data.data_out_last <= '0';
|
| 118 |
|
|
|
| 119 |
|
|
reset <= '1';
|
| 120 |
|
|
wait for clk_period*10;
|
| 121 |
|
|
reset <= '0';
|
| 122 |
|
|
wait for clk_period*5;
|
| 123 |
|
|
|
| 124 |
|
|
-- check reset conditions
|
| 125 |
|
|
|
| 126 |
|
|
assert ip_tx_start = '0' report "ip_tx_start not initialised correctly on reset";
|
| 127 |
|
|
assert ip_tx.data.data_out_valid = '0' report "ip_tx.data.data_out_valid not initialised correctly on reset";
|
| 128 |
|
|
assert ip_tx.data.data_out_last = '0' report "ip_tx.data.data_out_last not initialised correctly on reset";
|
| 129 |
|
|
assert udp_tx_result = UDPTX_RESULT_NONE report "udp_tx_result not initialised correctly on reset";
|
| 130 |
|
|
|
| 131 |
|
|
-- insert stimulus here
|
| 132 |
|
|
|
| 133 |
|
|
wait for clk_period*5;
|
| 134 |
|
|
|
| 135 |
|
|
------------
|
| 136 |
|
|
-- TEST 1 -- basic functional tx test
|
| 137 |
|
|
------------
|
| 138 |
|
|
|
| 139 |
|
|
report "T1: basic functional tx test - send 56, 57, 58 to port 8532";
|
| 140 |
|
|
|
| 141 |
|
|
udp_txi.hdr.dst_ip_addr <= x"c0123478";
|
| 142 |
|
|
udp_txi.hdr.dst_port <= x"1467";
|
| 143 |
|
|
udp_txi.hdr.src_port <= x"8532";
|
| 144 |
|
|
udp_txi.hdr.data_length <= x"0003";
|
| 145 |
|
|
|
| 146 |
|
|
udp_tx_start <= '1';
|
| 147 |
|
|
ip_tx_data_out_ready <= '1'; -- IP layer can accept data
|
| 148 |
|
|
wait for clk_period;
|
| 149 |
|
|
udp_tx_start <= '0'; wait for clk_period;
|
| 150 |
|
|
ip_tx_result <= IPTX_RESULT_NONE;
|
| 151 |
|
|
|
| 152 |
|
|
assert udp_tx_result = UDPTX_RESULT_SENDING report "T1: result should be UDPTX_RESULT_SENDING";
|
| 153 |
|
|
|
| 154 |
|
|
wait until udp_tx_data_out_ready = '1';
|
| 155 |
|
|
|
| 156 |
|
|
-- start to tx IP data
|
| 157 |
|
|
udp_txi.data.data_out_valid <= '1';
|
| 158 |
|
|
udp_txi.data.data_out <= x"56"; wait for clk_period;
|
| 159 |
|
|
udp_txi.data.data_out <= x"57"; wait for clk_period;
|
| 160 |
|
|
|
| 161 |
|
|
udp_txi.data.data_out <= x"58";
|
| 162 |
|
|
udp_txi.data.data_out_last <= '1';
|
| 163 |
|
|
wait for clk_period;
|
| 164 |
|
|
|
| 165 |
|
|
assert ip_tx.data.data_out_last = '1' report "T1: ip_tx.datda_out_last not set on last byte";
|
| 166 |
|
|
|
| 167 |
|
|
udp_txi.data.data_out_valid <= '0';
|
| 168 |
|
|
udp_txi.data.data_out_last <= '0';
|
| 169 |
|
|
wait for clk_period*2;
|
| 170 |
|
|
ip_tx_result <= IPTX_RESULT_SENT;
|
| 171 |
|
|
|
| 172 |
|
|
assert udp_tx_result = UDPTX_RESULT_SENT report "T1: result should be UDPTX_RESULT_SENT";
|
| 173 |
|
|
wait for clk_period*2;
|
| 174 |
|
|
|
| 175 |
|
|
------------
|
| 176 |
|
|
-- TEST 2 -- 2nd pkt
|
| 177 |
|
|
------------
|
| 178 |
|
|
|
| 179 |
|
|
report "T2: send a second pkt - 56,57,58,59 to port 8532";
|
| 180 |
|
|
|
| 181 |
|
|
udp_txi.hdr.dst_ip_addr <= x"c0123475";
|
| 182 |
|
|
udp_txi.hdr.dst_port <= x"1467";
|
| 183 |
|
|
udp_txi.hdr.src_port <= x"8532";
|
| 184 |
|
|
udp_txi.hdr.data_length <= x"0005";
|
| 185 |
|
|
|
| 186 |
|
|
udp_tx_start <= '1';
|
| 187 |
|
|
ip_tx_data_out_ready <= '1'; -- IP layer can accept data
|
| 188 |
|
|
wait for clk_period;
|
| 189 |
|
|
udp_tx_start <= '0'; wait for clk_period;
|
| 190 |
|
|
|
| 191 |
|
|
assert udp_tx_result = UDPTX_RESULT_SENDING report "T1: result should be UDPTX_RESULT_SENDING";
|
| 192 |
|
|
|
| 193 |
|
|
wait until udp_tx_data_out_ready = '1';
|
| 194 |
|
|
|
| 195 |
|
|
-- start to tx IP data
|
| 196 |
|
|
udp_txi.data.data_out_valid <= '1';
|
| 197 |
|
|
udp_txi.data.data_out <= x"56"; wait for clk_period;
|
| 198 |
|
|
udp_txi.data.data_out <= x"57"; wait for clk_period;
|
| 199 |
|
|
udp_txi.data.data_out <= x"58"; wait for clk_period;
|
| 200 |
|
|
udp_txi.data.data_out <= x"59"; wait for clk_period;
|
| 201 |
|
|
|
| 202 |
|
|
udp_txi.data.data_out <= x"5a";
|
| 203 |
|
|
udp_txi.data.data_out_last <= '1';
|
| 204 |
|
|
wait for clk_period;
|
| 205 |
|
|
assert ip_tx.data.data_out_last = '1' report "T1: ip_tx.datda_out_last not set on last byte";
|
| 206 |
|
|
|
| 207 |
|
|
udp_txi.data.data_out_valid <= '0';
|
| 208 |
|
|
udp_txi.data.data_out_last <= '0';
|
| 209 |
|
|
wait for clk_period*2;
|
| 210 |
|
|
|
| 211 |
|
|
assert udp_tx_result = UDPTX_RESULT_SENT report "T1: result should be UDPTX_RESULT_SENT";
|
| 212 |
|
|
wait for clk_period*2;
|
| 213 |
|
|
|
| 214 |
|
|
report "--- end of tests ---";
|
| 215 |
|
|
|
| 216 |
|
|
wait;
|
| 217 |
|
|
end process;
|
| 218 |
|
|
|
| 219 |
|
|
END;
|