ch2-Queues
2019-10-24
SystemVerilog Queues
A SystemVerilog queue is a First In First Out scheme which can have a variable size to store elements of the same data type.
Queue Syntax
A queue is distinguished by it’s specification of the size using $ operator.
SystemVerilog Queue Example
1 |
|
What are queue slice expressions ?
A slice expression selects a subset of the existing variable. Queue elements can be selected using slice expressions as shown in the example below.
Some simulators provide different results, hence using queue methods is recommended.
1 |
|
Queue Methods Example
In addition to array operators, queues provide several built-in methods.
Function | Description |
---|---|
function int size (); | Returns the number of items in the queue, 0 if empty |
function void insert (input integer index, input element_t item); | Inserts the given item at the specified index position |
function void delete ( [input integer index] ); | Deletes the element at the specified index, and if not provided all elements will be deleted |
function element_t pop_front (); | Removes and returns the first element of the queue |
function element_t pop_back (); | Removes and returns the last element of the queue |
function void push_front (input element_t item); | Inserts the given element at the front of the queue |
function void push_back (input element_t item); | Inserts the given element at the end of the queues |
How to create a queue of dynamic arrays in SystemVerilog ?
1 |
|
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!