System Verilog Queues
Queues in System Verilog
Arrays :
1. size( )
2. delete( )
Queues
Bounded Queues
Queues methods
1.size( )
2. delete( ) & delete(index)
3. insert( )
4. push( ) methods
5. pop( ) methods
Associative arrays
Associative array methods
1.size( )
2.delete ( ) & delete(index)
3.num ( )
4.exists( )
5.first( ) ,next( ), prev ( ), last( )
Common Methods for Dynamic Arrays & Queues :
Queues in System Verilog
Queues in system Verilog are type of dynamic arrays which is having a FIFO type of functionality. Queues allows to store sequnece of elements in first-in-first-out manner. It is also an unpacked array with FIFO functionality.
–> Size of the Queue will increase with increase in incoming data and shrinks when the data inside Queue
is read (or) removed.
Syntax : data_type variable_name[ $ ];
Example:
int packet[ $ ];
In the above example “packet” is a Queue with undefined variable size. we mention “$” as range after the array_name , so this one dimension unpacked “packet array” will work like Queue .
Bounded Queue :
–> A Queue which is having a fixed size is called Bounded Queue.
–> Queues does not need to be allocated particular size as queue size will vary based on the data.
–> If we want to make Queue as bounded one i.e. If we want to set fixed size for queue we can declare queue as follows in the example.
Example :
int packet[ $ : 2 ]; // queue with size 3
int xtn[ $ : 9 ]; // queue with size 10.
Simulated_example:
module tb();
int array [$];
initial
begin
array ={2,3};
$display(” values of an array = %p”,array);
array={5,6,7,8};
$display(” values of an array = %p”,array);
array = {10,20,30,40,50,60};
$display(” values of an array = %p”,array);
end
endmodule
Simulator_output :
*********************************************************************
values of an array = ‘{2, 3}
values of an array = ‘{5, 6, 7, 8}
values of an array = ‘{10, 20, 30, 40, 50, 60}
*********************************************************************