summaryrefslogtreecommitdiffstats
path: root/src/opt/dau
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2014-07-20 22:11:00 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2014-07-20 22:11:00 -0700
commitea73401db5258da2311e6ad4d31a9a7e10437f33 (patch)
tree9bd82d0068598191c7a68b3c8c13532e428f0933 /src/opt/dau
parentba3f2ac6c02f06f197447326be150dfbd93d1879 (diff)
downloadabc-ea73401db5258da2311e6ad4d31a9a7e10437f33.tar.gz
abc-ea73401db5258da2311e6ad4d31a9a7e10437f33.tar.bz2
abc-ea73401db5258da2311e6ad4d31a9a7e10437f33.zip
Updates and changes to several packages.
Diffstat (limited to 'src/opt/dau')
-rw-r--r--src/opt/dau/dau.h3
-rw-r--r--src/opt/dau/dauDsd.c74
-rw-r--r--src/opt/dau/dauGia.c24
3 files changed, 90 insertions, 11 deletions
diff --git a/src/opt/dau/dau.h b/src/opt/dau/dau.h
index 0ccee987..ddffa905 100644
--- a/src/opt/dau/dau.h
+++ b/src/opt/dau/dau.h
@@ -80,6 +80,7 @@ extern unsigned Abc_TtCanonicizePhase( word * pTruth, int nVars );
/*=== dauDsd.c ==========================================================*/
extern int * Dau_DsdComputeMatches( char * p );
extern int Dau_DsdDecompose( word * pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char * pRes );
+extern int Dau_DsdDecomposeLevel( word * pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char * pRes, int * pVarLevels );
extern void Dau_DsdPrintFromTruthFile( FILE * pFile, word * pTruth, int nVarsInit );
extern void Dau_DsdPrintFromTruth( word * pTruth, int nVarsInit );
extern word * Dau_DsdToTruth( char * p, int nVars );
@@ -87,7 +88,7 @@ extern word Dau_Dsd6ToTruth( char * p );
extern void Dau_DsdNormalize( char * p );
extern int Dau_DsdCountAnds( char * pDsd );
extern void Dau_DsdTruthCompose_rec( word * pFunc, word pFanins[DAU_MAX_VAR][DAU_MAX_WORD], word * pRes, int nVars, int nWordsR );
-extern int Dau_DsdCheck1Step( word * pTruth, int nVarsInit );
+extern int Dau_DsdCheck1Step( void * p, word * pTruth, int nVarsInit, int * pVarLevels );
/*=== dauGia.c ==========================================================*/
extern int Dsm_ManTruthToGia( void * p, word * pTruth, Vec_Int_t * vLeaves, Vec_Int_t * vCover );
diff --git a/src/opt/dau/dauDsd.c b/src/opt/dau/dauDsd.c
index e5d83d0c..8469da4b 100644
--- a/src/opt/dau/dauDsd.c
+++ b/src/opt/dau/dauDsd.c
@@ -890,24 +890,43 @@ void Dau_DsdTest3()
SeeAlso []
***********************************************************************/
-int Dau_DsdCheck1Step( word * pTruth, int nVarsInit )
+int Dau_DsdCheck1Step( void * p, word * pTruth, int nVarsInit, int * pVarLevels )
{
word pCofTemp[DAU_MAX_WORD];
+ int pVarPrios[DAU_MAX_VAR];
int nWords = Abc_TtWordNum(nVarsInit);
int nSizeNonDec, nSizeNonDec0, nSizeNonDec1;
- int v, vBest = -2, nSumCofsBest = ABC_INFINITY, nSumCofs;
+ int i, vBest = -2, nSumCofsBest = ABC_INFINITY, nSumCofs;
nSizeNonDec = Dau_DsdDecompose( pTruth, nVarsInit, 0, 0, NULL );
if ( nSizeNonDec == 0 )
return -1;
assert( nSizeNonDec > 0 );
- for ( v = 0; v < nVarsInit; v++ )
+ // find variable priority
+ for ( i = 0; i < nVarsInit; i++ )
+ pVarPrios[i] = i;
+ if ( pVarLevels )
+ {
+ extern int Dau_DsdLevelVar( void * pMan, int iVar );
+ int pVarLevels[DAU_MAX_VAR];
+ for ( i = 0; i < nVarsInit; i++ )
+ pVarLevels[i] = -Dau_DsdLevelVar( p, i );
+// for ( i = 0; i < nVarsInit; i++ )
+// printf( "%d ", -pVarLevels[i] );
+// printf( "\n" );
+ Vec_IntSelectSortCost2( pVarPrios, nVarsInit, pVarLevels );
+// for ( i = 0; i < nVarsInit; i++ )
+// printf( "%d ", pVarPrios[i] );
+// printf( "\n\n" );
+ }
+ for ( i = 0; i < nVarsInit; i++ )
{
+ assert( pVarPrios[i] >= 0 && pVarPrios[i] < nVarsInit );
// try first cofactor
- Abc_TtCofactor0p( pCofTemp, pTruth, nWords, v );
+ Abc_TtCofactor0p( pCofTemp, pTruth, nWords, pVarPrios[i] );
nSumCofs = Abc_TtSupportSize( pCofTemp, nVarsInit );
nSizeNonDec0 = Dau_DsdDecompose( pCofTemp, nVarsInit, 0, 0, NULL );
// try second cofactor
- Abc_TtCofactor1p( pCofTemp, pTruth, nWords, v );
+ Abc_TtCofactor1p( pCofTemp, pTruth, nWords, pVarPrios[i] );
nSumCofs += Abc_TtSupportSize( pCofTemp, nVarsInit );
nSizeNonDec1 = Dau_DsdDecompose( pCofTemp, nVarsInit, 0, 0, NULL );
// compare cofactors
@@ -915,7 +934,7 @@ int Dau_DsdCheck1Step( word * pTruth, int nVarsInit )
continue;
if ( nSumCofsBest > nSumCofs )
{
- vBest = v;
+ vBest = pVarPrios[i];
nSumCofsBest = nSumCofs;
}
}
@@ -944,6 +963,7 @@ struct Dau_Dsd_t_
int uConstMask; // constant decomposition mask
int fSplitPrime; // represent prime function as 1-step DSD
int fWriteTruth; // writing truth table as a hex string
+ int * pVarLevels; // variable levels
char pVarDefs[32][8]; // variable definitions
char Cache[32][32]; // variable cache
char pOutput[DAU_MAX_STR]; // output stream
@@ -995,6 +1015,21 @@ static inline void Dau_DsdWriteVar( Dau_Dsd_t * p, int iVar, int fInv )
else
p->pOutput[ p->nPos++ ] = *pStr;
}
+int Dau_DsdLevelVar( void * pMan, int iVar )
+{
+ Dau_Dsd_t * p = (Dau_Dsd_t *)pMan;
+ char * pStr;
+ int LevelMax = 0, Level;
+ for ( pStr = p->pVarDefs[iVar]; *pStr; pStr++ )
+ {
+ if ( *pStr >= 'a' + p->nVarsInit && *pStr < 'a' + p->nVarsUsed )
+ Level = 1 + Dau_DsdLevelVar( p, *pStr - 'a' );
+ else
+ Level = p->pVarLevels[*pStr - 'a'];
+ LevelMax = Abc_MaxInt( LevelMax, Level );
+ }
+ return LevelMax;
+}
static inline void Dau_DsdTranslate( Dau_Dsd_t * p, int * pVars, int nVars, char * pStr )
{
for ( ; *pStr; pStr++ )
@@ -1011,7 +1046,7 @@ static inline int Dau_DsdWritePrime( Dau_Dsd_t * p, word * pTruth, int * pVars,
{
word pCofTemp[DAU_MAX_WORD];
int nWords = Abc_TtWordNum(nVars);
- int vBest = Dau_DsdCheck1Step( pTruth, nVars );
+ int vBest = Dau_DsdCheck1Step( p, pTruth, nVars, p->pVarLevels );
assert( vBest != -1 );
if ( vBest == -2 ) // non-dec
p->nPos += Abc_TtWriteHexRev( p->pOutput + p->nPos, pTruth, nVars );
@@ -1879,6 +1914,31 @@ int Dau_DsdDecompose( word * pTruth, int nVarsInit, int fSplitPrime, int fWriteT
Dau_Dsd_t P, * p = &P;
p->fSplitPrime = fSplitPrime;
p->fWriteTruth = fWriteTruth;
+ p->pVarLevels = NULL;
+ p->nSizeNonDec = 0;
+ if ( (pTruth[0] & 1) == 0 && Abc_TtIsConst0(pTruth, Abc_TtWordNum(nVarsInit)) )
+ { if ( pRes ) pRes[0] = '0', pRes[1] = 0; }
+ else if ( (pTruth[0] & 1) && Abc_TtIsConst1(pTruth, Abc_TtWordNum(nVarsInit)) )
+ { if ( pRes ) pRes[0] = '1', pRes[1] = 0; }
+ else
+ {
+ int Status = Dau_DsdDecomposeInt( p, pTruth, nVarsInit );
+ Dau_DsdRemoveBraces( p->pOutput, Dau_DsdComputeMatches(p->pOutput) );
+ if ( pRes )
+ strcpy( pRes, p->pOutput );
+ assert( fSplitPrime || Status != 1 );
+ if ( fSplitPrime && Status == 2 )
+ return -1;
+ }
+// assert( p->nSizeNonDec == 0 );
+ return p->nSizeNonDec;
+}
+int Dau_DsdDecomposeLevel( word * pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char * pRes, int * pVarLevels )
+{
+ Dau_Dsd_t P, * p = &P;
+ p->fSplitPrime = fSplitPrime;
+ p->fWriteTruth = fWriteTruth;
+ p->pVarLevels = pVarLevels;
p->nSizeNonDec = 0;
if ( (pTruth[0] & 1) == 0 && Abc_TtIsConst0(pTruth, Abc_TtWordNum(nVarsInit)) )
{ if ( pRes ) pRes[0] = '0', pRes[1] = 0; }
diff --git a/src/opt/dau/dauGia.c b/src/opt/dau/dauGia.c
index cf644102..1d821a30 100644
--- a/src/opt/dau/dauGia.c
+++ b/src/opt/dau/dauGia.c
@@ -414,14 +414,23 @@ int Dau_DsdToGia( Gia_Man_t * pGia, char * p, int * pLits, Vec_Int_t * vCover )
***********************************************************************/
int Dsm_ManTruthToGia( void * p, word * pTruth, Vec_Int_t * vLeaves, Vec_Int_t * vCover )
{
+ int fUseMuxes = 0;
int fDelayBalance = 1;
Gia_Man_t * pGia = (Gia_Man_t *)p;
- char pDsd[1000];
int nSizeNonDec;
+ char pDsd[1000];
m_Calls++;
assert( Vec_IntSize(vLeaves) <= DAU_DSD_MAX_VAR );
-// static int Counter = 0; Counter++;
- nSizeNonDec = Dau_DsdDecompose( pTruth, Vec_IntSize(vLeaves), 0, 1, pDsd );
+ // collect delay information
+ if ( fDelayBalance && fUseMuxes )
+ {
+ int i, iLit, pVarLevels[DAU_DSD_MAX_VAR];
+ Vec_IntForEachEntry( vLeaves, iLit, i )
+ pVarLevels[i] = Gia_ObjLevelId( pGia, Abc_Lit2Var(iLit) );
+ nSizeNonDec = Dau_DsdDecomposeLevel( pTruth, Vec_IntSize(vLeaves), fUseMuxes, 1, pDsd, pVarLevels );
+ }
+ else
+ nSizeNonDec = Dau_DsdDecompose( pTruth, Vec_IntSize(vLeaves), fUseMuxes, 1, pDsd );
if ( nSizeNonDec )
m_NonDsd++;
// printf( "%s\n", pDsd );
@@ -505,6 +514,15 @@ void * Dsm_ManDeriveGia( void * pGia, int fUseMuxes )
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
Vec_IntFree( vLeaves );
Vec_IntFree( vCover );
+/*
+ Gia_ManForEachAnd( pNew, pObj, i )
+ {
+ int iLev = Gia_ObjLevelId(pNew, i);
+ int iLev0 = Gia_ObjLevelId(pNew, Gia_ObjFaninId0(pObj, i));
+ int iLev1 = Gia_ObjLevelId(pNew, Gia_ObjFaninId1(pObj, i));
+ assert( iLev == 1 + Abc_MaxInt(iLev0, iLev1) );
+ }
+*/
// perform cleanup
pNew = Gia_ManCleanup( pTemp = pNew );
Gia_ManStop( pTemp );