Reputation: 413
I have the following queue which I create in my sequence:
bit [31:0] transfers_seq [$];
I enter the following values to the queue:
{{00000000, 12345678, 54871245},{12454612, 00000000, 12367894}}
Now I have to pass the transfers_seq to another queue which in the transaction file by initial function that I wrote in the transaction file
transaction file:
class axi_transaction extends uvm_sequence_item();
bit [31:0] transfers [$];
function init ( bit [31:0] transfers2init [$]);
endfunction: init
How can I assign the "bit [31:0] transfers2init [$]" to the "bit [31:0] transfers [$]" in the init function?
Upvotes: 0
Views: 99
Reputation: 13937
Your function needs to return something and, to return a queue, you need a typedef
:
typedef bit [31:0] queue [$];
Then, in your function, you can just copy one queue to the other (as suggested in another answer here):
function queue init ( queue transfers2init);
init=transfers2init;
endfunction: init
But this is so simple, you don't really need a function.
https://www.edaplayground.com/x/3kyE
Upvotes: 1
Reputation: 408
You can simply assign one queue to another:
transfers = transfers2init;
It will copy the elements of transfer2init to transfers. You can check it here: https://www.edaplayground.com/x/3q3f
Upvotes: 2