I have a 32-bit datastream coming from a sensor. The data is encoded as a Type-Length-Value encoding. This means the first byte indicates what kind of data there is and the second byte contains the length. The body is variable sized from 1 byte to 32 bytes.
Now the problems lies in that a message can have arbitrary alignment and worse can be smaller then 32-bit which means it's possible to parse multiple packets in a single 32-bit word.
I'm honestly at a loss on how to efficiently implement this. There is just an explosion of cases. Message type is at pos 0, 1, 2, 3. Which leads to either being able to grab the length or not. Which means you MIGHT need to parse the next message type.
I unfortunately don't have the option to do back-pressure which would at least make it a bit more doable.
How to decode something like this efficiently on an FPGA?
procedure
and aloop
-- basically, I have four blocks that each accept the old aligner state, a single byte and a byte enable signal, and output an aligned word and a new aligner state. Because there are no register stages between the steps, the optimizer flattens that. \$\endgroup\$