codec.crc


template <
    auto Width,
    uint<Width> P,
    uint<Width> Init,
    uint<Width> XorOut,
    bool ReflectInput,
    bool ReflectOutput,
    auto MaxBytes,
    auto ThreadCount
    >
class crc_calculator §source

Cyclic Redundancy Check (CRC) computation

Example CRC-32 with 64-bytes/cycle input width and 4 simultaneous input streams:

crc_calculator<32, 0xEDB88320, 0xFFFFFFFF, 0xFFFFFFFF, true, true, 64, 4> crc_calc;

Parameters

  • auto Width
    

    Width (in bits) of the computed CRC.

  • uint<Width> P
    

    The reversed polynomial.

  • uint<Width> Init
    

    The initial value of CRC.

  • uint<Width> XorOut
    

    The value to XOR with the final result.

  • bool ReflectInput
    

    Whether to reverse the bits of each input byte.

  • bool ReflectOutput
    

    Whether to reverse the bits of the CRC output result.

  • auto MaxBytes
    

    The maximum number of bytes that can be processed per call.

  • auto ThreadCount
    

    Number of CRC values that can be computed concurrently.

Methods

  • inline 
    uint<Width>
    compute(
        count_t<ThreadCount> identifier,
        uint8[MaxBytes] input,
        count_t<MaxBytes> input_bytes,
        bool reset
        ) §source
    

    Process up to MaxBytes of new input data.

    Arguments

    • count_t<ThreadCount> identifier
      

      Which of the ThreadCount CRCs to update.

    • uint8[MaxBytes] input
      

      Input data.

    • count_t<MaxBytes> input_bytes
      

      Number of valid bytes in the input data.

    • bool reset
      

      Indicates if CRC value should be reset before processing input. Should be set to true on the first call associated with a particular input stream.