Пример #1
0
void CirGate::netflow(int &cnt, bool flag[]) const
{   assert(getTypeStr() != "UNDEF");
    if (flag[_id]) return;
    for (int i = 0; i < _fanin.size(); ++i)
    {   CirGate* ptr = (CirGate*)(_fanin[i] & ~(size_t)(0x1));
        if (ptr->getTypeStr() != "UNDEF")
            ptr->netflow(cnt, flag);
    }

    flag[_id] = true; // Visited
    cout << "["<< cnt++ << "] ";
    if (getTypeStr() == "CONST")
        cout << "CONST0";
    else if (getTypeStr() == "AIG")
        cout << "AIG";
    else if (getTypeStr() == "PI")
        cout << "PI ";
    else if (getTypeStr() == "PO")
        cout << "PO ";
    if (_id) cout << " " << _id;
    for (int i = 0; i < _fanin.size(); ++i)
    {   cout << " ";
        CirGate* ptr = (CirGate*)(_fanin[i] & ~(size_t)0x1);
        if (ptr->getTypeStr() == "UNDEF") cout << "*";
        if (_fanin[i] & 1) cout << "!";
        cout << ptr->_id;
    }
    if (getTypeStr() == "PI" && ((CirPiGate*)this)->_name != "") cout << " (" << ((CirPiGate*)this)->_name << ")";
    if (getTypeStr() == "PO" && ((CirPoGate*)this)->_name != "") cout << " (" << ((CirPoGate*)this)->_name << ")";
    cout << endl;
}
Пример #2
0
void
CirMgr::strash()
{
  HashMap<myStrashKey, CirGate*> myHash;

  for (size_t i = 0, dfsSize = _dfsOrder.size(); i < dfsSize; ++i)
  {
    CirGate* gate = _dfsOrder.at(i);

    if (gate->getTypeStr() != "AIG") {
      continue;
    }

    CirGate* existedGate = new Aig();
    myStrashKey key(gate);

    if (myHash.check(key, existedGate)) {
      cout << "Strashing: " << existedGate->getId() << " merging " << gate->getId() << "..." << endl;

      AigGateV newFanin(existedGate, 0);
      gate->connectFaninToEachFanout(newFanin);

      // clean up
      deleteAndCleanUpGate(gate);

      /* _dfsOrder.erase(_dfsOrder.begin() + i); */
      /* --i, --dfsSize; */
    } else {
      myHash.insert(key, gate);
    }
  }

  _dfsOrder.clear();
  topoSort();
}