abc/src/map/super/superGate.c
/**Function*************************************************************

  Synopsis    [Check the manager's unique table for comparable gates.]

  Description [Returns 0 if the gate is dominated by others. Returns 1 
  if the gate is new or is better than the available ones. In this case, 
  cleans the table by removing the gates that are worse than the given one.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Check the manager's unique table for comparable gates.]

Description [Returns 0 if the gate is dominated by others. Returns 1
if the gate is new or is better than the available ones. In this case,
cleans the table by removing the gates that are worse than the given one.]




Function Synopsis [ Check the manager ' s unique table for comparable gates . ] Description [ Returns 0 if the gate is dominated by others . Returns 1 if the gate is new or is better than the available ones . In this case cleans the table by removing the gates that are worse than the given one . ]
int Super_CompareGates( Super_Man_t * pMan, unsigned uTruth[], float Area, float tPinDelaysRes[], int nPins )
{
    Super_Gate_t ** ppList, * pPrev, * pGate, * pGate2;
    int i, fNewIsBetter, fGateIsBetter;
    ABC_PTRUINT_T Key;
    if ( pMan->nVarsMax < 6 )
    {
        if ( uTruth[0] == 0 || ~uTruth[0] == 0 )
            return 0;
    }
    else
    {
        if ( ( uTruth[0] == 0 && uTruth[1] == 0 ) || ( ~uTruth[0] == 0 && ~uTruth[1] == 0 ) )
            return 0;
    }
    Key = uTruth[0] ^ uTruth[1];
    if ( !stmm_find( pMan->tTable, (char *)Key, (char ***)&ppList ) )
        return 1; 
    pPrev = NULL;
    for ( pGate = *ppList, pGate2 = pGate? pGate->pNext: NULL; pGate; 
        pGate = pGate2, pGate2 = pGate? pGate->pNext: NULL )
    {
        pMan->nLookups++;
        if ( pGate->uTruth[0] != uTruth[0] || pGate->uTruth[1] != uTruth[1] )
        {
            pMan->nAliases++;
            continue;
        }
        fGateIsBetter = 0;
        fNewIsBetter  = 0;
        if ( pGate->Area + SUPER_EPSILON < Area )
            fGateIsBetter = 1;
        else if ( pGate->Area > Area + SUPER_EPSILON )
            fNewIsBetter = 1;
        for ( i = 0; i < nPins; i++ )
        {
            if ( pGate->ptDelays[i] == SUPER_NO_VAR || tPinDelaysRes[i] == SUPER_NO_VAR )
                continue;
            if ( pGate->ptDelays[i] + SUPER_EPSILON < tPinDelaysRes[i] )
                fGateIsBetter = 1;
            else if ( pGate->ptDelays[i] > tPinDelaysRes[i] + SUPER_EPSILON )
                fNewIsBetter = 1;
            if ( fGateIsBetter && fNewIsBetter )
                break;
        }
        if ( fGateIsBetter && fNewIsBetter ) 
            pPrev = pGate;
        else if ( fNewIsBetter ) 
        {
            if ( pPrev == NULL )
                *ppList = pGate->pNext;
            else
                pPrev->pNext = pGate->pNext;
            Extra_MmFixedEntryRecycle( pMan->pMem, (char *)pGate );
            pMan->nRemoved++;
        }
        else if ( fGateIsBetter ) 
            return 0;
        else 
            return 0;
    }
    return 1;
}
int Super_CompareGates ( Super_Man_t * pMan , unsigned uTruth [ ] , float Area , float tPinDelaysRes [ ] , int nPins ) { Super_Gate_t * * ppList , * pPrev , * pGate , * pGate2 ; int i , fNewIsBetter , fGateIsBetter ; ABC_PTRUINT_T Key ; if ( pMan -> nVarsMax < 6 ) { if ( uTruth [ 0 ] == 0 || ~ uTruth [ 0 ] == 0 ) return 0 ; } else { if ( ( uTruth [ 0 ] == 0 && uTruth [ 1 ] == 0 ) || ( ~ uTruth [ 0 ] == 0 && ~ uTruth [ 1 ] == 0 ) ) return 0 ; } Key = uTruth [ 0 ] ^ uTruth [ 1 ] ; if ( ! stmm_find ( pMan -> tTable , ( char * ) Key , ( char * * * ) & ppList ) ) return 1 ; pPrev = NULL ; for ( pGate = * ppList , pGate2 = pGate ? pGate -> pNext : NULL ; pGate ; pGate = pGate2 , pGate2 = pGate ? pGate -> pNext : NULL ) { pMan -> nLookups ++ ; if ( pGate -> uTruth [ 0 ] != uTruth [ 0 ] || pGate -> uTruth [ 1 ] != uTruth [ 1 ] ) { pMan -> nAliases ++ ; continue ; } fGateIsBetter = 0 ; fNewIsBetter = 0 ; if ( pGate -> Area + SUPER_EPSILON < Area ) fGateIsBetter = 1 ; else if ( pGate -> Area > Area + SUPER_EPSILON ) fNewIsBetter = 1 ; for ( i = 0 ; i < nPins ; i ++ ) { if ( pGate -> ptDelays [ i ] == SUPER_NO_VAR || tPinDelaysRes [ i ] == SUPER_NO_VAR ) continue ; if ( pGate -> ptDelays [ i ] + SUPER_EPSILON < tPinDelaysRes [ i ] ) fGateIsBetter = 1 ; else if ( pGate -> ptDelays [ i ] > tPinDelaysRes [ i ] + SUPER_EPSILON ) fNewIsBetter = 1 ; if ( fGateIsBetter && fNewIsBetter ) break ; } if ( fGateIsBetter && fNewIsBetter ) pPrev = pGate ; else if ( fNewIsBetter ) { if ( pPrev == NULL ) * ppList = pGate -> pNext ; else pPrev -> pNext = pGate -> pNext ; Extra_MmFixedEntryRecycle ( pMan -> pMem , ( char * ) pGate ) ; pMan -> nRemoved ++ ; } else if ( fGateIsBetter ) return 0 ; else return 0 ; } return 1 ; }
Function
Synopsis    [Check the manager's unique table for comparable gates.]
Function Synopsis [ Check the manager ' s unique table for comparable gates . ]
// skip constant functions // get hold of the place where the entry is stored //    Key = uTruth[0] + 2003 * uTruth[1]; // the entry with this truth table is found // consider 4 cases // Pareto points; save both // gate is worse; remove the gate // new is worse, already dominated no need to see others // if ( !fGateIsBetter && !fNewIsBetter ) // they are identical, no need to see others