abc/src/base/abc/abcNetlist.c
/**Function*************************************************************

  Synopsis    [Transform the logic network into a netlist.]

  Description [The logic network given to this procedure should
  have exactly the same structure as the resulting netlist. The COs
  can only point to CIs if they have identical names. Otherwise, 
  they should have a node between them, even if this node is 
  inverter or buffer.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Transform the logic network into a netlist.]

Description [The logic network given to this procedure should
have exactly the same structure as the resulting netlist. The COs
can only point to CIs if they have identical names. Otherwise,
they should have a node between them, even if this node is
inverter or buffer.]




Function Synopsis [ Transform the logic network into a netlist . ] Description [ The logic network given to this procedure should have exactly the same structure as the resulting netlist . The COs can only point to CIs if they have identical names . Otherwise they should have a node between them even if this node is inverter or buffer . ]
Abc_Ntk_t * Abc_NtkLogicToNetlist( Abc_Ntk_t * pNtk )
{
    Abc_Ntk_t * pNtkNew; 
    Abc_Obj_t * pObj, * pNet, * pDriver, * pFanin;
    int i, k;
    assert( Abc_NtkIsLogic(pNtk) );
    Abc_NtkCleanup( pNtk, 0 );
    Abc_NtkCheckUniqueCiNames( pNtk );
    Abc_NtkCheckUniqueCoNames( pNtk );
    Abc_NtkCheckUniqueCioNames( pNtk );
    if ( !Abc_NtkLogicHasSimpleCos(pNtk) )
    {
        if ( !Abc_FrameReadFlag("silentmode") )
            printf( "Abc_NtkLogicToNetlist() warning: The network is converted to have simple COs.\n" );
        Abc_NtkLogicMakeSimpleCos( pNtk, 0 );
    }
    pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_NETLIST, pNtk->ntkFunc );
    Abc_NtkForEachCi( pNtk, pObj, i )
    {
        pNet = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pObj) );
        Abc_ObjAddFanin( pNet, pObj->pCopy );
        pObj->pCopy->pCopy = pNet;
    }
    Abc_NtkForEachNode( pNtk, pObj, i )
        Abc_NtkDupObj(pNtkNew, pObj, 0);
    Abc_NtkForEachCo( pNtk, pObj, i )
    {
        pDriver = Abc_ObjFanin0(pObj);
        if ( Abc_ObjIsCi(pDriver) )
        {
            assert( !strcmp( Abc_ObjName(pDriver), Abc_ObjName(pObj) ) );
            Abc_ObjAddFanin( pObj->pCopy, pDriver->pCopy->pCopy );
            continue;
        }
        assert( Abc_ObjIsNode(pDriver) );
        if ( pDriver->pCopy->pCopy == NULL )
        {
            pNet = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pObj) );
            Abc_ObjAddFanin( pObj->pCopy, pNet );
            Abc_ObjAddFanin( pNet, pDriver->pCopy );
            pDriver->pCopy->pCopy = pNet;
        }
        else
        {
            assert( !strcmp( Abc_ObjName(pDriver->pCopy->pCopy), Abc_ObjName(pObj) ) );
            Abc_ObjAddFanin( pObj->pCopy, pDriver->pCopy->pCopy );
        }
    }
    Abc_NtkForEachNode( pNtk, pObj, i )
    {
        if ( pObj->pCopy->pCopy ) 
            continue;
        pNet = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pObj) ); 
        Abc_ObjAddFanin( pNet, pObj->pCopy );
        pObj->pCopy->pCopy = pNet;
    }
    Abc_NtkForEachNode( pNtk, pObj, i )
        Abc_ObjForEachFanin( pObj, pFanin, k )
            Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy->pCopy );
    if ( pNtk->pExdc )
        pNtkNew->pExdc = Abc_NtkToNetlist( pNtk->pExdc );
    if ( !Abc_NtkCheck( pNtkNew ) )
        fprintf( stdout, "Abc_NtkLogicToNetlist(): Network check has failed.\n" );
    return pNtkNew;
}
Abc_Ntk_t * Abc_NtkLogicToNetlist ( Abc_Ntk_t * pNtk ) { Abc_Ntk_t * pNtkNew ; Abc_Obj_t * pObj , * pNet , * pDriver , * pFanin ; int i , k ; assert ( Abc_NtkIsLogic ( pNtk ) ) ; Abc_NtkCleanup ( pNtk , 0 ) ; Abc_NtkCheckUniqueCiNames ( pNtk ) ; Abc_NtkCheckUniqueCoNames ( pNtk ) ; Abc_NtkCheckUniqueCioNames ( pNtk ) ; if ( ! Abc_NtkLogicHasSimpleCos ( pNtk ) ) { if ( ! Abc_FrameReadFlag ( " " ) ) printf ( " \n " ) ; Abc_NtkLogicMakeSimpleCos ( pNtk , 0 ) ; } pNtkNew = Abc_NtkStartFrom ( pNtk , ABC_NTK_NETLIST , pNtk -> ntkFunc ) ; Abc_NtkForEachCi ( pNtk , pObj , i ) { pNet = Abc_NtkFindOrCreateNet ( pNtkNew , Abc_ObjName ( pObj ) ) ; Abc_ObjAddFanin ( pNet , pObj -> pCopy ) ; pObj -> pCopy -> pCopy = pNet ; } Abc_NtkForEachNode ( pNtk , pObj , i ) Abc_NtkDupObj ( pNtkNew , pObj , 0 ) ; Abc_NtkForEachCo ( pNtk , pObj , i ) { pDriver = Abc_ObjFanin0 ( pObj ) ; if ( Abc_ObjIsCi ( pDriver ) ) { assert ( ! strcmp ( Abc_ObjName ( pDriver ) , Abc_ObjName ( pObj ) ) ) ; Abc_ObjAddFanin ( pObj -> pCopy , pDriver -> pCopy -> pCopy ) ; continue ; } assert ( Abc_ObjIsNode ( pDriver ) ) ; if ( pDriver -> pCopy -> pCopy == NULL ) { pNet = Abc_NtkFindOrCreateNet ( pNtkNew , Abc_ObjName ( pObj ) ) ; Abc_ObjAddFanin ( pObj -> pCopy , pNet ) ; Abc_ObjAddFanin ( pNet , pDriver -> pCopy ) ; pDriver -> pCopy -> pCopy = pNet ; } else { assert ( ! strcmp ( Abc_ObjName ( pDriver -> pCopy -> pCopy ) , Abc_ObjName ( pObj ) ) ) ; Abc_ObjAddFanin ( pObj -> pCopy , pDriver -> pCopy -> pCopy ) ; } } Abc_NtkForEachNode ( pNtk , pObj , i ) { if ( pObj -> pCopy -> pCopy ) continue ; pNet = Abc_NtkFindOrCreateNet ( pNtkNew , Abc_ObjName ( pObj ) ) ; Abc_ObjAddFanin ( pNet , pObj -> pCopy ) ; pObj -> pCopy -> pCopy = pNet ; } Abc_NtkForEachNode ( pNtk , pObj , i ) Abc_ObjForEachFanin ( pObj , pFanin , k ) Abc_ObjAddFanin ( pObj -> pCopy , pFanin -> pCopy -> pCopy ) ; if ( pNtk -> pExdc ) pNtkNew -> pExdc = Abc_NtkToNetlist ( pNtk -> pExdc ) ; if ( ! Abc_NtkCheck ( pNtkNew ) ) fprintf ( stdout , " \n " ) ; return pNtkNew ; }
Function
Synopsis    [Transform the logic network into a netlist.]
Function Synopsis [ Transform the logic network into a netlist . ]
// remove dangling nodes // make sure the CO names are unique //    assert( Abc_NtkLogicHasSimpleCos(pNtk) ); // start the netlist by creating PI/PO/Latch objects // create the CI nets and remember them in the new CI nodes // duplicate all nodes // first add the nets to the CO drivers // if the CO driver has no net, create it // create the CO net and connect it to CO //if ( Abc_NtkFindNet(pNtkNew, Abc_ObjName(pDriver)) == NULL ) //    pNet = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pDriver) ); //else // connect the CO net to the new driver and remember it in the new driver // create the missing nets // the net of the new object is already created // create the new net // here we create ridiculous names net line "n48", where 48 is the ID of the node // connect nodes to the fanins nets // duplicate EXDC 