System Verilog Queue Methods – pop_methods( )
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 :
pop_methods( ) of Queue in System Verilog
pop_methods will removes the value from the Queue and returns the removed value (or) element.
two pop_methods : a.pop_front( );
b.pop_back( );
5.a)pop_front( );
–> pop_front( ) will removes element (or) value of Queue from the front side of Queue .
–> it will removes the element at the index 0
–> After removing elements will shift towards index 0 accordingly. i.e. element in “index 1” will shift to “index 0”
and element in “index 2” will shift to “index 1” and so on …..
Syntax : array_name.pop_front( ) ;
Example :
int mem[$ ];
mem={1,2,3};
mem.pop_front( );
5.b)pop_back( );
–> pop_back( ) will removes the element from the backside of Queue i.e element will be removed at the last index.
–> After the element is removed the size of the Queue will shrink.
Syntax :array_name.pop_back( );
Example:
int pkt[$];
pkt ={1,2,3};
pkt.pop_back( );
Simulated_Example:
module tb();
int xtn[$];
int front_value;
int back_value;
initial
begin
xtn = {10,20,30,40,50};
$display(“values of queue mem = %p”,xtn);
front_value = xtn.pop_front( );
back_value = xtn.pop_back( );
$display(“pop_front value of xtn = %0d”,front_value);
$display(“values of queue mem after pop_front= %p”,xtn);
$display(“pop_back value of xtn = %0d”,back_value);
$display(“values of queue mem after pop_back = %p”,xtn);
end
endmodule
Simulator_output:
***************************************************************************
values of queue mem = ‘{10, 20, 30, 40, 50}
pop_front value of xtn = 10
values of queue mem = ‘{20, 30, 40, 50}
pop_back value of xtn = 50
values of queue mem = ‘{20, 30, 40}
***************************************************************************