Queue:
int queue[$] = {1,2,3};
int queue[$:256]; //A queue whose maximum size is 256 bits
7.10.1 operator
queue[0:$] //travel the queue
7.10.3 methods
function int size();
function void insert(input integer index, input element_t item);
function void delete( [input integer index] ); // input index is optional, is index is not specified, then the delete() method deletes all the elements in the queue.
function element_t pop_front();
function element_t pop_back();
function void push_front(input element_t item);
function void push_back(input element_t item);
所以queue 在sv中是没有find/exists function的,但是可以使用array 中的find_xxx function 返回一个queue
function:
-find() returns all the elements satisfying the given expression.
-find_index() returns the indices of all the elements satisfying the given expression.
-find_first() returns the first element satisfying the given expression.
-find_first_index() returns the index of the first element satisfying the given expression
-find_last() returns the last element satisfying the given expression.
-find_last_index() returns the index of the last element satisfying the given expression.
program automatic queue_demo;
int queue[$] = {1,2,3};
initial begin
queue.push_back(4);
queue.push_back(3);
$display("queue:%p",queue);
queue=queue.find(x) with (x==3); //find() with(item !=3) delete the element"3"
$display("queue:%p",queue);
//foreach(queue[idx])
// $display("queue:%d",queue[idx]);
end
endprogram
结果:
queue:'{1, 2, 3, 4, 3}
queue:'{3, 3}