OpenCores
URL https://opencores.org/ocsvn/udp_ip_stack/udp_ip_stack/trunk

Subversion Repositories udp_ip_stack

[/] [udp_ip_stack/] [trunk/] [rtl/] [vhdl/] [IPv4_TX.vhd] - Blame information for rev 8

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 pjf
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer:            Peter Fall
4
-- 
5
-- Create Date:    16:20:42 06/01/2011 
6
-- Design Name: 
7
-- Module Name:    IPv4_TX - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--              handle simple IP TX
13
--              doesnt handle segmentation
14
--              dest MAC addr resolution through ARP layer
15
--              Handle IPv4 protocol
16
-- Dependencies: 
17
--
18
-- Revision: 
19
-- Revision 0.01 - File Created
20
-- Revision 0.02 - fixed up setting of tx_result control defaults
21 4 pjf
-- Revision 0.03 - Added data_out_first
22 6 pjf
-- Revision 0.04 - Added handling of broadcast address
23 2 pjf
-- Additional Comments: 
24
--
25
----------------------------------------------------------------------------------
26
library IEEE;
27
use IEEE.STD_LOGIC_1164.ALL;
28
use IEEE.NUMERIC_STD.ALL;
29
use work.axi.all;
30
use work.ipv4_types.all;
31
use work.arp_types.all;
32
 
33
entity IPv4_TX is
34
    Port (
35
                        -- IP Layer signals
36
                        ip_tx_start                             : in std_logic;
37
                        ip_tx                                           : in ipv4_tx_type;                                                              -- IP tx cxns
38
                        ip_tx_result                    : out std_logic_vector (1 downto 0);             -- tx status (changes during transmission)
39
                        ip_tx_data_out_ready    : out std_logic;                                                                        -- indicates IP TX is ready to take data
40
 
41
                        -- system signals
42
                        clk                                             : in  STD_LOGIC;                                                                        -- same clock used to clock mac data and ip data
43
                        reset                                   : in  STD_LOGIC;
44
                        our_ip_address          : in STD_LOGIC_VECTOR (31 downto 0);
45
                        our_mac_address                 : in std_logic_vector (47 downto 0);
46
                        -- ARP lookup signals
47
                        arp_req_req                             : out arp_req_req_type;
48
                        arp_req_rslt                    : in arp_req_rslt_type;
49
                        -- MAC layer TX signals
50
                        mac_tx_req                              : out std_logic;                                                                        -- indicates that ip wants access to channel (stays up for as long as tx)
51
                        mac_tx_granted                  : in std_logic;                                                                 -- indicates that access to channel has been granted            
52
                        mac_data_out_ready      : in std_logic;                                                                 -- indicates system ready to consume data
53
                        mac_data_out_valid      : out std_logic;                                                                -- indicates data out is valid
54 4 pjf
                        mac_data_out_first      : out std_logic;                                                                        -- with data out valid indicates the first byte of a frame
55 2 pjf
                        mac_data_out_last               : out std_logic;                                                                        -- with data out valid indicates the last byte of a frame
56
                        mac_data_out                    : out std_logic_vector (7 downto 0)              -- ethernet frame (from dst mac addr through to last byte of frame)      
57
                        );
58
end IPv4_TX;
59
 
60
architecture Behavioral of IPv4_TX is
61
 
62
        type tx_state_type is (
63
                        IDLE,
64
                        WAIT_MAC,                               -- waiting for response from ARP for mac lookup
65
                        WAIT_CHN,                               -- waiting for tx access to MAC channel
66
                        SEND_ETH_HDR,                   -- sending the ethernet header
67
                        SEND_IP_HDR,                    -- sending the IP header
68
                        SEND_USER_DATA                  -- sending the users data
69
                        );
70
 
71
        type crc_state_type is (IDLE,TOT_LEN,ID,FLAGS,TTL,CKS,SAH,SAL,DAH,DAL,FINAL,WAIT_END);
72
 
73
        type count_mode_type is (RST, INCR, HOLD);
74
        type settable_cnt_type is (RST, SET, INCR, HOLD);
75
        type set_clr_type is (SET, CLR, HOLD);
76
 
77
        -- Configuration
78
 
79 6 pjf
        constant IP_TTL                 : std_logic_vector (7 downto 0)  := x"80";
80 2 pjf
 
81
        -- TX state variables
82
        signal tx_state                 : tx_state_type;
83
        signal tx_count                         : unsigned (11 downto 0);
84
        signal tx_result_reg            : std_logic_vector (1 downto 0);
85
        signal tx_mac                           : std_logic_vector (47 downto 0);
86
        signal tx_mac_chn_reqd  : std_logic;
87
        signal tx_hdr_cks                       : std_logic_vector (23 downto 0);
88
        signal mac_lookup_req   : std_logic;
89
        signal crc_state                        : crc_state_type;
90
        signal arp_req_ip_reg   : std_logic_vector (31 downto 0);
91
        signal mac_data_out_ready_reg   : std_logic;
92
 
93
        -- tx control signals
94
        signal next_tx_state    : tx_state_type;
95
        signal set_tx_state             : std_logic;
96
        signal next_tx_result   : std_logic_vector (1 downto 0);
97
        signal set_tx_result            : std_logic;
98 6 pjf
        signal tx_mac_value             : std_logic_vector (47 downto 0);
99 2 pjf
        signal set_tx_mac                       : std_logic;
100
        signal tx_count_val             : unsigned (11 downto 0);
101
        signal tx_count_mode            : settable_cnt_type;
102
        signal tx_data                          : std_logic_vector (7 downto 0);
103
        signal set_last                 : std_logic;
104
        signal set_chn_reqd             : set_clr_type;
105
        signal set_mac_lku_req  : set_clr_type;
106
        signal tx_data_valid            : std_logic;                    -- indicates whether data is valid to tx or not
107
 
108
        -- tx temp signals
109
        signal total_length             : std_logic_vector (15 downto 0);        -- computed combinatorially from header size
110
 
111
 
112
        FUNCTION inv_if_one(s1:std_logic_vector;en:std_logic) return std_logic_vector is
113
                  --this function inverts all the bits of a vector if
114
                  --'en' is '1'.
115
        VARIABLE Z : std_logic_vector(s1'high downto s1'low);
116
        BEGIN
117
        FOR i IN (s1'low) to s1'high LOOP
118
            Z(i) := en XOR s1(i);
119
        END LOOP;
120
        RETURN Z;
121
        END inv_if_one; -- end function
122
 
123
 
124
-- IP datagram header format
125
--
126
--      0          4          8                      16      19             24                    31
127
--      --------------------------------------------------------------------------------------------
128
--      | Version  | *Header  |    Service Type      |        Total Length including header        |
129
--      |   (4)    |  Length  |     (ignored)        |                 (in bytes)                  |
130
--      --------------------------------------------------------------------------------------------
131
--      |           Identification                   | Flags |       Fragment Offset               |
132
--      |                                            |       |      (in 32 bit words)              |
133
--      --------------------------------------------------------------------------------------------
134
--      |    Time To Live     |       Protocol       |             Header Checksum                 |
135
--      |     (ignored)       |                      |                                             |
136
--      --------------------------------------------------------------------------------------------
137
--      |                                   Source IP Address                                      |
138
--      |                                                                                          |
139
--      --------------------------------------------------------------------------------------------
140
--      |                                 Destination IP Address                                   |
141
--      |                                                                                          |
142
--      --------------------------------------------------------------------------------------------
143
--      |                          Options (if any - ignored)               |       Padding        |
144
--      |                                                                   |      (if needed)     |
145
--      --------------------------------------------------------------------------------------------
146
--      |                                          Data                                            |
147
--      |                                                                                          |
148
--      --------------------------------------------------------------------------------------------
149
--      |                                          ....                                            |
150
--      |                                                                                          |
151
--      --------------------------------------------------------------------------------------------
152
--
153
-- * - in 32 bit words 
154
 
155
begin
156
        -----------------------------------------------------------------------
157
        -- combinatorial process to implement FSM and determine control signals
158
        -----------------------------------------------------------------------
159
 
160
        tx_combinatorial : process(
161
                -- input signals
162
                ip_tx_start, ip_tx, clk, our_ip_address, our_mac_address, arp_req_rslt,
163
                mac_tx_granted, mac_data_out_ready,
164
                -- state variables
165
                tx_state, tx_count, tx_result_reg, tx_mac, tx_mac_chn_reqd,
166
                mac_lookup_req, tx_hdr_cks, arp_req_ip_reg, mac_data_out_ready_reg,
167
                -- control signals
168 6 pjf
                next_tx_state, set_tx_state, next_tx_result, set_tx_result, tx_mac_value, set_tx_mac, tx_count_mode,
169 2 pjf
                tx_data, set_last, set_chn_reqd, set_mac_lku_req, total_length,
170
                tx_data_valid, tx_count_val
171
                )
172
        begin
173
                -- set output followers
174
                ip_tx_result <= tx_result_reg;
175
                mac_tx_req <= tx_mac_chn_reqd;
176
                arp_req_req.lookup_req <= mac_lookup_req;
177
                arp_req_req.ip <= arp_req_ip_reg;
178
 
179 4 pjf
                -- set initial values for combinatorial outputs
180
                mac_data_out_first <= '0';
181
 
182 2 pjf
                case tx_state is
183
                        when SEND_ETH_HDR | SEND_IP_HDR =>
184
                                mac_data_out <= tx_data;
185
                                tx_data_valid <= mac_data_out_ready;    -- generated internally
186
                                mac_data_out_last <= set_last;
187
 
188
                        when SEND_USER_DATA =>
189
                                mac_data_out <= ip_tx.data.data_out;
190
                                tx_data_valid <= ip_tx.data.data_out_valid;
191
                                mac_data_out_last <= ip_tx.data.data_out_last;
192
 
193
                        when others =>
194
                                mac_data_out <= (others => '0');
195
                                tx_data_valid <= '0';                                            -- not transmitting during this phase
196
                                mac_data_out_last <= '0';
197
                end case;
198
 
199
                mac_data_out_valid <= tx_data_valid and mac_data_out_ready;
200
 
201
                -- set signal defaults
202
                next_tx_state <= IDLE;
203
                set_tx_state <= '0';
204
                tx_count_mode <= HOLD;
205
                tx_data <= x"00";
206
                set_last <= '0';
207
                set_tx_mac <= '0';
208
                set_chn_reqd <= HOLD;
209
                set_mac_lku_req <= HOLD;
210
                next_tx_result <= IPTX_RESULT_NONE;
211
                set_tx_result <= '0';
212
                tx_count_val <= (others => '0');
213 6 pjf
                tx_mac_value <= (others => '0');
214 2 pjf
 
215
                -- set temp signals
216
                total_length <= std_logic_vector(unsigned(ip_tx.hdr.data_length) + 20);         -- total length = user data length + header length (bytes)
217
 
218
                -- TX FSM
219
                case tx_state is
220
                        when IDLE =>
221
                                ip_tx_data_out_ready <= '0';             -- in this state, we are unable to accept user data for tx
222
                                tx_count_mode <= RST;
223
                                set_chn_reqd <= CLR;
224
                                if ip_tx_start = '1' then
225
                                        -- check header count for error if too high
226
                                        if unsigned(ip_tx.hdr.data_length) > 1480 then
227
                                                next_tx_result <= IPTX_RESULT_ERR;
228
                                                set_tx_result <= '1';
229
                                        else
230 6 pjf
                                                next_tx_result <= IPTX_RESULT_SENDING;
231
                                                set_tx_result <= '1';
232
 
233 2 pjf
                                                -- TODO - check if we already have the mac addr for this ip, if so, bypass the WAIT_MAC state
234
 
235 6 pjf
                                                if ip_tx.hdr.dst_ip_addr = IP_BC_ADDR then
236
                                                        -- for IP broadcast, dont need to look up the MAC addr
237
                                                        tx_mac_value <= MAC_BC_ADDR;
238
                                                        set_tx_mac <= '1';
239
                                                        next_tx_state <= WAIT_CHN;
240
                                                        set_tx_state <= '1';
241
                                                else
242
                                                        -- need to req the mac address for this ip
243
                                                        set_mac_lku_req <= SET;
244
                                                        next_tx_state <= WAIT_MAC;
245
                                                        set_tx_state <= '1';
246
                                                end if;
247 2 pjf
                                        end if;
248
                                else
249
                                        set_mac_lku_req <= CLR;
250
                                end if;
251
 
252
                        when WAIT_MAC =>
253
                                ip_tx_data_out_ready <= '0';             -- in this state, we are unable to accept user data for tx
254 8 pjf
                                set_mac_lku_req <= CLR;                         -- clear the request - will have been latched in the ARP layer
255 2 pjf
                                if arp_req_rslt.got_mac = '1' then
256
                                        -- save the MAC we got back from the ARP lookup
257 6 pjf
                                        tx_mac_value <= arp_req_rslt.mac;
258 2 pjf
                                        set_tx_mac <= '1';
259
                                        set_chn_reqd <= SET;
260
                                        -- check for optimise when already have the channel
261
                                        if mac_tx_granted = '1' then
262
                                                -- ready to send data
263
                                                next_tx_state <= SEND_ETH_HDR;
264
                                                set_tx_state <= '1';
265
                                        else
266
                                                next_tx_state <= WAIT_CHN;
267
                                                set_tx_state <= '1';
268
                                        end if;
269
                                elsif arp_req_rslt.got_err = '1' then
270
                                        set_mac_lku_req <= CLR;
271
                                        next_tx_result <= IPTX_RESULT_ERR;
272
                                        set_tx_result <= '1';
273
                                        next_tx_state <= IDLE;
274
                                        set_tx_state <= '1';
275
                                end if;
276
 
277
                        when WAIT_CHN =>
278
                                ip_tx_data_out_ready <= '0';             -- in this state, we are unable to accept user data for tx
279
                                if mac_tx_granted = '1' then
280
                                        -- ready to send data
281
                                        next_tx_state <= SEND_ETH_HDR;
282
                                        set_tx_state <= '1';
283
                                end if;
284
                                -- probably should handle a timeout here
285
 
286
                        when SEND_ETH_HDR =>
287
                                ip_tx_data_out_ready <= '0';             -- in this state, we are unable to accept user data for tx
288
                                if mac_data_out_ready = '1' then
289
                                        if tx_count = x"00d" then
290
                                                tx_count_mode <= RST;
291
                                                next_tx_state <= SEND_IP_HDR;
292
                                                set_tx_state <= '1';
293
                                        else
294
                                                tx_count_mode <= INCR;
295
                                        end if;
296
                                        case tx_count is
297 4 pjf
                                                when x"000"  =>
298
                                                        mac_data_out_first <= mac_data_out_ready;
299
                                                        tx_data <= tx_mac (47 downto 40);                       -- trg = mac from ARP lookup                                            
300
 
301 2 pjf
                                                when x"001"  => tx_data <= tx_mac (39 downto 32);
302
                                                when x"002"  => tx_data <= tx_mac (31 downto 24);
303
                                                when x"003"  => tx_data <= tx_mac (23 downto 16);
304
                                                when x"004"  => tx_data <= tx_mac (15 downto 8);
305
                                                when x"005"  => tx_data <= tx_mac (7 downto 0);
306
                                                when x"006"  => tx_data <= our_mac_address (47 downto 40);      -- src = our mac
307
                                                when x"007"  => tx_data <= our_mac_address (39 downto 32);
308
                                                when x"008"  => tx_data <= our_mac_address (31 downto 24);
309
                                                when x"009"  => tx_data <= our_mac_address (23 downto 16);
310
                                                when x"00a"  => tx_data <= our_mac_address (15 downto 8);
311
                                                when x"00b"  => tx_data <= our_mac_address (7 downto 0);
312
                                                when x"00c"  => tx_data <= x"08";                                                                       -- pkt type = 0800 : IP                                         
313
                                                when x"00d"  => tx_data <= x"00";
314
                                                when others =>
315
                                                        -- shouldnt get here - handle as error
316
                                                        next_tx_result <= IPTX_RESULT_ERR;
317
                                                        set_tx_result <= '1';
318
                                                        next_tx_state <= IDLE;
319
                                                        set_tx_state <= '1';
320
                                        end case;
321
                                end if;
322
 
323
                        when SEND_IP_HDR =>
324
                                ip_tx_data_out_ready <= '0';             -- in this state, we are unable to accept user data for tx
325
                                if mac_data_out_ready    = '1' then
326
                                        if tx_count = x"013" then
327
                                                tx_count_val <= x"001";
328
                                                tx_count_mode <= SET;
329
                                                next_tx_state <= SEND_USER_DATA;
330
                                                set_tx_state <= '1';
331
                                        else
332
                                                tx_count_mode <= INCR;
333
                                        end if;
334
                                        case tx_count is
335
                                                when x"000"  => tx_data <= x"45";                                                                       -- v4, 5 words in hdr
336
                                                when x"001"  => tx_data <= x"00";                                                                       -- service type
337
                                                when x"002"  => tx_data <= total_length (15 downto 8);          -- total length
338
                                                when x"003"  => tx_data <= total_length (7 downto 0);
339
                                                when x"004"  => tx_data <= x"00";                                                                       -- identification
340
                                                when x"005"  => tx_data <= x"00";
341
                                                when x"006"  => tx_data <= x"00";                                                                       -- flags and fragment offset
342
                                                when x"007"  => tx_data <= x"00";
343
                                                when x"008"  => tx_data <= IP_TTL;                                                                      -- TTL
344
                                                when x"009"  => tx_data <= ip_tx.hdr.protocol;                                  -- protocol
345
                                                when x"00a"  => tx_data <= tx_hdr_cks (15 downto 8);                    -- HDR checksum
346
                                                when x"00b"  => tx_data <= tx_hdr_cks (7 downto 0);                      -- HDR checksum
347
                                                when x"00c" => tx_data <= our_ip_address (31 downto 24);                -- src ip
348
                                                when x"00d" => tx_data <= our_ip_address (23 downto 16);
349
                                                when x"00e" => tx_data <= our_ip_address (15 downto 8);
350
                                                when x"00f" => tx_data <= our_ip_address (7 downto 0);
351
                                                when x"010" => tx_data <= ip_tx.hdr.dst_ip_addr (31 downto 24); -- dst ip
352
                                                when x"011" => tx_data <= ip_tx.hdr.dst_ip_addr (23 downto 16);
353
                                                when x"012" => tx_data <= ip_tx.hdr.dst_ip_addr (15 downto 8);
354
                                                when x"013" => tx_data <= ip_tx.hdr.dst_ip_addr (7 downto 0);
355
                                                when others =>
356
                                                        -- shouldnt get here - handle as error
357
                                                        next_tx_result <= IPTX_RESULT_ERR;
358
                                                        set_tx_result <= '1';
359
                                                        next_tx_state <= IDLE;
360
                                                        set_tx_state <= '1';
361
                                        end case;
362
                                end if;
363
 
364
                        when SEND_USER_DATA =>
365
                                ip_tx_data_out_ready <= mac_data_out_ready and mac_data_out_ready_reg;          -- in this state, we are always ready to accept user data for tx
366
                                if mac_data_out_ready = '1' then
367
                                        if ip_tx.data.data_out_valid = '1' or tx_count = x"000" then
368
                                                -- only increment if ready and valid has been subsequently established, otherwise data count moves on too fast
369
                                                if unsigned(tx_count) = unsigned(ip_tx.hdr.data_length) then
370
                                                        set_last <= '1';
371
                                                        set_chn_reqd <= CLR;
372
                                                        tx_data <= ip_tx.data.data_out;
373
                                                        next_tx_result <= IPTX_RESULT_SENT;
374
                                                        set_tx_result <= '1';
375
                                                        next_tx_state <= IDLE;
376
                                                        set_tx_state <= '1';
377
                                                else
378
                                                        tx_count_mode <= INCR;
379
                                                        tx_data <= ip_tx.data.data_out;
380
                                                end if;
381
                                        end if;
382
                                end if;
383
 
384
                end case;
385
        end process;
386
 
387
        -----------------------------------------------------------------------------
388
        -- sequential process to action control signals and change states and outputs
389
        -----------------------------------------------------------------------------
390
 
391
        tx_sequential : process (clk,reset,mac_data_out_ready_reg)
392
        begin
393
                if rising_edge(clk) then
394
                        mac_data_out_ready_reg <= mac_data_out_ready;
395
                else
396
                        mac_data_out_ready_reg <= mac_data_out_ready_reg;
397
                end if;
398
 
399
                if rising_edge(clk) then
400
                        if reset = '1' then
401
                                -- reset state variables
402
                                tx_state <= IDLE;
403
                                tx_count <= x"000";
404
                                tx_result_reg <= IPTX_RESULT_NONE;
405
                                tx_mac <= (others => '0');
406
                                tx_mac_chn_reqd <= '0';
407 4 pjf
                                mac_lookup_req <= '0';
408
 
409 2 pjf
                        else
410
                                -- Next tx_state processing
411
                                if set_tx_state = '1' then
412
                                        tx_state <= next_tx_state;
413
                                else
414
                                        tx_state <= tx_state;
415
                                end if;
416
 
417
                                -- tx result processing
418
                                if set_tx_result = '1' then
419
                                        tx_result_reg <= next_tx_result;
420
                                else
421
                                        tx_result_reg <= tx_result_reg;
422
                                end if;
423
 
424
                                -- control arp lookup request
425
                                case set_mac_lku_req is
426
                                        when SET =>
427
                                                arp_req_ip_reg <= ip_tx.hdr.dst_ip_addr;
428
                                                mac_lookup_req <= '1';
429
 
430
                                        when CLR =>
431
                                                mac_lookup_req <= '0';
432
                                                arp_req_ip_reg <= arp_req_ip_reg;
433
 
434
                                        when HOLD =>
435
                                                mac_lookup_req <= mac_lookup_req;
436
                                                arp_req_ip_reg <= arp_req_ip_reg;
437
                                end case;
438
 
439
                                -- save MAC
440
                                if set_tx_mac = '1' then
441 6 pjf
                                        tx_mac <= tx_mac_value;
442 2 pjf
                                else
443
                                        tx_mac <= tx_mac;
444
                                end if;
445
 
446
                                -- control access request to mac tx chn
447
                                case set_chn_reqd is
448
                                        when SET => tx_mac_chn_reqd <= '1';
449
                                        when CLR => tx_mac_chn_reqd <= '0';
450
                                        when HOLD => tx_mac_chn_reqd <= tx_mac_chn_reqd;
451
                                end case;
452
 
453
                                -- tx_count processing
454
                                case tx_count_mode is
455
                                        when RST  =>    tx_count <= x"000";
456
                                        when SET  =>    tx_count <= tx_count_val;
457
                                        when INCR =>    tx_count <= tx_count + 1;
458
                                        when HOLD =>    tx_count <= tx_count;
459
                                end case;
460
 
461
                        end if;
462
                end if;
463
        end process;
464
 
465
        -----------------------------------------------------------------------------
466
        -- Process to calculate CRC in parallel with pkt out processing
467
        -- this process must yield a valid CRC before it is required to be used in the hdr
468
        -----------------------------------------------------------------------------
469
 
470
        crc : process (clk,reset)
471
        begin
472
                if rising_edge(clk) then
473
                        case crc_state is
474
                                when IDLE =>
475
                                        if ip_tx_start = '1' then
476
                                                tx_hdr_cks <= x"004500";                        -- vers & hdr len & service
477
                                                crc_state <= TOT_LEN;
478
                                        end if;
479
 
480
                                when TOT_LEN =>
481
                                        tx_hdr_cks <= std_logic_vector (unsigned(tx_hdr_cks) + unsigned(total_length));
482
                                        crc_state <= ID;
483
 
484
                                when ID =>
485
                                        tx_hdr_cks <= tx_hdr_cks;
486
                                        crc_state <= FLAGS;
487
 
488
                                when FLAGS =>
489
                                        tx_hdr_cks <= tx_hdr_cks;
490
                                        crc_state <= TTL;
491
 
492
                                when TTL =>
493
                                        tx_hdr_cks <= std_logic_vector (unsigned(tx_hdr_cks) + unsigned(IP_TTL & ip_tx.hdr.protocol));
494
                                        crc_state <= CKS;
495
 
496
                                when CKS =>
497
                                        tx_hdr_cks <= tx_hdr_cks;
498
                                        crc_state <= SAH;
499
 
500
                                when SAH =>
501
                                        tx_hdr_cks <= std_logic_vector (unsigned(tx_hdr_cks) + unsigned(our_ip_address(31 downto 16)));
502
                                        crc_state <= SAL;
503
 
504
                                when SAL =>
505
                                        tx_hdr_cks <= std_logic_vector (unsigned(tx_hdr_cks) + unsigned(our_ip_address(15 downto 0)));
506
                                        crc_state <= DAH;
507
 
508
                                when DAH =>
509
                                        tx_hdr_cks <= std_logic_vector (unsigned(tx_hdr_cks) + unsigned(ip_tx.hdr.dst_ip_addr(31 downto 16)));
510
                                        crc_state <= DAL;
511
 
512
                                when DAL =>
513
                                        tx_hdr_cks <= std_logic_vector (unsigned(tx_hdr_cks) + unsigned(ip_tx.hdr.dst_ip_addr(15 downto 0)));
514
                                        crc_state <= FINAL;
515
 
516
                                when FINAL =>
517
                                        tx_hdr_cks <= inv_if_one(std_logic_vector (unsigned(tx_hdr_cks) + unsigned(tx_hdr_cks(23 downto 16))),'1');
518
                                        crc_state <= WAIT_END;
519
 
520
                                when WAIT_END =>
521
                                        tx_hdr_cks <= tx_hdr_cks;
522
                                        if ip_tx_start = '0' then
523
                                                crc_state <= IDLE;
524
                                        else
525
                                                crc_state <= WAIT_END;
526
                                        end if;
527
 
528
 
529
                        end case;
530
                end if;
531
  end process;
532
 
533
 
534
end Behavioral;
535
 

powered by: WebSVN 2.1.0

© copyright 1999-2022 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.