Pregunta

As a bit of insight into what I am doing, I am attempting to process AES/EBU subframes for an SDI interface. That shouldn't be too important; let's abstract away from that.

Page 12 of a standards document calls for a CRC check using the polynomial: G(x) = x^8 + x^4 + x^3 + x^2 + 1 (or x^0).

The document can be found here: http://tech.ebu.ch/docs/tech/tech3250.pdf

As you can probably anticipate, I would like to generate a CRC table for the given formula. I've come across a code-snippet which uses the formula G(x) = x^8 + x^2 + x^1 + x^0.

The code snippet can be located here: http://www.koders.com/cpp/fid9C544B36B8C41721691790197D38DAC91D2C29EF.aspx?s=crc#L8

Could the formula be modified (see the modified version below) to work with the my AES3 CRC? Will the following work?

// x^8 + x^4 + x^3 + x^2 + x^0 or (1)
void make_crc_table( void )
{
    int i, j;
    unsigned long poly, c;

    /* terms of polynomial defining this crc (except x^8): */
    static const byte p[] = {0,2,3,4};

    poly = 0L;

    for ( i = 0; i < sizeof( p ) / sizeof( byte ); i++ )
    {
        poly |= 1L << p[i];
    }

    for ( i = 0; i < 256; i++ )
    {
        c = i;

        for ( j = 0; j < 8; j++ )
        {
                            //ZeroDefect: This part has me worried.
            c = ( c & 0x80 ) ? poly ^ ( c << 1 ) : ( c << 1 );
        }
        crctable[i] = (byte) c;
    }
}

Any tips/suggestions would be much appreciated.

ZeroDefect.

¿Fue útil?

Solución

As far as I can tell, this is just encoding all the possible state transitions for the CRC feedback register (see the diagrams at Wikipedia) into a lookup table.

It looks like all you should need to do is modify the p[] array to take account of your tap positions.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top