summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2012-04-28 12:09:38 +0700
committerAlan Mishchenko <alanmi@berkeley.edu>2012-04-28 12:09:38 +0700
commit490e84c4bcbd726ac40700e6bfa93042d1f79c7d (patch)
tree08df31195e050f052aa05358d0a2af20fe6abb23 /src
parent334911a116309accef78bf28f267f883d2f228f4 (diff)
downloadabc-490e84c4bcbd726ac40700e6bfa93042d1f79c7d.tar.gz
abc-490e84c4bcbd726ac40700e6bfa93042d1f79c7d.tar.bz2
abc-490e84c4bcbd726ac40700e6bfa93042d1f79c7d.zip
Adding on-the-fly truth-table minimization.
Diffstat (limited to 'src')
-rw-r--r--src/map/if/if.h2
-rw-r--r--src/map/if/ifDec16.c17
-rw-r--r--src/map/if/ifMan.c3
-rw-r--r--src/map/if/ifTruth.c1
4 files changed, 22 insertions, 1 deletions
diff --git a/src/map/if/if.h b/src/map/if/if.h
index 7a4ab551..ec1dedfa 100644
--- a/src/map/if/if.h
+++ b/src/map/if/if.h
@@ -177,6 +177,7 @@ struct If_Man_t_
int nCutsUsed; // the number of cuts currently used
int nCutsMerged; // the total number of cuts merged
unsigned * puTemp[4]; // used for the truth table computation
+ If_Cut_t * pCutTemp; // temporary cut
int SortMode; // one of the three sorting modes
int fNextRound; // set to 1 after the first round
int nChoices; // the number of choice nodes
@@ -495,6 +496,7 @@ extern float If_CutDelay( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pC
extern void If_CutPropagateRequired( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut, float Required );
extern void If_CutRotatePins( If_Man_t * p, If_Cut_t * pCut );
/*=== ifTruth.c ===========================================================*/
+extern int If_CutTruthMinimize( If_Man_t * p, If_Cut_t * pCut );
extern int If_CutComputeTruth( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int fCompl0, int fCompl1 );
extern void If_CutTruthPermute( unsigned * pOut, unsigned * pIn, int nVars, float * pDelays, int * pVars );
/*=== ifUtil.c ============================================================*/
diff --git a/src/map/if/ifDec16.c b/src/map/if/ifDec16.c
index 2f7d5ff9..cedf4f06 100644
--- a/src/map/if/ifDec16.c
+++ b/src/map/if/ifDec16.c
@@ -2040,6 +2040,23 @@ int If_CutPerformCheck16( If_Man_t * p, unsigned * pTruth, int nVars, int nLeave
{
If_Grp_t G1 = {0};//, G3 = {0};
int i, nLutLeaf, nLutLeaf2, nLutRoot, Length;
+ // if cutmin is disabled, minimize the cut
+ if ( !p->pPars->fCutMin && If_CluSupportSize((word *)pTruth, nVars) < nLeaves )
+ {
+ If_Cut_t * pCut = p->pCutTemp;
+ pCut->nLimit = nVars;
+ pCut->nLeaves = nLeaves;
+ pCut->pLeaves = (int *)(pCut + 1);
+ for ( i = 0; i < nLeaves; i++ )
+ pCut->pLeaves[i] = i;
+ pCut->pTruth = (unsigned *)pCut->pLeaves + pCut->nLimit + p->nPermWords;
+ If_CluCopy( (word *)If_CutTruth(pCut), (word *)pTruth, nVars );
+ if ( If_CutTruthMinimize( p, pCut ) >= 2 )
+ return 0;
+ nLeaves = pCut->nLeaves;
+ If_CluCopy( (word *)pTruth, (word *)If_CutTruth(pCut), nVars );
+ }
+
// quit if parameters are wrong
Length = strlen(pStr);
if ( Length != 2 && Length != 3 )
diff --git a/src/map/if/ifMan.c b/src/map/if/ifMan.c
index 5bc648f2..9b834906 100644
--- a/src/map/if/ifMan.c
+++ b/src/map/if/ifMan.c
@@ -78,6 +78,8 @@ If_Man_t * If_ManStart( If_Par_t * pPars )
p->puTemp[1] = p->puTemp[0] + p->nTruthWords;
p->puTemp[2] = p->puTemp[1] + p->nTruthWords;
p->puTemp[3] = p->puTemp[2] + p->nTruthWords;
+ p->pCutTemp = (If_Cut_t *)ABC_ALLOC( char, p->nCutBytes );
+
// create the constant node
p->pConst1 = If_ManSetupObj( p );
p->pConst1->Type = IF_CONST1;
@@ -160,6 +162,7 @@ void If_ManStop( If_Man_t * p )
ABC_FREE( p->pMemCi );
ABC_FREE( p->pMemAnd );
ABC_FREE( p->puTemp[0] );
+ ABC_FREE( p->pCutTemp );
// free pars memory
if ( p->pPars->pTimesArr )
ABC_FREE( p->pPars->pTimesArr );
diff --git a/src/map/if/ifTruth.c b/src/map/if/ifTruth.c
index fe3bf8fc..f0289695 100644
--- a/src/map/if/ifTruth.c
+++ b/src/map/if/ifTruth.c
@@ -27,7 +27,6 @@ ABC_NAMESPACE_IMPL_START
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static int If_CutTruthMinimize( If_Man_t * p, If_Cut_t * pCut );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///