Email: bknpk@hotmail.com Phone: +972-54-7649119


V

 

ASIC/FPGA Design and Verification Out Source Services

ETHERNET IP frame checksum calculation

  1. The following is a specman method that calculates the header checksum.The IP header structure is shown below:

  2. The calculation is done using one's complement.
  3. The code is checked in a bigger project. A VHDL DUT is used, which knows how to analyses ETHERNET frames. The project can be seen at: VHDL IP stack main page.
  4. The code is first checked on a sample frame, which was downloaded from the WEB. This frame was also checked with the DUT, using a small VHDL test-bench.
  5. The numerical values, which were used in the WEB example are:

    0x4500+0x0054+0xaafb+0x4000+0x0000+0xfc01+0x8b85+0xe902+0x8b85+0xd96e=0x505ca
    0x5+0x05ca=0x05cf -> 0xfa30 checksum.
    Note: the checksum field is zero in the calculatation.
  6. The e-code follows:

  7. calc_check_sum(data : list of bit) : uint(bits:16) is {
      var chk_sum : uint(bits:32);
      var tmp : uint(bits:16);
      var tmps: uint(bits:16);
      for i from 0 to data.size()-16 step 16 do {
        unpack(packing.low, data[i+15:i], tmp);
        --shuffle nibbles to the right sum order
        tmps[ 3: 0]=tmp[ 7: 4];
        tmps[ 7: 4]=tmp[ 3: 0];
        tmps[11: 8]=tmp[15:12];
        tmps[15:12]=tmp[11: 8];
        chk_sum += tmps.as_a(uint(bits:32));
        --hanlde carry
        if(chk_sum[19:16] != 0) then {
          chk_sum = chk_sum[19:16]+chk_sum[15:0];
        };
      };--for
      --do one's complement
      for i from 0 to 15 do {
        result[i:i]=~chk_sum[i:i];
      };
    };--calc_check_sum

Contact me at:

  ...


Also available on this project:


Home

Download Area

Specman: can code style affects performance?



SD slave CRC16 calculation in VHDL








Search This Site


Feedback This Site




new pages on this site