diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/aig/gia/giaTruth.c | 34 | ||||
-rw-r--r-- | src/base/abci/abc.c | 89 |
2 files changed, 123 insertions, 0 deletions
diff --git a/src/aig/gia/giaTruth.c b/src/aig/gia/giaTruth.c index 86f17594..2062f2ad 100644 --- a/src/aig/gia/giaTruth.c +++ b/src/aig/gia/giaTruth.c @@ -63,6 +63,40 @@ static inline word * Gla_ObjTruthDup( Gia_Man_t * p, word * pDst, word * pSrc, i SeeAlso [] ***********************************************************************/ +word Gia_LutComputeTruth6Simple_rec( Gia_Man_t * p, int iObj ) +{ + word Truth0, Truth1, Truth; + Gia_Obj_t * pObj = Gia_ManObj(p, iObj); + if ( Gia_ObjIsConst0(pObj) ) + return 0; + if ( Gia_ObjIsCi(pObj) ) + return s_Truths6[Gia_ObjCioId(pObj)]; + Truth0 = Gia_LutComputeTruth6Simple_rec( p, Gia_ObjFaninId0(pObj, iObj) ); + Truth1 = Gia_LutComputeTruth6Simple_rec( p, Gia_ObjFaninId1(pObj, iObj) ); + Truth0 = Gia_ObjFaninC0(pObj) ? ~Truth0 : Truth0; + Truth1 = Gia_ObjFaninC1(pObj) ? ~Truth1 : Truth1; + Truth = Gia_ObjIsXor(pObj) ? Truth0 ^ Truth1 : Truth0 & Truth1; + return Truth; +} +word Gia_LutComputeTruth6Simple( Gia_Man_t * p, int iPo ) +{ + Gia_Obj_t * pObj = Gia_ManPo( p, iPo ); + word Truth = Gia_LutComputeTruth6Simple_rec( p, Gia_ObjFaninId0p(p, pObj) ); + return Gia_ObjFaninC0(pObj) ? ~Truth : Truth; + +} + +/**Function************************************************************* + + Synopsis [Compute truth table.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ word Gia_LutComputeTruth6_rec( Gia_Man_t * p, int iNode, Vec_Wrd_t * vTruths ) { Gia_Obj_t * pObj; diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 21b89cee..06cd00f1 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -389,6 +389,7 @@ static int Abc_CommandAbc9PFan ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9PSig ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Status ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9MuxProfile ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9PrintTruth ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Unate ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Rex2Gia ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9RexWalk ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1086,6 +1087,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&psig", Abc_CommandAbc9PSig, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&status", Abc_CommandAbc9Status, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&profile", Abc_CommandAbc9MuxProfile, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&print_truth", Abc_CommandAbc9PrintTruth, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&unate", Abc_CommandAbc9Unate, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&rex2gia", Abc_CommandAbc9Rex2Gia, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&rexwalk", Abc_CommandAbc9RexWalk, 0 ); @@ -30694,6 +30696,93 @@ usage: SeeAlso [] ***********************************************************************/ +int Abc_CommandAbc9PrintTruth( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern word Gia_LutComputeTruth6Simple( Gia_Man_t * p, int iPo ); + int i, c, iOutNum = 0, nOutRange = -1, fVerbose = 0; word Truth; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "ORvh" ) ) != EOF ) + { + switch ( c ) + { + case 'O': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" ); + goto usage; + } + iOutNum = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( iOutNum < 0 ) + goto usage; + break; + case 'R': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" ); + goto usage; + } + nOutRange = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nOutRange < 0 ) + goto usage; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9PrintTruth(): There is no AIG.\n" ); + return 1; + } + if ( Gia_ManPiNum(pAbc->pGia) > 6 ) + { + Abc_Print( -1, "The number of inputs of the AIG exceeds 6.\n" ); + return 1; + } + if ( iOutNum < 0 || iOutNum + nOutRange > Gia_ManPoNum(pAbc->pGia) ) + { + Abc_Print( -1, "Abc_CommandAbc9PrintTruth(): Range of outputs to extract is incorrect.\n" ); + return 1; + } + if ( nOutRange == -1 ) + nOutRange = Gia_ManCoNum(pAbc->pGia); + for ( i = iOutNum; i < iOutNum + nOutRange; i++ ) + { + Truth = Gia_LutComputeTruth6Simple( pAbc->pGia, i ); + printf( "Output %8d : ", i ); + Extra_PrintHex( stdout, (unsigned *)&Truth, Gia_ManCiNum(pAbc->pGia) ); + printf( "\n" ); + } + return 0; + +usage: + Abc_Print( -2, "usage: &print_truth [-OR num] [-vh]\n" ); + Abc_Print( -2, "\t prints truth tables of outputs in hex notation\n" ); + Abc_Print( -2, "\t-O num : the index of first PO to print [default = %d]\n", iOutNum ); + Abc_Print( -2, "\t-R num : (optional) the number of outputs to extract [default = all]\n" ); + Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : print the command usage\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ int Abc_CommandAbc9Unate( Abc_Frame_t * pAbc, int argc, char ** argv ) { extern void Gia_ManCheckUnateTest( Gia_Man_t * p, int fComputeAll, int fVerbose ); |