Merge pull request #159 from Silimate/localize_external_package_global_net

Localize external package/global net
This commit is contained in:
Akash Levy 2026-04-30 14:59:58 -07:00 committed by GitHub
commit 24374c8d6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 34 additions and 1 deletions

View File

@ -2814,7 +2814,32 @@ struct VerificExtNets
cursor = ((Instance*)cursor->GetReferences()->GetLast())->Owner();
}
log_error("No common ancestor found between %s and %s.\n", get_full_netlist_name(A), get_full_netlist_name(B));
return nullptr;
}
// Handles the case where a net belongs to an external package or global scope
// (i.e., there is no common ancestor in the design hierarchy). Creates a fresh
// local net in `nl` and disconnects it from the original package/global net.
// For input ports the new net will be undriven; for output ports, writes will
// not be propagated back to the package/global object.
Net *localize_external_package_net(Netlist *nl, Net *net, Port *port)
{
string name = stringf("___extnets_%d", portname_cnt++);
Net *new_net = new Net(name.c_str());
nl->Add(new_net);
if (port->IsInput())
log_warning("Localizing external package/global net reference '%s.%s' on %s.%s; "
"reads from the package/global object will return an undriven (floating) value.\n",
get_full_netlist_name(net->Owner()).c_str(), net->Name(),
get_full_netlist_name(nl).c_str(), port->Name());
else
log_warning("Localizing external package/global net reference '%s.%s' on %s.%s; "
"writes to the package/global object are not propagated.\n",
get_full_netlist_name(net->Owner()).c_str(), net->Name(),
get_full_netlist_name(nl).c_str(), port->Name());
return new_net;
}
void run(Netlist *nl)
@ -2847,6 +2872,14 @@ struct VerificExtNets
Netlist *ca_nl = find_common_ancestor(nl, ext_nl);
if (ca_nl == nullptr) {
Net *new_net = localize_external_package_net(nl, net, port);
if (verific_verbose)
log(" localized external package/global net: %s\n", new_net->Name());
todo_connect.push_back(tuple<Instance*, Port*, Net*>(inst, port, new_net));
continue;
}
if (verific_verbose)
log(" common ancestor: %s\n", get_full_netlist_name(ca_nl));