systemverilog queue 的使用,如何判断元素是否存在
2016-10-18 23:01
4251 查看
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
4000
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}
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
4000
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}
相关文章推荐
- jQuery -- 如何使用jQuery判断某个元素是否存在
- 如何使用jQuery判断一个元素是否存在
- 如何使用JQuery去判断一个元素(对象)是否存在
- jQuery -- 如何使用jQuery判断某个元素是否存在
- javascript中如何判断一个元素在页面中是否存在(转)
- 在JSP使用EL和JSTL判断指定元素是否存在于指定集合中
- (笔试题)如何判断数组中是否存在重复元素
- indexOf() 如何判断一个元素在指定数组中是否存在? 找出指定元素出现的所有位置? indexOf()方法 是正序查找,lastIndexOf()是倒叙查找
- 在jQuery,如何判断页面元素是否存在?
- javascript(jquery)中如何判断一个元素在页面中是否存在
- 如何用JS判断网页中某个id的网页元素是否存在
- php使用DOMDocument的时候如何判断xml中某节点是否存在
- java HashSet 如何判断元素是否存在
- 如何在前端用js判断一个元素在一个数组中是否存在
- 关于如何使用ajax异步判断用户名是否存在
- 怎么使用jquery判断一个元素是否含有一个指定的类(class)另外如何给元素动态添加类
- javascript和jquery如何判断元素是否存在最佳。
- 优先队列priority_queue容器的使用方法:出队,入队,删除队首元素,判断是否为空
- java HashSet 如何判断元素是否存在
- 判断元素是否为空,是否存在,元素值=sss,y元素值包含aa