System Verilog Queue Methods – push_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 :
push_methods of Queue in System Verilog
push method will pushes the value into the queue either from front side of queue or from the back
side of queue .
two push methods : a. push_front( )
b.push_back( )
4.a)push_front( ) ;
–> push_front will insert value at the front side of queue. It will insert the value at the index “0”.
–> when element is pushed using push_front( ) , the elements which are already present in the Queue will shift to
immediate next index accordingly. i.e. element in “index 0” will shifts to “index 1” and element in “index 1”
will shift to “index 2” and so on……..
Syntax: array_name.push_front( );
Example :
int xtn [$ ];
xtn={10,20,30};
xtn.push_front(40); // injects value 40 at index 0
4.b)push_back( ):
–> push_back( ) will insert value at the back side of Queue. The element will be injected at the immediate index number
of last index.
Syntax : array_name.push_back( );
Example :
int xtn [$ ];
xtn.push_back( 50); // injecting value at the back side of Queue.
Simulated_Example:
module tb();
int xtn[$];
initial
begin
xtn = {10,20,30};
$display(“values of queue mem = %p”,xtn);
xtn.push_front(40);
$display(“values of queue mem = %p”,xtn);
xtn.push_back(50);
$display(“values of queue mem = %p”,xtn);
end
endmodule
Simulator_output:
****************************************************************
values of queue mem = ‘{10, 20, 30}
values of queue mem = ‘{40, 10, 20, 30}
values of queue mem = ‘{40, 10, 20, 30, 50}
****************************************************************