Grace90
Grace90

Reputation: 227

How to ignore specific covergroup instances of a multi dimensional dynamic array covergroup instantiation

I have a covergroup something like this

  covergroup cover_routers with function sample(bit inj_val,eje_val);
   option.per_instance = 1; 

    inj_val_cp : coverpoint inj_val
                  {
                   bins inject_valid[] = {[0:1]};
                  } 
    eje_val_cp : coverpoint eje_val
                  {
                    bins eject_valid[] = {[0:1]};
                  }   
   endgroup

Below I have multi dimentional dynamic array instance of the covergroup. Since it is a 8x4 array, so there will be 32 instances of the covergroup cov_routers but I want to exclude certain instances based on values of i and j, where i and j are two dimensions of the array, If I don't do so, it shows holes in covergroup instances in verdi

For some values of i and j, I dont want coverage i.e just for example for the following instances of covergroups I don't want coverage,

cov_routers[2][0]; cov_routers[2][1], cov_routers[2][2], cov_routers[7][3] and cov_routers[7][2]

I don't want to sample them so I tried doing something like following:

   class my_cov extends ovm_component;
    `ovm_component_utils_begin(my_cov)
    `ovm_component_utils_end
    cover_routers cov_routers[][];// ixj= 8x4 array
     function new(input string name = "my_cov", ovm_component parent = null);
     super.new(name,parent);
     endfunction
     
     function void build();
     super.build();
      cov_routers  = new[8]; 
          foreach(cov_routers[i])
          begin
             if (i==2)
             cov_routers[i] = new[1]; // since i want coverage only for 1 instance cov_routers[2][3] 
             else if (i==7)
             cov_routers[i] = new[2];// since i want cov only for cov_routers[7][0] & cov_routers[7][1]
              else 
              cov_routers[i] = new[4];
              end

              for (int i=0; i<8; i++) 
              begin
                 for (int j=0; j<4; j++)
                 begin
                   if (((i==2) && (j ==0))||((i==2) && (j ==1))||((i==2) && (j ==2))||((i==7)&&(j==3))||((i==7)&&(j==2))
                   begin
                 //do nothing
                   end
                   else
                   begin
                    cov_routers[i][j] =new;
                   end
                  end
                 end

          task run();
            super.run();
              fork
              router_coverage();
              join
           endtask

           task automatic router_coverage();
           for (int p=0; p<8; p++) 
              begin
              automatic int i=p;
                 for (int q=0; q<4; q++)
                 begin
                 automatic int j=q;
                  if (((i==2) && (j ==0))||((i==2) && (j ==1))||((i==2) && (j ==2))||((i==7)&&(j==3))||((i==7)&&(j==2))
                  begin
                  // do nothing
                  end
                  else
                  begin
                   fork
                   begin
                   router_c(i,j)
                   end
                   join_none
                  end
               endtask

            task automatic router_c(int i, int j);
            forever
            begin
            .....waiting for clock
            .....sampling coverpoints inj_val  and eje_val through proprietary fns
            cov_routers[i][j].sample(inj_val, eje_val)
            end
            endtask

                

but when I do sampling of following instance in run task, it gives the error below

                     cov_routers[2][3].sample(....) 

Error-[NOA] Null object access The object is being used before it was constructed/allocated. Please make sure that the object is allocated before using it.

Please help me with what I am doing wrong here or is there any other easier way of ignoring coverage for certain instances of covergroups, I will be very grateful

Upvotes: 0

Views: 796

Answers (1)

dave_59
dave_59

Reputation: 42738

If you don't construct a covergroup, you can't sample it. You either have to use the same logic you used to choose which covergroup instances got constructed, or you can check if the instance is null before sampling.

if (cov_rbox_val[i][j] != null) cov_rbox_val[i][j].sample(....) 

Upvotes: 0

Related Questions