It’s primary use case is to measure the level of exercise of SystemC models, basically to measure how many of model’s features were run and which parameters were used during runs. A SystemC model can be run in a standalone environment (e.g. for architectural exploration, in the context of a unit test etc.) or within a verification environment as a reference. In the former case one can use FC4SC to measure the model’s level of exercise achieved during a run. In the latter case one can use the SystemVerilog coverage to approximate the level of exercise (see more here) or can also include FC4SC coverage definitions as a double-check.
Comparison with SystemVerilog
FC4SC has its roots in functional coverage facilities provided by SystemVerilog and e-Language, that is why a comparison with IEEE1800 implementation is useful. One can access the comparison table here.
Installation and Integration
Start by downloading FC4SC project from its GitHub repo. Open the User Guide and follow the steps in the Install and Integration Section.
Examples
One can find examples of how to define coverage groups, coverage points etc. in the provided tests. These tests use Google’s unit testing framework as a testing infrastructure.
For reader’s delight here it is an example of how to define and use a covergroup:
#include "fc4sc.hpp"
...
class my_first_cvg : public covergroup {
public:
int SAMPLE_POINT(value,values_cvp);
int SAMPLE_POINT(flags, flags_cvp);
// Must call parent constructor somewhere register a new covergroup
CG_CONS(test_coverage) {
option.weight = 2; // set this instances weight
values_cvp.option.at_least = 4; // hit each bin in values_cvp at least 4 times
}
// We just move the data to be sampled inside our covergroup and trigger sampling across coverpoints
void sample(int value, int flags) {
this->value = value;
this->valid = flags;
covergroup::sample();
}
// Coverpoint with 4 bins
coverpoint values_cvp = coverpoint (this ,
bin( "low1", interval(1,6), 7), // intervals are inclusive
bin( "med1", interval(10,16), 17),
bin( "med2", interval(20,26), 27),
bin( "high", interval(30,36), 37)
);
coverpoint flags_cvp = coverpoint (this ,
bin( "zero", 1),
bin( "one", 2),
bin( "ten", 1024),
illegal_bin( "some_illegal_config", 3),
ignore_bin("uninteresting", 8)
);
// Cross (cartesian product) the two coverpoints
cross valid_data_cross = cross (this,
&input_valid_cvp, // the coverpoitns crossed
&values_cvp
);
};
// in the test create an instance of the coverage group
my_first_cvg my_cg;
.............
// sample the data after its correctness is checked
my_cg.sample(vdata, vflags);
.......
// at the end of a test one should save the collected coverage
fc4sc::global::coverage_save("results.xml");
Reporting
The FC4SC saves collected data in UCIS format in order to be compatible with functional coverage tools provided by 3rd party vendors (e.g. Cadence, Mentor, Synopsys).
One can generate a basic HTML/JS report that allows functional coverage analysis (e.g. show coverage holes, show partially covered coverage bins).
Roadmap
This first release focuses on the core engine together with few utilities. There are features we thought of that still need to be implemented:
- Implement other output formats(e.g. json, xml) for the collected data in case one doesn’t need to port collected data to other tools (e.g. one runs a C++ program in a standalone environment).
- Possibility to use and customize default bins
- Better filtering of crosses (e.g. binsof , intersect)
- Automated translation of SystemVerilog coverage definitions. This is a nice to have for
SystemC models that are used for verification purposes and which can follow the same
functional coverage model. - Merge of different coverage databases
Enjoy! I look forward for your feedback.
Leo Matturi
February 26th, 2018 16:33:55