torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::bitstream::Spartan6Bitstream::CRC Struct Reference

CRC class for the Spartan6 architecture. More...

#include <Spartan6Bitstream.hpp>

Public Types

enum  { eLen = 22 }
 Length of the CRC calculation. More...
 

Public Member Functions

 CRC (void)
 Default constructor. More...
 
void reset (void)
 Function to clear the CRC calculation. More...
 
void update (uint32_t inAddress, uint32_t inWord)
 Update the CRC with new data. More...
 
uint8_toperator[] (int i)
 Index operator. More...
 
 operator uint32_t (void) const
 Cast operator to return the CRC as an integer. More...
 

Data Fields

uint8_t mBits [eLen]
 CRC calculation bits. More...
 
uint32_t mValue
 CRC calculation value. More...
 

Detailed Description

CRC class for the Spartan6 architecture.

Definition at line 42 of file Spartan6Bitstream.hpp.

Member Enumeration Documentation

anonymous enum

Length of the CRC calculation.

Enumerator
eLen 

Definition at line 44 of file Spartan6Bitstream.hpp.

Constructor & Destructor Documentation

torc::bitstream::Spartan6Bitstream::CRC::CRC ( void  )
inline

Default constructor.

Definition at line 50 of file Spartan6Bitstream.hpp.

50 { reset(); }
void reset(void)
Function to clear the CRC calculation.

+ Here is the call graph for this function:

Member Function Documentation

torc::bitstream::Spartan6Bitstream::CRC::operator uint32_t ( void  ) const
inline

Cast operator to return the CRC as an integer.

Definition at line 81 of file Spartan6Bitstream.hpp.

81 { return mValue; }
uint32_t mValue
CRC calculation value.
uint8_t& torc::bitstream::Spartan6Bitstream::CRC::operator[] ( int  i)
inline

Index operator.

Definition at line 79 of file Spartan6Bitstream.hpp.

79 { return mBits[i]; }
uint8_t mBits[eLen]
CRC calculation bits.
void torc::bitstream::Spartan6Bitstream::CRC::reset ( void  )
inline

Function to clear the CRC calculation.

Definition at line 52 of file Spartan6Bitstream.hpp.

52 { for(int32_t i = 0; i < eLen; i++) mBits[i] = 0; mValue = 0; }
uint32_t mValue
CRC calculation value.
uint8_t mBits[eLen]
CRC calculation bits.

+ Here is the caller graph for this function:

void torc::bitstream::Spartan6Bitstream::CRC::update ( uint32_t  inAddress,
uint32_t  inWord 
)
inline

Update the CRC with new data.

Definition at line 54 of file Spartan6Bitstream.hpp.

54  {
55  uint8_t input[eLen];
56  uint8_t next[eLen];
57  // initialize the input with the current register address and data word
58  for(int32_t i = 21, mask = 0x20; i >= 16; i--, mask >>= 1)
59  input[i] = (inAddress & mask) ? 1 : 0;
60  for(int32_t i = 15, mask = 0x8000; i >= 0; i--, mask >>= 1)
61  input[i] = (inWord & mask) ? 1 : 0;
62  // update the CRC
63  for(int32_t i = 21; i >= 16; i--) next[i] = mBits[i - 1] ^ input[i];
64  next[15] = mBits[14] ^ input[15] ^ mBits[21];
65  for(int32_t i = 14; i >= 13; i--) next[i] = mBits[i - 1] ^ input[i];
66  next[12] = mBits[11] ^ input[12] ^ mBits[21];
67  for(int32_t i = 11; i >= 8; i--) next[i] = mBits[i - 1] ^ input[i];
68  next[7] = mBits[6] ^ input[7] ^ mBits[21];
69  for(int32_t i = 6; i >= 1; i--) next[i] = mBits[i - 1] ^ input[i];
70  next[0] = input[0] ^ mBits[21];
71  // copy the updated bits into place
72  mValue = 0;
73  for(int32_t i = 0, mask = 1; i < eLen; i++, mask <<= 1) {
74  mBits[i] = next[i];
75  mValue |= mBits[i] ? mask : 0;
76  }
77  }
boost::uint8_t uint8_t
Imported type name.
uint32_t mValue
CRC calculation value.
uint8_t mBits[eLen]
CRC calculation bits.

+ Here is the caller graph for this function:

Field Documentation

uint8_t torc::bitstream::Spartan6Bitstream::CRC::mBits[eLen]

CRC calculation bits.

Definition at line 46 of file Spartan6Bitstream.hpp.

uint32_t torc::bitstream::Spartan6Bitstream::CRC::mValue

CRC calculation value.

Definition at line 48 of file Spartan6Bitstream.hpp.


The documentation for this struct was generated from the following file: