const uint32_t dfsNtkForReductionOrder(V3Ntk* const ntk, V3NetVec& orderMap, const V3NetVec& targetNets, const bool& reduceLatch) { assert (ntk); V3BoolVec m(ntk->getNetSize(), false); orderMap.clear(); orderMap.reserve(ntk->getNetSize()); orderMap.push_back(V3NetId::makeNetId(0)); // AIG_FALSE or BV_CONST (1'b0) // Mark Fanin Cone of targetNets Recursively (Through FF Boundaries) if (targetNets.size()) for (uint32_t i = 0; i < targetNets.size(); ++i) dfsMarkFaninCone(ntk, targetNets[i], m); else for (uint32_t i = 0; i < ntk->getOutputSize(); ++i) dfsMarkFaninCone(ntk, ntk->getOutput(i), m); // (Pseudo) Primary Inputs V3NetVec latchList; latchList.clear(); latchList.reserve(ntk->getLatchSize()); for (uint32_t i = 0; i < ntk->getInputSize(); ++i) orderMap.push_back(ntk->getInput(i)); for (uint32_t i = 0; i < ntk->getInoutSize(); ++i) orderMap.push_back(ntk->getInout(i)); for (uint32_t i = 0; i < ntk->getLatchSize(); ++i) if (!reduceLatch || m[ntk->getLatch(i).id]) { orderMap.push_back(ntk->getLatch(i)); latchList.push_back(ntk->getLatch(i)); } // DFS Traverse Marked Nets for (uint32_t i = 0; i < m.size(); ++i) m[i] = false; for (uint32_t i = 0; i < orderMap.size(); ++i) m[orderMap[i].id] = true; // Pseudo Primary Input Initial State Logics for (uint32_t i = 0; i < latchList.size(); ++i) dfsGeneralOrder(ntk, ntk->getInputNetId(latchList[i], 1), m, orderMap); // Record End of Initial Logic if Needed (e.g. simulator) const uint32_t initEndIndex = orderMap.size(); // (Pseudo) Primary Output Fanin Logics for (uint32_t i = 0; i < latchList.size(); ++i) dfsGeneralOrder(ntk, ntk->getInputNetId(latchList[i], 0), m, orderMap); for (uint32_t i = 0; i < ntk->getInoutSize(); ++i) dfsGeneralOrder(ntk, ntk->getInputNetId(ntk->getInout(i), 0), m, orderMap); if (targetNets.size()) for (uint32_t i = 0; i < targetNets.size(); ++i) dfsGeneralOrder(ntk, targetNets[i], m, orderMap); else for (uint32_t i = 0; i < ntk->getOutputSize(); ++i) dfsGeneralOrder(ntk, ntk->getOutput(i), m, orderMap); assert (orderMap.size() <= ntk->getNetSize()); return initEndIndex; }
void V3NtkHandler::printUnreachables() const { assert (_ntk); uint32_t x = 0, y = 0, z = 0; V3BoolVec m(_ntk->getNetSize(), false); for (uint32_t i = 0; i < _ntk->getOutputSize(); ++i) dfsMarkFaninCone(_ntk, _ntk->getOutput(i), m); for (uint32_t i = 0; i < _ntk->getInputSize(); ++i) { if (m[_ntk->getInput(i).id]) continue; if (!x) Msg(MSG_IFO) << "Unreachable PIs (index):"; Msg(MSG_IFO) << " " << i; ++x; } for (uint32_t i = 0; i < _ntk->getInoutSize(); ++i) { if (m[_ntk->getInout(i).id]) continue; if (!y) Msg(MSG_IFO) << "Unreachable PIOs (index):"; Msg(MSG_IFO) << " " << i; ++y; } for (uint32_t i = 0; i < _ntk->getLatchSize(); ++i) { if (m[_ntk->getLatch(i).id]) continue; if (!z) Msg(MSG_IFO) << "Unreachable Latches (index):"; Msg(MSG_IFO) << " " << i; ++z; } if (x + y + z) { Msg(MSG_IFO) << endl; Msg(MSG_WAR) << "Totally " << (x + y + z) << " PI/PIO/FF Found Unreachable from Any POs !!" << endl; Msg(MSG_WAR) << "Please fix them to ensure expected operations on this network !!" << endl; } }