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
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:
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
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.