Dynamic Array Methods in System Verilog

Arrays :

                       1. size( )

                       2. delete( )

                                    1.size( )

                                   2. delete( ) & delete(index)

                                   3. insert(  )

                                   4. push( ) methods

                                   5. pop( ) methods

                                   1.size( )

                                   2.delete ( ) & delete(index)

                                  3.num ( )

                                  4.exists( )

                                  5.first( ) ,next( ), prev ( ), last( )

Common  Methods for Dynamic Arrays & Queues :

delete( ) method of dynamic array

 

2.delete( ) : 

       –> The delete( ) method of dynamic array will deletes the entire data of an array.

       –> delete( ) method clears all the elements of an array and becomes an empty array.

      –> After deleting the entire array ,the size of an array will become “zero”

      Syntax : array_name.delete( );

      Example : 

               int xtn [ ];

              xtn.delete( );

 

Simulated_Example

module tb();

            int mem[ ];

            initial

              begin

               mem = new [5];

               for(int i=0 ; i<mem.size() ; i=i+1)

                begin

                 mem[i] = i;

                end

            $display(” values of mem =%p “, mem);

            mem.delete();

            $display(” values of mem after delete() = %p” ,mem);

          end

        endmodule

.

 

 

 

 

 

Simulator_output : 

      *************************************************************************

        values of mem ='{0, 1, 2, 3, 4} 

        values of mem after delete() = ‘{}       // no values inside array

        ************************************************************************