diff --git a/frontends/verific/verific.cc b/frontends/verific/verific.cc index 212761028..acbe4b5a7 100644 --- a/frontends/verific/verific.cc +++ b/frontends/verific/verific.cc @@ -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(inst, port, new_net)); + continue; + } + if (verific_verbose) log(" common ancestor: %s\n", get_full_netlist_name(ca_nl));