Skip to content

Commit

Permalink
Add attributes to the hierarchical cells (#1405)
Browse files Browse the repository at this point in the history
* Adds attributes to the hierarchical cells

* python: add binding for hierarchical cells attributes

* frontend/base: import hierarchical cells attributes
  • Loading branch information
tarikgraba authored Dec 17, 2024
1 parent d810aac commit f01465f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common/kernel/nextpnr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ struct HierarchicalCell
dict<IdString, HierarchicalPort> ports;
// Name inside cell instance -> global name
dict<IdString, IdString> hier_cells;
// Cell attributes
dict<IdString, Property> attrs;
};

NEXTPNR_NAMESPACE_END
Expand Down
3 changes: 3 additions & 0 deletions common/kernel/pybindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ PYBIND11_EMBEDDED_MODULE(MODULE_NAME, m)
wrap_context<IdIdMap &>>::def_wrap(hierarchy_cls, "nets");
readonly_wrapper<HierarchicalCell &, decltype(&HierarchicalCell::hier_cells), &HierarchicalCell::hier_cells,
wrap_context<IdIdMap &>>::def_wrap(hierarchy_cls, "hier_cells");
readonly_wrapper<HierarchicalCell &, decltype(&HierarchicalCell::attrs), &HierarchicalCell::attrs,
wrap_context<AttrMap &>>::def_wrap(hierarchy_cls, "attrs");

WRAP_MAP(m, AttrMap, conv_to_str<Property>, "AttrMap");
WRAP_MAP(m, PortMap, wrap_context<PortInfo &>, "PortMap");
WRAP_MAP(m, IdIdMap, conv_to_str<IdString>, "IdIdMap");
Expand Down
3 changes: 3 additions & 0 deletions frontend/frontend_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,9 @@ template <typename FrontendType> struct GenericFrontend
// Do the submodule import
auto type = impl.get_cell_type(cd);
import_module(submod, name, type, mod_refs.at(type));
// Add current cell attributes to the imported module
impl.foreach_attr( cd, [&](const std::string &name, const Property &value)
{ ctx->hierarchy[submod.path].attrs[ctx->id(name)] = value; } );
}

// Import the cells section of a module
Expand Down

0 comments on commit f01465f

Please sign in to comment.