Commit 3368b2dd by Alan Mishchenko

Improvements to handling boxes and flops.

parent df83fb5e
......@@ -1317,7 +1317,8 @@ extern Gia_Man_t * Gia_ManSpeedup( Gia_Man_t * p, int Percentage, int De
extern void Gia_ManStgPrint( FILE * pFile, Vec_Int_t * vLines, int nIns, int nOuts, int nStates );
extern Gia_Man_t * Gia_ManStgRead( char * pFileName, int kHot, int fVerbose );
/*=== giaSweep.c ============================================================*/
extern Gia_Man_t * Gia_ManFraigSweep( Gia_Man_t * p, void * pPars );
extern Gia_Man_t * Gia_ManFraigSweepSimple( Gia_Man_t * p, void * pPars );
extern Gia_Man_t * Gia_ManSweepWithBoxes( Gia_Man_t * p, void * pParsC, void * pParsS, int fConst, int fEquiv, int fVerbose );
/*=== giaSweeper.c ============================================================*/
extern Gia_Man_t * Gia_SweeperStart( Gia_Man_t * p );
extern void Gia_SweeperStop( Gia_Man_t * p );
......@@ -1349,6 +1350,7 @@ extern Vec_Int_t * Gia_ManComputeSwitchProbs( Gia_Man_t * pGia, int nFra
extern Vec_Flt_t * Gia_ManPrintOutputProb( Gia_Man_t * p );
/*=== giaTim.c ===========================================================*/
extern int Gia_ManBoxNum( Gia_Man_t * p );
extern int Gia_ManRegBoxNum( Gia_Man_t * p );
extern int Gia_ManIsSeqWithBoxes( Gia_Man_t * p );
extern int Gia_ManIsNormalized( Gia_Man_t * p );
extern Gia_Man_t * Gia_ManDupNormalize( Gia_Man_t * p );
......@@ -1360,8 +1362,8 @@ extern void * Gia_ManUpdateTimMan( Gia_Man_t * p, Vec_Int_t * vBoxP
extern void * Gia_ManUpdateTimMan2( Gia_Man_t * p, Vec_Int_t * vBoxesLeft );
extern Gia_Man_t * Gia_ManUpdateExtraAig( void * pTime, Gia_Man_t * pAig, Vec_Int_t * vBoxPres );
extern Gia_Man_t * Gia_ManUpdateExtraAig2( void * pTime, Gia_Man_t * pAig, Vec_Int_t * vBoxesLeft );
extern Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * vBoxPres );
extern int Gia_ManVerifyWithBoxes( Gia_Man_t * pGia, void * pParsInit, char * pFileSpec );
extern Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * vBoxPres, int fSeq );
extern int Gia_ManVerifyWithBoxes( Gia_Man_t * pGia, int nBTLimit, int nTimeLim, int fSeq, int fVerbose, char * pFileSpec );
/*=== giaTruth.c ===========================================================*/
extern word Gia_ObjComputeTruthTable6Lut( Gia_Man_t * p, int iObj, Vec_Wrd_t * vTemp );
extern word Gia_ObjComputeTruthTable6( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSupp, Vec_Wrd_t * vTruths );
......
......@@ -1885,9 +1885,10 @@ void Gia_ManTransferTiming( Gia_Man_t * p, Gia_Man_t * pGia )
{
if ( pGia->pManTime == NULL || p == pGia )
return;
p->pManTime = pGia->pManTime; pGia->pManTime = NULL;
p->pAigExtra = pGia->pAigExtra; pGia->pAigExtra = NULL;
p->nAnd2Delay = pGia->nAnd2Delay; pGia->nAnd2Delay = 0;
p->pManTime = pGia->pManTime; pGia->pManTime = NULL;
p->pAigExtra = pGia->pAigExtra; pGia->pAigExtra = NULL;
p->vRegClasses = pGia->vRegClasses; pGia->vRegClasses = NULL;
p->nAnd2Delay = pGia->nAnd2Delay; pGia->nAnd2Delay = 0;
}
/**Function*************************************************************
......
......@@ -19,8 +19,10 @@
***********************************************************************/
#include "gia.h"
#include "giaAig.h"
#include "misc/tim/tim.h"
#include "proof/cec/cec.h"
#include "proof/fra/fra.h"
ABC_NAMESPACE_IMPL_START
......@@ -48,6 +50,10 @@ int Gia_ManBoxNum( Gia_Man_t * p )
{
return p->pManTime ? Tim_ManBoxNum((Tim_Man_t *)p->pManTime) : 0;
}
int Gia_ManRegBoxNum( Gia_Man_t * p )
{
return p->vRegClasses ? Vec_IntSize(p->vRegClasses) : 0;
}
/**Function*************************************************************
......@@ -701,13 +707,14 @@ void Gia_ManDupCollapse_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Man_t * pNew )
if ( Gia_ObjSibl(p, Gia_ObjId(p, pObj)) )
pNew->pSibls[Abc_Lit2Var(pObj->Value)] = Abc_Lit2Var(Gia_ObjSiblObj(p, Gia_ObjId(p, pObj))->Value);
}
Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * vBoxPres )
Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * vBoxPres, int fSeq )
{
// this procedure assumes that sequential AIG with boxes is unshuffled to have valid boxes
Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
Gia_Man_t * pNew, * pTemp;
Gia_Obj_t * pObj, * pObjBox;
int i, k, curCi, curCo;
assert( !fSeq || p->vRegClasses );
//assert( Gia_ManRegNum(p) == 0 );
assert( Gia_ManCiNum(p) == Tim_ManPiNum(pManTime) + Gia_ManCoNum(pBoxes) );
pNew = Gia_ManStart( Gia_ManObjNum(p) );
......@@ -790,7 +797,7 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v
// verify counts
assert( curCi == Gia_ManCiNum(p) );
assert( curCo == Gia_ManCoNum(p) );
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
Gia_ManSetRegNum( pNew, (fSeq && p->vRegClasses) ? Vec_IntSize(p->vRegClasses) : Gia_ManRegNum(p) );
Gia_ManHashStop( pNew );
pNew = Gia_ManCleanup( pTemp = pNew );
Gia_ManCleanupRemap( p, pTemp );
......@@ -811,9 +818,8 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v
SeeAlso []
***********************************************************************/
int Gia_ManVerifyWithBoxes( Gia_Man_t * pGia, void * pParsInit, char * pFileSpec )
int Gia_ManVerifyWithBoxes( Gia_Man_t * pGia, int nBTLimit, int nTimeLim, int fSeq, int fVerbose, char * pFileSpec )
{
int fVerbose = 1;
int Status = -1;
Gia_Man_t * pSpec, * pGia0, * pGia1, * pMiter;
Vec_Int_t * vBoxPres = NULL;
......@@ -866,28 +872,48 @@ int Gia_ManVerifyWithBoxes( Gia_Man_t * pGia, void * pParsInit, char * pFileSpec
}
// collapse two designs
if ( Gia_ManBoxNum(pSpec) > 0 )
pGia0 = Gia_ManDupCollapse( pSpec, pSpec->pAigExtra, vBoxPres );
pGia0 = Gia_ManDupCollapse( pSpec, pSpec->pAigExtra, vBoxPres, fSeq );
else
pGia0 = Gia_ManDup( pSpec );
if ( Gia_ManBoxNum(pGia) > 0 )
pGia1 = Gia_ManDupCollapse( pGia, pGia->pAigExtra, NULL );
pGia1 = Gia_ManDupCollapse( pGia, pGia->pAigExtra, NULL, fSeq );
else
pGia1 = Gia_ManDup( pGia );
Vec_IntFreeP( &vBoxPres );
}
// compute the miter
pMiter = Gia_ManMiter( pGia0, pGia1, 0, 1, 0, 0, fVerbose );
if ( pMiter )
if ( fSeq )
{
pMiter = Gia_ManMiter( pGia0, pGia1, 0, 0, 1, 0, fVerbose );
if ( pMiter )
{
Aig_Man_t * pMan;
Fra_Sec_t SecPar, * pSecPar = &SecPar;
Fra_SecSetDefaultParams( pSecPar );
pSecPar->nBTLimit = nBTLimit;
pSecPar->TimeLimit = nTimeLim;
pSecPar->fVerbose = fVerbose;
pMan = Gia_ManToAig( pMiter, 0 );
Gia_ManStop( pMiter );
Status = Fra_FraigSec( pMan, pSecPar, NULL );
Aig_ManStop( pMan );
}
}
else
{
Cec_ParCec_t ParsCec, * pPars = &ParsCec;
Cec_ManCecSetDefaultParams( pPars );
pPars->fVerbose = fVerbose;
if ( pParsInit )
memcpy( pPars, pParsInit, sizeof(Cec_ParCec_t) );
Status = Cec_ManVerify( pMiter, pPars );
Gia_ManStop( pMiter );
if ( pPars->iOutFail >= 0 )
Abc_Print( 1, "Verification failed for at least one output (%d).\n", pPars->iOutFail );
pMiter = Gia_ManMiter( pGia0, pGia1, 0, 1, 0, 0, fVerbose );
if ( pMiter )
{
Cec_ParCec_t ParsCec, * pPars = &ParsCec;
Cec_ManCecSetDefaultParams( pPars );
pPars->nBTLimit = nBTLimit;
pPars->TimeLimit = nTimeLim;
pPars->fVerbose = fVerbose;
Status = Cec_ManVerify( pMiter, pPars );
if ( pPars->iOutFail >= 0 )
Abc_Print( 1, "Verification failed for at least one output (%d).\n", pPars->iOutFail );
Gia_ManStop( pMiter );
}
}
Gia_ManStop( pGia0 );
Gia_ManStop( pGia1 );
......
......@@ -20534,7 +20534,6 @@ int Abc_CommandDSec( Abc_Frame_t * pAbc, int argc, char ** argv )
int c;
int fIgnoreNames;
extern void Fra_SecSetDefaultParams( Fra_Sec_t * p );
extern int Abc_NtkDarSec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Fra_Sec_t * p );
pNtk = Abc_FrameReadNtk(pAbc);
......@@ -26544,12 +26543,12 @@ int Abc_CommandAbc9Strash( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Gia_Man_t * pUnshuffled = Gia_ManDupUnshuffleInputs( pAbc->pGia );
Gia_ManTransferTiming( pUnshuffled, pAbc->pGia );
pTemp = Gia_ManDupCollapse( pUnshuffled, pUnshuffled->pAigExtra, NULL );
pTemp = Gia_ManDupCollapse( pUnshuffled, pUnshuffled->pAigExtra, NULL, 0 );
Gia_ManTransferTiming( pAbc->pGia, pUnshuffled );
Gia_ManStop( pUnshuffled );
}
else
pTemp = Gia_ManDupCollapse( pAbc->pGia, pAbc->pGia->pAigExtra, NULL );
pTemp = Gia_ManDupCollapse( pAbc->pGia, pAbc->pGia->pAigExtra, NULL, 0 );
if ( !Abc_FrameReadFlag("silentmode") )
printf( "Collapsed AIG with boxes and logic of the boxes.\n" );
}
......@@ -29424,6 +29423,22 @@ int Abc_CommandAbc9Scl( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9Scl(): There is no AIG.\n" );
return 1;
}
if ( Gia_ManBoxNum(pAbc->pGia) && Gia_ManRegBoxNum(pAbc->pGia) )
{
if ( pAbc->pGia->pAigExtra == NULL )
{
printf( "Timing manager is given but there is no GIA of boxes.\n" );
return 0;
}
pTemp = Gia_ManSweepWithBoxes( pAbc->pGia, NULL, NULL, fConst, fEquiv, fVerbose );
Abc_FrameUpdateGia( pAbc, pTemp );
return 0;
}
if ( Gia_ManRegNum(pAbc->pGia) == 0 )
{
Abc_Print( -1, "The network is combinational.\n" );
return 0;
}
pTemp = Gia_ManSeqStructSweep( pAbc->pGia, fConst, fEquiv, fVerbose );
Abc_FrameUpdateGia( pAbc, pTemp );
return 0;
......@@ -29512,6 +29527,17 @@ int Abc_CommandAbc9Lcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9Lcorr(): There is no AIG.\n" );
return 1;
}
if ( Gia_ManBoxNum(pAbc->pGia) && Gia_ManRegBoxNum(pAbc->pGia) )
{
if ( pAbc->pGia->pAigExtra == NULL )
{
printf( "Timing manager is given but there is no GIA of boxes.\n" );
return 0;
}
pTemp = Gia_ManSweepWithBoxes( pAbc->pGia, NULL, pPars, 0, 0, pPars->fVerbose );
Abc_FrameUpdateGia( pAbc, pTemp );
return 0;
}
if ( Gia_ManRegNum(pAbc->pGia) == 0 )
{
Abc_Print( -1, "The network is combinational.\n" );
......@@ -29619,6 +29645,17 @@ int Abc_CommandAbc9Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9Scorr(): There is no AIG.\n" );
return 1;
}
if ( Gia_ManBoxNum(pAbc->pGia) && Gia_ManRegBoxNum(pAbc->pGia) )
{
if ( pAbc->pGia->pAigExtra == NULL )
{
printf( "Timing manager is given but there is no GIA of boxes.\n" );
return 0;
}
pTemp = Gia_ManSweepWithBoxes( pAbc->pGia, NULL, pPars, 0, 0, pPars->fVerbose );
Abc_FrameUpdateGia( pAbc, pTemp );
return 0;
}
if ( Gia_ManRegNum(pAbc->pGia) == 0 )
{
Abc_Print( -1, "The network is combinational.\n" );
......@@ -30735,11 +30772,9 @@ usage:
int Abc_CommandAbc9Verify( Abc_Frame_t * pAbc, int argc, char ** argv )
{
char * pFileSpec = NULL;
Cec_ParCec_t ParsCec, * pPars = &ParsCec;
int c;
Cec_ManCecSetDefaultParams( pPars );
int c, nBTLimit = 1000, nTimeLim = 0, fSeq = 0, fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "CTvh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "CTsvh" ) ) != EOF )
{
switch ( c )
{
......@@ -30749,9 +30784,9 @@ int Abc_CommandAbc9Verify( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nBTLimit = atoi(argv[globalUtilOptind]);
nBTLimit = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPars->nBTLimit < 0 )
if ( nBTLimit < 0 )
goto usage;
break;
case 'T':
......@@ -30760,13 +30795,16 @@ int Abc_CommandAbc9Verify( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
goto usage;
}
pPars->TimeLimit = atoi(argv[globalUtilOptind]);
nTimeLim = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPars->TimeLimit < 0 )
if ( nTimeLim < 0 )
goto usage;
break;
case 's':
fSeq ^= 1;
break;
case 'v':
pPars->fVerbose ^= 1;
fVerbose ^= 1;
break;
case 'h':
goto usage;
......@@ -30780,15 +30818,16 @@ int Abc_CommandAbc9Verify( Abc_Frame_t * pAbc, int argc, char ** argv )
Extra_FileNameCorrectPath( pFileSpec );
printf( "Taking spec from file \"%s\".\n", pFileSpec );
}
Gia_ManVerifyWithBoxes( pAbc->pGia, pPars, pFileSpec );
Gia_ManVerifyWithBoxes( pAbc->pGia, nBTLimit, nTimeLim, fSeq, fVerbose, pFileSpec );
return 0;
usage:
Abc_Print( -2, "usage: &verify [-CT num] [-vh] <file>\n" );
Abc_Print( -2, "usage: &verify [-CT num] [-svh] <file>\n" );
Abc_Print( -2, "\t performs verification of combinational design\n" );
Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes":"no");
Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nBTLimit );
Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nTimeLim );
Abc_Print( -2, "\t-s : toggle using sequential verification [default = %s]\n", fSeq? "yes":"no");
Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes":"no");
Abc_Print( -2, "\t-h : print the command usage\n");
Abc_Print( -2, "\t<file> : optional file name with the spec [default = not used\n" );
return 1;
......@@ -30876,7 +30915,15 @@ int Abc_CommandAbc9Sweep( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9Sweep(): There is no AIG.\n" );
return 1;
}
pTemp = Gia_ManFraigSweep( pAbc->pGia, pPars );
if ( Gia_ManBoxNum(pAbc->pGia) && pAbc->pGia->pAigExtra == NULL )
{
printf( "Timing manager is given but there is no GIA of boxes.\n" );
return 0;
}
if ( Gia_ManBoxNum(pAbc->pGia) )
pTemp = Gia_ManSweepWithBoxes( pAbc->pGia, pPars, NULL, 0, 0, pPars->fVerbose );
else
pTemp = Gia_ManFraigSweepSimple( pAbc->pGia, pPars );
Abc_FrameUpdateGia( pAbc, pTemp );
return 0;
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