Search the Community
Showing results for tags 'override sample'.
Found 1 result
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 - Coverage=81.25 % # cg_fa - Coverage=81.25 % ERROR TYPE1: Compile error with another simulator cg_fa - 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; initial begin $display("Make cg_fa"); cg_fa = new(); //supply transaction as ref to covergroup instances instances cg_fa.cg.set_inst_name("cg_fa"); $display("Make cg_fa"); cg_fa = new(); //supply transaction as ref to covergroup instances instances cg_fa.cg.set_inst_name("cg_fa"); //Sample each, but mainly  repeat (100) begin // many samples for  cg_fa.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  cg_fa.cg.sample( $urandom()%256 ); // //#5; end //Report coverage $display ("cg_fa - Coverage=%0.2f %%", cg_fa.cg.get_inst_coverage()); $display ("cg_fa - Coverage=%0.2f %%", cg_fa.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?