abc/src/bool/rpo/literal.h
/**Function*************************************************************

  Synopsis    [Create a literal given a polarity ]

  Description [The inputs are the function, index and its polarity and a the output is a literal]
               
  SideEffects []

  SeeAlso     []

 ***********************************************************************/
Function
Synopsis    [Create a literal given a polarity ]

Description [The inputs are the function, index and its polarity and a the output is a literal]




Function Synopsis [ Create a literal given a polarity ] Description [ The inputs are the function index and its polarity and a the output is a literal ]
static inline Literal_t* Lit_Alloc(unsigned* pTruth, int nVars, int varIdx, char pol) {
    unsigned * transition;
    unsigned * function;
    Vec_Str_t * exp;
    Literal_t* lit;
    assert(pol == '+' || pol == '-');
    transition = ABC_ALLOC(unsigned, Kit_TruthWordNum(nVars));
    if (pol == '+') {
        Lit_TruthPositiveTransition(pTruth, transition, nVars, varIdx);
    } else {
        Lit_TruthNegativeTransition(pTruth, transition, nVars, varIdx);
    }
    if (!Kit_TruthIsConst0(transition,nVars)) {
        function = ABC_ALLOC(unsigned, Kit_TruthWordNum(nVars));
        Kit_TruthIthVar(function, nVars, varIdx);
        exp = Vec_StrAlloc(5);
        if (pol == '-') {
            Kit_TruthNot(function, function, nVars);
            Vec_StrPutC(exp, '!');
        }
        Vec_StrPutC(exp, (char)('a' + varIdx));
        Vec_StrPutC(exp, '\0');
        lit = ABC_ALLOC(Literal_t, 1);
        lit->function = function;
        lit->transition = transition;
        lit->expression = exp;
        return lit;
    } else {
        ABC_FREE(transition); 
        return NULL;
    }
}
static inline Literal_t * Lit_Alloc ( unsigned * pTruth , int nVars , int varIdx , char pol ) { unsigned * transition ; unsigned * function ; Vec_Str_t * exp ; Literal_t * lit ; assert ( pol == ' ' || pol == ' ' ) ; transition = ABC_ALLOC ( unsigned , Kit_TruthWordNum ( nVars ) ) ; if ( pol == ' ' ) { Lit_TruthPositiveTransition ( pTruth , transition , nVars , varIdx ) ; } else { Lit_TruthNegativeTransition ( pTruth , transition , nVars , varIdx ) ; } if ( ! Kit_TruthIsConst0 ( transition , nVars ) ) { function = ABC_ALLOC ( unsigned , Kit_TruthWordNum ( nVars ) ) ; Kit_TruthIthVar ( function , nVars , varIdx ) ; exp = Vec_StrAlloc ( 5 ) ; if ( pol == ' ' ) { Kit_TruthNot ( function , function , nVars ) ; Vec_StrPutC ( exp , ' ' ) ; } Vec_StrPutC ( exp , ( char ) ( ' ' + varIdx ) ) ; Vec_StrPutC ( exp , ' \0 ' ) ; lit = ABC_ALLOC ( Literal_t , 1 ) ; lit -> function = function ; lit -> transition = transition ; lit -> expression = exp ; return lit ; } else { ABC_FREE ( transition ) ; return NULL ; } }
Function
Synopsis    [Create a literal given a polarity ]
Function Synopsis [ Create a literal given a polarity ]
//Abc_Print(-2, "Allocating function %X %d %c \n", *function, varIdx, pol); // free the function.