Re: crc on only data or including the address
- From: Philip Freidin <philip@xxxxxxxxxxxxxxx>
- Date: Fri, 28 Oct 2005 04:38:14 GMT
On 26 Oct 2005 16:12:34 -0700, "ashwin" <achiluka@xxxxxxxxx> wrote:
>Hello everyone,
>I am trying to transfer data between on board ethernet PHY and the PC.
>For that i am implementing ethernet packet generator in the fpga. The
>MII interface on the fpga has transmit data bus of width 4 bits. So i
>am sending 64 bytes of frame from the fpga with the most significand
>bit transmitted first.
My understanding is that the data is shifted out LSB first, which would
require you to send the low order 4 bits first.
>As you all know ethernet frame consists of
>
>preamble,startframe,destination ad,source ad,length/type,data,crc
>
>Is this what each block consists of
>
>preamble - 7 bytes - x"5";
you mean x"55"
>
>startframe - 1 byte -x"5d";
Given my belief that data is sent LSB first, this would be x"d5"
>destination - 6 bytes - PC mac address
>
>source - 6 bytes -- any choice of fpga mac.(any value)
>
>length/type - 2 bytes -- "0000_0000_0100_0000"
>
>data - --38 bytes -- any value
>
>crc - 4 bytes
Actually, what is sent is the FCS, which is bit reversed
version of the CRC.
>2) Is CRC implemented on only data or on whole frame?
CRC starts with the destination address
>3) Can anyone guide me on how crc is computed?
>From the spec:
3.2.8 Frame Check Sequence (FCS) field
A cyclic redundancy check (CRC) is used by the transmit and
receive algorithms to generate a CRC value for the FCS
field. The frame check sequence (FCS) field contains a
4-octet (32-bit) cyclic redundancy check (CRC) value. This
value is computed as a function of the contents of the
source address, destination address, length, LLC data and
pad (that is, all fields except the preamble, SFD, FCS, and
extension). The encoding is defined by the following
generating polynomial.
G(x) = x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 +
x8 + x7 + x5 + x4 + x2 + x + 1
Mathematically, the CRC value corresponding to a given frame
is defined by the following procedure:
a) The first 32 bits of the frame are complemented.
b) The n bits of the frame are then considered to be the
coefficients of a polynomial M(x) of degree n.1.
(The first bit of the Destination Address field
corresponds to the x(n.1) term and the last bit of
the data field corresponds to the x0 term.)
c) M(x) is multiplied by x32 and divided by G(x), producing
a remainder R(x) of degree .31.
d) The coefficients of R(x) are considered to be a 32-bit
sequence.
e) The bit sequence is complemented and the result is the
CRC. The 32 bits of the CRC value are placed in the
frame check sequence field so that the x31 term is the
leftmost bit of the first octet, and the x0 term is the
right most bit of the last octet. (The bits of the CRC
are thus transmitted in the order x31, x30, ... x1, x0.)
You will notice the amazing fact that unlike the rest of
the frame that is sent LSB first, the FCS is sent MSB first.
>4) If CRC is wrong, will the PHY still transmit the data onto the PC.
Yes. The PHY does not care, and since it doesn't see the FCS
until the end of a packet, how would it know not to send the
earlier stuff :-)
>I would request you to please answer my questions as soon as possible.
Sure.
Bet the following helps too. Here is a REAL packet!!!
55
55
55
55
55
55
55
d5
0d
0d
0d
0d
0d
0d
0c
0c
0c
0c
0c
0c
88
08
00
01
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
77
e5
5c
0b
f8
The calculated CRC is 58 c5 2f e0
so the calculated FCS is e5 5c 0b f8
Let me work the first byte for you:
58 complemented is A7 == 10100111
Then reverse the bit sequence == 11100101
which is E5, which is then the first byte of the FCS
that is sent out, LSB first, which means it goes out as
1, 0, 1, 0, 0, 1, 1, 1. Thus meeting the requirement
that the first transmitted bit of the FCS is from the
MSB of the CRC. The standard specifies what must happen,
but not how. Since I didnt want to have a shifter for the
FCS that was different from the rest of the packet, I
instead supply the FCS to the shifter in reverse byte order
(MSByte first), and by bit reversing the byte, the shifter
can shift out LSBit first and achieve the requirement of
the FCS effectively shifting out MSBit first.
>thanks
>ashwin
Have fun, I certainly did.
Philip
.
- References:
- crc on only data or including the address
- From: ashwin
- crc on only data or including the address
- Prev by Date: Re: hex rep. in VHDL
- Next by Date: Re: ASIC HDL coding styles
- Previous by thread: Re: crc on only data or including the address
- Next by thread: Optimizing a State Machine
- Index(es):
Relevant Pages
|
Loading