fvutils / pyucis

Python API to Unified Coverage Interoperability Standard (UCIS) Data
https://fvutils.github.io/pyucis
Apache License 2.0
21 stars 12 forks source link

Q: Disabled type coverage #16

Open eyck opened 2 years ago

eyck commented 2 years ago

In commit 207076a the type coverage calculation has been completely disabled. Why's that?

mballance commented 2 years ago

Type coverage is expected to reflect the merge of instance coverage. For example, given the instance-coverage data below: https://github.com/fvutils/pyucis/blob/62bf38c8b70967ded80cec0af1d4ad1a08d7dd08/ve/unit/test_merge.py#L58-L81 The expected type coverage would be 100%. For reporting purposes, coverage achieved for an covergroup (type or instance) is the weighted sum of coverage achieved by its coverpoints and crosses. The commented code was adding instance coverage to this weighted sum, which is incorrect. In the example above, adding in the weighted sum of instance coverage resulted in type coverage being reported as 66.67% ((100+50+50)/3) which is clearly not correct.

eyck commented 2 years ago

I somehow disagree for several reasons. For one reason using the attached UCIS XML TGC_C_AHB.ucis.xml.gzI get 0% type coverage if the cover group only contains instances. For another reason I do not follow your arguments: if there are 3 cover points (underneath the top covergroup) where 2 of them are only covered at 1/2 the weighted sum is only 2/3. Your argumentation drops the covergroups being part of the top covergroup (unfortunately in your example they all are called cg1)

eyck commented 2 years ago

I did some research. I guess the disagreement comes from union merge vs. non-union merge (as described here: https://tenthousandfailures.com/blog/2014/1/5/merging-system-verilog-covergroups-with-examples). I implemented a check for this here: https://github.com/fvutils/pyucis/commit/cefb7483c04a981f628f44f428712944e0a7280c @mballance if you think this is a viable solution I would create a PR

mballance commented 2 years ago

Hi @eyck, thanks for sharing the link to Eldon's article. Good reminder of the differences between the two key ways coverage can be merged/reported. I think we have two areas of misalignment. One is on where data needs to be 'adjusted' and the other is how to appropriately handle these two cases. I'm starting from a position that favors the 'union merge' semantics -- it's just what I'm most familiar with. So, when I see a coverage format (FC4SC captured as XML) that only represents instance coverage, my assumption is that the reader for that coverage capture will reconstruct the type coverage data (if type coverage is relevant). PyUCIS expects this reconstruction to happen before any API client attempts to access the data (ie it must happen in XmlReader). I'm a bit confused by the screenshots of non-union merge in the article. Despite specifying 'no instance coverage', Questa still shows instance data. But, leaving that aside... I think the following makes sense as a steps forward:

eyck commented 2 years ago

I'm a bit confused by the screenshots of non-union merge in the article. Despite specifying 'no instance coverage', Questa still shows instance data. But, leaving that aside...

This is exactly the commented part of https://github.com/fvutils/pyucis/commit/207076a8b7b7018a8f32aca99039f6aa255ab82d: the weighted sum of the instance coverages. Therfore only some percentage and no bins or crosses.


  • We can change the reporter to report type coverage as a weighted average of instance coverage when the relevant options are set to select non-union merge. It think this would be restoring the code removed in 207076a.

Actually I would assume: if there is some coverage data in the covergroup than some preprocessing has been done (e.g. a union-merge). If this is not the case than the reporter should fall-back to non-union merge coverage reporting. This is how I implemented it atm in our fork.

mballance commented 2 years ago

Okay, I'm still working to build my understanding of how UCIS represents these cases. Based on that understanding, it should be clear whether changes are needed to the XML reader. 6.4.3.12 Other Information Models for Covergroups

I think this means the following in terms of the coverage report:

I think this means the following in terms of the XML data format:

Thoughts?

eyck commented 2 years ago

I agree with the first and the second item. But I'm not sure if the XML reader shall reconstruct or compute the coverage. This contradicts the principle of separation of conserns. So either this is the job of the report generator or the database itself, not the XML reader.