URL
https://opencores.org/ocsvn/udp_ip_stack/udp_ip_stack/trunk
Subversion Repositories udp_ip_stack
Compare Revisions
- This comparison shows the changes necessary to convert path
/udp_ip_stack/trunk/bench/vhdl
- from Rev 11 to Rev 18
- ↔ Reverse comparison
Rev 11 → Rev 18
/arpv2_tb.vhd
16,7 → 16,7
-- |
-- Revision: |
-- Revision 0.01 - File Created |
-- Revision 0.02 - Added tests for ARP timeout |
-- Revision 0.02 - Added tests for ARP timeout |
-- Additional Comments: |
-- |
-- Notes: |
26,931 → 26,1109
-- 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; |
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; |
|
entity arpv2_tb is |
end arpv2_tb; |
|
architecture behavior of arpv2_tb is |
|
-- Component Declaration for the Unit Under Test (UUT) |
|
component arpv2 |
generic ( |
no_default_gateway : boolean := true; |
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); |
nwk_gateway : in std_logic_vector (31 downto 0); -- IP address of default gateway |
nwk_mask : in std_logic_vector (31 downto 0); -- Net mask |
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 nwk_gateway : std_logic_vector(31 downto 0) := (others => '0'); |
signal nwk_mask : 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; |
|
constant no_default_gateway : boolean := false; |
|
-- Clock period definitions |
constant clk_period : time := 8 ns; |
|
begin |
|
-- Instantiate the Unit Under Test (UUT) |
uut : arpv2 |
generic map ( |
no_default_gateway => no_default_gateway, |
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, |
nwk_gateway => nwk_gateway, |
nwk_mask => nwk_mask, |
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 |
nwk_mask <= x"FFFFFF00"; |
nwk_gateway <= x"c0a80501"; -- 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"; |
|
wait until clk = '1'; |
|
-- insert stimulus here |
arp_req_req.lookup_req <= '0'; |
arp_req_req.ip <= (others => '0'); |
data_out_ready <= '1'; |
|
--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 |
); |
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'; |
|
-- Clock process definitions |
clk_process :process |
begin |
clk <= '0'; |
wait for clk_period/2; |
clk <= '1'; |
wait for clk_period/2; |
end process; |
|
report "T1: Expect that we send an 'I have 192.168.5.9' msg"; |
|
-- Stimulus process |
stim_proc: process |
begin |
-- hold reset state for 100 ns. |
wait for 100 ns; |
-- check tx arbitration signals |
|
our_ip_address <= x"c0a80509"; -- 192.168.5.9 |
our_mac_address <= x"002320212223"; |
mac_tx_granted <= '1'; -- FIXME 0 |
control.clear_cache <= '0'; |
report "T1: waiting for tx req"; |
wait until mac_tx_req = '1'; |
|
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"; |
-- 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"; |
|
-- insert stimulus here |
arp_req_req.lookup_req <= '0'; |
arp_req_req.ip <= (others => '0'); |
data_out_ready <= '1'; |
-- 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"; |
|
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'; |
wait for clk_period*10; |
|
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 "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'; |
|
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'; |
-- ready to tx |
wait for clk_period*10; |
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'; |
wait for clk_period*50; |
|
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'; |
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; |
|
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; |
-- 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"; |
|
END; |
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"ff" report "T5: incorrect target mac.0"; |
wait for clk_period; |
assert data_out = x"ff" report "T5: incorrect target mac.1"; |
wait for clk_period; |
assert data_out = x"ff" report "T5: incorrect target mac.2"; |
wait for clk_period; |
assert data_out = x"ff" report "T5: incorrect target mac.3"; |
wait for clk_period; |
assert data_out = x"ff" report "T5: incorrect target mac.4"; |
wait for clk_period; |
assert data_out = x"ff" 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"ff" report "T7: incorrect target mac.0"; |
wait for clk_period; |
assert data_out = x"ff" report "T7: incorrect target mac.1"; |
wait for clk_period; |
assert data_out = x"ff" report "T7: incorrect target mac.2"; |
wait for clk_period; |
assert data_out = x"ff" report "T7: incorrect target mac.3"; |
wait for clk_period; |
assert data_out = x"ff" report "T7: incorrect target mac.4"; |
wait for clk_period; |
assert data_out = x"ff" 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.5.143 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"25"; wait for clk_period; |
data_in <= x"93"; 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; |
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_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; |
|
-- |
wait until clk = '1'; |
report "T11 - Send a request for the IP that is not on the local network"; |
arp_req_req.ip <= x"0a000003"; --c0a80501 |
arp_req_req.lookup_req <= '1'; |
wait until clk = '1'; --for clk_period |
arp_req_req.lookup_req <= '0'; |
report "T11: 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 "T11: expected got mac"; |
assert arp_req_rslt.got_err = '0' report "T11: expected got err = 0"; |
assert arp_req_rslt.mac = x"00231829267c" report "T11: wrong mac value";-- severity failure; |
wait for clk_period*2; |
-- |
|
report "T12: 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 "T12: should not yet have mac"; |
assert arp_req_rslt.got_err = '0' report "T12: should not have got err"; |
|
arp_req_req.lookup_req <= '0'; |
wait for clk_period*20; |
|
|
assert mac_tx_req = '1' report "T12: 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 "T12: should have got mac"; |
assert arp_req_rslt.mac = x"021503235554" report "T12: incorrect mac"; |
assert arp_req_rslt.got_err = '0' report "T12: should not have got err"; |
wait for clk_period*10; |
|
-- |
report "T13 - Send a request for the IP that is not on the local network"; |
arp_req_req.ip <= x"0a000003"; |
arp_req_req.lookup_req <= '1'; |
wait for clk_period; |
arp_req_req.lookup_req <= '0'; |
report "T13: waiting for data_out_valid"; |
wait until data_out_valid = '1'; |
report "T13: 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 "T13: 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 "T13: incorrect our mac.0"; |
wait for clk_period; |
assert data_out = x"23" report "T13: incorrect our mac.1"; |
wait for clk_period; |
assert data_out = x"20" report "T13: incorrect our mac.2"; |
wait for clk_period; |
assert data_out = x"21" report "T13: incorrect our mac.3"; |
wait for clk_period; |
assert data_out = x"22" report "T13: incorrect our mac.4"; |
wait for clk_period; |
assert data_out = x"23" report "T13: incorrect our mac.5"; |
-- expect our IP c0 a8 05 05 |
wait for clk_period; |
assert data_out = x"c0" report "T13: incorrect our IP.0"; |
wait for clk_period; |
assert data_out = x"a8" report "T13: incorrect our IP.1"; |
wait for clk_period; |
assert data_out = x"05" report "T13: incorrect our IP.2"; |
wait for clk_period; |
assert data_out = x"09" report "T13: incorrect our IP.3"; |
|
-- expect empty target mac |
wait for clk_period; |
assert data_out = x"ff" report "T13: incorrect target mac.0"; |
wait for clk_period; |
assert data_out = x"ff" report "T13: incorrect target mac.1"; |
wait for clk_period; |
assert data_out = x"ff" report "T13: incorrect target mac.2"; |
wait for clk_period; |
assert data_out = x"ff" report "T13: incorrect target mac.3"; |
wait for clk_period; |
assert data_out = x"ff" report "T13: incorrect target mac.4"; |
wait for clk_period; |
assert data_out = x"ff" report "T13: incorrect target mac.5"; |
-- expect target IP c0 a8 05 01 |
wait for clk_period; |
assert data_out = x"c0" report "T13: incorrect target IP.0"; |
wait for clk_period; |
assert data_out = x"a8" report "T13: incorrect target IP.1"; |
wait for clk_period; |
assert data_out = x"05" report "T13: incorrect target IP.2"; |
assert data_out_last = '0' report "T13: data out last incorrectly set on target IP.2 byte"; |
wait for clk_period; |
assert data_out = x"01" report "T13: incorrect target IP.3"; |
assert data_out_last = '1' report "T13: data out last should be set"; |
|
wait for clk_period*10; |
|
-- Send the reply |
data_out_ready <= '1'; |
|
report "T13.2: Send an ARP reply: 192.168.5.1 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"01"; 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 "T13.2: expected got mac"; |
assert arp_req_rslt.got_err = '0' report "T13.2: expected got err = 0"; |
assert arp_req_rslt.mac = x"021203230454" report "T13.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 "T14 - Send a request for an other IP that is not on the local network"; |
arp_req_req.ip <= x"0a000204"; |
arp_req_req.lookup_req <= '1'; |
wait for clk_period; |
arp_req_req.lookup_req <= '0'; |
report "T14: reply should be from cache"; |
-- wait until arp_req_rslt.got_mac = '1' or arp_req_rslt.got_err = '1'; |
assert arp_req_rslt.got_mac = '1' report "T14: expected got mac"; |
assert arp_req_rslt.got_err = '0' report "T14: expected got err = 0"; |
assert arp_req_rslt.mac = x"021203230454" report "T14: wrong mac value"; |
wait for clk_period*2; |
-- |
|
|
report "--- end of tests ---"; |
wait; |
end process; |
|
end; |
/IPv4_TX_tb.vhd
1,363 → 1,363
-------------------------------------------------------------------------------- |
-- 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'); |
-------------------------------------------------------------------------------- |
-- 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; |
|
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; |
|
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 until clk = '1'; |
wait for clk_period*5; |
wait until clk = '1'; |
|
-- 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 until clk = '1'; |
ip_tx_start <= '0'; |
arp_req_rslt.got_mac <= '0'; |
arp_req_rslt.got_err <= '0'; |
|
wait until clk = '1'; |
assert arp_req_req.lookup_req = '1' report "T1: lookup_req not set on tx start"; |
assert ip_tx_result = IPTX_RESULT_SENDING report "T1: result should be IPTX_RESULT_SENDING"; |
|
wait for clk_period*10; -- simulate arp lookup time |
wait until clk = '1'; |
arp_req_rslt.mac <= x"050423271016"; |
arp_req_rslt.got_mac <= '1'; |
|
wait until clk = '1'; |
wait until clk = '1'; |
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 |
wait until clk = '1'; |
mac_tx_granted <= '1'; |
wait until clk = '1'; wait until clk = '1'; mac_data_out_ready <= '1'; |
assert mac_data_out_valid = '0' report "T1: mac_data_out_valid asserted too early"; |
|
wait until clk = '1'; |
|
assert ip_tx_data_out_ready = '0' report "T1: IP data out ready asserted too early"; |
wait until clk = '1'; |
assert mac_data_out_valid = '1' report "T1: mac_data_out_valid not asserted"; |
|
-- wait until in eth hdr |
wait for clk_period*3; |
wait until clk = '1'; |
-- go mac not ready for 2 clocks |
mac_data_out_ready <= '0'; |
wait until clk = '1'; wait until clk = '1'; wait until clk = '1'; |
mac_data_out_ready <= '1'; |
|
|
wait until ip_tx_data_out_ready = '1'; |
wait until clk = '1'; |
|
-- start to tx IP data |
ip_tx.data.data_out_valid <= '1'; |
ip_tx.data.data_out <= x"56"; wait until clk = '1'; |
-- delay data in for 1 clk cycle |
ip_tx.data.data_out_valid <= '0'; |
ip_tx.data.data_out <= x"57"; wait until clk = '1'; |
ip_tx.data.data_out_valid <= '1'; wait until clk = '1'; |
ip_tx.data.data_out <= x"58"; wait until clk = '1'; |
ip_tx.data.data_out <= x"59"; wait until clk = '1'; |
--wait for clk_period; |
|
-- delay mac ready for 2 clk cycles |
mac_data_out_ready <= '0'; |
ip_tx.data.data_out <= x"5a"; wait until clk = '1'; |
--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 until clk = '1'; |
--wait for clk_period; |
mac_data_out_ready <= '1'; |
wait until ip_tx_data_out_ready = '1'; |
wait until clk = '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 until clk = '1'; |
ip_tx.data.data_out <= x"5c"; wait until clk = '1'; |
|
ip_tx.data.data_out <= x"5d"; |
ip_tx.data.data_out_last <= '1'; |
wait until clk = '1'; |
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 until clk = '1'; wait until clk = '1'; |
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 until clk = '1'; wait until clk = '1'; |
------------ |
-- 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 until clk = '1'; |
ip_tx_start <= '0'; wait until clk = '1'; |
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 until clk = '1'; -- simulate arp lookup time |
arp_req_rslt.mac <= x"050423271016"; |
arp_req_rslt.got_mac <= '1'; |
|
wait until clk = '1'; wait until clk = '1'; |
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 until clk = '1'; -- simulate mac chn access time |
mac_tx_granted <= '1'; |
wait until clk = '1'; wait until clk = '1'; 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 until clk = '1'; |
ip_tx.data.data_out <= x"c2"; wait until clk = '1'; |
ip_tx.data.data_out <= x"c3"; wait until clk = '1'; |
ip_tx.data.data_out <= x"c4"; wait until clk = '1'; |
ip_tx.data.data_out <= x"c5"; wait until clk = '1'; |
|
ip_tx.data.data_out <= x"c6"; |
ip_tx.data.data_out_last <= '1'; |
wait until clk = '1'; |
|
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 until clk = '1'; wait until clk = '1'; |
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 until clk = '1'; wait until clk = '1'; |
------------ |
-- 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 until clk = '1'; |
ip_tx_start <= '0'; wait until clk = '1'; |
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 until clk = '1'; -- simulate mac chn access time |
mac_tx_granted <= '1'; |
wait until clk = '1'; wait until clk = '1'; 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 until clk = '1'; |
ip_tx.data.data_out <= x"c2"; wait until clk = '1'; |
ip_tx.data.data_out <= x"c3"; wait until clk = '1'; |
ip_tx.data.data_out <= x"c4"; wait until clk = '1'; |
ip_tx.data.data_out <= x"c5"; wait until clk = '1'; |
|
ip_tx.data.data_out <= x"c6"; |
ip_tx.data.data_out_last <= '1'; |
wait until clk = '1'; |
|
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 until clk = '1'; wait until clk = '1'; |
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 until clk = '1'; wait until clk = '1'; |
|
report "--- end of tests ---"; |
|
wait; |
end process; |
|
end; |
/UDP_complete_nomac_tb.vhd
1016,12 → 1016,12
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"ff" report "T6: incorrect trg mac 0"; wait for clk_period; |
assert mac_tx_tdata = x"ff" report "T6: incorrect trg mac 1"; wait for clk_period; |
assert mac_tx_tdata = x"ff" report "T6: incorrect trg mac 2"; wait for clk_period; |
assert mac_tx_tdata = x"ff" report "T6: incorrect trg mac 3"; wait for clk_period; |
assert mac_tx_tdata = x"ff" report "T6: incorrect trg mac 4"; wait for clk_period; |
assert mac_tx_tdata = x"ff" 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; |
1146,141 → 1146,8
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; |
-- there should be no ARP exchange as this entry should already be cached. |
|
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'; |
1289,12 → 1156,12
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 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; |
/arp_STORE_tb.vhd
120,7 → 120,7
assert read_result.status = NOT_FOUND report "T1: expected NOT_FOUND"; |
wait for clk_period; |
read_req.req <= '0'; |
wait for clk_period; |
wait for clk_period*2; |
assert read_result.status = IDLE report "T1: expected IDLE"; |
assert entry_count = x"00" report "T1: wrong entry count"; |
|
144,7 → 144,7
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; |
wait for clk_period*3; |
assert read_result.status = IDLE report "T3: expected IDLE"; |
|
report "T4 - check unable to find missing entry with one entry in store"; |
155,7 → 155,7
assert read_result.status = NOT_FOUND report "T4: expected NOT_FOUND"; |
wait for clk_period; |
read_req.req <= '0'; |
wait for clk_period*2; |
wait for clk_period*3; |
assert read_result.status = IDLE report "T4: expected IDLE"; |
|
report "T5 - insert 2nd entry into store and check can find both entries"; |
175,7 → 175,7
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; |
wait for clk_period*3; |
assert read_result.status = IDLE report "T5.1: expected IDLE"; |
read_req.ip <= x"12345679"; |
read_req.req <= '1'; |
185,7 → 185,7
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; |
wait for clk_period*3; |
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"; |
212,7 → 212,7
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; |
wait for clk_period*3; |
assert read_result.status = IDLE report "T6.1: expected IDLE"; |
read_req.ip <= x"12345679"; |
read_req.req <= '1'; |
222,7 → 222,7
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; |
wait for clk_period*3; |
assert read_result.status = IDLE report "T6.2: expected IDLE"; |
read_req.ip <= x"1234567a"; |
read_req.req <= '1'; |
232,7 → 232,7
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; |
wait for clk_period*3; |
assert read_result.status = IDLE report "T6.3: expected IDLE"; |
read_req.ip <= x"1234567b"; |
read_req.req <= '1'; |
242,7 → 242,7
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; |
wait for clk_period*3; |
assert read_result.status = IDLE report "T6.4: expected IDLE"; |
|
report "T7 - with store full, check that we dont find missing item"; |
252,7 → 252,7
wait for clk_period; |
assert read_result.status = NOT_FOUND report "T7: expected NOT_FOUND"; |
read_req.req <= '0'; |
wait for clk_period*2; |
wait for clk_period*3; |
assert read_result.status = IDLE report "T7: expected IDLE"; |
|
report "T8 - insert additional entry into store - will erase one of the others"; |
272,7 → 272,7
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; |
wait for clk_period*3; |
assert read_result.status = IDLE report "T8: expected IDLE"; |
|
report "T9 - clear the store and ensure cant find something that was there"; |
287,7 → 287,7
wait for clk_period; |
assert read_result.status = NOT_FOUND report "T9: expected NOT_FOUND"; |
read_req.req <= '0'; |
wait for clk_period*2; |
wait for clk_period*3; |
assert read_result.status = IDLE report "T9: expected IDLE"; |
|
report "T10 - refill the store with three entries"; |
323,7 → 323,7
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; |
wait for clk_period*3; |
assert read_result.status = IDLE report "T11.1: expected IDLE"; |
write_req.entry.ip <= x"12345676"; |
write_req.entry.mac <= x"10120990340b"; |
340,7 → 340,7
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; |
wait for clk_period*3; |
assert read_result.status = IDLE report "T11.2: expected IDLE"; |
|
report "T12 - check 2nd write at beginning"; |
374,7 → 374,7
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; |
wait for clk_period*3; |
assert read_result.status = IDLE report "T12.5: expected IDLE"; |
|
report "--- end of tests ---"; |
/UDP_av2_complete_nomac_tb.vhd
1016,12 → 1016,12
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"FF" report "T6: incorrect trg mac 0"; wait for clk_period; |
assert mac_tx_tdata = x"FF" report "T6: incorrect trg mac 1"; wait for clk_period; |
assert mac_tx_tdata = x"FF" report "T6: incorrect trg mac 2"; wait for clk_period; |
assert mac_tx_tdata = x"FF" report "T6: incorrect trg mac 3"; wait for clk_period; |
assert mac_tx_tdata = x"FF" report "T6: incorrect trg mac 4"; wait for clk_period; |
assert mac_tx_tdata = x"FF" 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; |