summaryrefslogtreecommitdiff
path: root/netfpga10g/tests/eth_rx_test.vhd
blob: 7497a97ca64afcfff7e10877cf2110a4c4bc9f57 (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
 
ENTITY eth_rx_test IS
END eth_rx_test;
 
ARCHITECTURE behavior OF eth_rx_test IS 
 
        COMPONENT eth_rx
        PORT(
         clk : IN  std_logic;
         wr_en : OUT  std_logic;
         wr_data : OUT  std_logic_vector(63 downto 0);
         wr_done : OUT  std_logic;
         wr_accept : IN  std_logic;
         xgmii_rxd : IN  std_logic_vector(63 downto 0);
         xgmii_rxc : IN  std_logic_vector(7 downto 0)
        );
        END COMPONENT;

        signal clk : std_logic := '0';

        signal wr_en : std_logic;
        signal wr_data : std_logic_vector(63 downto 0);
        signal wr_done : std_logic;
        signal wr_accept : std_logic := '0';
        
        signal xgmii_rxd : std_logic_vector(63 downto 0) := (others => '0');
        signal xgmii_rxc : std_logic_vector(7 downto 0) := (others => '0');

        constant clk_period : time := 10 ns;
        
        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 ERR : std_logic_vector(7 downto 0) := x"FE";

        constant PRE : std_logic_vector(7 downto 0) := "01010101";
        constant SFD : std_logic_vector(7 downto 0) := "11010101";
        
        signal test_fail : std_logic := '0';
BEGIN
 
	-- Instantiate the Unit Under Test (UUT)
   uut: eth_rx PORT MAP (
          clk => clk,
          wr_en => wr_en,
          wr_data => wr_data,
          wr_done => wr_done,
          wr_accept => wr_accept,
          xgmii_rxd => xgmii_rxd,
          xgmii_rxc => xgmii_rxc
        );

   -- 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
        xgmii_rxd <= IDLE & IDLE & IDLE & IDLE & IDLE & IDLE & IDLE & IDLE;
        xgmii_rxc <= "00000000";
        
        wait for clk_period;
        
        if wr_en /= '0' or
           wr_data /= x"0000000000000000" or
           wr_done /= '0' then
                test_fail <= '1';
        end if;
        
        xgmii_rxd <= SFD & PRE & PRE & PRE & PRE & PRE & PRE & START;
        xgmii_rxc <= "00000001";
        wr_accept <= '1';
        
        wait for clk_period;
        
        if wr_en /= '0' or
           wr_data /= x"0000000000000000" or
           wr_done /= '0' then
                test_fail <= '1';
        end if;
        
        xgmii_rxd <= x"EFCDAB8967452301";
        xgmii_rxc <= "00000000";
        
        wait for clk_period;
        
        if wr_en /= '1' or
           wr_data /= x"0123456789ABCDEF" or
           wr_done /= '0' then
                test_fail <= '1';
        end if;
        
        xgmii_rxd <= IDLE & IDLE & IDLE & IDLE & IDLE & IDLE & IDLE & TERM;
        xgmii_rxc <= "11111111";
        
        wait for clk_period;
        
        if wr_done /= '1' then
                test_fail <= '1';
        end if;
        
        xgmii_rxd <= IDLE & IDLE & IDLE & IDLE & IDLE & IDLE & IDLE & IDLE;
        xgmii_rxc <= "11111111";
        
        wait for clk_period;
        
        if wr_en /= '0' or
           wr_data /= x"0000000000000000" or
           wr_done /= '0' then
                test_fail <= '1';
        end if;
        
        xgmii_rxd <= SFD & PRE & PRE & PRE & PRE & PRE & PRE & START;
        xgmii_rxc <= "00000001";
        wr_accept <= '0';
        
        wait for clk_period;
        
        if wr_en /= '0' or
           wr_data /= x"0000000000000000" or
           wr_done /= '0' then
                test_fail <= '1';
        end if;
        
        xgmii_rxd <= x"EFCDAB8967452301";
        xgmii_rxc <= "00000000";
        
        wait for clk_period;
        
        if wr_en /= '0' or
           wr_data /= x"0000000000000000" or
           wr_done /= '0' then
                test_fail <= '1';
        end if;
        
        xgmii_rxd <= SFD & PRE & PRE & PRE & PRE & PRE & PRE & START;
        xgmii_rxc <= "00000001";
        wr_accept <= '1';
        
        wait for clk_period;
        
        if wr_en /= '0' or
           wr_data /= x"0000000000000000" or
           wr_done /= '0' then
                test_fail <= '1';
        end if;
        
        xgmii_rxd <= x"ABCDABCDABCDABCD";
        xgmii_rxc <= "00000000";
        
        wait for clk_period;
        
        if wr_en /= '1' or
           wr_data /= x"CDABCDABCDABCDAB" or
           wr_done /= '0' then
                test_fail <= '1';
        end if;
        
        xgmii_rxd <= IDLE & IDLE & IDLE & ERR & IDLE & IDLE & IDLE & IDLE;
        xgmii_rxc <= "00010000";
        
        wait for clk_period;
        
        if wr_done /= '1' then
                test_fail <= '1';
        end if;
        
        xgmii_rxd <= PRE & PRE & PRE & START & IDLE & IDLE & IDLE & IDLE;
        xgmii_rxc <= "00011111";
        wr_accept <= '1';
        
        wait for clk_period;
        
        if wr_en /= '0' or
           wr_data /= x"0000000000000000" or
           wr_done /= '0' then
                test_fail <= '1';
        end if;
        
        xgmii_rxd <= x"67452311" & SFD & PRE & PRE & PRE;
        xgmii_rxc <= "00000000";
        
        wait for clk_period;
        
        if wr_en /= '0' or
           wr_data /= x"0000000000000000" or
           wr_done /= '0' then
                test_fail <= '1';
        end if;
        
        xgmii_rxd <= IDLE & IDLE & IDLE & TERM & x"EFCDAB89";
        xgmii_rxc <= "11110000";
        
        wait for clk_period;
        
        if wr_en /= '1' or
           wr_data /= x"1123456789ABCDEF" or
           wr_done /= '0' then
                test_fail <= '1';
        end if;
        
        xgmii_rxd <= IDLE & IDLE & IDLE & IDLE & IDLE & IDLE & IDLE & IDLE;
        xgmii_rxc <= "11111111";
        
        wait for clk_period;
        
        if wr_done /= '1' then
                test_fail <= '1';
        end if;
        
        wait;
   end process;

END;