Jump to content

Recommended Posts

Using an array of class objects which have a covergroup in them, I've run into the following problems.  I look for a solution which is supported by all/most simulators.  This topic array seems to be a common issue, based upon web search results.

ERROR TYPE0: Same coverage is recorded for both covergroups, despite option.per_instance=1 being used.
# vsim -voptargs=+acc=npr
# cg_fa[0] - Coverage=81.25 %
# cg_fa[1] - Coverage=81.25 %

ERROR TYPE1: Compile error with another simulator
cg_fa[0] - Coverage=xmsim: *N,COVNSM: (File: ./testbench.sv, Line: 42):(Time: 0 FS + 0) Sampling of covergroup type "cg_wrapper::cg" (./testbench.sv:7), referred in the statement is not enabled. As a result, coverage methods get_coverage(), get_inst_coverage(), get_hitcount(), and get_inst_hitcount() will return 0 coverage.

Relevant LRM reference:  IEEE_Std1800-2017  19.8.1 Overriding the built-in sample method

Code: https://edaplayground.com/x/6Zuh 

Does anyone have a tip for either of these issues?

 

package data_types_pkg;

  class cg_wrapper;
    covergroup cg with function sample ( bit [7:0] data );
      option.per_instance = 1;

      cp_data : coverpoint data[7:0];
    endgroup : cg

    function new();
      cg = new();
    endfunction

  endclass : cg_wrapper
endpackage : data_types_pkg


// MODULE: TOP
//  The testbench of covergroup array
module top;
  import data_types_pkg::*;

  cg_wrapper       cg_fa[2];

  initial begin
    $display("Make cg_fa[0]");
    cg_fa[0] = new(); //supply transaction as ref to covergroup instances instances
    cg_fa[0].cg.set_inst_name("cg_fa[0]");

    $display("Make cg_fa[1]");
    cg_fa[1] = new(); //supply transaction as ref to covergroup instances instances
    cg_fa[1].cg.set_inst_name("cg_fa[1]");

    //Sample each, but mainly [0]
    repeat (100) begin                       // many samples for [0]
      cg_fa[0].cg.sample( $urandom()%256 );  //  
      //#5;                                  // TRIED TO ADD DELAY SO DIFFERENT TIME SLOTS USED
    end                                      // ALSO TRIED TO CALL SAMPLE() from automatic function
    repeat ( 1)  begin                       // few samples for [1]
      cg_fa[1].cg.sample( $urandom()%256 );  // 
      //#5;
    end

    //Report coverage
    $display ("cg_fa[0] - Coverage=%0.2f %%", cg_fa[0].cg.get_inst_coverage());
    $display ("cg_fa[1] - Coverage=%0.2f %%", cg_fa[1].cg.get_inst_coverage());
  end
endmodule

 

As a side-note/question: If a simulator does not allow access to a covergroup's name with "cg.option.name" access (i.e. dot notation, such as to print it), then if name string is set with set_inst_name, how else can it be accessed?  Only in a tool output report?

Link to post
Share on other sites
  • 3 weeks later...

Note/Clarification:
With VCS 2019.06 and Riviera Pro 2020.04, the code in the original post works as I expected.

cg_fa[0] - Coverage=78.12 %
cg_fa[1] - Coverage=1.56 %

I try to write code which has "universal" support across "all" simulators.
Is the difference across simulators due to ambiguity in the LRM?  Is some aspect of my code using a poor style?  How can this code be improved for more universal simulator support?

(I am trying to avoid publically contrasting simulators, which afaik is verboten.)

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...