abc/src/map/fpga/fpgaCreate.c
/**Function*************************************************************

  Synopsis    [Looks up the AND2 node in the unique table.]

  Description [This procedure implements one-level hashing. All the nodes
  are hashed by their children. If the node with the same children was already
  created, it is returned by the call to this procedure. If it does not exist,
  this procedure creates a new node with these children. ]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Looks up the AND2 node in the unique table.]

Description [This procedure implements one-level hashing. All the nodes
are hashed by their children. If the node with the same children was already
created, it is returned by the call to this procedure. If it does not exist,
this procedure creates a new node with these children.




Function Synopsis [ Looks up the AND2 node in the unique table . ] Description [ This procedure implements one - level hashing . All the nodes are hashed by their children . If the node with the same children was already created it is returned by the call to this procedure . If it does not exist this procedure creates a new node with these children .
Fpga_Node_t * Fpga_TableLookup( Fpga_Man_t * pMan, Fpga_Node_t * p1, Fpga_Node_t * p2 )
{
    Fpga_Node_t * pEnt;
    unsigned Key;
    if ( p1 == p2 )
        return p1;
    if ( p1 == Fpga_Not(p2) )
        return Fpga_Not(pMan->pConst1);
    if ( Fpga_NodeIsConst(p1) )
    {
        if ( p1 == pMan->pConst1 )
            return p2;
        return Fpga_Not(pMan->pConst1);
    }
    if ( Fpga_NodeIsConst(p2) )
    {
        if ( p2 == pMan->pConst1 )
            return p1;
        return Fpga_Not(pMan->pConst1);
    }
    if ( Fpga_Regular(p1)->Num > Fpga_Regular(p2)->Num )
        pEnt = p1, p1 = p2, p2 = pEnt;
    Key = Fpga_HashKey2( p1, p2, pMan->nBins );
    for ( pEnt = pMan->pBins[Key]; pEnt; pEnt = pEnt->pNext )
        if ( pEnt->p1 == p1 && pEnt->p2 == p2 )
            return pEnt;
    if ( pMan->nNodes >= 2 * pMan->nBins )
    {
        Fpga_TableResize( pMan );
        Key = Fpga_HashKey2( p1, p2, pMan->nBins );
    }
    pEnt = Fpga_NodeCreate( pMan, p1, p2 );
    pEnt->pNext = pMan->pBins[Key];
    pMan->pBins[Key] = pEnt;
    return pEnt;
}
Fpga_Node_t * Fpga_TableLookup ( Fpga_Man_t * pMan , Fpga_Node_t * p1 , Fpga_Node_t * p2 ) { Fpga_Node_t * pEnt ; unsigned Key ; if ( p1 == p2 ) return p1 ; if ( p1 == Fpga_Not ( p2 ) ) return Fpga_Not ( pMan -> pConst1 ) ; if ( Fpga_NodeIsConst ( p1 ) ) { if ( p1 == pMan -> pConst1 ) return p2 ; return Fpga_Not ( pMan -> pConst1 ) ; } if ( Fpga_NodeIsConst ( p2 ) ) { if ( p2 == pMan -> pConst1 ) return p1 ; return Fpga_Not ( pMan -> pConst1 ) ; } if ( Fpga_Regular ( p1 ) -> Num > Fpga_Regular ( p2 ) -> Num ) pEnt = p1 , p1 = p2 , p2 = pEnt ; Key = Fpga_HashKey2 ( p1 , p2 , pMan -> nBins ) ; for ( pEnt = pMan -> pBins [ Key ] ; pEnt ; pEnt = pEnt -> pNext ) if ( pEnt -> p1 == p1 && pEnt -> p2 == p2 ) return pEnt ; if ( pMan -> nNodes >= 2 * pMan -> nBins ) { Fpga_TableResize ( pMan ) ; Key = Fpga_HashKey2 ( p1 , p2 , pMan -> nBins ) ; } pEnt = Fpga_NodeCreate ( pMan , p1 , p2 ) ; pEnt -> pNext = pMan -> pBins [ Key ] ; pMan -> pBins [ Key ] = pEnt ; return pEnt ; }
Function
Synopsis    [Looks up the AND2 node in the unique table.]
Function Synopsis [ Looks up the AND2 node in the unique table . ]
// resize the table // create the new node // add the node to the corresponding linked list in the table