Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check parameters in HW config file against schema #152

Open
colluca opened this issue Jun 13, 2024 · 0 comments
Open

Check parameters in HW config file against schema #152

colluca opened this issue Jun 13, 2024 · 0 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@colluca
Copy link
Collaborator

colluca commented Jun 13, 2024

Parameter ssr_nr_credits is defined in the default HW configuration:

However, this parameter is actually not used anywhere. The correct name for this parameter would be data_credits:

"{shift_width}, {rpt_width}, {index_credits}, {isect_slave_credits}, {data_credits}, "\

Regardless what value is set to ssr_nr_credits, the default for data_credits which is defined in the schema file is used:

"data_credits": {
"type": "number",
"description": "Number of credits and buffer depth of the data word FIFO.",
"minimum": 1,
"default": 4
},

To avoid incurring in the same situation in the future, the HW configuration file should be validated against the schema upon hardware generation, producing an error if some parameter is not defined in the schema.

This is done to some extent in the Generator class:

def validate(self, cfg):
# Validate the schema. This can fail.
try:
DefaultValidatingDraft7Validator(
self.root_schema, resolver=self.resolver).validate(cfg)
except ValidationError as e:
print(e)
exit(e)

But only against the root schema, which doesn't include all parameters. The ssr_nr_credits parameter is in the remote schema for the SnitchClusterTB class:

class SnitchClusterTB(Generator):
"""
A very simplistic system, which instantiates a single cluster and
surrounding DRAM to test and simulate this system. This can also serve as a
starting point on how to use the `snitchgen` library to generate more
complex systems.
"""
def __init__(self, cfg):
schema = Path(__file__).parent / "../../docs/schema/snitch_cluster_tb.schema.json"
remote_schemas = [Path(__file__).parent / "../../docs/schema/snitch_cluster.schema.json"]
super().__init__(schema, remote_schemas)
# Validate the schema.
self.validate(cfg)

@colluca colluca added bug Something isn't working enhancement New feature or request labels Jun 13, 2024
@colluca colluca self-assigned this Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant