summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2011-07-02 13:58:12 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2011-07-02 13:58:12 -0700
commitf866920eb5603f60fb087c96607d58c94fb31f28 (patch)
treeb2b92fd38a1c7e79b10ed45baaf13bfa2f8e67bd /src
parent6c2ac7661dc1ea3ddd83617dd247a467e00486de (diff)
downloadabc-f866920eb5603f60fb087c96607d58c94fb31f28.tar.gz
abc-f866920eb5603f60fb087c96607d58c94fb31f28.tar.bz2
abc-f866920eb5603f60fb087c96607d58c94fb31f28.zip
Added a new demitering feature for dual-output miters.
Diffstat (limited to 'src')
-rw-r--r--src/aig/aig/aig.h1
-rw-r--r--src/aig/aig/aigObj.c21
-rw-r--r--src/aig/saig/saig.h1
-rw-r--r--src/aig/saig/saigMiter.c57
-rw-r--r--src/base/abci/abc.c37
-rw-r--r--src/base/abci/abcDar.c68
6 files changed, 180 insertions, 5 deletions
diff --git a/src/aig/aig/aig.h b/src/aig/aig/aig.h
index aa55f2fc..4b95f682 100644
--- a/src/aig/aig/aig.h
+++ b/src/aig/aig/aig.h
@@ -557,6 +557,7 @@ extern void Aig_ObjConnect( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_
extern void Aig_ObjDisconnect( Aig_Man_t * p, Aig_Obj_t * pObj );
extern void Aig_ObjDelete( Aig_Man_t * p, Aig_Obj_t * pObj );
extern void Aig_ObjDelete_rec( Aig_Man_t * p, Aig_Obj_t * pObj, int fFreeTop );
+extern void Aig_ObjDeletePo( Aig_Man_t * p, Aig_Obj_t * pObj );
extern void Aig_ObjPrint( Aig_Man_t * p, Aig_Obj_t * pObj );
extern void Aig_ObjPatchFanin0( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFaninNew );
extern void Aig_ObjReplace( Aig_Man_t * p, Aig_Obj_t * pObjOld, Aig_Obj_t * pObjNew, int fUpdateLevel );
diff --git a/src/aig/aig/aigObj.c b/src/aig/aig/aigObj.c
index 141afaaa..36578d35 100644
--- a/src/aig/aig/aigObj.c
+++ b/src/aig/aig/aigObj.c
@@ -268,6 +268,27 @@ void Aig_ObjDelete_rec( Aig_Man_t * p, Aig_Obj_t * pObj, int fFreeTop )
/**Function*************************************************************
+ Synopsis [Deletes the node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Aig_ObjDeletePo( Aig_Man_t * p, Aig_Obj_t * pObj )
+{
+ assert( Aig_ObjIsPo(pObj) );
+ Aig_ObjDeref(Aig_ObjFanin0(pObj));
+ pObj->pFanin0 = NULL;
+ p->nObjs[pObj->Type]--;
+ Vec_PtrWriteEntry( p->vObjs, pObj->Id, NULL );
+ Aig_ManRecycleMemory( p, pObj );
+}
+
+/**Function*************************************************************
+
Synopsis [Replaces the first fanin of the node by the new fanin.]
Description []
diff --git a/src/aig/saig/saig.h b/src/aig/saig/saig.h
index af4d904e..e3de0a6d 100644
--- a/src/aig/saig/saig.h
+++ b/src/aig/saig/saig.h
@@ -168,6 +168,7 @@ extern Aig_Man_t * Saig_ManDualRail( Aig_Man_t * p, int fMiter );
extern Aig_Man_t * Saig_ManCreateMiterTwo( Aig_Man_t * pOld, Aig_Man_t * pNew, int nFrames );
extern int Saig_ManDemiterSimple( Aig_Man_t * p, Aig_Man_t ** ppAig0, Aig_Man_t ** ppAig1 );
extern int Saig_ManDemiterSimpleDiff( Aig_Man_t * p, Aig_Man_t ** ppAig0, Aig_Man_t ** ppAig1 );
+extern int Saig_ManDemiterDual( Aig_Man_t * p, Aig_Man_t ** ppAig0, Aig_Man_t ** ppAig1 );
extern int Ssw_SecSpecialMiter( Aig_Man_t * p0, Aig_Man_t * p1, int nFrames, int fVerbose );
/*=== saigOutdec.c ==========================================================*/
extern Aig_Man_t * Saig_ManDecPropertyOutput( Aig_Man_t * pAig, int nLits, int fVerbose );
diff --git a/src/aig/saig/saigMiter.c b/src/aig/saig/saigMiter.c
index 0fdac6cc..be80f545 100644
--- a/src/aig/saig/saigMiter.c
+++ b/src/aig/saig/saigMiter.c
@@ -696,6 +696,63 @@ int Saig_ManDemiterSimpleDiff( Aig_Man_t * p, Aig_Man_t ** ppAig0, Aig_Man_t **
/**Function*************************************************************
+ Synopsis [Returns 1 if AIG can be demitered.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_ManDemiterDual( Aig_Man_t * p, Aig_Man_t ** ppAig0, Aig_Man_t ** ppAig1 )
+{
+ Aig_Man_t * pTemp;
+ Aig_Obj_t * pObj;
+ int i, k;
+
+ if ( p->pFanData )
+ Aig_ManFanoutStop( p );
+
+ k = 0;
+ pTemp = Aig_ManDupSimple( p );
+ Saig_ManForEachPo( pTemp, pObj, i )
+ {
+ if ( i & 1 )
+ Aig_ObjDeletePo( pTemp, pObj );
+ else
+ Vec_PtrWriteEntry( pTemp->vPos, k++, pObj );
+ }
+ Saig_ManForEachLi( pTemp, pObj, i )
+ Vec_PtrWriteEntry( pTemp->vPos, k++, pObj );
+ Vec_PtrShrink( pTemp->vPos, k );
+ pTemp->nTruePos = k - Saig_ManRegNum(pTemp);
+ Aig_ManSeqCleanup( pTemp );
+ *ppAig0 = Aig_ManDupSimple( pTemp );
+ Aig_ManStop( pTemp );
+
+ k = 0;
+ pTemp = Aig_ManDupSimple( p );
+ Saig_ManForEachPo( pTemp, pObj, i )
+ {
+ if ( i & 1 )
+ Vec_PtrWriteEntry( pTemp->vPos, k++, pObj );
+ else
+ Aig_ObjDeletePo( pTemp, pObj );
+ }
+ Saig_ManForEachLi( pTemp, pObj, i )
+ Vec_PtrWriteEntry( pTemp->vPos, k++, pObj );
+ Vec_PtrShrink( pTemp->vPos, k );
+ pTemp->nTruePos = k - Saig_ManRegNum(pTemp);
+ Aig_ManSeqCleanup( pTemp );
+ *ppAig1 = Aig_ManDupSimple( pTemp );
+ Aig_ManStop( pTemp );
+
+ return 1;
+}
+
+/**Function*************************************************************
+
Synopsis [Duplicates the AIG to have constant-0 initial state.]
Description []
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 7486e384..926fb999 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -5513,21 +5513,30 @@ usage:
int Abc_CommandDemiter( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);//, * pNtkRes;
- int fSeq;
+ int fDual, fSeq, fVerbose;
int c;
extern int Abc_NtkDemiter( Abc_Ntk_t * pNtk );
extern int Abc_NtkDarDemiter( Abc_Ntk_t * pNtk );
+ extern int Abc_NtkDarDemiterDual( Abc_Ntk_t * pNtk, int fVerbose );
// set defaults
+ fDual = 0;
fSeq = 1;
+ fVerbose = 1;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "sh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "dsvh" ) ) != EOF )
{
switch ( c )
{
+ case 'd':
+ fDual ^= 1;
+ break;
case 's':
fSeq ^= 1;
break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
default:
goto usage;
}
@@ -5545,6 +5554,22 @@ int Abc_CommandDemiter( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
}
+ if ( (Abc_NtkPoNum(pNtk) & 1) )
+ {
+ Abc_Print( -1, "The number of POs should be even.\n" );
+ return 0;
+ }
+
+ if ( fDual )
+ {
+ if ( !Abc_NtkDarDemiterDual( pNtk, fVerbose ) )
+ {
+ Abc_Print( -1, "Demitering has failed.\n" );
+ return 1;
+ }
+ return 0;
+ }
+
// get the new network
if ( fSeq )
{
@@ -5577,9 +5602,11 @@ int Abc_CommandDemiter( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- Abc_Print( -2, "usage: demiter [-sh]\n" );
- Abc_Print( -2, "\t removes topmost EXOR from the miter to create two POs\n" );
- Abc_Print( -2, "\t-s : applied multi-output algorithm [default = %s]\n", fSeq? "yes": "no" );
+ Abc_Print( -2, "usage: demiter [-dsvh]\n" );
+ Abc_Print( -2, "\t removes topmost XOR from the miter to create two POs\n" );
+ Abc_Print( -2, "\t-d : demiters a dual-output miter (without XORs) [default = %s]\n", fSeq? "yes": "no" );
+ Abc_Print( -2, "\t-s : applies a multi-output algorithm [default = %s]\n", fSeq? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles outputting verbose information [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
diff --git a/src/base/abci/abcDar.c b/src/base/abci/abcDar.c
index c113d856..b1fe8bbe 100644
--- a/src/base/abci/abcDar.c
+++ b/src/base/abci/abcDar.c
@@ -2051,6 +2051,74 @@ int Abc_NtkDarDemiter( Abc_Ntk_t * pNtk )
Aig_ManStop( pMan );
return 1;
}
+
+/**Function*************************************************************
+
+ Synopsis [Gives the current ABC network to AIG manager for processing.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkDarDemiterDual( Abc_Ntk_t * pNtk, int fVerbose )
+{
+ char * pFileNameGeneric, pFileName0[1000], pFileName1[1000];
+ Aig_Man_t * pMan, * pPart0, * pPart1;//, * pMiter;
+ if ( (Abc_NtkPoNum(pNtk) & 1) )
+ {
+ printf( "The number of POs should be even.\n" );
+ return 0;
+ }
+ // derive the AIG manager
+ pMan = Abc_NtkToDar( pNtk, 0, 1 );
+ if ( pMan == NULL )
+ {
+ printf( "Converting network into AIG has failed.\n" );
+ return 0;
+ }
+// if ( !Saig_ManDemiterSimple( pMan, &pPart0, &pPart1 ) )
+ if ( !Saig_ManDemiterDual( pMan, &pPart0, &pPart1 ) )
+ {
+ printf( "Demitering has failed.\n" );
+ return 0;
+ }
+ // create new AIG
+ ABC_FREE( pPart0->pName );
+ pPart0->pName = Aig_UtilStrsav( "part0" );
+ // create new AIGs
+ ABC_FREE( pPart1->pName );
+ pPart1->pName = Aig_UtilStrsav( "part1" );
+ // create file names
+ pFileNameGeneric = Extra_FileNameGeneric( pNtk->pSpec );
+ sprintf( pFileName0, "%s%s", pFileNameGeneric, "_part0.aig" );
+ sprintf( pFileName1, "%s%s", pFileNameGeneric, "_part1.aig" );
+ ABC_FREE( pFileNameGeneric );
+ Ioa_WriteAiger( pPart0, pFileName0, 0, 0 );
+ Ioa_WriteAiger( pPart1, pFileName1, 0, 0 );
+ printf( "Demitering produced two files \"%s\" and \"%s\".\n", pFileName0, pFileName1 );
+ // dump files
+ if ( fVerbose )
+ {
+// printf( "Init: " );
+ Aig_ManPrintStats( pMan );
+// printf( "Part1: " );
+ Aig_ManPrintStats( pPart0 );
+// printf( "Part2: " );
+ Aig_ManPrintStats( pPart1 );
+ }
+ // create two-level miter
+// pMiter = Saig_ManCreateMiterTwo( pPart0, pPart1, 2 );
+// Aig_ManDumpBlif( pMiter, "miter01.blif", NULL, NULL );
+// Aig_ManStop( pMiter );
+// printf( "The new miter is written into file \"%s\".\n", "miter01.blif" );
+ Aig_ManStop( pPart0 );
+ Aig_ManStop( pPart1 );
+ Aig_ManStop( pMan );
+ return 1;
+}
/**Function*************************************************************