Turbo code implementation in C++
-
Hi everyone, I am trying to implement turbo encoder, i am not getting how to write the code for D-Flipflop because i am not getting how to access a single bit in C++. please help me out.. :)
In C/C++ single bits are acessed by using logical operators (and: &, or: |, xor: ^, not: ~) with masks with only one bit set. Additional bit operators are the shift left and right operators. An example would be counting the number of bits set in a variable:
unsigned CountBits(unsigned nVal)
{
unsigned nCount = 0;
while (nVal)
{
// test if lowest bit is set
if (nVal & 1)
++nCount;
// shift value right by one bit
nVal >>= 1;
}
return nCount;
} -
In C/C++ single bits are acessed by using logical operators (and: &, or: |, xor: ^, not: ~) with masks with only one bit set. Additional bit operators are the shift left and right operators. An example would be counting the number of bits set in a variable:
unsigned CountBits(unsigned nVal)
{
unsigned nCount = 0;
while (nVal)
{
// test if lowest bit is set
if (nVal & 1)
++nCount;
// shift value right by one bit
nVal >>= 1;
}
return nCount;
}Bit Field facility is available in C++ as well. http://publib.boulder.ibm.com/infocenter/macxhelp/v6v81/index.jsp?topic=%2Fcom.ibm.vacpp6m.doc%2Flanguage%2Fref%2Fclrc03defbitf.htm[^]
-
Bit Field facility is available in C++ as well. http://publib.boulder.ibm.com/infocenter/macxhelp/v6v81/index.jsp?topic=%2Fcom.ibm.vacpp6m.doc%2Flanguage%2Fref%2Fclrc03defbitf.htm[^]