#ifndef ECCHAMMIMG_H
#define ECCHAMMIMG_H

#include "eccbaseclass.h"


class ECCHamming : public ECCBaseClass
{
private:
    // Hamming constants for this special implementation
    const unsigned m_nDatawordSize = 8;     // bytes
    const unsigned m_nCodewordSize = 1;     // bytes

    inline unsigned InBits(unsigned n)
    {
        return n << 3;
    };    // use this if constants are needed in bits

public:
    // Function prototype for calculated the size of memory needed for saving the encoded data
    // Input nBytes: Number of bytes which have to be encoded
    // Return value: Number of bytes which have to be allocated for storing the encoded data
    virtual unsigned AllocationSize(unsigned nBytes);

protected:
    // Function prototype for encoding data.
    // Data pointer is provided in pDataIn, length in Bytes provided in nDataIn
    // Result should be written in pDataOut, which has a size of nDataOut.
    // pDataOut is already allocated with a size given by function AllocationEncode
    virtual void Encode(const unsigned char *pDataIn, const unsigned nDataIn,
                        unsigned char *pDataOut, const unsigned nDataOut);


    // Function prototype for decoding data.
    // Data pointer is provided in pDataIn, length in Bytes provided in nDataIn
    // Result should be written in pDataOut, which has a size of nDataOut.
    // pDataOut is already allocated with a size given by function AllocationDecode
    virtual void Decode(const unsigned char *pDataIn, const unsigned nDataIn,
                        unsigned char *pDataOut, const unsigned nDataOut);

public:
    ECCHamming(::sc_core::sc_module_name name) : ECCBaseClass(name)
    {};
};

#endif // ECCHAMMIMG_H
