Skip to content

feat: Adds CDC results parsing for Meridian in the CDC flow#237

Open
nsw-lowrisc wants to merge 1 commit into
lowRISC:masterfrom
nsw-lowrisc:add_cdc_flow
Open

feat: Adds CDC results parsing for Meridian in the CDC flow#237
nsw-lowrisc wants to merge 1 commit into
lowRISC:masterfrom
nsw-lowrisc:add_cdc_flow

Conversation

@nsw-lowrisc

Copy link
Copy Markdown

This commit adds parsing of the Meridian CDC reports. The parser is using the meridiancdc.py file in the tools directory, so the parser in the local repo is not required, however, if the report_cmd variable is set in the hjson this will be overridden and the parser called by make.

NOTE: the buckets have changed, adding waived and tofix, so the corresponding common_cdc_cfg.hjson file should be updated in line. This required a fix to msg_buckets.py to avoid an exception.

This commit adds parsing of the Meridian CDC reports. The parser is
using the meridiancdc.py file in the tools directory, so the parser in
the local repo is not required, however, if the report_cmd variable is
set in the hjson this will be overridden and the parser called by make.

NOTE: the buckets have changed, adding waived and tofix, so the
corresponding common_cdc_cfg.hjson file should be updated in line. This
required a fix to msg_buckets.py to avoid an exception.

Signed-off-by: Neil Webb <[email protected]>

@machshev machshev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nsw-lowrisc!
Some nits but the general concept seems fine.

Comment thread src/dvsim/flow/cdc.py
"""Class describing lint configuration object."""
"""Class describing CDC configuration object."""

import logging

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a configured logger available as from dvsim.logging import log. This does some extra setup to add new log levels. Could we use that please?

"""Parses Meridian CDC report and dumps filtered messages in hjson format."""

import argparse
import logging

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Comment on lines +16 to +24
# For stand alone
# Check if this file is the main entry point
IS_STANDALONE = __name__ == "__main__"
if IS_STANDALONE:
# Get the absolute path of the directory one level up (the project root)
project_root = str(Path(__file__).resolve().parent.parent.parent)
# Add it to Python's search path if it isn't already there
if project_root not in sys.path:
sys.path.insert(0, project_root)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we doing this? This looks really hacky... what are you trying to achieve?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @machshev for the review.

I think it is best to resolve this point first, as others depend on it.

The other parsers in this directory (lint/RDC/...) are imported from the "in-tree" version of dvsim. The in-tree versions are still run stand alone from the make file. This, the CDC parser, was initial derived from the standalone RDC parser. This is the only one that can now be called either way, from dvsim or the make file. This where the IS_STANDALONE logic comes from and also other things like the logging (I added this in the standalone version, so should be corrected) and parsing the input parameters with argparse.

So, if it is not desirable to keep the possibility of running stand alone then all the extra stuff should be removed. I am OK with either, what ever fits best into the bigger picture.

Comment thread src/dvsim/flow/cdc.py
from dvsim.utils import subst_wildcards

# Get the global logger definition
log = logging.getLogger(__name__)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log = logging.getLogger(__name__)
from dvsim.logging import log



# Get the global logger definition
log = logging.getLogger(__name__)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log = logging.getLogger(__name__)
from dvsim.logging import log

Comment on lines +45 to +47
category = ""
severity = ""
known_rule_names = {}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move these down the function closer to where they are used?

log = logging.getLogger(__name__)


def extract_rule_patterns(file_path: Path):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add typing for the return type... it looks like List[Tuple[str,str]]?
With this added then pyright is a lot more useful.



# Reuse the lint parser, but add more buckets.
class CdcParser(LintParser):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class docstring?

Comment on lines +275 to +283
# Configure Logging log to console if running stand alone
# logging format layout
log_layout = "[%(levelname).1s %(asctime)s %(filename)s:%(lineno)d] %(message)s"
time_layout = "%y%m%d %H:%M:%S"
console_handler = logging.StreamHandler()
console_handler.setFormatter(logging.Formatter(f"{log_layout}", datefmt=time_layout))
active_handlers = [console_handler]

logging.basicConfig(level=logging.INFO, handlers=active_handlers)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be covered if you use the dvsim logger?

Comment thread src/dvsim/msg_buckets.py
msg = f"Signatures in {k} must be a list of strings"
raise RuntimeError(msg)
self.buckets[k].signatures.extend(signatures)
# check the key is in the bucket list to avoid an exception

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to log a warning if it's not? Is this an error case?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only to prevent, dvsim crashing out completely with an esoteric error when there a mismatch between the buckets in the hjson and python. The idea is only to smooth transition when adopting the new parser. I would say that long term the way the buckets are managed should be revised, that is only one definition needed.

I can add a warning massage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants