summaryrefslogtreecommitdiffstats
path: root/src/aig
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2016-12-22 17:27:32 +0700
committerAlan Mishchenko <alanmi@berkeley.edu>2016-12-22 17:27:32 +0700
commitb56a532682e34ae440bc6ffa939e82d06cf06e62 (patch)
tree84807a449a344bd79d8ba2b428011e9ad29c250a /src/aig
parentcf5d4ad07f87e936a114afca483ed66ffb1a2120 (diff)
downloadabc-b56a532682e34ae440bc6ffa939e82d06cf06e62.tar.gz
abc-b56a532682e34ae440bc6ffa939e82d06cf06e62.tar.bz2
abc-b56a532682e34ae440bc6ffa939e82d06cf06e62.zip
Several changes in arithmetic circuit manipulation.
Diffstat (limited to 'src/aig')
-rw-r--r--src/aig/gia/gia.h2
-rw-r--r--src/aig/gia/giaDup.c112
-rw-r--r--src/aig/gia/giaShow.c12
3 files changed, 107 insertions, 19 deletions
diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h
index bf7bf349..ac40f975 100644
--- a/src/aig/gia/gia.h
+++ b/src/aig/gia/gia.h
@@ -1403,7 +1403,7 @@ extern Gia_Man_t * Gia_ManCleanupOutputs( Gia_Man_t * p, int nOutputs );
extern Gia_Man_t * Gia_ManSeqCleanup( Gia_Man_t * p );
extern Gia_Man_t * Gia_ManSeqStructSweep( Gia_Man_t * p, int fConst, int fEquiv, int fVerbose );
/*=== giaShow.c ===========================================================*/
-extern void Gia_ManShow( Gia_Man_t * pMan, Vec_Int_t * vBold, int fAdders );
+extern void Gia_ManShow( Gia_Man_t * pMan, Vec_Int_t * vBold, int fAdders, int fFadds );
/*=== giaShrink.c ===========================================================*/
extern Gia_Man_t * Gia_ManMapShrink4( Gia_Man_t * p, int fKeepLevel, int fVerbose );
extern Gia_Man_t * Gia_ManMapShrink6( Gia_Man_t * p, int nFanoutMax, int fKeepLevel, int fVerbose );
diff --git a/src/aig/gia/giaDup.c b/src/aig/gia/giaDup.c
index 7ced54a4..c58596b2 100644
--- a/src/aig/gia/giaDup.c
+++ b/src/aig/gia/giaDup.c
@@ -3377,6 +3377,26 @@ Gia_Man_t * Gia_ManDupOuts( Gia_Man_t * p )
SeeAlso []
***********************************************************************/
+Vec_Wec_t * Gia_ManCreateNodeSupps( Gia_Man_t * p, Vec_Int_t * vNodes, int fVerbose )
+{
+ abctime clk = Abc_Clock();
+ Gia_Obj_t * pObj; int i, Id;
+ Vec_Wec_t * vSuppsNo = Vec_WecStart( Vec_IntSize(vNodes) );
+ Vec_Wec_t * vSupps = Vec_WecStart( Gia_ManObjNum(p) );
+ Gia_ManForEachCiId( p, Id, i )
+ Vec_IntPush( Vec_WecEntry(vSupps, Id), i );
+ Gia_ManForEachAnd( p, pObj, Id )
+ Vec_IntTwoMerge2( Vec_WecEntry(vSupps, Gia_ObjFaninId0(pObj, Id)),
+ Vec_WecEntry(vSupps, Gia_ObjFaninId1(pObj, Id)),
+ Vec_WecEntry(vSupps, Id) );
+ Gia_ManForEachObjVec( vNodes, p, pObj, i )
+ Vec_IntAppend( Vec_WecEntry(vSuppsNo, i), Vec_WecEntry(vSupps, Gia_ObjId(p, pObj)) );
+ Vec_WecFree( vSupps );
+ if ( fVerbose )
+ Abc_PrintTime( 1, "Support computation", Abc_Clock() - clk );
+ return vSuppsNo;
+}
+
Vec_Wec_t * Gia_ManCreateCoSupps( Gia_Man_t * p, int fVerbose )
{
abctime clk = Abc_Clock();
@@ -3690,6 +3710,81 @@ Gia_Man_t * Gia_ManDupDemiter( Gia_Man_t * p, int fVerbose )
SeeAlso []
***********************************************************************/
+void Gia_ManDupDemiterOrderXors2( Gia_Man_t * p, Vec_Int_t * vXors )
+{
+ int i, iObj, * pPerm;
+ Vec_Int_t * vSizes = Vec_IntAlloc( 100 );
+ Vec_IntForEachEntry( vXors, iObj, i )
+ Vec_IntPush( vSizes, Gia_ManSuppSize(p, &iObj, 1) );
+ pPerm = Abc_MergeSortCost( Vec_IntArray(vSizes), Vec_IntSize(vSizes) );
+ Vec_IntClear( vSizes );
+ for ( i = 0; i < Vec_IntSize(vXors); i++ )
+ Vec_IntPush( vSizes, Vec_IntEntry(vXors, pPerm[i]) );
+ ABC_FREE( pPerm );
+ Vec_IntClear( vXors );
+ Vec_IntAppend( vXors, vSizes );
+ Vec_IntFree( vSizes );
+}
+int Gia_ManDupDemiterFindMin( Vec_Wec_t * vSupps, Vec_Int_t * vTakenIns, Vec_Int_t * vTakenOuts )
+{
+ Vec_Int_t * vLevel;
+ int i, k, iObj, iObjBest = -1;
+ int Count, CountBest = ABC_INFINITY;
+ Vec_WecForEachLevel( vSupps, vLevel, i )
+ {
+ if ( Vec_IntEntry(vTakenOuts, i) )
+ continue;
+ Count = 0;
+ Vec_IntForEachEntry( vLevel, iObj, k )
+ Count += !Vec_IntEntry(vTakenIns, iObj);
+ if ( CountBest > Count )
+ {
+ CountBest = Count;
+ iObjBest = i;
+ }
+ }
+ return iObjBest;
+}
+void Gia_ManDupDemiterOrderXors( Gia_Man_t * p, Vec_Int_t * vXors )
+{
+ extern Vec_Wec_t * Gia_ManCreateNodeSupps( Gia_Man_t * p, Vec_Int_t * vNodes, int fVerbose );
+ Vec_Wec_t * vSupps = Gia_ManCreateNodeSupps( p, vXors, 0 );
+ Vec_Int_t * vTakenIns = Vec_IntStart( Gia_ManCiNum(p) );
+ Vec_Int_t * vTakenOuts = Vec_IntStart( Vec_IntSize(vXors) );
+ Vec_Int_t * vOrder = Vec_IntAlloc( Vec_IntSize(vXors) );
+ int i, k, iObj;
+ // add outputs in the order of increasing supports
+ for ( i = 0; i < Vec_IntSize(vXors); i++ )
+ {
+ int Index = Gia_ManDupDemiterFindMin( vSupps, vTakenIns, vTakenOuts );
+ assert( Index >= 0 && Index < Vec_IntSize(vXors) );
+ Vec_IntPush( vOrder, Vec_IntEntry(vXors, Index) );
+ assert( !Vec_IntEntry( vTakenOuts, Index ) );
+ Vec_IntWriteEntry( vTakenOuts, Index, 1 );
+ Vec_IntForEachEntry( Vec_WecEntry(vSupps, Index), iObj, k )
+ Vec_IntWriteEntry( vTakenIns, iObj, 1 );
+ }
+ Vec_WecFree( vSupps );
+ Vec_IntFree( vTakenIns );
+ Vec_IntFree( vTakenOuts );
+ // reload
+ Vec_IntClear( vXors );
+ Vec_IntAppend( vXors, vOrder );
+ Vec_IntFree( vOrder );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
void Gia_ManSetMark0Dfs_rec( Gia_Man_t * p, int iObj )
{
Gia_Obj_t * pObj;
@@ -3781,8 +3876,8 @@ void Gia_ManCollectTopXors_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vXo
}
Vec_Int_t * Gia_ManCollectTopXors( Gia_Man_t * p )
{
- int i, iObj, iObj2, fFlip, * pPerm, Count1 = 0;
- Vec_Int_t * vXors, * vSizes, * vPart[2], * vOrder;
+ int i, iObj, iObj2, fFlip, Count1 = 0;
+ Vec_Int_t * vXors, * vPart[2], * vOrder;
Gia_Obj_t * pFan[2], * pObj = Gia_ManCo(p, 0);
assert( Gia_ManCoNum(p) == 1 );
vXors = Vec_IntAlloc( 100 );
@@ -3791,17 +3886,8 @@ Vec_Int_t * Gia_ManCollectTopXors( Gia_Man_t * p )
else
Vec_IntPush( vXors, Gia_ObjId(p, Gia_ObjFanin0(pObj)) );
// order by support size
- vSizes = Vec_IntAlloc( 100 );
- Vec_IntForEachEntry( vXors, iObj, i )
- Vec_IntPush( vSizes, Gia_ManSuppSize(p, &iObj, 1) );
- pPerm = Abc_MergeSortCost( Vec_IntArray(vSizes), Vec_IntSize(vSizes) );
- Vec_IntClear( vSizes );
- for ( i = 0; i < Vec_IntSize(vXors); i++ )
- Vec_IntPush( vSizes, Vec_IntEntry(vXors, pPerm[i]) );
- ABC_FREE( pPerm );
- Vec_IntClear( vXors );
- Vec_IntAppend( vXors, vSizes );
- Vec_IntFree( vSizes );
+ Gia_ManDupDemiterOrderXors( p, vXors );
+ //Vec_IntPrint( vXors );
Vec_IntReverseOrder( vXors ); // from MSB to LSB
// divide into groups
Gia_ManCleanMark01(p);
diff --git a/src/aig/gia/giaShow.c b/src/aig/gia/giaShow.c
index afc58bf8..afd36fff 100644
--- a/src/aig/gia/giaShow.c
+++ b/src/aig/gia/giaShow.c
@@ -713,11 +713,13 @@ void Gia_WriteDotAig( Gia_Man_t * p, char * pFileName, Vec_Int_t * vAdds, Vec_In
SeeAlso []
***********************************************************************/
-Vec_Int_t * Gia_ShowMapAdds( Gia_Man_t * p, Vec_Int_t * vAdds )
+Vec_Int_t * Gia_ShowMapAdds( Gia_Man_t * p, Vec_Int_t * vAdds, int fFadds )
{
Vec_Int_t * vMapAdds = Vec_IntStartFull( Gia_ManObjNum(p) ); int i;
for ( i = 0; 6*i < Vec_IntSize(vAdds); i++ )
{
+ if ( fFadds && Vec_IntEntry(vAdds, 6*i+2) == 0 )
+ continue;
Vec_IntWriteEntry( vMapAdds, Vec_IntEntry(vAdds, 6*i+3), i );
Vec_IntWriteEntry( vMapAdds, Vec_IntEntry(vAdds, 6*i+4), i );
}
@@ -800,9 +802,9 @@ Vec_Int_t * Gia_ShowCollectObjs( Gia_Man_t * p, Vec_Int_t * vAdds, Vec_Int_t * v
SeeAlso []
***********************************************************************/
-void Gia_ShowProcess( Gia_Man_t * p, char * pFileName, Vec_Int_t * vAdds, Vec_Int_t * vXors )
+void Gia_ShowProcess( Gia_Man_t * p, char * pFileName, Vec_Int_t * vAdds, Vec_Int_t * vXors, int fFadds )
{
- Vec_Int_t * vMapAdds = Gia_ShowMapAdds( p, vAdds );
+ Vec_Int_t * vMapAdds = Gia_ShowMapAdds( p, vAdds, fFadds );
Vec_Int_t * vMapXors = Gia_ShowMapXors( p, vXors );
Vec_Int_t * vOrder = Gia_ShowCollectObjs( p, vAdds, vXors, vMapAdds, vMapXors );
Gia_WriteDotAig( p, pFileName, vAdds, vXors, vMapAdds, vMapXors, vOrder );
@@ -810,7 +812,7 @@ void Gia_ShowProcess( Gia_Man_t * p, char * pFileName, Vec_Int_t * vAdds, Vec_In
Vec_IntFree( vMapXors );
Vec_IntFree( vOrder );
}
-void Gia_ManShow( Gia_Man_t * pMan, Vec_Int_t * vBold, int fAdders )
+void Gia_ManShow( Gia_Man_t * pMan, Vec_Int_t * vBold, int fAdders, int fFadds )
{
extern Vec_Int_t * Ree_ManComputeCuts( Gia_Man_t * p, Vec_Int_t ** pvXors, int fVerbose );
extern void Ree_ManRemoveTrivial( Gia_Man_t * p, Vec_Int_t * vAdds );
@@ -837,7 +839,7 @@ void Gia_ManShow( Gia_Man_t * pMan, Vec_Int_t * vBold, int fAdders )
fclose( pFile );
// generate the file
if ( fAdders )
- Gia_ShowProcess( pMan, FileNameDot, vAdds, vXors );
+ Gia_ShowProcess( pMan, FileNameDot, vAdds, vXors, fFadds );
else
Gia_WriteDotAigSimple( pMan, FileNameDot, vBold );
// visualize the file