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 29

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

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

powered by: WebSVN 2.1.0

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