summaryrefslogtreecommitdiff
path: root/netfpga10g/tests/eth_tx_test.vhd
blob: 0697b84e2a81f4b50a291286c08b73321e321101 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
 
ENTITY eth_tx_test IS
END eth_tx_test;
 
ARCHITECTURE behavior OF eth_tx_test IS 

        -- Component Declaration for the Unit Under Test (UUT)
 
        COMPONENT eth_tx
        PORT(
         clk : IN  std_logic;
         rd_en : OUT  std_logic;
         rd_data : IN  std_logic_vector(63 downto 0);
         rd_valid : IN  std_logic;
         xgmii_txd : OUT  std_logic_vector(63 downto 0);
         xgmii_txc : OUT  std_logic_vector(7 downto 0)
        );
        END COMPONENT;
    
        signal clk : std_logic := '0';
        signal rd_en : std_logic;
        signal rd_data : std_logic_vector(63 downto 0) := (others => '0');
        signal rd_valid : std_logic := '0';

        signal xgmii_txd : std_logic_vector(63 downto 0);
        signal xgmii_txc : std_logic_vector(7 downto 0);

        -- Clock period definitions
        constant clk_period : time := 10 ns;

        signal test_fail : std_logic := '0';
   
        constant IDLE : std_logic_vector(7 downto 0) := x"07";
        constant START : std_logic_vector(7 downto 0) := x"FB";
        constant TERM : std_logic_vector(7 downto 0) := x"FD";

        constant PRE : std_logic_vector(7 downto 0) := "01010101";
        constant SFD : std_logic_vector(7 downto 0) := "11010101";
BEGIN
 
	-- Instantiate the Unit Under Test (UUT)
   uut: eth_tx PORT MAP (
          clk => clk,
          rd_en => rd_en,
          rd_data => rd_data,
          rd_valid => rd_valid,
          xgmii_txd => xgmii_txd,
          xgmii_txc => xgmii_txc
        );

   -- 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
        for i in 1 to 5 loop
        
                if i = 1 or i = 2 then
                        wait for clk_period;
                                
                        if rd_en /= '0' or
                           xgmii_txd /= IDLE & IDLE & IDLE & IDLE & IDLE & IDLE & IDLE & IDLE or
                           xgmii_txc /= "11111111" then
                           test_fail <= '1';
                        end if;
                end if;
                
                rd_valid <= '1';
                rd_data <= x"0123456789ABCDEF";
                
                wait for clk_period;
                
                if rd_en /= '1' or
                   xgmii_txd /= SFD & PRE & PRE & PRE & PRE & PRE & PRE & START or
                   xgmii_txc /= "00000001" then
                   test_fail <= '1';
                end if;
                
                wait for clk_period;
                
                if rd_en /= '1' or
                   xgmii_txd /= x"EFCDAB8967452301" or
                   xgmii_txc /= "00000000" then
                   test_fail <= '1';
                end if;
                
                rd_valid <= '1';
                rd_data <= x"BBBBBBBBBBBBBBBB";
                
                wait for clk_period;
                
                if rd_en /= '1' or
                   xgmii_txd /= x"BBBBBBBBBBBBBBBB" or
                   xgmii_txc /= "00000000" then
                   test_fail <= '1';
                end if;
                
                rd_valid <= '0';
                rd_data <= x"0000000000000000";
                
                wait for clk_period;
                
                if rd_en /= '0' or
                   xgmii_txd /= IDLE & IDLE & IDLE & IDLE & IDLE & IDLE & IDLE & TERM or
                   xgmii_txc /= "11111111" then
                   test_fail <= '1';
                end if;
                
        end loop;
        
        wait;
   end process;

END;