I have a parameterized design, and I want to create a coverage database on the design parameters. My question is: Is it possible to sample covergroups whose coverpoints are static design parameters?
For example:
module dut #(
mode = 1,
type = fast
)
(
);
I have a coverage model with all the parameters defined as coverpoints (in above example coverpoints will be mode and type). Can I sample these ? Is there a way I can refer/reference these design parameters? Or I was thinking of creating an Interface to reference paramters.
You can define parameter as cover point. You can refer to parameter with module instance path. Here are two ways to do this - one to implement the coverage model in the dut, one is to implement the coverage model in test bench.
typedef enum int {fast, slow, med} dutT;
module tb ();
dut #(2, slow) dut1();
dut #(3, med) dut2();
dut #(4, fast) dut3();
//way 1
covergroup cg_param with function sample (int mode, dutT dut_type);
option.per_instance = 1;
coverpoint mode;
coverpoint dut_type;
endgroup
cg_param cg_param_inst=new;
initial begin
$display("dut1.mode=%0d, dut1.dut_type=%0s",dut1.mode, dut1.dut_type.name());
$display("dut2.mode=%0d, dut2.dut_type=%0s",dut2.mode, dut2.dut_type.name());
$display("dut3.mode=%0d, dut3.dut_type=%0s",dut3.mode, dut3.dut_type.name());
//way 1 define the covergroup in tb
cg_param_inst.sample(dut1.mode, dut1.dut_type);
cg_param_inst.sample(dut2.mode, dut2.dut_type);
cg_param_inst.sample(dut3.mode, dut3.dut_type);
//way 2 define the covergroup in the dut
dut1.cg_param_inst.sample();
dut2.cg_param_inst.sample();
dut3.cg_param_inst.sample();
end
endmodule
module dut #(parameter int mode = 1, dutT dut_type = fast) ();
covergroup cg_param;
option.per_instance = 1;
coverpoint mode;
coverpoint dut_type;
endgroup
cg_param cg_param_inst=new;
endmodule
Thank you for the options. I am planning to implement my covergroup’s in TB. In my case the parameterized design lies down in the hierarchy of design. So, can I bind the sample function hierarchical? For example:
Instead of
//way 1 define the covergroup in tb
cg_param_inst.sample(dut1.mode, dut1.dut_type);
Is it legal to do below ?:
cg_param_inst.sample(dut1.dut_inst1.dut_inst.mode, dut1.dut_inst1.dut_inst.dut_type);
it is okay. covergroup cg_param is implemented with overridden sample function which accepts two arguments “mode” and “dut_type”. These two arguments can be passed with any type-compatible variables or parameters down to your design hierarchy.
covergroup cg_param with function sample (int mode, dutT dut_type);
..
endgroup
String type variable can’t be used as cover point.
Variable of type other than integral/real is illegal for specifying as coverpoint/cross expression.
The term integral refers to the data types that can represent a single basic integer data type, packed array, packed structure, packed union, enum variable, or time variable.
Regarding the same level implementation on string:
The requirement is passing test key string from the command line and wanted to write a covergroup when test is PASSED with that test key.
There are several ways of getting the name of the test string passed in with +UVM_TESTNAME, including uvm_cmdline_proc.get_arg_value(), then you can proceed as above.
Note that you should not have to do this as any tool following the UCIS standard for collecting coverage data has mechanisms for mapping requirements to many different types of coverage metrics. Mapping a requirement to the passing of a test is one of them.
Hi Thanks for you response.
Actually the requirement is “Set of (Test passed + test_key used) → feature covered bin = 1”
I am doing in the same way as you explaned.
In my coverage_collector component, test_key is getting using this code:
uvm_cmdline_processor cmdline_processor = uvm_cmdline_processor::get_inst();
function void connect_phase(uvm_phase phase);
string data_key;
if (cmdline_processor.get_arg_value(“+TEST=”, data_key) != “”) begin
end
endfunction: connect_phase
And in report phase i am sample when that particular test is passed.
if(srvr.get_severity_count(UVM_FATAL) + srvr.get_severity_count(UVM_ERROR) == 0) begin
test_results_cg.sample(“data_key”);
And covergroup is:
covergroup test_results_cg with function sample(string test_key);
cp_dir_key_p : coverpoint test_key==“data_key” {
bins covered_test_p = {1};
}
endgroup: test_results_cg
So not getting how to pass test_key to covergroup on every test provided. Is this something i am doing wrong for this requirement?, could you please suggest.