C++ Implementation of Functional Coverage for SystemC

We release Functional Coverage for SystemC (FC4SC) library which provides mechanisms for functional coverage definition, collection and reporting. FC4SC is a header-only, C++2011-based library, that can be integrated with C++ applications, including SystemC models.

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.


Comments

Leo Matturi February 26th, 2018 16:33:55

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!


    Teo Vasilache February 27th, 2018 14:41:59

    I’m glad you find it interesting! If you have feedback/suggestions don’t be shy to tell us.


Hassan August 19th, 2018 22:58:35

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?


stefan August 26th, 2018 09:55:03

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.


Leave a Comment:

Your comment will be visible after approval.

(will not be published)

This site uses Akismet to reduce spam. Learn how your comment data is processed.