summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2018-03-23 21:32:14 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2018-03-23 21:32:14 -0700
commita6d489e7d813a1bc727a2e8d9a2ce923d837dc0c (patch)
treee4c4decbe5cb2650ae50c9db362e0530949d0aba /src
parent53e7d1f9ef0b13e63f2b316c6f1de253fec6f42e (diff)
downloadabc-a6d489e7d813a1bc727a2e8d9a2ce923d837dc0c.tar.gz
abc-a6d489e7d813a1bc727a2e8d9a2ce923d837dc0c.tar.bz2
abc-a6d489e7d813a1bc727a2e8d9a2ce923d837dc0c.zip
Updating &mfs to support hard objects.
Diffstat (limited to 'src')
-rw-r--r--src/aig/gia/giaMfs.c27
-rw-r--r--src/misc/util/utilTruth.h30
2 files changed, 55 insertions, 2 deletions
diff --git a/src/aig/gia/giaMfs.c b/src/aig/gia/giaMfs.c
index 3229e0d0..23038eff 100644
--- a/src/aig/gia/giaMfs.c
+++ b/src/aig/gia/giaMfs.c
@@ -105,6 +105,11 @@ Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p )
nVars = Abc_Tt6MinBase( &uTruth, Vec_IntArray(vArray), Vec_IntSize(vArray) );
Vec_IntShrink( vArray, nVars );
Vec_WrdWriteEntry( vTruths, Counter, uTruth );
+ if ( Gia_ObjLutIsMux(p, Id) )
+ {
+ Vec_StrWriteEntry( vFixed, Counter, (char)1 );
+ Vec_StrWriteEntry( vEmpty, Counter, (char)1 );
+ }
Gia_ObjSetCopyArray( p, Id, Counter++ );
}
Gia_ObjComputeTruthTableStop( p );
@@ -251,7 +256,7 @@ Gia_Man_t * Gia_ManInsertMfs( Gia_Man_t * p, Sfm_Ntk_t * pNtk, int fAllBoxes )
int nMfsNodes;
word * pTruth, uTruthVar = ABC_CONST(0xAAAAAAAAAAAAAAAA);
Vec_Wec_t * vGroups = Vec_WecStart( nBoxes );
- Vec_Int_t * vMfs2Gia;
+ Vec_Int_t * vMfs2Gia, * vMfs2Old;
Vec_Int_t * vGroupMap;
Vec_Int_t * vMfsTopo, * vCover, * vBoxesLeft;
Vec_Int_t * vArray, * vLeaves;
@@ -260,7 +265,11 @@ Gia_Man_t * Gia_ManInsertMfs( Gia_Man_t * p, Sfm_Ntk_t * pNtk, int fAllBoxes )
if ( pManTime ) Tim_ManBlackBoxIoNum( pManTime, &nBbIns, &nBbOuts );
nMfsNodes = 1 + Gia_ManCiNum(p) + Gia_ManLutNum(p) + Gia_ManCoNum(p) + nBbIns + nBbOuts;
vMfs2Gia = Vec_IntStartFull( nMfsNodes );
+ vMfs2Old = Vec_IntStartFull( nMfsNodes );
vGroupMap = Vec_IntStartFull( nMfsNodes );
+ Gia_ManForEachObj( p, pObj, i )
+ if ( Gia_ObjCopyArray(p, i) > 0 )
+ Vec_IntWriteEntry( vMfs2Old, Gia_ObjCopyArray(p, i), i );
// collect nodes
curCi = nRealPis;
curCo = 0;
@@ -342,7 +351,20 @@ Gia_Man_t * Gia_ManInsertMfs( Gia_Man_t * p, Sfm_Ntk_t * pNtk, int fAllBoxes )
if ( iGroup == -1 ) // internal node
{
assert( Sfm_NodeReadUsed(pNtk, iMfsId) );
- iLitNew = Gia_ManFromIfLogicCreateLut( pNew, pTruth, vLeaves, vCover, vMapping, vMapping2 );
+ if ( Gia_ObjLutIsMux(p, Vec_IntEntry(vMfs2Old, iMfsId)) )
+ {
+ int MapSize = Vec_IntSize(vMapping2);
+ int nVarsNew, Res = Abc_TtSimplify( pTruth, Vec_IntArray(vLeaves), Vec_IntSize(vLeaves), &nVarsNew );
+ Vec_IntShrink( vLeaves, nVarsNew );
+ iLitNew = Gia_ManFromIfLogicCreateLut( pNew, pTruth, vLeaves, vCover, vMapping, vMapping2 );
+ if ( MapSize < Vec_IntSize(vMapping2) )
+ {
+ assert( Vec_IntEntryLast(vMapping2) == Abc_Lit2Var(iLitNew) );
+ Vec_IntWriteEntry(vMapping2, Vec_IntSize(vMapping2)-1, -Abc_Lit2Var(iLitNew) );
+ }
+ }
+ else
+ iLitNew = Gia_ManFromIfLogicCreateLut( pNew, pTruth, vLeaves, vCover, vMapping, vMapping2 );
}
else if ( Abc_LitIsCompl(iGroup) ) // internal CI
{
@@ -411,6 +433,7 @@ Gia_Man_t * Gia_ManInsertMfs( Gia_Man_t * p, Sfm_Ntk_t * pNtk, int fAllBoxes )
Vec_IntFree( vMfsTopo );
Vec_IntFree( vGroupMap );
Vec_IntFree( vMfs2Gia );
+ Vec_IntFree( vMfs2Old );
Vec_IntFree( vBoxesLeft );
return pNew;
}
diff --git a/src/misc/util/utilTruth.h b/src/misc/util/utilTruth.h
index e0210a66..36da1271 100644
--- a/src/misc/util/utilTruth.h
+++ b/src/misc/util/utilTruth.h
@@ -1534,6 +1534,36 @@ static inline int Abc_TtMinimumBase( word * t, int * pSupp, int nVarsAll, int *
Abc_TtShrink( t, iVar, nVarsAll, uSupp );
return 1;
}
+static inline int Abc_TtSimplify( word * t, int * pLits, int nVarsAll, int * pnVars )
+{
+ int v, u;
+ for ( v = 0; v < nVarsAll; v++ )
+ {
+ if ( pLits[v] == 0 )
+ Abc_TtCofactor0( t, Abc_TtWordNum(nVarsAll), v );
+ else if ( pLits[v] == 1 )
+ Abc_TtCofactor1( t, Abc_TtWordNum(nVarsAll), v );
+ }
+ for ( v = 0; v < nVarsAll; v++ )
+ for ( u = v+1; u < nVarsAll; u++ )
+ if ( Abc_Lit2Var(pLits[v]) == Abc_Lit2Var(pLits[u]) )
+ {
+ assert( nVarsAll <= 6 );
+ if ( pLits[v] == pLits[u] )
+ {
+ word t0 = Abc_Tt6Cofactor0(Abc_Tt6Cofactor0(*t, v), u);
+ word t1 = Abc_Tt6Cofactor1(Abc_Tt6Cofactor1(*t, v), u);
+ *t = (t0 & s_Truths6Neg[v]) | (t1 & s_Truths6[v]);
+ }
+ else // if ( pLits[v] == Abc_LitNot(pLits[u]) )
+ {
+ word t0 = Abc_Tt6Cofactor1(Abc_Tt6Cofactor0(*t, v), u);
+ word t1 = Abc_Tt6Cofactor0(Abc_Tt6Cofactor1(*t, v), u);
+ *t = (t0 & s_Truths6Neg[v]) | (t1 & s_Truths6[v]);
+ }
+ }
+ return Abc_TtMinimumBase( t, pLits, nVarsAll, pnVars );
+}
/**Function*************************************************************