summaryrefslogtreecommitdiffstats
path: root/src/aig
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2014-08-08 12:45:28 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2014-08-08 12:45:28 -0700
commit68ce0bc1c1a642495358e8e5d96e9212236a517b (patch)
treeab5264ec26d4bdc5fe0822f09061782d85f8821b /src/aig
parent35b816dd57f0ce6667f1fad7e4e37780aa6384aa (diff)
downloadabc-68ce0bc1c1a642495358e8e5d96e9212236a517b.tar.gz
abc-68ce0bc1c1a642495358e8e5d96e9212236a517b.tar.bz2
abc-68ce0bc1c1a642495358e8e5d96e9212236a517b.zip
Adding delay optimization to synthesis script &syn2.
Diffstat (limited to 'src/aig')
-rw-r--r--src/aig/gia/gia.h3
-rw-r--r--src/aig/gia/giaBalance.c53
-rw-r--r--src/aig/gia/giaIf.c32
3 files changed, 84 insertions, 4 deletions
diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h
index e12b66e2..d509d856 100644
--- a/src/aig/gia/gia.h
+++ b/src/aig/gia/gia.h
@@ -1021,7 +1021,7 @@ extern void Gia_AigerWriteSimple( Gia_Man_t * pInit, char * pFile
/*=== giaBalance.c ===========================================================*/
extern Gia_Man_t * Gia_ManBalance( Gia_Man_t * p, int fSimpleAnd, int fVerbose );
extern Gia_Man_t * Gia_ManAreaBalance( Gia_Man_t * p, int fSimpleAnd, int nNewNodesMax, int fVerbose, int fVeryVerbose );
-extern Gia_Man_t * Gia_ManAigSyn2( Gia_Man_t * p, int fOldAlgo, int fCoarsen, int fCutMin, int nRelaxRatio, int fVerbose, int fVeryVerbose );
+extern Gia_Man_t * Gia_ManAigSyn2( Gia_Man_t * p, int fOldAlgo, int fCoarsen, int fCutMin, int nRelaxRatio, int fDelayMin, int fVerbose, int fVeryVerbose );
extern Gia_Man_t * Gia_ManAigSyn3( Gia_Man_t * p, int fVerbose, int fVeryVerbose );
extern Gia_Man_t * Gia_ManAigSyn4( Gia_Man_t * p, int fVerbose, int fVeryVerbose );
/*=== giaBidec.c ===========================================================*/
@@ -1186,6 +1186,7 @@ extern void Gia_ManMappingVerify( Gia_Man_t * p );
extern void Gia_ManTransferMapping( Gia_Man_t * pGia, Gia_Man_t * p );
extern Gia_Man_t * Gia_ManPerformMapping( Gia_Man_t * p, void * pIfPars, int fNormalized );
extern Gia_Man_t * Gia_ManPerformSopBalance( Gia_Man_t * p, int nCutNum, int nRelaxRatio, int fVerbose );
+extern Gia_Man_t * Gia_ManPerformDsdBalance( Gia_Man_t * p, int nCutNum, int nRelaxRatio, int fVerbose );
/*=== giaJf.c ===========================================================*/
extern void Jf_ManSetDefaultPars( Jf_Par_t * pPars );
extern Gia_Man_t * Jf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars );
diff --git a/src/aig/gia/giaBalance.c b/src/aig/gia/giaBalance.c
index 611bbf87..65c87387 100644
--- a/src/aig/gia/giaBalance.c
+++ b/src/aig/gia/giaBalance.c
@@ -1017,7 +1017,7 @@ void Gia_ManAigTransferPiLevels( Gia_Man_t * pNew, Gia_Man_t * p )
SeeAlso []
***********************************************************************/
-Gia_Man_t * Gia_ManAigSyn2( Gia_Man_t * p, int fOldAlgo, int fCoarsen, int fCutMin, int nRelaxRatio, int fVerbose, int fVeryVerbose )
+Gia_Man_t * Gia_ManAigSyn2( Gia_Man_t * p, int fOldAlgo, int fCoarsen, int fCutMin, int nRelaxRatio, int fDelayMin, int fVerbose, int fVeryVerbose )
{
Gia_Man_t * pNew, * pTemp;
Jf_Par_t Pars, * pPars = &Pars;
@@ -1029,18 +1029,65 @@ Gia_Man_t * Gia_ManAigSyn2( Gia_Man_t * p, int fOldAlgo, int fCoarsen, int fCutM
else
{
Lf_ManSetDefaultPars( pPars );
- pPars->fCoarsen = fCoarsen;
pPars->fCutMin = fCutMin;
+ pPars->fCoarsen = fCoarsen;
pPars->nRelaxRatio = nRelaxRatio;
pPars->nAreaTuner = 1;
+ pPars->nCutNum = 4;
}
if ( fVerbose ) Gia_ManPrintStats( p, NULL );
+ p = Gia_ManDup( pTemp = p );
+ Gia_ManAigTransferPiLevels( p, pTemp );
if ( Gia_ManAndNum(p) == 0 )
- return Gia_ManDup(p);
+ return p;
+ // delay optimization
+ if ( fDelayMin )
+ {
+ int Area0, Area1, Delay0, Delay1;
+ int fCutMin = pPars->fCutMin;
+ int fCoarsen = pPars->fCoarsen;
+ int nRelaxRatio = pPars->nRelaxRatio;
+ pPars->fCutMin = 0;
+ pPars->fCoarsen = 0;
+ pPars->nRelaxRatio = 0;
+ // perform mapping
+ if ( fOldAlgo )
+ Jf_ManPerformMapping( p, pPars );
+ else
+ Lf_ManPerformMapping( p, pPars );
+ Area0 = (int)pPars->Area;
+ Delay0 = (int)pPars->Delay;
+ // perform balancing
+ pNew = Gia_ManPerformDsdBalance( p, 4, 0, 0 );
+ // perform mapping again
+ if ( fOldAlgo )
+ Jf_ManPerformMapping( pNew, pPars );
+ else
+ Lf_ManPerformMapping( pNew, pPars );
+ Area1 = (int)pPars->Area;
+ Delay1 = (int)pPars->Delay;
+ // choose the best result
+ if ( Delay1 < Delay0 - 1 || (Delay1 == Delay0 + 1 && 100.0 * (Area1 - Area0) / Area1 < 3.0) )
+ {
+ Gia_ManAigTransferPiLevels( pNew, p );
+ Gia_ManStop( p );
+ p = pNew;
+ }
+ else
+ {
+ Gia_ManStop( pNew );
+ Vec_IntFreeP( &p->vMapping );
+ }
+ // reset params
+ pPars->fCutMin = fCutMin;
+ pPars->fCoarsen = fCoarsen;
+ pPars->nRelaxRatio = nRelaxRatio;
+ }
// perform balancing
pNew = Gia_ManAreaBalance( p, 0, ABC_INFINITY, fVeryVerbose, 0 );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
Gia_ManAigTransferPiLevels( pNew, p );
+ Gia_ManStop( p );
// perform mapping
if ( fOldAlgo )
pNew = Jf_ManPerformMapping( pTemp = pNew, pPars );
diff --git a/src/aig/gia/giaIf.c b/src/aig/gia/giaIf.c
index a3ebf305..61b40117 100644
--- a/src/aig/gia/giaIf.c
+++ b/src/aig/gia/giaIf.c
@@ -1758,6 +1758,38 @@ Gia_Man_t * Gia_ManPerformSopBalance( Gia_Man_t * p, int nCutNum, int nRelaxRati
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
return pNew;
}
+Gia_Man_t * Gia_ManPerformDsdBalance( Gia_Man_t * p, int nCutNum, int nRelaxRatio, int fVerbose )
+{
+ Gia_Man_t * pNew;
+ If_Man_t * pIfMan;
+ If_Par_t Pars, * pPars = &Pars;
+ If_ManSetDefaultPars( pPars );
+ pPars->nCutsMax = nCutNum;
+ pPars->nRelaxRatio = nRelaxRatio;
+ pPars->fVerbose = fVerbose;
+ pPars->nLutSize = 6;
+ pPars->fDsdBalance = 1;
+ pPars->fUseDsd = 1;
+ pPars->fCutMin = 1;
+ pPars->fTruth = 1;
+ pPars->fExpRed = 0;
+ if ( Abc_FrameReadManDsd() == NULL )
+ Abc_FrameSetManDsd( If_DsdManAlloc(pPars->nLutSize, 0) );
+ // perform mapping
+ pIfMan = Gia_ManToIf( p, pPars );
+ pIfMan->pIfDsdMan = (If_DsdMan_t *)Abc_FrameReadManDsd();
+ if ( pPars->fDsdBalance )
+ If_DsdManAllocIsops( pIfMan->pIfDsdMan, pPars->nLutSize );
+ If_ManPerformMapping( pIfMan );
+ pNew = Gia_ManFromIfAig( pIfMan );
+ If_ManStop( pIfMan );
+ // transfer name
+ assert( pNew->pName == NULL );
+ pNew->pName = Abc_UtilStrsav( p->pName );
+ pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ return pNew;
+}
/**Function*************************************************************