mirror of https://github.com/YosysHQ/abc.git
Adding command &print_truth to print truth tables for primary outputs.
This commit is contained in:
parent
91b5428154
commit
890ff42cb7
|
|
@ -52,6 +52,40 @@ static inline word * Gla_ObjTruthDup( Gia_Man_t * p, word * pDst, word * pSrc, i
|
|||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Compute truth table.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
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.]
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
@ -30683,6 +30685,93 @@ usage:
|
|||
return 1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
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 []
|
||||
|
|
|
|||
Loading…
Reference in New Issue