abc/src/opt/nwk/nwkMan.c
/**Function*************************************************************

  Synopsis    [If the network is best, saves it in "best.blif" and returns 1.]

  Description [If the networks are incomparable, saves the new network, 
  returns its parameters in the internal parameter structure, and returns 1.
  If the new network is not a logic network, quits without saving and returns 0.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [If the network is best, saves it in "best.blif" and returns 1.]

Description [If the networks are incomparable, saves the new network,
returns its parameters in the internal parameter structure, and returns 1.
If the new network is not a logic network, quits without saving and returns 0.]




Function Synopsis [ If the network is best saves it in " best . blif " and returns 1 . ] Description [ If the networks are incomparable saves the new network returns its parameters in the internal parameter structure and returns 1 . If the new network is not a logic network quits without saving and returns 0 . ]
int Nwk_ManCompareAndSaveBest( Nwk_Man_t * pNtk, void * pNtl )
{
    extern void Nwk_ManDumpBlif( Nwk_Man_t * pNtk, char * pFileName, Vec_Ptr_t * vPiNames, Vec_Ptr_t * vPoNames );
    static struct ParStruct {
        char * pName;  
        int    Depth;  
        int    Flops;  
        int    Nodes;  
        int    nPis;   
        int    nPos;   
    } ParsNew, ParsBest = { 0 };
    if ( pNtk == NULL )
    {
        ABC_FREE( ParsBest.pName );
        return 0;
    }
    ParsNew.Depth = Nwk_ManLevel( pNtk );
    ParsNew.Flops = Nwk_ManLatchNum( pNtk );
    ParsNew.Nodes = Nwk_ManNodeNum( pNtk );
    ParsNew.nPis  = Nwk_ManPiNum( pNtk );
    ParsNew.nPos  = Nwk_ManPoNum( pNtk );
    if (  ParsBest.pName == NULL ||
          strcmp(ParsBest.pName, pNtk->pName) ||
          ParsBest.Depth >  ParsNew.Depth ||
         (ParsBest.Depth == ParsNew.Depth && ParsBest.Flops >  ParsNew.Flops) ||
         (ParsBest.Depth == ParsNew.Depth && ParsBest.Flops == ParsNew.Flops && ParsBest.Nodes >  ParsNew.Nodes) )
    {
        ABC_FREE( ParsBest.pName );
        ParsBest.pName = Abc_UtilStrsav( pNtk->pName );
        ParsBest.Depth = ParsNew.Depth; 
        ParsBest.Flops = ParsNew.Flops; 
        ParsBest.Nodes = ParsNew.Nodes; 
        ParsBest.nPis  = ParsNew.nPis; 
        ParsBest.nPos  = ParsNew.nPos;
        return 1;
    }
    return 0;
}
int Nwk_ManCompareAndSaveBest ( Nwk_Man_t * pNtk , void * pNtl ) { extern void Nwk_ManDumpBlif ( Nwk_Man_t * pNtk , char * pFileName , Vec_Ptr_t * vPiNames , Vec_Ptr_t * vPoNames ) ; static struct ParStruct { char * pName ; int Depth ; int Flops ; int Nodes ; int nPis ; int nPos ; } ParsNew , ParsBest = { 0 } ; if ( pNtk == NULL ) { ABC_FREE ( ParsBest . pName ) ; return 0 ; } ParsNew . Depth = Nwk_ManLevel ( pNtk ) ; ParsNew . Flops = Nwk_ManLatchNum ( pNtk ) ; ParsNew . Nodes = Nwk_ManNodeNum ( pNtk ) ; ParsNew . nPis = Nwk_ManPiNum ( pNtk ) ; ParsNew . nPos = Nwk_ManPoNum ( pNtk ) ; if ( ParsBest . pName == NULL || strcmp ( ParsBest . pName , pNtk -> pName ) || ParsBest . Depth > ParsNew . Depth || ( ParsBest . Depth == ParsNew . Depth && ParsBest . Flops > ParsNew . Flops ) || ( ParsBest . Depth == ParsNew . Depth && ParsBest . Flops == ParsNew . Flops && ParsBest . Nodes > ParsNew . Nodes ) ) { ABC_FREE ( ParsBest . pName ) ; ParsBest . pName = Abc_UtilStrsav ( pNtk -> pName ) ; ParsBest . Depth = ParsNew . Depth ; ParsBest . Flops = ParsNew . Flops ; ParsBest . Nodes = ParsNew . Nodes ; ParsBest . nPis = ParsNew . nPis ; ParsBest . nPos = ParsNew . nPos ; return 1 ; } return 0 ; }
Function
Synopsis    [If the network is best, saves it in "best.blif" and returns 1.]
Function Synopsis [ If the network is best saves it in " best . blif " and returns 1 . ]
//    extern void Ntl_WriteBlifLogic( Nwk_Man_t * pNtk, void * pNtl, char * pFileName ); // name of the best saved network // depth of the best saved network // flops in the best saved network  // nodes in the best saved network // the number of primary inputs // the number of primary outputs // free storage for the name // get the parameters // reset the parameters if the network has the same name // write the network //        Ntl_WriteBlifLogic( pNtk, pNtl, "best.blif" ); //        Nwk_ManDumpBlif( pNtk, "best_map.blif", NULL, NULL );