In reply to dave_59:
I messed up between my real case and the made up example. Let’s stick to the example since it’s the only shared code so far.
Did you mean to declare data_t as struct packed?
Yes indeed, the data_t should be packed
And did you mean to say you have a function that writes a 13-bit packed struct, not 132?
Correct, let’s assume I have a struct of 13 bits that I want to push on a bit queue for later retrieval.
To answer your direct question "does this line of code work? Yes it does, but we still cannot answer if it does what you want it to do.
I’m trying to push data on the queue data_t bits at a time, while I want to pop it out one byte at a time. Since I want to preserve the ordering of the input vs output (so the msb on the data_t should be the same as the msb of the output byte), I’m currently doing this:
// Writing to the queue
bit [12:0] data13;
{>>{data13}} = data;
for (integer i = $size(data13); i > 0; i--) queue.push_back(data13[i-1]);
// Reading from the queue
byte data8;
for (integer i = $size(data8); i > 0; i--) data8[i-1] = queue.pop_front()
I was wondering if I could simply do instead:
// Writing to the queue
{>>{queue}} = data; // Should store data msb first
// Reading from the queue
{>>{data8}} = queue; // I doubt this will work!