Skip to content

Check parameters in HW config file against schema #152

@colluca

Description

@colluca

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)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions