I know that we have the concept of queue of dynamic arrays,but is it possible to copy the contents of a dynamic array into a queue?Please help me.
In reply to leya:
you can do following thing.
module top (/*port details*/);
bit [7:0] d_array[];
bit [7:0] queue[$];
initial
begin
d_array = '{1,2,3,4,5,6};
queue = { >> {d_array}}; // copying d_array in queue
$display(" QUEUE = %0p",queue);
end
endmodule: top
// Even below code will aslo work
// Code your testbench here
// or browse Examples
module top (/*port details*/);
bit [7:0] d_array[];
bit [7:0] queue[$];
initial
begin
d_array = '{1,2,3,4,5,6};
queue = d_array; // copying d_array in queue
$display(" QUEUE = %0p",queue);
end
endmodule: top
Thanks for the help…now i got it
In reply to kerulmodi:
how to do the reverse ??
and what if queue already has some values so how to override it
In reply to mittal:
Similar manner you can do it in reverse way.
module top (/*port details*/);
bit [7:0] d_array[];
bit [7:0] queue[$];
initial
begin
queue = '{1,2,3,4,5,6};
d_array = { >> {queue}}; // copying queue in d_array
$display(" D_ARRAY = %0p",d_array);
end
endmodule: top
if want this using function then how we can write it?
All of “this” can be done in one statement without writing a function. There are a number of things being discussed here. What is the “this” you want to do?