frontend/base: Fix lookup of nets by module index
Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
parent
3e21f894f4
commit
c9a0033c5c
@ -298,6 +298,10 @@ template <typename FrontendType> struct GenericFrontend
|
||||
// Get a net by index in modulestate (not flatindex); creating it if it doesn't already exist
|
||||
NetInfo *create_or_get_net(HierModuleState &m, int idx)
|
||||
{
|
||||
auto &midx = m.net_by_idx(idx);
|
||||
if (midx != -1) {
|
||||
return net_flatindex.at(midx);
|
||||
} else {
|
||||
std::string name;
|
||||
if (idx < int(m.net_names.size()) && !m.net_names.at(idx).empty()) {
|
||||
// Use the rule above to find the preferred name for a net
|
||||
@ -312,10 +316,7 @@ template <typename FrontendType> struct GenericFrontend
|
||||
// Add to the flat index of nets
|
||||
net->udata = int(net_flatindex.size());
|
||||
net_flatindex.push_back(net);
|
||||
// Add to the module-level index of nets
|
||||
auto &midx = m.net_by_idx(idx);
|
||||
// Check we don't try and create more than one net with the same index
|
||||
NPNR_ASSERT(midx == -1);
|
||||
// Add to the module-level index of netsd
|
||||
midx = net->udata;
|
||||
// Create aliases for all possible names
|
||||
if (idx < int(m.net_names.size()) && !m.net_names.at(idx).empty()) {
|
||||
@ -330,6 +331,7 @@ template <typename FrontendType> struct GenericFrontend
|
||||
}
|
||||
return net;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the name of a vector bit given basename; settings and index
|
||||
std::string get_bit_name(const std::string &base, int index, int length, int offset = 0, bool upto = false)
|
||||
|
Loading…
Reference in New Issue
Block a user