abc/src/base/abci/abcVerify.c

312 lines
8.3 KiB
C
Raw Normal View History

2005-07-29 17:01:00 +02:00
/**CFile****************************************************************
FileName [abcVerify.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Network and node package.]
Synopsis [Combinational and sequential verification for two networks.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: abcVerify.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "abc.h"
#include "fraig.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
2008-01-30 17:01:00 +01:00
/// FUNCTION DEFITIONS ///
2005-07-29 17:01:00 +02:00
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Verifies combinational equivalence by brute-force SAT.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
2008-01-30 17:01:00 +01:00
void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 )
2005-07-29 17:01:00 +02:00
{
Abc_Ntk_t * pMiter;
Abc_Ntk_t * pCnf;
int RetValue;
// get the miter of the two networks
2008-01-30 17:01:00 +01:00
pMiter = Abc_NtkMiter( pNtk1, pNtk2, 1 );
2005-07-29 17:01:00 +02:00
if ( pMiter == NULL )
{
printf( "Miter computation has failed.\n" );
return;
}
RetValue = Abc_NtkMiterIsConstant( pMiter );
2008-01-30 17:01:00 +01:00
if ( RetValue == 1 )
2005-07-29 17:01:00 +02:00
{
2005-10-05 17:01:00 +02:00
Abc_NtkDelete( pMiter );
2008-01-30 17:01:00 +01:00
printf( "Networks are NOT EQUIVALENT after structural hashing.\n" );
2005-07-29 17:01:00 +02:00
return;
}
2008-01-30 17:01:00 +01:00
if ( RetValue == 0 )
2005-07-29 17:01:00 +02:00
{
Abc_NtkDelete( pMiter );
printf( "Networks are equivalent after structural hashing.\n" );
return;
}
// convert the miter into a CNF
2008-01-30 17:01:00 +01:00
pCnf = Abc_NtkRenode( pMiter, 0, 100, 1, 0, 0 );
2005-07-29 17:01:00 +02:00
Abc_NtkDelete( pMiter );
if ( pCnf == NULL )
{
printf( "Renoding for CNF has failed.\n" );
return;
}
// solve the CNF using the SAT solver
2008-01-30 17:01:00 +01:00
if ( Abc_NtkMiterSat( pCnf, 0 ) )
2005-08-14 17:01:00 +02:00
printf( "Networks are NOT EQUIVALENT after SAT.\n" );
2005-07-29 17:01:00 +02:00
else
2005-08-14 17:01:00 +02:00
printf( "Networks are equivalent after SAT.\n" );
2005-07-29 17:01:00 +02:00
Abc_NtkDelete( pCnf );
}
/**Function*************************************************************
Synopsis [Verifies sequential equivalence by fraiging followed by SAT.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
2008-01-30 17:01:00 +01:00
void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fVerbose )
2005-07-29 17:01:00 +02:00
{
2008-01-30 17:01:00 +01:00
Fraig_Params_t Params;
2005-07-29 17:01:00 +02:00
Abc_Ntk_t * pMiter;
2008-01-30 17:01:00 +01:00
Abc_Ntk_t * pFraig;
2005-07-29 17:01:00 +02:00
int RetValue;
// get the miter of the two networks
2008-01-30 17:01:00 +01:00
pMiter = Abc_NtkMiter( pNtk1, pNtk2, 1 );
2005-07-29 17:01:00 +02:00
if ( pMiter == NULL )
{
printf( "Miter computation has failed.\n" );
return;
}
RetValue = Abc_NtkMiterIsConstant( pMiter );
2005-09-08 17:01:00 +02:00
if ( RetValue == 1 )
2005-07-29 17:01:00 +02:00
{
2005-10-05 17:01:00 +02:00
Abc_NtkDelete( pMiter );
2008-01-30 17:01:00 +01:00
printf( "Networks are NOT EQUIVALENT after structural hashing.\n" );
2005-07-29 17:01:00 +02:00
return;
}
2007-03-02 17:01:00 +01:00
if ( RetValue == 0 )
{
Abc_NtkDelete( pMiter );
printf( "Networks are equivalent after structural hashing.\n" );
return;
}
2008-01-30 17:01:00 +01:00
// convert the miter into a FRAIG
Fraig_ParamsSetDefault( &Params );
Params.fVerbose = fVerbose;
pFraig = Abc_NtkFraig( pMiter, &Params, 0 );
2007-04-28 17:01:00 +02:00
Abc_NtkDelete( pMiter );
2008-01-30 17:01:00 +01:00
if ( pFraig == NULL )
2007-04-28 17:01:00 +02:00
{
2008-01-30 17:01:00 +01:00
printf( "Fraiging has failed.\n" );
2007-04-28 17:01:00 +02:00
return;
}
2008-01-30 17:01:00 +01:00
RetValue = Abc_NtkMiterIsConstant( pFraig );
Abc_NtkDelete( pFraig );
2007-04-28 17:01:00 +02:00
if ( RetValue == 0 )
{
2008-01-30 17:01:00 +01:00
printf( "Networks are equivalent after fraiging.\n" );
2007-04-28 17:01:00 +02:00
return;
}
2008-01-30 17:01:00 +01:00
printf( "Networks are NOT EQUIVALENT after fraiging.\n" );
2007-03-02 17:01:00 +01:00
}
2005-07-29 17:01:00 +02:00
/**Function*************************************************************
Synopsis [Verifies sequential equivalence by brute-force SAT.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
2008-01-30 17:01:00 +01:00
void Abc_NtkSecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames )
2005-07-29 17:01:00 +02:00
{
Abc_Ntk_t * pMiter;
Abc_Ntk_t * pFrames;
Abc_Ntk_t * pCnf;
int RetValue;
// get the miter of the two networks
2008-01-30 17:01:00 +01:00
pMiter = Abc_NtkMiter( pNtk1, pNtk2, 0 );
2005-07-29 17:01:00 +02:00
if ( pMiter == NULL )
{
printf( "Miter computation has failed.\n" );
return;
}
RetValue = Abc_NtkMiterIsConstant( pMiter );
2008-01-30 17:01:00 +01:00
if ( RetValue == 1 )
2005-07-29 17:01:00 +02:00
{
Abc_NtkDelete( pMiter );
2005-08-14 17:01:00 +02:00
printf( "Networks are NOT EQUIVALENT after structural hashing.\n" );
2005-07-29 17:01:00 +02:00
return;
}
2008-01-30 17:01:00 +01:00
if ( RetValue == 0 )
2005-07-29 17:01:00 +02:00
{
Abc_NtkDelete( pMiter );
printf( "Networks are equivalent after structural hashing.\n" );
return;
}
// create the timeframes
pFrames = Abc_NtkFrames( pMiter, nFrames, 1 );
Abc_NtkDelete( pMiter );
if ( pFrames == NULL )
{
printf( "Frames computation has failed.\n" );
return;
}
RetValue = Abc_NtkMiterIsConstant( pFrames );
2008-01-30 17:01:00 +01:00
if ( RetValue == 1 )
2005-07-29 17:01:00 +02:00
{
Abc_NtkDelete( pFrames );
2005-08-14 17:01:00 +02:00
printf( "Networks are NOT EQUIVALENT after framing.\n" );
2005-07-29 17:01:00 +02:00
return;
}
2008-01-30 17:01:00 +01:00
if ( RetValue == 0 )
2005-07-29 17:01:00 +02:00
{
Abc_NtkDelete( pFrames );
printf( "Networks are equivalent after framing.\n" );
return;
}
// convert the miter into a CNF
2008-01-30 17:01:00 +01:00
pCnf = Abc_NtkRenode( pFrames, 0, 100, 1, 0, 0 );
2005-07-29 17:01:00 +02:00
Abc_NtkDelete( pFrames );
if ( pCnf == NULL )
{
printf( "Renoding for CNF has failed.\n" );
return;
}
// solve the CNF using the SAT solver
2008-01-30 17:01:00 +01:00
if ( Abc_NtkMiterSat( pCnf, 0 ) )
2005-08-14 17:01:00 +02:00
printf( "Networks are NOT EQUIVALENT after SAT.\n" );
2005-07-29 17:01:00 +02:00
else
2005-08-14 17:01:00 +02:00
printf( "Networks are equivalent after SAT.\n" );
2005-07-29 17:01:00 +02:00
Abc_NtkDelete( pCnf );
}
/**Function*************************************************************
Synopsis [Verifies combinational equivalence by fraiging followed by SAT]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
2008-01-30 17:01:00 +01:00
void Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames )
2005-07-29 17:01:00 +02:00
{
Fraig_Params_t Params;
Abc_Ntk_t * pMiter;
2008-01-30 17:01:00 +01:00
Abc_Ntk_t * pFraig;
2005-07-29 17:01:00 +02:00
Abc_Ntk_t * pFrames;
int RetValue;
// get the miter of the two networks
2008-01-30 17:01:00 +01:00
pMiter = Abc_NtkMiter( pNtk1, pNtk2, 0 );
2005-07-29 17:01:00 +02:00
if ( pMiter == NULL )
{
printf( "Miter computation has failed.\n" );
2008-01-30 17:01:00 +01:00
return;
2005-07-29 17:01:00 +02:00
}
RetValue = Abc_NtkMiterIsConstant( pMiter );
2008-01-30 17:01:00 +01:00
if ( RetValue == 1 )
2005-07-29 17:01:00 +02:00
{
2005-10-07 17:01:00 +02:00
Abc_NtkDelete( pMiter );
2008-01-30 17:01:00 +01:00
printf( "Networks are NOT EQUIVALENT after structural hashing.\n" );
return;
2005-07-29 17:01:00 +02:00
}
2008-01-30 17:01:00 +01:00
if ( RetValue == 0 )
2005-07-29 17:01:00 +02:00
{
Abc_NtkDelete( pMiter );
printf( "Networks are equivalent after structural hashing.\n" );
2008-01-30 17:01:00 +01:00
return;
2005-07-29 17:01:00 +02:00
}
// create the timeframes
pFrames = Abc_NtkFrames( pMiter, nFrames, 1 );
Abc_NtkDelete( pMiter );
if ( pFrames == NULL )
{
printf( "Frames computation has failed.\n" );
2008-01-30 17:01:00 +01:00
return;
2005-07-29 17:01:00 +02:00
}
RetValue = Abc_NtkMiterIsConstant( pFrames );
2008-01-30 17:01:00 +01:00
if ( RetValue == 1 )
2005-07-29 17:01:00 +02:00
{
2005-10-07 17:01:00 +02:00
Abc_NtkDelete( pFrames );
2008-01-30 17:01:00 +01:00
printf( "Networks are NOT EQUIVALENT after framing.\n" );
return;
2005-07-29 17:01:00 +02:00
}
2008-01-30 17:01:00 +01:00
if ( RetValue == 0 )
2005-07-29 17:01:00 +02:00
{
Abc_NtkDelete( pFrames );
printf( "Networks are equivalent after framing.\n" );
2008-01-30 17:01:00 +01:00
return;
2005-07-29 17:01:00 +02:00
}
// convert the miter into a FRAIG
Fraig_ParamsSetDefault( &Params );
2008-01-30 17:01:00 +01:00
pFraig = Abc_NtkFraig( pFrames, &Params, 0 );
2005-10-07 17:01:00 +02:00
Abc_NtkDelete( pFrames );
2008-01-30 17:01:00 +01:00
if ( pFraig == NULL )
2005-09-08 17:01:00 +02:00
{
2008-01-30 17:01:00 +01:00
printf( "Fraiging has failed.\n" );
2005-10-07 17:01:00 +02:00
return;
}
2008-01-30 17:01:00 +01:00
RetValue = Abc_NtkMiterIsConstant( pFraig );
Abc_NtkDelete( pFraig );
if ( RetValue == 0 )
2005-10-07 17:01:00 +02:00
{
2008-01-30 17:01:00 +01:00
printf( "Networks are equivalent after fraiging.\n" );
return;
2005-10-07 17:01:00 +02:00
}
2008-01-30 17:01:00 +01:00
printf( "Networks are NOT EQUIVALENT after fraiging.\n" );
2006-06-11 17:01:00 +02:00
}
2005-10-07 17:01:00 +02:00
2005-07-29 17:01:00 +02:00
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////