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

Add attributes to the hierarchical cells #1405

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tarikgraba
Copy link
Contributor

Hi,

I did not find a way to retrieve attributes (assigned in the verilog) of hierarchical cells even though yosys preserves them in the json netlist.

This patch adds an "attrs" dictionary to the HierarchicalCell structure and expose it through the python bindings.

Those attributes are imported in the front end after the import of the submodule.

This last point I am not sure of and maybe I am not doing this correctly/efficietly.

I wanted to add this feature to mimic the behavior of Xilinx's LOC/RLOC attributes where, in a hierarchy, you can assign a relative location to primitive cells within a module and a global location for instances of this module.

@tarikgraba
Copy link
Contributor Author

I have tested the patch locally and it seems to behave correctly.

As an example of usage in a pre-pack python script:

mloc_attr_name  = "LOC"
rloc_attr_name = "RLOC"

def setBelForRloc(cell,cinfo,loc):
    if rloc_attr_name in cinfo.attrs:
        rloc = cinfo.attrs[rloc_attr_name] 
        cinfo.setAttr("BEL",  loc + "/" + rloc)
        print(f"BEL set for {cell} : {cinfo.type}")
        print(f"              BEL  : {cinfo.attrs['BEL']}")
    else:
        print(f"No RLOC for {cell} : {cinfo.type}")

for m, minfo in ctx.hierarchy:
    if mloc_attr_name in minfo.attrs:
        loc = minfo.attrs[mloc_attr_name]
        print(f"location attribute {loc} for {m}")
        for _, gname in minfo.leaf_cells:
            setBelForRloc(gname,ctx.cells[gname],loc)
    else:
        print(f"no location attribute for {m}")

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.

1 participant