summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2019-04-21 17:15:08 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2019-04-21 17:15:08 -0700
commit14a1ea844764de72a3935bc49f55d6170958aa27 (patch)
tree48062cf2e15bec62db83c6b02d16e0d911e0218e
parentcd0102f61e89e3d12281d026e5a26820cec4aed5 (diff)
downloadabc-14a1ea844764de72a3935bc49f55d6170958aa27.tar.gz
abc-14a1ea844764de72a3935bc49f55d6170958aa27.tar.bz2
abc-14a1ea844764de72a3935bc49f55d6170958aa27.zip
Adding switch &st -s for MUX restructring.
-rw-r--r--src/aig/gia/giaMuxes.c74
-rw-r--r--src/base/abci/abc.c17
2 files changed, 89 insertions, 2 deletions
diff --git a/src/aig/gia/giaMuxes.c b/src/aig/gia/giaMuxes.c
index 4ce109f6..c0414d14 100644
--- a/src/aig/gia/giaMuxes.c
+++ b/src/aig/gia/giaMuxes.c
@@ -219,6 +219,80 @@ Gia_Man_t * Gia_ManDupMuxesTest( Gia_Man_t * p )
/**Function*************************************************************
+ Synopsis [Test these procedures.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManMuxRestructure( Gia_Man_t * p )
+{
+ Gia_Man_t * pNew, * pTemp;
+ Gia_Obj_t * pObj;
+ int i, nNodes = 0;
+ Vec_Bit_t * vUsed = Vec_BitStart( Gia_ManObjNum(p) );
+ assert( !Gia_ManHasChoices(p) );
+ assert( !Gia_ManHasMapping(p) );
+ assert( p->pMuxes != NULL );
+ ABC_FREE( p->pRefs );
+ Gia_ManCreateRefs( p );
+ // start the new manager
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Abc_UtilStrsav( p->pName );
+ pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+ pNew->pMuxes = ABC_CALLOC( unsigned, pNew->nObjsAlloc );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManHashStart( pNew );
+ Gia_ManForEachObj1( p, pObj, i )
+ {
+ if ( Gia_ObjIsCi(pObj) )
+ pObj->Value = Gia_ManAppendCi( pNew );
+ else if ( Gia_ObjIsCo(pObj) )
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ else if ( Gia_ObjIsBuf(pObj) )
+ pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
+ else if ( Gia_ObjIsMuxId(p, i) &&
+ Gia_ObjIsMuxId(p, Gia_ObjFaninId0(pObj, i)) && !Vec_BitEntry(vUsed, Gia_ObjFaninId0(pObj, i)) &&
+ Gia_ObjIsMuxId(p, Gia_ObjFaninId1(pObj, i)) && !Vec_BitEntry(vUsed, Gia_ObjFaninId1(pObj, i)) &&
+ Gia_ObjFaninId2(p, Gia_ObjFaninId0(pObj, i)) == Gia_ObjFaninId2(p, Gia_ObjFaninId1(pObj, i)) )
+ {
+ Gia_Obj_t * pFan1 = Gia_ObjFanin1(pObj);
+ int Value0 = Gia_ManHashMux( pNew, Gia_ObjFanin2Copy(p, pObj), Gia_ObjFanin2Copy(p, pFan1), Gia_ObjFanin0Copy(pObj) );
+ int Value1 = Gia_ManHashMux( pNew, Value0, Gia_ObjFanin1Copy(pFan1), Gia_ObjFanin0Copy(pFan1) );
+ pObj->Value = Gia_ManHashMux( pNew, Gia_ObjFanin2Copy(p, pObj), Value1, Value0 );
+ Vec_BitWriteEntry( vUsed, Gia_ObjFaninId0(pObj, i), 1 );
+ Vec_BitWriteEntry( vUsed, Gia_ObjFaninId1(pObj, i), 1 );
+ Vec_BitWriteEntry( vUsed, i, 1 );
+ nNodes++;
+ }
+ else if ( Gia_ObjIsMuxId(p, i) )
+ pObj->Value = Gia_ManHashMux( pNew, Gia_ObjFanin2Copy(p, pObj), Gia_ObjFanin1Copy(pObj), Gia_ObjFanin0Copy(pObj) );
+ else if ( Gia_ObjIsXor(pObj) )
+ pObj->Value = Gia_ManHashXor( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ else
+ pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ }
+ Vec_BitFree( vUsed );
+ Gia_ManHashStop( pNew );
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ // perform cleanup
+ pNew = Gia_ManCleanup( pTemp = pNew );
+ Gia_ManStop( pTemp );
+ return pNew;
+}
+Gia_Man_t * Gia_ManDupMuxRestructure( Gia_Man_t * p )
+{
+ Gia_Man_t * pTemp, * pNew = Gia_ManDupMuxes( p, 2 );
+ pNew = Gia_ManMuxRestructure( pTemp = pNew ); Gia_ManStop( pTemp );
+ pNew = Gia_ManDupNoMuxes( pTemp = pNew ); Gia_ManStop( pTemp );
+ return pNew;
+}
+
+/**Function*************************************************************
+
Synopsis [Returns the size of MUX structure.]
Description []
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 77d11cd1..6ece3b64 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -30995,14 +30995,16 @@ usage:
***********************************************************************/
int Abc_CommandAbc9Strash( Abc_Frame_t * pAbc, int argc, char ** argv )
{
+ extern Gia_Man_t * Gia_ManDupMuxRestructure( Gia_Man_t * p );
Gia_Man_t * pTemp;
int c, Limit = 2;
int fAddStrash = 0;
int fCollapse = 0;
int fAddMuxes = 0;
+ int fStrMuxes = 0;
int fRehashMap = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "Lacmrh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "Lacmrsh" ) ) != EOF )
{
switch ( c )
{
@@ -31029,6 +31031,9 @@ int Abc_CommandAbc9Strash( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'r':
fRehashMap ^= 1;
break;
+ case 's':
+ fStrMuxes ^= 1;
+ break;
case 'h':
goto usage;
default:
@@ -31040,7 +31045,15 @@ int Abc_CommandAbc9Strash( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9Strash(): There is no AIG.\n" );
return 1;
}
- if ( Gia_ManHasMapping(pAbc->pGia) && fRehashMap )
+ if ( fStrMuxes )
+ {
+ if ( Gia_ManHasMapping(pAbc->pGia) )
+ Abc_Print( 0, "Restructing the current AIG destroys the LUT mapping.\n" );
+ Vec_IntFreeP( &pAbc->pGia->vMapping );
+ pTemp = Gia_ManDupMuxRestructure( pAbc->pGia );
+ Abc_Print( 1, "Finished AIG restructing to enable efficient mapping of 4:1 MUXes into 4-LUTs.\n" );
+ }
+ else if ( Gia_ManHasMapping(pAbc->pGia) && fRehashMap )
{
pTemp = Gia_ManDupHashMapping( pAbc->pGia );
Gia_ManTransferPacking( pTemp, pAbc->pGia );