[systemverilog] cover group

Q:

class cg ;

int skew_val_vl[20];

   covergroup skew_val_cg (int skew_val_vl);

     coverpoint skew_val_vl {

      bins skew_range_1 ={[124:0]};

      bins skew_range_2 ={[325:125]};

      bins skew_range_3 ={[526:326]};

      bins skew_range_oor ={[1100:929]};

     }

   endgroup: skew_val_cg

   function new(string name, uvm_component parent =null);

      super.new(name, parent);

      foreach(skew_val_vl[i])

         skew_val_cg skew_cg[i]=new(skew_val_vl[i]);  //getting error for this line

   endfunction// new

endclass


A:

 上面寫法會報error ,因爲

A covergroup declaration within a class is an embedded covergroup declaration. An embedded
covergroup declaration declares an anonymous covergroup type and an instance variable of the
anonymous type. The covergroup_identifier defines the name of the instance variable. In the above
example, a variable skew_val_cg (of the anonymous coverage group) is implicitly declared.


推薦用法:(covergroup寫在class外面)

  covergroup skew_val_cg ( ref int skew_val_vl);    //一定要加ref

      coverpoint skew_val_vl {

      bins skew_range_1 ={[124:0]};

      bins skew_range_2 ={[325:125]};

      bins skew_range_3 ={[526:326]};

      bins skew_range_oor ={[1100:929]};

      }

   endgroup: skew_val_cg


class cg;
            glb_cfg  cfg;

   int skew_val_vl[20];

   skew_val_cg  sv_cg[20];  

   function new(string name, uvm_component parent =null);

       super.new(name, parent);

       foreach(sv_cg[ii])

           sv_cg[ii]=new(skew_val_vl[ii]);  

   endfunction// new


  function sample_sig();       

       foreach(sv_cg[ii]) begin

           skew_val_vl[ii] = cfg.skew_val_vl[ii];    //先更新變量的值,再sample

           sv_cg[ii].sample();  

       end

  endfunction

 endclass

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章