Commit 0aefe77e by Alan Mishchenko

Added command 'reconcile'.

parent ddd97589
......@@ -171,17 +171,122 @@ Abc_Cex_t * Llb4_Nonlin4TransformCex( Aig_Man_t * pAig, Vec_Ptr_t * vStates, int
pCex->iPo = status;
else
{
printf( "Inter_ManGetCounterExample(): Counter-example verification has FAILED.\n" );
printf( "Llb4_Nonlin4TransformCex(): Counter-example verification has FAILED.\n" );
ABC_FREE( pCex );
return NULL;
}
// report the results
// if ( fVerbose )
// Abc_PrintTime( 1, "SAT-based cex generation time", clock() - clk );
// Abc_PrintTime( 1, "SAT-based cex generation time", clock() - clk );
return pCex;
}
/**Function*************************************************************
Synopsis [Resimulates the counter-example.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Llb4_Nonlin4VerifyCex( Aig_Man_t * pAig, Abc_Cex_t * p )
{
Vec_Ptr_t * vStates;
Aig_Obj_t * pObj, * pObjRi, * pObjRo;
int i, k, iBit = 0;
// create storage for states
vStates = Vec_PtrAllocSimInfo( p->iFrame+1, Aig_BitWordNum(Aig_ManRegNum(pAig)) );
Vec_PtrCleanSimInfo( vStates, 0, Aig_BitWordNum(Aig_ManRegNum(pAig)) );
// verify counter-example
Aig_ManCleanMarkB(pAig);
Aig_ManConst1(pAig)->fMarkB = 1;
Saig_ManForEachLo( pAig, pObj, i )
pObj->fMarkB = Aig_InfoHasBit(p->pData, iBit++);
for ( i = 0; i <= p->iFrame; i++ )
{
// save current state
Saig_ManForEachLo( pAig, pObj, k )
if ( pObj->fMarkB )
Aig_InfoSetBit( (unsigned *)Vec_PtrEntry(vStates, i), k );
// compute new state
Saig_ManForEachPi( pAig, pObj, k )
pObj->fMarkB = Aig_InfoHasBit(p->pData, iBit++);
Aig_ManForEachNode( pAig, pObj, k )
pObj->fMarkB = (Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj)) &
(Aig_ObjFanin1(pObj)->fMarkB ^ Aig_ObjFaninC1(pObj));
Aig_ManForEachPo( pAig, pObj, k )
pObj->fMarkB = Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj);
if ( i == p->iFrame )
break;
Saig_ManForEachLiLo( pAig, pObjRi, pObjRo, k )
pObjRo->fMarkB = pObjRi->fMarkB;
}
/*
{
unsigned * pNext;
Vec_PtrForEachEntry( unsigned *, vStates, pNext, i )
{
printf( "%4d : ", i );
Extra_PrintBinary( stdout, pNext, Aig_ManRegNum(pAig) );
printf( "\n" );
}
}
*/
assert( iBit == p->nBits );
if ( Aig_ManPo(pAig, p->iPo)->fMarkB == 0 )
Vec_PtrFreeP( &vStates );
Aig_ManCleanMarkB(pAig);
return vStates;
}
/**Function*************************************************************
Synopsis [Translates a sequence of states into a counter-example.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Cex_t * Llb4_Nonlin4NormalizeCex( Aig_Man_t * pAigOrg, Aig_Man_t * pAigRpm, Abc_Cex_t * pCexRpm )
{
Abc_Cex_t * pCexOrg;
Vec_Ptr_t * vStates;
// check parameters of the AIG
if ( Saig_ManRegNum(pAigOrg) != Saig_ManRegNum(pAigRpm) )
{
printf( "Llb4_Nonlin4NormalizeCex(): The number of flops in the original and reparametrized AIGs do not agree.\n" );
return NULL;
}
if ( Saig_ManRegNum(pAigRpm) != pCexRpm->nRegs )
{
printf( "Llb4_Nonlin4NormalizeCex(): The number of flops in the reparametrized AIG and in the CEX do not agree.\n" );
return NULL;
}
if ( Saig_ManPiNum(pAigRpm) != pCexRpm->nPis )
{
printf( "Llb4_Nonlin4NormalizeCex(): The number of PIs in the reparametrized AIG and in the CEX do not agree.\n" );
return NULL;
}
// get the sequence of states
vStates = Llb4_Nonlin4VerifyCex( pAigRpm, pCexRpm );
if ( vStates == NULL )
{
Abc_Print( 1, "Llb4_Nonlin4NormalizeCex(): The given CEX does not fail outputs of pAigRpm.\n" );
return NULL;
}
// derive updated counter-example
pCexOrg = Llb4_Nonlin4TransformCex( pAigOrg, vStates, 0 );
Vec_PtrFree( vStates );
return pCexOrg;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -107,6 +107,8 @@ struct Llb_Grp_t_
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
static inline int Llb_ObjBddVar( Vec_Int_t * vOrder, Aig_Obj_t * pObj ) { return Vec_IntEntry(vOrder, Aig_ObjId(pObj)); }
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
......
......@@ -276,6 +276,7 @@ static int Abc_CommandFold ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandBm ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandTestCex ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandPdr ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandReconcile ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandTraceStart ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandTraceCheck ( Abc_Frame_t * pAbc, int argc, char ** argv );
......@@ -693,6 +694,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Verification", "bm", Abc_CommandBm, 1 );
Cmd_CommandAdd( pAbc, "Verification", "testcex", Abc_CommandTestCex, 0 );
Cmd_CommandAdd( pAbc, "Verification", "pdr", Abc_CommandPdr, 0 );
Cmd_CommandAdd( pAbc, "Verification", "reconcile", Abc_CommandReconcile, 1 );
Cmd_CommandAdd( pAbc, "ABC8", "*r", Abc_CommandAbc8Read, 0 );
......@@ -8527,13 +8529,16 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
{
// extern void Llb_Nonlin4Cluster( Aig_Man_t * pAig );
// extern void Aig_ManTerSimulate( Aig_Man_t * pAig );
extern void Llb4_Nonlin4Sweep( Aig_Man_t * pAig, int nBddLimit );
extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
Aig_Man_t * pAig = Abc_NtkToDar( pNtk, 0, 0 );
// Aig_ManTerSimulate( pAig );
// Llb_Nonlin4Cluster( pAig );
Llb4_Nonlin4Sweep( pAig, 100 );
Aig_ManStop( pAig );
}
*/
/*
{
extern void Ssm_ManExperiment( char * pFileIn, char * pFileOut );
......@@ -20009,6 +20014,94 @@ usage:
SeeAlso []
***********************************************************************/
int Abc_CommandReconcile( Abc_Frame_t * pAbc, int argc, char ** argv )
{
extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
extern Abc_Cex_t * Llb4_Nonlin4NormalizeCex( Aig_Man_t * pAigOrg, Aig_Man_t * pAigRpm, Abc_Cex_t * pCexRpm );
Abc_Cex_t * pCex;
Abc_Ntk_t * pNtk1, * pNtk2;
Aig_Man_t * pAig1, * pAig2;
int c;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
switch ( c )
{
case 'h':
goto usage;
default:
Abc_Print( -2, "Unknown switch.\n");
goto usage;
}
}
if ( argc != globalUtilOptind + 2 )
{
printf( "Does not seen to have two files names as arguments.\n" );
return 1;
}
if ( pAbc->pCex == NULL )
{
printf( "There is no current counter-example.\n" );
return 1;
}
// derive networks
pNtk1 = Io_Read( argv[globalUtilOptind], Io_ReadFileType(argv[globalUtilOptind]), 1 );
if ( pNtk1 == NULL )
return 1;
pNtk2 = Io_Read( argv[globalUtilOptind+1], Io_ReadFileType(argv[globalUtilOptind+1]), 1 );
if ( pNtk2 == NULL )
{
Abc_NtkDelete( pNtk1 );
return 1;
}
// create counter-examples
pAig1 = Abc_NtkToDar( pNtk1, 0, 0 );
pAig2 = Abc_NtkToDar( pNtk2, 0, 0 );
pCex = Llb4_Nonlin4NormalizeCex( pAig1, pAig2, pAbc->pCex );
Aig_ManStop( pAig1 );
Aig_ManStop( pAig2 );
Abc_NtkDelete( pNtk2 );
if ( pCex == NULL )
{
printf( "Counter-example computation has failed.\n" );
Abc_NtkDelete( pNtk1 );
return 1;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk1 );
// update the counter-example
pAbc->nFrames = pCex->iFrame;
Abc_FrameReplaceCex( pAbc, &pCex );
return 0;
usage:
Abc_Print( -2, "usage: reconcile [-h] <fileOrigin> <fileReparam>\n" );
Abc_Print( -2, "\t reconciles current CEX with <fileOrigin>\n" );
Abc_Print( -2, "\t More specifically:\n" );
Abc_Print( -2, "\t (i) assumes that <fileReparam> is an AIG derived by input\n" );
Abc_Print( -2, "\t reparametrization of <fileOrigin> without seq synthesis;\n" );
Abc_Print( -2, "\t (ii) assumes that current CEX is valid for <fileReparam>;\n" );
Abc_Print( -2, "\t (iii) derives new CEX for <fileOrigin> and sets this CEX\n" );
Abc_Print( -2, "\t and <fileOrigin> to be current CEX and current network\n" );
Abc_Print( -2, "\t<fileOrigin> : file name with the original AIG\n");
Abc_Print( -2, "\t<fileReparam> : file name with the reparametrized AIG\n");
Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_CommandTraceStart( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
......@@ -27995,7 +28088,7 @@ int Abc_CommandAbc9ReachY( Abc_Frame_t * pAbc, int argc, char ** argv )
pPars->fReorder = 0;
pPars->nBddMax = 1000;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "BFTLcryzvwh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "BFTLbcryzvwh" ) ) != EOF )
{
switch ( c )
{
......@@ -28041,6 +28134,9 @@ int Abc_CommandAbc9ReachY( Abc_Frame_t * pAbc, int argc, char ** argv )
pLogFileName = argv[globalUtilOptind];
globalUtilOptind++;
break;
case 'b':
pPars->fBackward ^= 1;
break;
case 'c':
pPars->fCluster ^= 1;
break;
......@@ -28090,12 +28186,13 @@ int Abc_CommandAbc9ReachY( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
Abc_Print( -2, "usage: &reachy [-BFT num] [-L file] [-cryzvh]\n" );
Abc_Print( -2, "usage: &reachy [-BFT num] [-L file] [-bcryzvh]\n" );
Abc_Print( -2, "\t model checking via BDD-based reachability (non-linear-QS-based)\n" );
Abc_Print( -2, "\t-B num : the BDD node threshold for clustering [default = %d]\n", pPars->nBddMax );
Abc_Print( -2, "\t-F num : max number of reachability iterations [default = %d]\n", pPars->nIterMax );
Abc_Print( -2, "\t-T num : approximate time limit in seconds (0=infinite) [default = %d]\n", pPars->TimeLimit );
Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
Abc_Print( -2, "\t-b : enable using backward enumeration [default = %s]\n", pPars->fBackward? "yes": "no" );
Abc_Print( -2, "\t-c : enable reparametrization clustering [default = %s]\n", pPars->fCluster? "yes": "no" );
Abc_Print( -2, "\t-r : enable additional BDD var reordering before image [default = %s]\n", pPars->fReorder? "yes": "no" );
Abc_Print( -2, "\t-y : skip checking property outputs [default = %s]\n", pPars->fSkipOutCheck? "yes": "no" );
......
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