abc/src/map/mapper/mapperSuper.c
/**Function*************************************************************

  Synopsis    [Derives the functionality of the supergate.]

  Description [This procedure is useful for verification the supergate 
  library. The truth table derived by this procedure should be the same
  as the one contained in the original supergate file.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Derives the functionality of the supergate.]

Description [This procedure is useful for verification the supergate
library. The truth table derived by this procedure should be the same
as the one contained in the original supergate file.]




Function Synopsis [ Derives the functionality of the supergate . ] Description [ This procedure is useful for verification the supergate library . The truth table derived by this procedure should be the same as the one contained in the original supergate file . ]
void Map_LibraryComputeTruth_rec( Map_SuperLib_t * pLib, char * pFormula, unsigned uTruthsIn[][2], unsigned uTruthRes[] )
{
    Mio_Gate_t * pMioGate;
    char * pGateName, * pStrings[6];
    unsigned uTruthsFanins[6][2];
    int nStrings, i;
    pGateName = Map_LibraryReadFormulaStep( pFormula, pStrings, &nStrings );
    if ( nStrings == 0 ) 
    {
        assert( pGateName[0] - 'a' < pLib->nVarsMax );
        uTruthRes[0] = uTruthsIn[pGateName[0] - 'a'][0];
        uTruthRes[1] = uTruthsIn[pGateName[0] - 'a'][1];
        return;
    }
    for ( i = 0; i < nStrings; i++ )
        Map_LibraryComputeTruth_rec( pLib, pStrings[i], uTruthsIn, uTruthsFanins[i] );
    pMioGate = Mio_LibraryReadGateByName( pLib->pGenlib, pGateName, NULL );
    if ( pMioGate == NULL )
        printf( "A supergate contains gate \"%s\" that is not in \"%s\".\n", pGateName, Mio_LibraryReadName(pLib->pGenlib) ); 
    Mio_DeriveTruthTable( pMioGate, uTruthsFanins, nStrings, pLib->nVarsMax, uTruthRes );
}
void Map_LibraryComputeTruth_rec ( Map_SuperLib_t * pLib , char * pFormula , unsigned uTruthsIn [ ] [ 2 ] , unsigned uTruthRes [ ] ) { Mio_Gate_t * pMioGate ; char * pGateName , * pStrings [ 6 ] ; unsigned uTruthsFanins [ 6 ] [ 2 ] ; int nStrings , i ; pGateName = Map_LibraryReadFormulaStep ( pFormula , pStrings , & nStrings ) ; if ( nStrings == 0 ) { assert ( pGateName [ 0 ] - ' ' < pLib -> nVarsMax ) ; uTruthRes [ 0 ] = uTruthsIn [ pGateName [ 0 ] - ' ' ] [ 0 ] ; uTruthRes [ 1 ] = uTruthsIn [ pGateName [ 0 ] - ' ' ] [ 1 ] ; return ; } for ( i = 0 ; i < nStrings ; i ++ ) Map_LibraryComputeTruth_rec ( pLib , pStrings [ i ] , uTruthsIn , uTruthsFanins [ i ] ) ; pMioGate = Mio_LibraryReadGateByName ( pLib -> pGenlib , pGateName , NULL ) ; if ( pMioGate == NULL ) printf ( " \" \" \" \" \n " , pGateName , Mio_LibraryReadName ( pLib -> pGenlib ) ) ; Mio_DeriveTruthTable ( pMioGate , uTruthsFanins , nStrings , pLib -> nVarsMax , uTruthRes ) ; }
Function
Synopsis    [Derives the functionality of the supergate.]
Function Synopsis [ Derives the functionality of the supergate . ]
// perform one step parsing of the formula // detect the root gate name, the next-step strings, and their number // elementary variable // derive the functionality of the fanins // get the root supergate // derive the functionality of the output of the supergate