System Verilog Queue Methods – size( )
Queue Methods 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 :
size( ) method of Queue in System Verilog
1.size( ) :
–> size method will return the size at the current point of time.
–> size of the queue will increase with increase in incoming data and shrinks when data is removed .
–> size( ) method will return the size value and if we want to capture the size value we need another
variable to store data.
Syntax : array_name.size( );
Example :
int packet[$];
int size;
size=packet.size( ) ;
In the above example , we declared a queue with name “packet” which is capable storing integer
type of data. we are assigning the returned value by size( ) method to the variable “size” for
capturing the data.
Simulated_example:
module tb();
int array_1[$];
int array_2[$];
int size ;
initial
begin
array_1 = {10,20,30,40,50};
size = array_1.size();
for(int i=0 ; i<100 ; i=i+1)
begin
array_2 [i]= i;
end
$display(” size of an array_1 = %d “, size);
$display(” size of an array_2 = %d “, array_2.size());
end
endmodule
Simulator_output :
*************************************************************************
size of an array_1 = 5’
size of an array_2 = 100
*************************************************************************