ConcreteNetwork::replaceCell failed if port order differed

This commit is contained in:
James Cherry 2019-06-21 12:02:35 -07:00
parent e87c2e1da3
commit 527b74b8e4
1 changed files with 10 additions and 11 deletions

View File

@ -1149,20 +1149,19 @@ ConcreteNetwork::replaceCell(Instance *inst,
Cell *cell)
{
ConcreteCell *ccell = reinterpret_cast<ConcreteCell*>(cell);
InstancePinIterator *pin_iter = pinIterator(inst);
while (pin_iter->hasNext()) {
Pin *pin = pin_iter->next();
ConcretePin *cpin = reinterpret_cast<ConcretePin*>(pin);
int port_count = ccell->portBitCount();
ConcreteInstance *cinst = reinterpret_cast<ConcreteInstance*>(inst);
ConcretePin **pins = cinst->pins_;
ConcretePin **rpins = new ConcretePin*[port_count];
for (int i = 0; i < port_count; i++) {
ConcretePin *cpin = pins[i];
ConcretePort *pin_cport = reinterpret_cast<ConcretePort*>(cpin->port());
ConcretePort *cport = ccell->findPort(pin_cport->name());
if (cport)
cpin->port_ = cport;
else
deletePin(pin);
rpins[cport->pinIndex()] = cpin;
cpin->port_ = cport;
}
delete pin_iter;
ConcreteInstance *cinst = reinterpret_cast<ConcreteInstance*>(inst);
delete [] pins;
cinst->pins_ = rpins;
cinst->setCell(ccell);
}