Skip to content

Commit

Permalink
odb/cdl: Handle top-level pins wired to nets of different name
Browse files Browse the repository at this point in the history
ATM the code seem to assume that for each top level pin, the
net name is equal to the pin name.

That's not always the case and this produces an incorect netlist.

To solve that, during pin name enumeration when creating the subckt
line, we create a mapping from "net name" -> "pin name" for each
pin connected to a net of a different name. Then when outputting
the connections between sub blocks, we use the pin name instead
of the DB net name.

Signed-off-by: Sylvain Munaut <[email protected]>
  • Loading branch information
smunaut committed Oct 28, 2024
1 parent cd519bb commit f5abb2d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/odb/src/cdl/cdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ std::string getUnconnectedNet(dbBlock* block, int& unconnectedNets)
std::string getNetName(dbBlock* block,
dbInst* inst,
dbMTerm* mterm,
std::map<std::string,std::string> &net2pin,
int& unconnectedNets)
{
if (mterm == nullptr) {
Expand All @@ -105,7 +106,14 @@ std::string getNetName(dbBlock* block,
return getUnconnectedNet(block, unconnectedNets);
}

return net->getName();
std::string net_name = net->getName();

auto pin_name_match = net2pin.find(net_name);
if (pin_name_match != net2pin.end()) {
return pin_name_match->second;
}

return net_name;
}

// Look for .subckt lines and record the terminal order for module to
Expand Down Expand Up @@ -189,6 +197,7 @@ bool cdl::writeCdl(utl::Logger* logger,
}
int unconnectedNets = 0;
utl::FileHandler fileHandler(outFileName);
std::map<std::string,std::string> net2pin;
FILE* f = fileHandler.getFile();

if (f == nullptr) {
Expand All @@ -204,6 +213,10 @@ bool cdl::writeCdl(utl::Logger* logger,
std::string line = ".SUBCKT " + block->getName();
for (auto&& pin : block->getBTerms()) {
line += " " + pin->getName();
auto net = pin->getNet();
if ((net != nullptr) && (net->getName() != pin->getName())) {
net2pin.emplace(net->getName(), pin->getName());
}
}

writeLine(f, line);
Expand Down Expand Up @@ -231,7 +244,7 @@ bool cdl::writeCdl(utl::Logger* logger,
}
} else {
for (auto&& mterm : it->second) {
line += " " + getNetName(block, inst, mterm, unconnectedNets);
line += " " + getNetName(block, inst, mterm, net2pin, unconnectedNets);
}
}

Expand Down

0 comments on commit f5abb2d

Please sign in to comment.