Skip to content

Fix data range when copy a queue#1204

Open
BHgin wants to merge 1 commit into
VUnit:masterfrom
BHgin:master
Open

Fix data range when copy a queue#1204
BHgin wants to merge 1 commit into
VUnit:masterfrom
BHgin:master

Conversation

@BHgin

@BHgin BHgin commented Jun 10, 2026

Copy link
Copy Markdown

I encounterd an issue when I copied a queue_t that already has been popped from.
In an minimal example it looks like this:

constant QUEUE : queue_t := new_queue;
...
variable data_a : std_logic_vector(63 downto 0) := (others => '0');
variable data_b : std_logic_vector(63 downto 0) := (others => '1');
variable data : std_logic_vector(63 downto 0);
...
push(QUEUE, data_a);
push(QUEUE, data_b);

data := pop(QUEUE);
check_equal(data, data_a);

data := pop(copy(QUEUE)) -- is also data_a
check_equal(data, data_b); -- error, data_a instead of data_b was popped above!

The problem is that while copying the data of QUEUE the range 0 to length(queue) - 1 is used rather than the actual head and tail values get(queue.p_meta, head_idx) to get(queue.p_meta, tail_idx) - 1.

The copied queue still does not have the same head and tail as the origin but they have the same content and length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant