Altera_Forum
Honored Contributor
14 years agoLooking for tips on how to implement variable length data transformation / parsing.
Sirs,
I am looking for any tips and tricks as for how to process unaligned, variable-length data in FPGAs. Basically, the data is coming from 10G MAC through Avalon interface with 64-bit data width. Then UDP payload is extracted. In a single UDP payload, there are many many smaller "messages" that should be passed further through Avalon ST with "its own" beginofpacket, end of packet etc. The basic format is like this: First 16 bit of each message is its payload size in bytes (not including these 2 bytes of size). Then goes payload. Right when payload ends the next message starts. Unfortunately, there is no guarantee for data alignment - message length can be 1, 2 or 1K bytes. Since I have never done anything like this before, I have many questions. First question is - is there any existing IP, whitepapers, reference designs, or anything that help on the way of designing a module like this? The main issues that I have is.... put it simple - I don't know how to implement it best. All my idea smell so bad I can't stand them myself. My thoughts are these: In order to process a single 64-bit chunk, I have to keep track of chunks that I still need to send. Than take, say, modulo of division by 8 to figure out offset where to read next size. Since I have to perform multiple operations, I have (or I think I have) two choices - first is set "ready" flag in the sink interface to 1'b0 in order to stop data flowing in. Then take my cycles to do math on number and pass message further. But I am not sure if it is generally an acceptable practice to "pause" a source to sink data flow in the middle of receiving a packet. But even it is - I dislike this way very much because it literally kills the throughput. So if I don't pause, I will have to do pipelining. Getting more data in while I don't really know what to do with it. But then comes a good question - what if I got, say, 5 samples into my sink, during that time I've done my calculations and it turned out that message size was 1 byte and now I have to go back to the first chunk and start all over. Another point is this - say I am trying to align 5 chunks of 64-bit samples with 5 steps of calculations I need to do. What if... source actually desserts "valid" signal on some stages? Should I also check for "valid" on every math operation and... waste a cycle if source is not valid? Please help. Any thoughts, hints, links, criticism is highly appreciated.