0

My application receives a 32-bit word from hardware.

The first byte signifies the data type, the remaining 3 bytes are the data (24 hard decision bits)

The application is required to buffer the data bits until a sufficient number is available for processing. 30 bits are required for further processing.

So once the second word has been received, the application will have 30 bits of the first packet and 18 bits of the second packet.

My question is how best to buffer and output bits from the fifo. The bits also need to be packed into a 32-bit word

I've tried using streams and bitset to no avail. I haven't tried bitshifts yet as I was hoping to find something a little bit more 'elegant' and learn something!

Any C++ suggestions?

EDIT - Hopefully this will make things a bit clearer...ideally I want to read the 3 bytes I receive into a stream. Once that stream has 30 or more bits with it, I then want to read those 30 bits out. The remaining bits will be left, until there are another 30 bits available. Basically I want a bit FIFO, that I can write to and read bits from.

user3542787
  • 31
  • 1
  • 4
  • use byte arrays, enums, `reinterpret_cast` if you know the hardware. Can't really give any specific solutions to such a broad question. – Red Alert May 08 '14 at 22:30
  • You said the remaining 3 bytes are the data (24 bits). After your receive the second word, do you want to split the second data into two parts? The first part (6 bits) into the first packet and the remaining 18 bits in a second packet? – Yuchen May 08 '14 at 22:54

0 Answers0