opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[topgen] Fail more understandably if we start in an unexpected place

Open rswarbrick opened this issue 1 year ago • 2 comments

This should fix issue #24595. The problem that caused the issue is that we compute paths to the various IP blocks that should be included by following relative paths from the -t argument. This doesn't work very well if the top_earlgrey.hjson file moves around!

A sensible design would probably point more explicitly at where to find IPs, but this should hopefully be a little easier to debug.

rswarbrick avatar Sep 18 '24 16:09 rswarbrick

I believe topgen has a option to point to places where to look for hjson files (--hjson-path), the doc says:

If defined, topgen uses supplied path to search for ip hjson. This applies only to ip's with the reggen_only attribute. If an hjson is located both in the conventional path and the alternate path, the alternate path has priority.

pamaury avatar Sep 18 '24 19:09 pamaury

Yep, you're right. The issue that prompted the change is triggered by a block that isn't marked reggen_only. The code (before this change) is:

        if reggen_only and args.hjson_path:
            ip_hjson = Path(args.hjson_path) / f"{ip}.hjson"
        else:
            ip_hjson = hjson_dir.parent / f"ip/{ip}/data/{ip}.hjson"

where hjson_dir is derived from the -t argument.

This change is basically just adding a somewhat helpful error message earlier if the derived directory is wrong.

rswarbrick avatar Sep 19 '24 10:09 rswarbrick

I've come back to this and it sees lots of merge conflicts. And I wasn't completely convinced it was a change worth doing! Let's worry about it some other time :-)

rswarbrick avatar Feb 18 '25 11:02 rswarbrick