abc/src/bdd/cudd/cuddCache.c
/**Function********************************************************************

  Synopsis [Looks up in the cache for the result of op applied to f,
  g, and h.]

  Description [Looks up in the cache for the result of op applied to f,
  g, and h. Assumes that the calling procedure (e.g.,
  Cudd_bddIteConstant) is only interested in whether the result is
  constant or not. Returns the result if found (possibly
  DD_NON_CONSTANT); otherwise it returns NULL.]

  SideEffects [None]

  SeeAlso     [cuddCacheLookup]

******************************************************************************/
Function
Synopsis [Looks up in the cache for the result of op applied to f,
g, and h.]

Description [Looks up in the cache for the result of op applied to f,
g, and h. Assumes that the calling procedure  is only interested in whether the result is
constant or not. Returns the result if found (possibly
DD_NON_CONSTANT); otherwise it returns NULL.]




Function Synopsis [ Looks up in the cache for the result of op applied to f g and h . ] Description [ Looks up in the cache for the result of op applied to f g and h . Assumes that the calling procedure is only interested in whether the result is constant or not . Returns the result if found ( possibly DD_NON_CONSTANT ) ; otherwise it returns NULL . ]
DdNode *
cuddConstantLookup(
  DdManager * table,
  ptruint op,
  DdNode * f,
  DdNode * g,
  DdNode * h)
{
    int posn;
    DdCache *en,*cache;
    ptruint uf, ug, uh;
    ptruint ufc, ugc, uhc;
    uf = (ptruint) f | (op & 0xe);
    ug = (ptruint) g | (op >> 4);
    uh = (ptruint) h;
    ufc = (ptruint) cuddF2L(f) | (op & 0xe);
    ugc = (ptruint) cuddF2L(g) | (op >> 4);
    uhc = (ptruint) cuddF2L(h);
    cache = table->cache;
#ifdef DD_DEBUG
    if (cache == NULL) {
        return(NULL);
    }
#endif
    posn = ddCHash2(uhc,ufc,ugc,table->cacheShift);
    en = &cache[posn];
    if (en->data != NULL &&
        en->f == (DdNodePtr)uf && en->g == (DdNodePtr)ug && en->h == uh) {
        table->cacheHits++;
        return(en->data);
    }
    table->cacheMisses++;
    if (table->cacheSlack >= 0 &&
        table->cacheHits > table->cacheMisses * table->minHit) {
        cuddCacheResize(table);
    }
    return(NULL);
}
DdNode * cuddConstantLookup ( DdManager * table , ptruint op , DdNode * f , DdNode * g , DdNode * h ) { int posn ; DdCache * en , * cache ; ptruint uf , ug , uh ; ptruint ufc , ugc , uhc ; uf = ( ptruint ) f | ( op & 0xe ) ; ug = ( ptruint ) g | ( op >> 4 ) ; uh = ( ptruint ) h ; ufc = ( ptruint ) cuddF2L ( f ) | ( op & 0xe ) ; ugc = ( ptruint ) cuddF2L ( g ) | ( op >> 4 ) ; uhc = ( ptruint ) cuddF2L ( h ) ; cache = table -> cache ; #ifdef DD_DEBUG if ( cache == NULL ) { return ( NULL ) ; } #endif posn = ddCHash2 ( uhc , ufc , ugc , table -> cacheShift ) ; en = & cache [ posn ] ; if ( en -> data != NULL && en -> f == ( DdNodePtr ) uf && en -> g == ( DdNodePtr ) ug && en -> h == uh ) { table -> cacheHits ++ ; return ( en -> data ) ; } table -> cacheMisses ++ ; if ( table -> cacheSlack >= 0 && table -> cacheHits > table -> cacheMisses * table -> minHit ) { cuddCacheResize ( table ) ; } return ( NULL ) ; }
Function
Synopsis [Looks up in the cache for the result of op applied to f,
g, and h.]
Function Synopsis [ Looks up in the cache for the result of op applied to f g and h . ]
/* We do not reclaim here because the result should not be
     * referenced, but only tested for being a constant.
     */ /* Cache miss: decide whether to resize. */