Issue in Generating coverage when i have coverpoints with macros

Hi

I am using macro based coverpoints in my class.I am using Quests10.4 for simulations.

I am not getting any compilations issues and simulation is also clean but I am not getting any coverage output.

My commands are:
qvlog -sv samp_cg.sv
vsim -c main -do “run;-coverage”

Please find the output below code.My query is How to use macros inside coverage and cross coverage and generate output aswell.
//////////////////////////////////////////////////////////////////////////////////////////////////

program main;
    typedef enum {PINK,BLUE} my_color;
    `define cov_macro coverpoint my_c {\
                      bins PINK_C={PINK};\
                      bins BLUE_C={BLUE};\
                      }
  class basic;
    rand my_color my_c;
    rand bit en;
    int my_en;
    covergroup my_cg;
      cp_macro:`cov_macro
      en_cp: coverpoint en
      {
        bins BIN_1={1};
        bins BIN_0={0};
      }
      cross_cov: cross en_cp,cp_macro{
         ignore_bins my_ig = binsof(en_cp.BIN_1);
      }
    endgroup:my_cg
    function new();
      my_cg=new();
    endfunction:new
    task run();
      my_cg.sample();
    endtask:run
  endclass
  initial begin
    basic b_obj=new();
    repeat(1) begin
      b_obj.randomize();
      $display(",b_obj=%p",b_obj);
      b_obj.run();
    end
  end
endprogram:main

//////////////////////////////////////////////////////////////////////////////////////////////////
Output:
Loading sv_std.std

Loading work.main(fast)

run

,b_obj='{my_c:BLUE, en:0, my_en:0, my_cg:{ref to covergroup #my_cg#}}

End time: 11:33:04 on Aug 22,2016, Elapsed time: 0:00:04

Errors: 0, Warnings: 2

In reply to TransVerif:

Code looks OK to me. I ran in another tool and got 50% coverage for your code and by changing repeat () got even 100%. Try and add the following line to query and print FCOV:

$display ("FCOV obtained: %3.2f%%", $get_coverage());

Perhaps you are missing “fcover” commands in Questa - Simple usage would be:

fcover -report

Regards
Srini
www.go2uvm.org

In reply to Srini @ CVCblr.com:

Hello Srini,

Can you please share the commands you used to generate.

Did i miss the switches to generate coverage using questasim.

Regards
Bharath

In reply to TransVerif:

I didn’t run on Questa. But by adding that line you can see with any tool without any extra switch the results. For Questa specific - do refer to the command that I indicated (fcover). My modified code:

program main;
    typedef enum {PINK,BLUE} my_color;
    `define cov_macro coverpoint my_c {\
                      bins PINK_C={PINK};\
                      bins BLUE_C={BLUE};\
                      }
  class basic;
    rand my_color my_c;
    rand bit en;
    int my_en;
    covergroup my_cg;
      cp_macro:`cov_macro
      en_cp: coverpoint en
      {
        bins BIN_1={1};
        bins BIN_0={0};
      }
      cross_cov: cross en_cp,cp_macro{
         ignore_bins my_ig = binsof(en_cp.BIN_1);
      }
    endgroup:my_cg
    function new();
      my_cg=new();
    endfunction:new
    task run();
      my_cg.sample();
    endtask:run
  endclass
  initial begin
    basic b_obj=new();
    repeat(11) begin // Srini increased to 11
      b_obj.randomize();
      $display(",b_obj=%p",b_obj);
      b_obj.run();
    end
   $display ("FCOV obtained: %3.2f%%", $get_coverage()); // Srini added for results

  end
endprogram:main

In reply to TransVerif:

Coverage is available when you utilize the Questa GUI without any additional commands or switches. If you want to visualize coverage post-simulation, there are some additional commands which you will need to use.

Please refer to the Questa documentation on how to generate this information, or contact your Mentor support person for additional assistance.

In reply to cgales:

Hello Srini/cgales,

It worked for me and i could generate coverage as expected.

Command line switch i have used for simualtion and run is below:

vsim -c main -do “run;-coverage fcover -report”

With Thanks…