Commit 40375f8b by Alan Mishchenko

Updates to arithmetic verification.

parent 50e324ce
......@@ -475,8 +475,8 @@ static int Abc_CommandAbc9Bmci ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandAbc9PoXsim ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Demiter ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Fadds ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Polyn ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9ATree ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Polyn ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Acec ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Esop ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Exorcism ( Abc_Frame_t * pAbc, int argc, char ** argv );
......@@ -1116,8 +1116,8 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "ABC9", "&poxsim", Abc_CommandAbc9PoXsim, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&demiter", Abc_CommandAbc9Demiter, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&fadds", Abc_CommandAbc9Fadds, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&polyn", Abc_CommandAbc9Polyn, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&atree", Abc_CommandAbc9ATree, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&polyn", Abc_CommandAbc9Polyn, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&acec", Abc_CommandAbc9Acec, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&esop", Abc_CommandAbc9Esop, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&exorcism", Abc_CommandAbc9Exorcism, 0 );
......@@ -40183,20 +40183,21 @@ usage:
SeeAlso []
***********************************************************************/
int Abc_CommandAbc9Polyn( Abc_Frame_t * pAbc, int argc, char ** argv )
int Abc_CommandAbc9ATree( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Vec_Int_t * vOrder = NULL;
int c, fSimple = 1, fSigned = 0, fVerbose = 0, fVeryVerbose = 0;
extern Gia_Man_t * Gia_PolynCoreDetectTest( Gia_Man_t * pGia, int fAddExtra, int fAddCones, int fVerbose );
Gia_Man_t * pTemp = NULL;
int c, fAddExtra = 0, fAddCones = 0, fVerbose = 0, fVeryVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "asvwh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "ecvwh" ) ) != EOF )
{
switch ( c )
{
case 'a':
fSimple ^= 1;
case 'e':
fAddExtra ^= 1;
break;
case 's':
fSigned ^= 1;
case 'c':
fAddCones ^= 1;
break;
case 'v':
fVerbose ^= 1;
......@@ -40215,16 +40216,15 @@ int Abc_CommandAbc9Polyn( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9Esop(): There is no AIG.\n" );
return 0;
}
vOrder = fSimple ? NULL : Gia_PolynReorder( pAbc->pGia, fVerbose, fVeryVerbose );
Gia_PolynBuild( pAbc->pGia, vOrder, fSigned, fVerbose, fVeryVerbose );
Vec_IntFreeP( &vOrder );
pTemp = Gia_PolynCoreDetectTest( pAbc->pGia, fAddExtra, fAddCones, fVerbose );
Abc_FrameUpdateGia( pAbc, pTemp );
return 0;
usage:
Abc_Print( -2, "usage: &polyn [-asvwh]\n" );
Abc_Print( -2, "\t derives algebraic polynomial from AIG\n" );
Abc_Print( -2, "\t-a : toggles simple computation [default = %s]\n", fSimple? "yes": "no" );
Abc_Print( -2, "\t-s : toggles signed computation [default = %s]\n", fSigned? "yes": "no" );
Abc_Print( -2, "usage: &atree [-ecvwh]\n" );
Abc_Print( -2, "\t extracts adder tree rooting in primary outputs\n" );
Abc_Print( -2, "\t-e : toggles adding extra outputs [default = %s]\n", fAddExtra? "yes": "no" );
Abc_Print( -2, "\t-c : toggles duplicating complete AIG [default = %s]\n", fAddCones? "yes": "no" );
Abc_Print( -2, "\t-v : toggles printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-w : toggles printing very verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
......@@ -40242,16 +40242,36 @@ usage:
SeeAlso []
***********************************************************************/
int Abc_CommandAbc9ATree( Abc_Frame_t * pAbc, int argc, char ** argv )
int Abc_CommandAbc9Polyn( Abc_Frame_t * pAbc, int argc, char ** argv )
{
extern Gia_Man_t * Gia_PolynCoreDetectTest( Gia_Man_t * pGia );
Gia_Man_t * pTemp = NULL;
int c, fVerbose = 0, fVeryVerbose = 0;
extern void Gia_PolynBuild2Test( Gia_Man_t * pGia, int nExtra, int fSigned, int fVerbose, int fVeryVerbose );
Vec_Int_t * vOrder = NULL;
int c, nExtra = -1, fOld = 0, fSimple = 1, fSigned = 0, fVerbose = 0, fVeryVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "vwh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "Noasvwh" ) ) != EOF )
{
switch ( c )
{
case 'N':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nExtra = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nExtra < 0 )
goto usage;
break;
case 'o':
fOld ^= 1;
break;
case 'a':
fSimple ^= 1;
break;
case 's':
fSigned ^= 1;
break;
case 'v':
fVerbose ^= 1;
break;
......@@ -40269,13 +40289,23 @@ int Abc_CommandAbc9ATree( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9Esop(): There is no AIG.\n" );
return 0;
}
pTemp = Gia_PolynCoreDetectTest( pAbc->pGia );
Abc_FrameUpdateGia( pAbc, pTemp );
if ( fOld )
{
vOrder = fSimple ? NULL : Gia_PolynReorder( pAbc->pGia, fVerbose, fVeryVerbose );
Gia_PolynBuild( pAbc->pGia, vOrder, fSigned, fVerbose, fVeryVerbose );
Vec_IntFreeP( &vOrder );
}
else
Gia_PolynBuild2Test( pAbc->pGia, nExtra, fSigned, fVerbose, fVeryVerbose );
return 0;
usage:
Abc_Print( -2, "usage: &atree [-vwh]\n" );
Abc_Print( -2, "\t extracts adder tree rooting in primary outputs\n" );
Abc_Print( -2, "usage: &polyn [-N num] [-oasvwh]\n" );
Abc_Print( -2, "\t derives algebraic polynomial from AIG\n" );
Abc_Print( -2, "\t-N num : the number of additional primary outputs (-1 = unused) [default = %d]\n", nExtra );
Abc_Print( -2, "\t-o : toggles old computation [default = %s]\n", fOld? "yes": "no" );
Abc_Print( -2, "\t-a : toggles simple computation [default = %s]\n", fSimple? "yes": "no" );
Abc_Print( -2, "\t-s : toggles signed computation [default = %s]\n", fSigned? "yes": "no" );
Abc_Print( -2, "\t-v : toggles printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-w : toggles printing very verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
......@@ -70,7 +70,8 @@ Vec_Int_t * Gia_PolynAddHaRoots( Gia_Man_t * pGia )
Vec_IntPush( vNewOuts, Abc_Lit2Var(iRoot) );
}
Vec_IntFree( vXorPairs );
printf( "On top of %d COs, created %d new adder outputs.\n", Gia_ManCoNum(pGia), Vec_IntSize(vNewOuts) );
Vec_IntReverseOrder( vNewOuts );
// Vec_IntPop( vNewOuts );
return vNewOuts;
}
......@@ -220,15 +221,28 @@ Vec_Int_t * Gia_PolynCoreCollect( Gia_Man_t * pGia, Vec_Int_t * vAdds, Vec_Int_t
SeeAlso []
***********************************************************************/
void Gia_PolynCorePrintCones( Gia_Man_t * pGia, Vec_Int_t * vLeaves )
void Gia_PolynCorePrintCones( Gia_Man_t * pGia, Vec_Int_t * vLeaves, int fVerbose )
{
int i, iObj;
Vec_IntForEachEntry( vLeaves, iObj, i )
if ( fVerbose )
{
printf( "%4d : ", i );
printf( "Supp = %3d ", Gia_ManSuppSize(pGia, &iObj, 1) );
printf( "Cone = %3d ", Gia_ManConeSize(pGia, &iObj, 1) );
printf( "\n" );
Vec_IntForEachEntry( vLeaves, iObj, i )
{
printf( "%4d : ", i );
printf( "Supp = %3d ", Gia_ManSuppSize(pGia, &iObj, 1) );
printf( "Cone = %3d ", Gia_ManConeSize(pGia, &iObj, 1) );
printf( "\n" );
}
}
else
{
int SuppMax = 0, ConeMax = 0;
Vec_IntForEachEntry( vLeaves, iObj, i )
{
SuppMax = Abc_MaxInt( SuppMax, Gia_ManSuppSize(pGia, &iObj, 1) );
ConeMax = Abc_MaxInt( ConeMax, Gia_ManConeSize(pGia, &iObj, 1) );
}
printf( "Remaining cones: Count = %d. SuppMax = %d. ConeMax = %d.\n", Vec_IntSize(vLeaves), SuppMax, ConeMax );
}
}
......@@ -243,7 +257,16 @@ void Gia_PolynCorePrintCones( Gia_Man_t * pGia, Vec_Int_t * vLeaves )
SeeAlso []
***********************************************************************/
Gia_Man_t * Gia_PolynCoreDupTree( Gia_Man_t * p, Vec_Int_t * vAddCos, Vec_Int_t * vLeaves, Vec_Int_t * vNodes )
int Gia_PolynCoreDupTreePlus_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj )
{
if ( ~pObj->Value )
return pObj->Value;
assert( Gia_ObjIsAnd(pObj) );
Gia_PolynCoreDupTreePlus_rec( pNew, p, Gia_ObjFanin0(pObj) );
Gia_PolynCoreDupTreePlus_rec( pNew, p, Gia_ObjFanin1(pObj) );
return pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
}
Gia_Man_t * Gia_PolynCoreDupTree( Gia_Man_t * p, Vec_Int_t * vAddCos, Vec_Int_t * vLeaves, Vec_Int_t * vNodes, int fAddCones )
{
Gia_Man_t * pNew;
Gia_Obj_t * pObj;
......@@ -254,8 +277,18 @@ Gia_Man_t * Gia_PolynCoreDupTree( Gia_Man_t * p, Vec_Int_t * vAddCos, Vec_Int_t
pNew->pName = Abc_UtilStrsav( p->pName );
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
Gia_ManConst0(p)->Value = 0;
Gia_ManForEachObjVec( vLeaves, p, pObj, i )
pObj->Value = Gia_ManAppendCi(pNew);
if ( fAddCones )
{
Gia_ManForEachPi( p, pObj, i )
pObj->Value = Gia_ManAppendCi(pNew);
Gia_ManForEachObjVec( vLeaves, p, pObj, i )
pObj->Value = Gia_PolynCoreDupTreePlus_rec( pNew, p, pObj );
}
else
{
Gia_ManForEachObjVec( vLeaves, p, pObj, i )
pObj->Value = Gia_ManAppendCi(pNew);
}
Gia_ManForEachObjVec( vNodes, p, pObj, i )
pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
Gia_ManForEachCo( p, pObj, i )
......@@ -277,7 +310,7 @@ Gia_Man_t * Gia_PolynCoreDupTree( Gia_Man_t * p, Vec_Int_t * vAddCos, Vec_Int_t
SeeAlso []
***********************************************************************/
Gia_Man_t * Gia_PolynCoreDetectTest_int( Gia_Man_t * pGia, Vec_Int_t * vAddCos )
Gia_Man_t * Gia_PolynCoreDetectTest_int( Gia_Man_t * pGia, Vec_Int_t * vAddCos, int fAddCones, int fVerbose )
{
extern Vec_Int_t * Ree_ManComputeCuts( Gia_Man_t * p, int fVerbose );
abctime clk = Abc_Clock();
......@@ -289,9 +322,9 @@ Gia_Man_t * Gia_PolynCoreDetectTest_int( Gia_Man_t * pGia, Vec_Int_t * vAddCos )
Vec_IntSize(vAdds), Vec_IntSize(vLeaves), Vec_IntSize(vRoots), Vec_IntSize(vNodes), Vec_IntSize(vOrder) );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
Gia_PolynCorePrintCones( pGia, vLeaves );
Gia_PolynCorePrintCones( pGia, vLeaves, fVerbose );
pNew = Gia_PolynCoreDupTree( pGia, vAddCos, vLeaves, vNodes );
pNew = Gia_PolynCoreDupTree( pGia, vAddCos, vLeaves, vNodes, fAddCones );
Vec_IntFree( vAdds );
Vec_IntFree( vLeaves );
......@@ -300,10 +333,11 @@ Gia_Man_t * Gia_PolynCoreDetectTest_int( Gia_Man_t * pGia, Vec_Int_t * vAddCos )
Vec_IntFree( vNodes );
return pNew;
}
Gia_Man_t * Gia_PolynCoreDetectTest( Gia_Man_t * pGia )
Gia_Man_t * Gia_PolynCoreDetectTest( Gia_Man_t * pGia, int fAddExtra, int fAddCones, int fVerbose )
{
Vec_Int_t * vAddCos = Gia_PolynAddHaRoots( pGia );
Gia_Man_t * pNew = Gia_PolynCoreDetectTest_int( pGia, vAddCos );
Vec_Int_t * vAddCos = fAddExtra ? Gia_PolynAddHaRoots( pGia ) : Vec_IntAlloc(0);
Gia_Man_t * pNew = Gia_PolynCoreDetectTest_int( pGia, vAddCos, fAddCones, fVerbose );
printf( "On top of %d COs, created %d new adder outputs.\n", Gia_ManCoNum(pGia), Vec_IntSize(vAddCos) );
Vec_IntFree( vAddCos );
return pNew;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment