Jump to content

FC4SC XML->YAML via report.py Python script with ZeroDivisionError


Recommended Posts

Hello,

OS: Red Hat Enterprise Linux Server release 7.9

The "/fc4sc/examples/fir" came with "coverage_results_gold.yaml" file. I run the "fir" example which generated "coverage_results.yaml" file.

Based on  "/fc4sc/contrib/fetch-tools.sh" I added "tools", so now I have  "/fc4sc/tools".

I try to using  "/fc4sc/tools/coverage_report/report.py" Python script to convert from XML to YAML. The "report.py" working OK on  "coverage_results_gold.yaml" file, but NOT-OK  on 

"coverage_results.yaml" file with ZeroDivisionError (see below). Can anyone please help me fix the error of the  "report.py" script?

 

OK (GOLD XML->YAML), From "coverage_results_gold.xml" to "coverage_results_gold.yaml" with "report.py" script is working (see below):

examples/fir%  python ../../tools/coverage_report/report.py --xml_report coverage_results_gold.xml --yaml_out coverage_results_gold.yaml

  Overall Summary:
  
    Total Coverage:  51.04
    
  Module Summary:

      62.50 : output_coverage

      62.50 : output_coverage_1

          75.00 : data_ready_cvp 
          50.00 : output_valid_cvp 
      40.62 : stimulus_coverage

      81.25 : stimulus_coverage_1

          80.00 : values_cvp 
         100.00 : reset_cvp 
         100.00 : input_valid_cvp 
          45.00 : reset valid 
       0.00 : stimulus_coverage_2

           0.00 : values_cvp 
           0.00 : reset_cvp 
           0.00 : input_valid_cvp 
           0.00 : reset valid 
      50.00 : shift_coverage

      50.00 : shift_coverage_1

          50.00 : shift_cvp 

 

NOT-OK  (FRASH XML->YAML), From "coverage_results.xml" to "coverage_results.yaml" with "report.py" script is not working (ZeroDivisionError see below):

examples/fir% python ../../tools/coverage_report/report.py --xml_report coverage_results.xml --yaml_out coverage_results.yaml
Traceback (most recent call last):
  File "../../tools/coverage_report/report.py", line 211, in <module>
    d = parser.get_report_data(args.xml_report)
  File "../../tools/coverage_report/report.py", line 34, in get_report_data
    data['pct_cov'] = sum([cg['pct_cov']*cg['weight'] for cg in data['modules'].values()]) \
ZeroDivisionError: float division by zero

 

NOTE: Need to update "display.cpp" file to get "fir" example running(see below):

   // generate the coverage database from the collected data
    std::ofstream ofs("coverage_results.xml");
    if(ofs)
      xml_printer::coverage_save(ofs);

Thank you.

Vlad.

Link to comment
Share on other sites

You are trying to use the AMIQ tools (which worked with a former version of FC4SC) with the refactored Accellera.

You could patch the script at line 30/31 & line 34/35 to check if the divisor is not 0.

But I guess you are better off using PYUCIS which is available via PyPI. There is also a graphical viewer called pyucis-viewer ...

 

Link to comment
Share on other sites

  • 1 month later...

I try using PYUCIS to convert from XML to YAML but got error.

GOLDEN XML is "coverage_results_gold.xml" from https://github.com/accellera-official/fc4sc/tree/master/examples/fir

Simple Python script which reads GOLDEN XML file: 

from _io import StringIO
from ucis.xml.xml_reader import XmlReader

filename = 'coverage_results_gold.xml'
input = StringIO(filename)

reader = XmlReader()
db = reader.read(input)

 

Error Output:

Traceback (most recent call last):
  File "./report.py", line 10, in <module>
    db = reader.read(input)
  File "/cad2/tools/Anaconda/2020.11/lib/python3.8/site-packages/ucis/xml/xml_reader.py", line 50, in read
    tree = etree.parse(file)
  File "src/lxml/etree.pyx", line 3521, in lxml.etree.parse
  File "src/lxml/parser.pxi", line 1876, in lxml.etree._parseDocument
  File "src/lxml/parser.pxi", line 1896, in lxml.etree._parseMemoryDocument
  File "src/lxml/parser.pxi", line 1777, in lxml.etree._parseDoc
  File "src/lxml/parser.pxi", line 1082, in lxml.etree._BaseParser._parseUnicodeDoc
  File "src/lxml/parser.pxi", line 615, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 725, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 654, in lxml.etree._raiseParseError
  File "<string>", line 1
lxml.etree.XMLSyntaxError: Start tag expected, '<' not found, line 1, column 1

 

All I am trying to do is have a  Python with PYUCIS to read GOLDEN XML file and write YAML file, can you please help?

Thank you.

Vlad.

Link to comment
Share on other sites

As far as I can tell PyUCIS cannot cope with the XML prolog. You might be able to run it by deleting the first line in the XML.

To my experience the original FC4SC implementation by AMIQ did not conform fully to the UCIS schema. I don't know how the Accellera version behaves...

Link to comment
Share on other sites

Hi Eyck,

There are three FC4SC GitHub repos I found:

  • Original FC4SC implementation by AMIQ
  • Official FC4SC version by Accellera
  • Forked from Official FC4SC by MINRES Technologies 

I see that you have "fixes coverpointBin generation to adhere to schema"  in "xml_printer.hpp" file below:

I try to use your fixed "xml_printer.hpp" file with the FIR example below:

 

I try to read in the XML file from FIR example using the Python with PYUCIS script below: 

from ucis.xml import validate_ucis_xml
from ucis.xml.xml_reader import XmlReader

xml_filename = 'coverage_results.xml'

# First, validate the incoming XML
if type(xml_filename) == str:
    fp = open(xml_filename)
else:
    fp = xml_filename

validate_ucis_xml(fp)

# Second, read the incoming XML
fp.seek(0)
reader = XmlReader()
ret = reader.read(fp)

 

The good news is that it passed the "First, validate the incoming XML", but the bad news it I get error with the "Second, read the incoming XML", see blow:

Traceback (most recent call last):
  File "./report.py", line 19, in <module>
    ret = reader.read(fp)
  File "/cad2/tools/Anaconda/2020.11/lib/python3.8/site-packages/ucis/xml/xml_reader.py", line 70, in read
    self.readInstanceCoverage(instN)
  File "/cad2/tools/Anaconda/2020.11/lib/python3.8/site-packages/ucis/xml/xml_reader.py", line 146, in readInstanceCoverage
    self.readCovergroup(cg, inst_scope)
  File "/cad2/tools/Anaconda/2020.11/lib/python3.8/site-packages/ucis/xml/xml_reader.py", line 175, in readCovergroup
    cp = self.readCoverpoint(cpN, covergroup_scope)
  File "/cad2/tools/Anaconda/2020.11/lib/python3.8/site-packages/ucis/xml/xml_reader.py", line 191, in readCoverpoint
    self.readCoverpointBin(cpBin, cp)
  File "/cad2/tools/Anaconda/2020.11/lib/python3.8/site-packages/ucis/xml/xml_reader.py", line 197, in readCoverpointBin
    seq = next(cpBin.iter("sequence"))
  File "src/lxml/etree.pyx", line 2921, in lxml.etree.ElementDepthFirstIterator.__next__
StopIteration

 

I been trying to get FIR XML to YAML working for some time now without any luck, I think you are part of MINRES Technologies with GitHub write access link below.  Is it too much to ask for you to update the MINRES GitHub repo so FIR example is working i.e.  sim runes and XML to YAML via PYUCIS works?

 

Thank you.

Vlad.

 

Link to comment
Share on other sites

Well, the one you reference i swork in progress. Maybe you best bet is to use https://github.com/Minres/fc4sc which is a fork of the AMIQ repo and contains the fixes to make it (Py)UCIS compliant.

For the Accelera FC4SC we use our own writer as the one being part of FC4SC does the reporting of groups in a way that does not fir our needs. But this writer is part of our design project.

Link to comment
Share on other sites

I try to using https://github.com/Minres/fc4sc which contains the fixes to make it (Py)UCIS compliant, as you can see below PyUCIS still is not working.

PyUCIS script:

from ucis.xml import validate_ucis_xml
from ucis.xml.xml_reader import XmlReader

xml_filename = 'coverage_results.xml'

# First, validate the incoming XML
if type(xml_filename) == str:
    fp = open(xml_filename)
else:
    fp = xml_filename

validate_ucis_xml(fp)

# Second, read the incoming XML
fp.seek(0)
reader = XmlReader()
ret = reader.read(fp)

PyUCIS error:

Traceback (most recent call last):
  File "./PyUCIS.py", line 19, in <module>
    ret = reader.read(fp)
  File "/cad2/tools/Anaconda/2020.11/lib/python3.8/site-packages/ucis/xml/xml_reader.py", line 70, in read
    self.readInstanceCoverage(instN)
  File "/cad2/tools/Anaconda/2020.11/lib/python3.8/site-packages/ucis/xml/xml_reader.py", line 146, in readInstanceCoverage
    self.readCovergroup(cg, inst_scope)
  File "/cad2/tools/Anaconda/2020.11/lib/python3.8/site-packages/ucis/xml/xml_reader.py", line 175, in readCovergroup
    cp = self.readCoverpoint(cpN, covergroup_scope)
  File "/cad2/tools/Anaconda/2020.11/lib/python3.8/site-packages/ucis/xml/xml_reader.py", line 191, in readCoverpoint
    self.readCoverpointBin(cpBin, cp)
  File "/cad2/tools/Anaconda/2020.11/lib/python3.8/site-packages/ucis/xml/xml_reader.py", line 197, in readCoverpointBin
    seq = next(cpBin.iter("sequence"))
  File "src/lxml/etree.pyx", line 2921, in lxml.etree.ElementDepthFirstIterator.__next__
StopIteration

 

The good news is I try using the AMIQ XML-> YAML script on FIR DUT and it's working i.e. now I have YAML file.

 

Thank you for your help.

Vlad.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...