2008-09-01 17:01:00 +02:00
|
|
|
/**CFile****************************************************************
|
|
|
|
|
|
|
|
|
|
FileName [sswCore.c]
|
|
|
|
|
|
|
|
|
|
SystemName [ABC: Logic synthesis and verification system.]
|
|
|
|
|
|
|
|
|
|
PackageName [Inductive prover with constraints.]
|
|
|
|
|
|
|
|
|
|
Synopsis [The core procedures.]
|
|
|
|
|
|
|
|
|
|
Author [Alan Mishchenko]
|
|
|
|
|
|
|
|
|
|
Affiliation [UC Berkeley]
|
|
|
|
|
|
|
|
|
|
Date [Ver. 1.0. Started - September 1, 2008.]
|
|
|
|
|
|
|
|
|
|
Revision [$Id: sswCore.c,v 1.00 2008/09/01 00:00:00 alanmi Exp $]
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "sswInt.h"
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// DECLARATIONS ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// FUNCTION DEFINITIONS ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis [This procedure sets default parameters.]
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
void Ssw_ManSetDefaultParams( Ssw_Pars_t * p )
|
|
|
|
|
{
|
|
|
|
|
memset( p, 0, sizeof(Ssw_Pars_t) );
|
|
|
|
|
p->nPartSize = 0; // size of the partition
|
|
|
|
|
p->nOverSize = 0; // size of the overlap between partitions
|
|
|
|
|
p->nFramesK = 1; // the induction depth
|
2008-09-27 17:01:00 +02:00
|
|
|
p->nFramesAddSim = 0; // additional frames to simulate
|
2008-09-01 17:01:00 +02:00
|
|
|
p->nConstrs = 0; // treat the last nConstrs POs as seq constraints
|
|
|
|
|
p->nBTLimit = 1000; // conflict limit at a node
|
2008-09-10 17:01:00 +02:00
|
|
|
p->nMinDomSize = 100; // min clock domain considered for optimization
|
2008-09-01 17:01:00 +02:00
|
|
|
p->fPolarFlip = 0; // uses polarity adjustment
|
2008-09-21 17:01:00 +02:00
|
|
|
p->fSkipCheck = 0; // do not run equivalence check for unaffected cones
|
2008-09-09 17:01:00 +02:00
|
|
|
p->fLatchCorr = 0; // performs register correspondence
|
2008-09-22 17:01:00 +02:00
|
|
|
p->fSemiFormal = 0; // enable semiformal filtering
|
2008-09-27 17:01:00 +02:00
|
|
|
p->fUniqueness = 0; // enable uniqueness constraints
|
2008-09-09 17:01:00 +02:00
|
|
|
p->fVerbose = 0; // verbose stats
|
2008-09-19 17:01:00 +02:00
|
|
|
// latch correspondence
|
|
|
|
|
p->fLatchCorrOpt = 0; // performs optimized register correspondence
|
2008-09-21 17:01:00 +02:00
|
|
|
p->nSatVarMax = 1000; // the max number of SAT variables
|
|
|
|
|
p->nRecycleCalls = 50; // calls to perform before recycling SAT solver
|
2008-09-19 17:01:00 +02:00
|
|
|
// return values
|
2008-09-01 17:01:00 +02:00
|
|
|
p->nIters = 0; // the number of iterations performed
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-21 17:01:00 +02:00
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis [This procedure sets default parameters.]
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
void Ssw_ManSetDefaultParamsLcorr( Ssw_Pars_t * p )
|
|
|
|
|
{
|
|
|
|
|
Ssw_ManSetDefaultParams( p );
|
|
|
|
|
p->fLatchCorrOpt = 1;
|
|
|
|
|
p->nBTLimit = 10000;
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-01 17:01:00 +02:00
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis [Performs computation of signal correspondence with constraints.]
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
2008-09-15 17:01:00 +02:00
|
|
|
Aig_Man_t * Ssw_SignalCorrespondenceRefine( Ssw_Man_t * p )
|
2008-09-01 17:01:00 +02:00
|
|
|
{
|
2008-09-21 17:01:00 +02:00
|
|
|
int nSatProof, nSatCallsSat, nRecycles, nSatFailsReal;
|
2008-09-05 17:01:00 +02:00
|
|
|
Aig_Man_t * pAigNew;
|
2008-09-15 17:01:00 +02:00
|
|
|
int RetValue, nIter;
|
|
|
|
|
int clk, clkTotal = clock();
|
2008-09-09 17:01:00 +02:00
|
|
|
// get the starting stats
|
|
|
|
|
p->nLitsBeg = Ssw_ClassesLitNum( p->ppClasses );
|
2008-09-15 17:01:00 +02:00
|
|
|
p->nNodesBeg = Aig_ManNodeNum(p->pAig);
|
|
|
|
|
p->nRegsBeg = Aig_ManRegNum(p->pAig);
|
2008-09-01 17:01:00 +02:00
|
|
|
// refine classes using BMC
|
2008-09-15 17:01:00 +02:00
|
|
|
if ( p->pPars->fVerbose )
|
2008-09-09 17:01:00 +02:00
|
|
|
{
|
|
|
|
|
printf( "Before BMC: " );
|
2008-09-05 17:01:00 +02:00
|
|
|
Ssw_ClassesPrint( p->ppClasses, 0 );
|
2008-09-09 17:01:00 +02:00
|
|
|
}
|
2008-09-19 17:01:00 +02:00
|
|
|
if ( !p->pPars->fLatchCorr )
|
|
|
|
|
{
|
|
|
|
|
Ssw_ManSweepBmc( p );
|
|
|
|
|
Ssw_ManCleanup( p );
|
|
|
|
|
}
|
2008-09-15 17:01:00 +02:00
|
|
|
if ( p->pPars->fVerbose )
|
2008-09-09 17:01:00 +02:00
|
|
|
{
|
|
|
|
|
printf( "After BMC: " );
|
2008-09-05 17:01:00 +02:00
|
|
|
Ssw_ClassesPrint( p->ppClasses, 0 );
|
2008-09-09 17:01:00 +02:00
|
|
|
}
|
2008-09-22 17:01:00 +02:00
|
|
|
// apply semi-formal filtering
|
|
|
|
|
if ( p->pPars->fSemiFormal )
|
|
|
|
|
{
|
|
|
|
|
Aig_Man_t * pSRed;
|
|
|
|
|
Ssw_FilterUsingBmc( p, 0, 2000, p->pPars->fVerbose );
|
|
|
|
|
// Ssw_FilterUsingBmc( p, 1, 100000, p->pPars->fVerbose );
|
|
|
|
|
pSRed = Ssw_SpeculativeReduction( p );
|
|
|
|
|
Aig_ManDumpBlif( pSRed, "srm.blif", NULL, NULL );
|
|
|
|
|
Aig_ManStop( pSRed );
|
|
|
|
|
}
|
2008-09-01 17:01:00 +02:00
|
|
|
// refine classes using induction
|
2008-09-21 17:01:00 +02:00
|
|
|
nSatProof = nSatCallsSat = nRecycles = nSatFailsReal = 0;
|
2008-09-01 17:01:00 +02:00
|
|
|
for ( nIter = 0; ; nIter++ )
|
|
|
|
|
{
|
|
|
|
|
clk = clock();
|
2008-09-19 17:01:00 +02:00
|
|
|
if ( p->pPars->fLatchCorrOpt )
|
2008-09-21 17:01:00 +02:00
|
|
|
{
|
2008-09-19 17:01:00 +02:00
|
|
|
RetValue = Ssw_ManSweepLatch( p );
|
2008-09-21 17:01:00 +02:00
|
|
|
if ( p->pPars->fVerbose )
|
|
|
|
|
{
|
|
|
|
|
printf( "%3d : Const = %6d. Cl = %6d. Pr = %5d. Cex = %5d. Rcl = %3d. F = %3d. ",
|
|
|
|
|
nIter, Ssw_ClassesCand1Num(p->ppClasses), Ssw_ClassesClassNum(p->ppClasses),
|
|
|
|
|
p->nSatProof-nSatProof, p->nSatCallsSat-nSatCallsSat,
|
|
|
|
|
p->nRecycles-nRecycles, p->nSatFailsReal-nSatFailsReal );
|
|
|
|
|
PRT( "T", clock() - clk );
|
|
|
|
|
nSatProof = p->nSatProof;
|
|
|
|
|
nSatCallsSat = p->nSatCallsSat;
|
|
|
|
|
nRecycles = p->nRecycles;
|
|
|
|
|
nSatFailsReal = p->nSatFailsReal;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-09-19 17:01:00 +02:00
|
|
|
else
|
2008-09-01 17:01:00 +02:00
|
|
|
{
|
2008-09-21 17:01:00 +02:00
|
|
|
RetValue = Ssw_ManSweep( p );
|
|
|
|
|
if ( p->pPars->fVerbose )
|
|
|
|
|
{
|
2008-09-27 17:01:00 +02:00
|
|
|
printf( "%3d : Const = %6d. Cl = %6d. LR = %6d. NR = %6d. U = %3d. F = %2d. ",
|
2008-09-21 17:01:00 +02:00
|
|
|
nIter, Ssw_ClassesCand1Num(p->ppClasses), Ssw_ClassesClassNum(p->ppClasses),
|
2008-09-27 17:01:00 +02:00
|
|
|
p->nConstrReduced, Aig_ManNodeNum(p->pFrames), p->nUniques, p->nSatFailsReal );
|
2008-09-21 17:01:00 +02:00
|
|
|
if ( p->pPars->fSkipCheck )
|
|
|
|
|
printf( "Use = %5d. Skip = %5d. ",
|
|
|
|
|
p->nRefUse, p->nRefSkip );
|
|
|
|
|
PRT( "T", clock() - clk );
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-09-05 17:01:00 +02:00
|
|
|
Ssw_ManCleanup( p );
|
2008-09-01 17:01:00 +02:00
|
|
|
if ( !RetValue )
|
|
|
|
|
break;
|
2008-09-27 17:01:00 +02:00
|
|
|
/*
|
2008-09-22 17:01:00 +02:00
|
|
|
{
|
|
|
|
|
static int Flag = 0;
|
|
|
|
|
if ( Flag++ == 4 && nIter == 4 )
|
|
|
|
|
{
|
|
|
|
|
Aig_Man_t * pSRed;
|
|
|
|
|
pSRed = Ssw_SpeculativeReduction( p );
|
|
|
|
|
Aig_ManDumpBlif( pSRed, "srm.blif", NULL, NULL );
|
|
|
|
|
Aig_ManStop( pSRed );
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-09-27 17:01:00 +02:00
|
|
|
*/
|
2008-09-22 17:01:00 +02:00
|
|
|
|
2008-09-05 17:01:00 +02:00
|
|
|
}
|
2008-09-09 17:01:00 +02:00
|
|
|
p->pPars->nIters = nIter + 1;
|
2008-09-01 17:01:00 +02:00
|
|
|
p->timeTotal = clock() - clkTotal;
|
2008-09-15 17:01:00 +02:00
|
|
|
pAigNew = Aig_ManDupRepr( p->pAig, 0 );
|
2008-09-05 17:01:00 +02:00
|
|
|
Aig_ManSeqCleanup( pAigNew );
|
2008-09-09 17:01:00 +02:00
|
|
|
// get the final stats
|
|
|
|
|
p->nLitsEnd = Ssw_ClassesLitNum( p->ppClasses );
|
|
|
|
|
p->nNodesEnd = Aig_ManNodeNum(pAigNew);
|
|
|
|
|
p->nRegsEnd = Aig_ManRegNum(pAigNew);
|
2008-09-15 17:01:00 +02:00
|
|
|
return pAigNew;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis [Performs computation of signal correspondence with constraints.]
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
Aig_Man_t * Ssw_SignalCorrespondence( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
|
|
|
|
|
{
|
|
|
|
|
Ssw_Pars_t Pars;
|
|
|
|
|
Aig_Man_t * pAigNew;
|
|
|
|
|
Ssw_Man_t * p;
|
2008-09-19 17:01:00 +02:00
|
|
|
assert( Aig_ManRegNum(pAig) > 0 );
|
2008-09-15 17:01:00 +02:00
|
|
|
// reset random numbers
|
|
|
|
|
Aig_ManRandom( 1 );
|
|
|
|
|
// if parameters are not given, create them
|
|
|
|
|
if ( pPars == NULL )
|
|
|
|
|
Ssw_ManSetDefaultParams( pPars = &Pars );
|
|
|
|
|
// consider the case of empty AIG
|
|
|
|
|
if ( Aig_ManNodeNum(pAig) == 0 )
|
|
|
|
|
{
|
|
|
|
|
pPars->nIters = 0;
|
|
|
|
|
// Ntl_ManFinalize() needs the following to satisfy an assertion
|
|
|
|
|
Aig_ManReprStart( pAig,Aig_ManObjNumMax(pAig) );
|
|
|
|
|
return Aig_ManDupOrdered(pAig);
|
|
|
|
|
}
|
|
|
|
|
// check and update parameters
|
2008-09-19 17:01:00 +02:00
|
|
|
if ( pPars->fLatchCorrOpt )
|
2008-09-21 17:01:00 +02:00
|
|
|
{
|
2008-09-19 17:01:00 +02:00
|
|
|
pPars->fLatchCorr = 1;
|
2008-09-21 17:01:00 +02:00
|
|
|
pPars->nFramesAddSim = 0;
|
|
|
|
|
}
|
2008-09-19 17:01:00 +02:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
assert( pPars->nFramesK > 0 );
|
|
|
|
|
if ( pPars->nFramesK > 1 )
|
|
|
|
|
pPars->fSkipCheck = 0;
|
|
|
|
|
// perform partitioning
|
|
|
|
|
if ( (pPars->nPartSize > 0 && pPars->nPartSize < Aig_ManRegNum(pAig))
|
|
|
|
|
|| (pAig->vClockDoms && Vec_VecSize(pAig->vClockDoms) > 0) )
|
|
|
|
|
return Ssw_SignalCorrespondencePart( pAig, pPars );
|
|
|
|
|
}
|
2008-09-15 17:01:00 +02:00
|
|
|
// start the induction manager
|
|
|
|
|
p = Ssw_ManCreate( pAig, pPars );
|
|
|
|
|
// compute candidate equivalence classes
|
|
|
|
|
// p->pPars->nConstrs = 1;
|
|
|
|
|
if ( p->pPars->nConstrs == 0 )
|
|
|
|
|
{
|
|
|
|
|
// perform one round of seq simulation and generate candidate equivalence classes
|
|
|
|
|
p->ppClasses = Ssw_ClassesPrepare( pAig, pPars->fLatchCorr, pPars->nMaxLevs, pPars->fVerbose );
|
2008-09-22 17:01:00 +02:00
|
|
|
// p->ppClasses = Ssw_ClassesPrepareTargets( pAig );
|
2008-09-15 17:01:00 +02:00
|
|
|
p->pSml = Ssw_SmlStart( pAig, 0, p->nFrames + p->pPars->nFramesAddSim, 1 );
|
2008-09-21 17:01:00 +02:00
|
|
|
Ssw_ClassesSetData( p->ppClasses, p->pSml, Ssw_SmlObjHashWord, Ssw_SmlObjIsConstWord, Ssw_SmlObjsAreEqualWord );
|
2008-09-15 17:01:00 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// create trivial equivalence classes with all nodes being candidates for constant 1
|
|
|
|
|
p->ppClasses = Ssw_ClassesPrepareSimple( pAig, pPars->fLatchCorr, pPars->nMaxLevs );
|
2008-09-21 17:01:00 +02:00
|
|
|
Ssw_ClassesSetData( p->ppClasses, NULL, NULL, Ssw_SmlObjIsConstBit, Ssw_SmlObjsAreEqualBit );
|
2008-09-15 17:01:00 +02:00
|
|
|
}
|
|
|
|
|
// perform refinement of classes
|
|
|
|
|
pAigNew = Ssw_SignalCorrespondenceRefine( p );
|
2008-09-09 17:01:00 +02:00
|
|
|
// cleanup
|
|
|
|
|
Ssw_ManStop( p );
|
2008-09-05 17:01:00 +02:00
|
|
|
return pAigNew;
|
2008-09-01 17:01:00 +02:00
|
|
|
}
|
|
|
|
|
|
2008-09-21 17:01:00 +02:00
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis [Performs computation of latch correspondence.]
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
Aig_Man_t * Ssw_LatchCorrespondence( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
|
|
|
|
|
{
|
|
|
|
|
Ssw_Pars_t Pars;
|
|
|
|
|
if ( pPars == NULL )
|
|
|
|
|
Ssw_ManSetDefaultParamsLcorr( pPars = &Pars );
|
|
|
|
|
return Ssw_SignalCorrespondence( pAig, pPars );
|
|
|
|
|
}
|
2008-09-10 17:01:00 +02:00
|
|
|
|
|
|
|
|
|
2008-09-01 17:01:00 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// END OF FILE ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|