abc/src/base/abci/abcExact.c
// this procedure returns a new node whose output in terms of the given fanins
// has the smallest possible arrival time (in agreement with the above Abc_ExactDelayCost)
this procedure returns a new node whose output in terms of the given fanins
has the smallest possible arrival time (in agreement with the above Abc_ExactDelayCost)
this procedure returns a new node whose output in terms of the given fanins has the smallest possible arrival time ( in agreement with the above Abc_ExactDelayCost )
Abc_Obj_t * Abc_ExactBuildNode( word * pTruth, int nVars, int * pArrTimeProfile, Abc_Obj_t ** pFanins, Abc_Ntk_t * pNtk )
{
    char * pSol = NULL;
    int i, j, nMaxArrival;
    int pNormalArrTime[8];
    char const * p;
    Abc_Obj_t * pObj;
    Vec_Ptr_t * pGates;
    char pGateTruth[5];
    char * pSopCover;
    abctime timeStart = Abc_Clock();
    if ( nVars == 0 )
    {
        s_pSesStore->timeTotal += ( Abc_Clock() - timeStart );
        return (pTruth[0] & 1) ? Abc_NtkCreateNodeConst1(pNtk) : Abc_NtkCreateNodeConst0(pNtk);
    }
    if ( nVars == 1 )
    {
        s_pSesStore->timeTotal += ( Abc_Clock() - timeStart );
        return (pTruth[0] & 1) ? Abc_NtkCreateNodeInv(pNtk, pFanins[0]) : Abc_NtkCreateNodeBuf(pNtk, pFanins[0]);
    }
    for ( i = 0; i < nVars; ++i )
        pNormalArrTime[i] = pArrTimeProfile[i];
    Abc_NormalizeArrivalTimes( pNormalArrTime, nVars, &nMaxArrival );
    assert( Ses_StoreGetEntry( s_pSesStore, pTruth, nVars, pNormalArrTime, &pSol ) );
    if ( !pSol )
    {
        s_pSesStore->timeTotal += ( Abc_Clock() - timeStart );
        return NULL;
    }
    assert( pSol[ABC_EXACT_SOL_NVARS] == nVars );
    assert( pSol[ABC_EXACT_SOL_NFUNC] == 1 );
    pGates = Vec_PtrAlloc( nVars + pSol[ABC_EXACT_SOL_NGATES] );
    pGateTruth[3] = '0';
    pGateTruth[4] = '\0';
    for ( i = 0; i < nVars; ++i )
    {
        assert( pFanins[i] );
        Vec_PtrPush( pGates, pFanins[i] );
    }
    p = pSol + 3;
    for ( i = 0; i < pSol[ABC_EXACT_SOL_NGATES]; ++i )
    {
        pGateTruth[2] = '0' + ( *p & 1 );
        pGateTruth[1] = '0' + ( ( *p >> 1 ) & 1 );
        pGateTruth[0] = '0' + ( ( *p >> 2 ) & 1 );
        ++p;
        assert( *p == 2 ); 
        ++p;
        if ( i + 1 == pSol[ABC_EXACT_SOL_NGATES] && Abc_LitIsCompl( *( p + 2 ) ) )
            for ( j = 0; j < 4; ++j )
                pGateTruth[j] = ( pGateTruth[j] == '0' ) ? '1' : '0';
        pSopCover = Abc_SopFromTruthBin( pGateTruth );
        pObj = Abc_NtkCreateNode( pNtk );
        assert( pObj );
        pObj->pData = Abc_SopRegister( (Mem_Flex_t*)pNtk->pManFunc, pSopCover );
        Vec_PtrPush( pGates, pObj );
        ABC_FREE( pSopCover );
        Abc_ObjAddFanin( pObj, (Abc_Obj_t *)Vec_PtrEntry( pGates, *p++ ) );
        Abc_ObjAddFanin( pObj, (Abc_Obj_t *)Vec_PtrEntry( pGates, *p++ ) );
    }
    pObj = (Abc_Obj_t *)Vec_PtrEntry( pGates, nVars + Abc_Lit2Var( *p ) );
    Vec_PtrFree( pGates );
    s_pSesStore->timeTotal += ( Abc_Clock() - timeStart );
    return pObj;
}
Abc_Obj_t * Abc_ExactBuildNode ( word * pTruth , int nVars , int * pArrTimeProfile , Abc_Obj_t * * pFanins , Abc_Ntk_t * pNtk ) { char * pSol = NULL ; int i , j , nMaxArrival ; int pNormalArrTime [ 8 ] ; char const * p ; Abc_Obj_t * pObj ; Vec_Ptr_t * pGates ; char pGateTruth [ 5 ] ; char * pSopCover ; abctime timeStart = Abc_Clock ( ) ; if ( nVars == 0 ) { s_pSesStore -> timeTotal += ( Abc_Clock ( ) - timeStart ) ; return ( pTruth [ 0 ] & 1 ) ? Abc_NtkCreateNodeConst1 ( pNtk ) : Abc_NtkCreateNodeConst0 ( pNtk ) ; } if ( nVars == 1 ) { s_pSesStore -> timeTotal += ( Abc_Clock ( ) - timeStart ) ; return ( pTruth [ 0 ] & 1 ) ? Abc_NtkCreateNodeInv ( pNtk , pFanins [ 0 ] ) : Abc_NtkCreateNodeBuf ( pNtk , pFanins [ 0 ] ) ; } for ( i = 0 ; i < nVars ; ++ i ) pNormalArrTime [ i ] = pArrTimeProfile [ i ] ; Abc_NormalizeArrivalTimes ( pNormalArrTime , nVars , & nMaxArrival ) ; assert ( Ses_StoreGetEntry ( s_pSesStore , pTruth , nVars , pNormalArrTime , & pSol ) ) ; if ( ! pSol ) { s_pSesStore -> timeTotal += ( Abc_Clock ( ) - timeStart ) ; return NULL ; } assert ( pSol [ ABC_EXACT_SOL_NVARS ] == nVars ) ; assert ( pSol [ ABC_EXACT_SOL_NFUNC ] == 1 ) ; pGates = Vec_PtrAlloc ( nVars + pSol [ ABC_EXACT_SOL_NGATES ] ) ; pGateTruth [ 3 ] = ' ' ; pGateTruth [ 4 ] = ' \0 ' ; for ( i = 0 ; i < nVars ; ++ i ) { assert ( pFanins [ i ] ) ; Vec_PtrPush ( pGates , pFanins [ i ] ) ; } p = pSol + 3 ; for ( i = 0 ; i < pSol [ ABC_EXACT_SOL_NGATES ] ; ++ i ) { pGateTruth [ 2 ] = ' ' + ( * p & 1 ) ; pGateTruth [ 1 ] = ' ' + ( ( * p >> 1 ) & 1 ) ; pGateTruth [ 0 ] = ' ' + ( ( * p >> 2 ) & 1 ) ; ++ p ; assert ( * p == 2 ) ; ++ p ; if ( i + 1 == pSol [ ABC_EXACT_SOL_NGATES ] && Abc_LitIsCompl ( * ( p + 2 ) ) ) for ( j = 0 ; j < 4 ; ++ j ) pGateTruth [ j ] = ( pGateTruth [ j ] == ' ' ) ? ' ' : ' ' ; pSopCover = Abc_SopFromTruthBin ( pGateTruth ) ; pObj = Abc_NtkCreateNode ( pNtk ) ; assert ( pObj ) ; pObj -> pData = Abc_SopRegister ( ( Mem_Flex_t * ) pNtk -> pManFunc , pSopCover ) ; Vec_PtrPush ( pGates , pObj ) ; ABC_FREE ( pSopCover ) ; Abc_ObjAddFanin ( pObj , ( Abc_Obj_t * ) Vec_PtrEntry ( pGates , * p ++ ) ) ; Abc_ObjAddFanin ( pObj , ( Abc_Obj_t * ) Vec_PtrEntry ( pGates , * p ++ ) ) ; } pObj = ( Abc_Obj_t * ) Vec_PtrEntry ( pGates , nVars + Abc_Lit2Var ( * p ) ) ; Vec_PtrFree ( pGates ) ; s_pSesStore -> timeTotal += ( Abc_Clock ( ) - timeStart ) ; return pObj ; }
this procedure returns a new node whose output in terms of the given fanins
has the smallest possible arrival time (in agreement with the above Abc_ExactDelayCost)
this procedure returns a new node whose output in terms of the given fanins has the smallest possible arrival time ( in agreement with the above Abc_ExactDelayCost )
/* primary inputs */ /* gates */ /* binary gate */ /* invert truth table if we are last gate and inverted */ /* output */