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.
8 Responses
This is excellent. I will definitely give it a go. I had started developing my own version but you are there already and the comparison with SV FC shows you’ve come quite far!! Well done!
I’m glad you find it interesting! If you have feedback/suggestions don’t be shy to tell us.
Awesome. I have been thinking of creating one on my own, but this is just great.
One question though, is there any automated way to create bins? Like if I want to create 100 bins, for a signal where each bin has 2 values inside it. Will I have to create all 100 bins manually? Or is there any option for a FOR loop which can ease the process?
Hello,
There is a class bin_array in fc4sc_bin.hpp which is supposed to do that, but it is not thoroughly tested and was omitted in the documentation. It might be that some edge case don’t work as expected.
It would be helpful if you could try it out and let us know on the results.
The new API looks great… concise and clean!
It would be helpful to know the state of coverage database merge support (in any output format.) Is there any public discussion on the topic?
Also, the library appears to be independent from SystemC which is a plus for those doing C++ verification without SystemC. Is maintaining that independence in the plan?
Hello Armond,
The merge feature was already requested by few other engineers. There were face to face discussions about it during DVCon EU and SystemC Evolution Day 2018.
So I developed a Python script that I will release soon (end of November). The output of the merge will still be a UCIS DB.
Regarding C++ vs SystemC: yes we plan to create a separate repo (fc4cpp) that will be dedicated to C++ projects.
We will split it like that in order to keep separate, clean development tracks. Most probably the fc4sc will include SystemC-specific constructs in the future.
Cheers!
Hi I followed the example and have the result.xml generated, what’s the next step?
How to analysis the report? Convert it to html and analyze? or could you elaborate how to open it in coverage viewers in tools from like Synopsys, Cadence, Mentor?
Hi Tuo,
The resulted XML can be used by the tools provided under our repository at this location: https://github.com/amiq-consulting/fc4sc/tree/master/tools. You can visualize the coverage database in the web browser by using the GUI tool, or report different data from it using the report python script.
Currently, coverage databases generated by FC4SC cannot be loaded in commercial tools. This feature will however be included in the Accellera Verification WorkingGroup FC4SC release.
Best Regards,
Dragos