@@ -296,7 +296,7 @@ void Gia_ManStochSynthesis( Vec_Ptr_t * vAigs, char * pScript )
296296 SeeAlso []
297297
298298***********************************************************************/
299- int Gia_ManFilterPartitions ( Gia_Man_t * p , Vec_Ptr_t * vvIns , Vec_Ptr_t * vvNodes , Vec_Ptr_t * vvOuts , Vec_Ptr_t * vWins , Vec_Int_t * vGains )
299+ int Gia_ManFilterPartitions ( Gia_Man_t * p , Vec_Ptr_t * vvIns , Vec_Ptr_t * vvNodes , Vec_Ptr_t * vvOuts , Vec_Ptr_t * vWins , Vec_Int_t * vGains , int fDelayOpt )
300300{
301301 int RetValue = Vec_PtrSize (vvIns );
302302 Vec_Ptr_t * vvInsNew = Vec_PtrAlloc ( 10 );
@@ -312,8 +312,8 @@ int Gia_ManFilterPartitions( Gia_Man_t * p, Vec_Ptr_t * vvIns, Vec_Ptr_t * vvNod
312312 Vec_PtrPush ( vvInsNew , Vec_IntDup ((Vec_Int_t * )Vec_PtrEntry (vvIns , iEntry )) );
313313 Vec_PtrPush ( vvOutsNew , Vec_IntDup ((Vec_Int_t * )Vec_PtrEntry (vvOuts , iEntry )) );
314314 Vec_PtrPush ( vvWinsNew , Gia_ManDupDfs ((Gia_Man_t * )Vec_PtrEntry (vWins , iEntry )) );
315- extern void Gia_ManMarkTfiTfo ( Vec_Int_t * vOne , Gia_Man_t * pMan );
316- Gia_ManMarkTfiTfo ( (Vec_Int_t * )Vec_PtrEntryLast (vvInsNew ), p );
315+ extern void Gia_ManMarkTfiTfo ( Vec_Int_t * vOne , Gia_Man_t * pMan , int fDelayOpt );
316+ Gia_ManMarkTfiTfo ( (Vec_Int_t * )Vec_PtrEntryLast (vvInsNew ), p , fDelayOpt );
317317 Vec_IntForEachEntry ( vGains , Gain , i ) {
318318 if ( Gain < 0 )
319319 continue ;
@@ -556,12 +556,14 @@ void Gia_ManSelectRemove( Vec_Wec_t * vSupps, Vec_Int_t * vOne )
556556 Vec_WecRemoveEmpty ( vSupps );
557557}
558558// marks TFI/TFO of this one
559- void Gia_ManMarkTfiTfo ( Vec_Int_t * vOne , Gia_Man_t * pMan )
559+ void Gia_ManMarkTfiTfo ( Vec_Int_t * vOne , Gia_Man_t * pMan , int fDelayOpt )
560560{
561561 int i ; Gia_Obj_t * pObj ;
562562 Gia_ManForEachObjVec ( vOne , pMan , pObj , i ) {
563- //Gia_ObjSetTravIdPrevious(pMan, pObj);
564- //Gia_ObjDfsMark_rec( pMan, pObj );
563+ if ( fDelayOpt ) {
564+ Gia_ObjSetTravIdPrevious (pMan , pObj );
565+ Gia_ObjDfsMark_rec ( pMan , pObj );
566+ }
565567 Gia_ObjSetTravIdPrevious (pMan , pObj );
566568 Gia_ObjDfsMark2_rec ( pMan , pObj );
567569 }
@@ -632,7 +634,7 @@ Vec_Ptr_t * Gia_ManDeriveWinInsAll( Vec_Wec_t * vSupps, int nSuppMax, Gia_Man_t
632634 }
633635 return vRes ;
634636}
635- Gia_Man_t * Gia_ManDupFromArrays ( Gia_Man_t * p , Vec_Int_t * vCis , Vec_Int_t * vAnds , Vec_Int_t * vCos )
637+ Gia_Man_t * Gia_ManDupFromArrays ( Gia_Man_t * p , Vec_Int_t * vCis , Vec_Int_t * vAnds , Vec_Int_t * vCos , Vec_Int_t * vLevels [ 2 ], int nLevels )
636638{
637639 Gia_Man_t * pNew ;
638640 Gia_Obj_t * pObj ;
@@ -647,10 +649,28 @@ Gia_Man_t * Gia_ManDupFromArrays( Gia_Man_t * p, Vec_Int_t * vCis, Vec_Int_t * v
647649 pObj -> Value = Gia_ManAppendAnd ( pNew , Gia_ObjFanin0Copy (pObj ), Gia_ObjFanin1Copy (pObj ) );
648650 Gia_ManForEachObjVec ( vCos , p , pObj , i )
649651 pObj -> Value = Gia_ManAppendCo ( pNew , pObj -> Value );
652+ if ( vLevels [0 ] ) {
653+ pNew -> vCiArrs = Vec_IntAlloc ( Gia_ManCiNum (pNew ) );
654+ Gia_ManForEachObjVec ( vCis , p , pObj , i )
655+ Vec_IntPush ( pNew -> vCiArrs , Gia_ObjLevel (p , pObj ) );
656+ pNew -> vCoReqs = Vec_IntAlloc ( Gia_ManCoNum (pNew ) );
657+ Gia_ManForEachObjVec ( vCos , p , pObj , i )
658+ Vec_IntPush ( pNew -> vCoReqs , nLevels - Gia_ObjLevel (p , pObj ) );
659+ }
650660 return pNew ;
651661}
652- Vec_Ptr_t * Gia_ManDupWindows ( Gia_Man_t * pMan , Vec_Ptr_t * vvIns , Vec_Ptr_t * vvNodes , Vec_Ptr_t * vvOuts )
662+ Vec_Ptr_t * Gia_ManDupWindows ( Gia_Man_t * pMan , Vec_Ptr_t * vvIns , Vec_Ptr_t * vvNodes , Vec_Ptr_t * vvOuts , int fDelayOpt )
653663{
664+ // compute direct and reverse level
665+ Vec_Int_t * vLevels [2 ] = {NULL };
666+ if ( fDelayOpt ) {
667+ int Levels [2 ];
668+ Levels [0 ] = Gia_ManLevelNum ( pMan );
669+ ABC_SWAP ( Vec_Int_t * , vLevels [0 ], pMan -> vLevels );
670+ Levels [1 ] = Gia_ManLevelRNum ( pMan );
671+ ABC_SWAP ( Vec_Int_t * , vLevels [1 ], pMan -> vLevels );
672+ assert ( Levels [0 ] == Levels [1 ] );
673+ }
654674 Vec_Int_t * vNodes ; int i ;
655675 Vec_Ptr_t * vWins = Vec_PtrAlloc ( Vec_PtrSize (vvIns ) );
656676 assert ( Vec_PtrSize (vvIns ) == Vec_PtrSize (vvNodes ) );
@@ -660,9 +680,11 @@ Vec_Ptr_t * Gia_ManDupWindows( Gia_Man_t * pMan, Vec_Ptr_t * vvIns, Vec_Ptr_t *
660680 Vec_PtrForEachEntry ( Vec_Int_t * , vvNodes , vNodes , i ) {
661681 Vec_Int_t * vIns = (Vec_Int_t * )Vec_PtrEntry (vvIns , i );
662682 Vec_Int_t * vOuts = (Vec_Int_t * )Vec_PtrEntry (vvOuts , i );
663- Gia_Man_t * pNew = Gia_ManDupFromArrays ( pMan , vIns , vNodes , vOuts );
683+ Gia_Man_t * pNew = Gia_ManDupFromArrays ( pMan , vIns , vNodes , vOuts , vLevels , pMan -> nLevels );
664684 Vec_PtrPush ( vWins , pNew );
665685 }
686+ Vec_IntFreeP ( & vLevels [0 ] );
687+ Vec_IntFreeP ( & vLevels [1 ] );
666688 return vWins ;
667689}
668690int Gia_ManLevelR ( Gia_Man_t * pMan )
@@ -675,7 +697,7 @@ int Gia_ManLevelR( Gia_Man_t * pMan )
675697 Gia_ObjSetLevel ( pMan , pNode , 0 );
676698 return LevelMax ;
677699}
678- Vec_Ptr_t * Gia_ManExtractPartitions ( Gia_Man_t * pMan , int Iter , int nSuppMax , Vec_Ptr_t * * pvIns , Vec_Ptr_t * * pvOuts , Vec_Ptr_t * * pvNodes , int fOverlap )
700+ Vec_Ptr_t * Gia_ManExtractPartitions ( Gia_Man_t * pMan , int Iter , int nSuppMax , Vec_Ptr_t * * pvIns , Vec_Ptr_t * * pvOuts , Vec_Ptr_t * * pvNodes , int fOverlap , int fDelayOpt )
679701{
680702 // if ( Gia_ManCiNum(pMan) <= nSuppMax ) {
681703 // Vec_Ptr_t * vWins = Vec_PtrAlloc( 1 );
@@ -695,7 +717,7 @@ Vec_Ptr_t * Gia_ManExtractPartitions( Gia_Man_t * pMan, int Iter, int nSuppMax,
695717 Vec_Ptr_t * vIns = Gia_ManDeriveWinInsAll ( vSupps , nSuppMax , pMan , fOverlap );
696718 Vec_Ptr_t * vNodes = Gia_ManDeriveWinNodesAll ( pMan , vIns , vStore );
697719 Vec_Ptr_t * vOuts = Gia_ManDeriveWinOutsAll ( pMan , vNodes );
698- Vec_Ptr_t * vWins = Gia_ManDupWindows ( pMan , vIns , vNodes , vOuts );
720+ Vec_Ptr_t * vWins = Gia_ManDupWindows ( pMan , vIns , vNodes , vOuts , fDelayOpt );
699721 Vec_WecFree ( vSupps );
700722 Vec_WecFree ( vStore );
701723 * pvIns = vIns ;
@@ -742,7 +764,7 @@ void Gia_ManCollectNodes( Gia_Man_t * p, Vec_Int_t * vCis, Vec_Int_t * vAnds, Ve
742764 Vec_IntForEachEntry ( vCos , iObj , i )
743765 Gia_ManCollectNodes_rec ( p , iObj , vAnds );
744766}
745- Gia_Man_t * Gia_ManDupDivideOne ( Gia_Man_t * p , Vec_Int_t * vCis , Vec_Int_t * vAnds , Vec_Int_t * vCos )
767+ Gia_Man_t * Gia_ManDupDivideOne ( Gia_Man_t * p , Vec_Int_t * vCis , Vec_Int_t * vAnds , Vec_Int_t * vCos , Vec_Int_t * vLevels [ 2 ], int nLevels )
746768{
747769 Vec_Int_t * vMapping ; int i ;
748770 Gia_Man_t * pNew ; Gia_Obj_t * pObj ;
@@ -757,8 +779,16 @@ Gia_Man_t * Gia_ManDupDivideOne( Gia_Man_t * p, Vec_Int_t * vCis, Vec_Int_t * vA
757779 Gia_ManForEachObjVec ( vCos , p , pObj , i )
758780 Gia_ManAppendCo ( pNew , pObj -> Value );
759781 assert ( Gia_ManCiNum (pNew ) > 0 && Gia_ManCoNum (pNew ) > 0 );
760- if ( !Gia_ManHasMapping (p ) )
782+ if ( !Gia_ManHasMapping (p ) ) {
783+ if ( vLevels [0 ] == NULL ) return pNew ;
784+ pNew -> vCiArrs = Vec_IntAlloc ( Gia_ManCiNum (pNew ) );
785+ Gia_ManForEachObjVec ( vCis , p , pObj , i )
786+ Vec_IntPush ( pNew -> vCiArrs , Gia_ObjLevel (p , pObj ) );
787+ pNew -> vCoReqs = Vec_IntAlloc ( Gia_ManCoNum (pNew ) );
788+ Gia_ManForEachObjVec ( vCos , p , pObj , i )
789+ Vec_IntPush ( pNew -> vCoReqs , nLevels - Gia_ObjLevel (p , pObj ) );
761790 return pNew ;
791+ }
762792 vMapping = Vec_IntAlloc ( 4 * Gia_ManObjNum (pNew ) );
763793 Vec_IntFill ( vMapping , Gia_ManObjNum (pNew ), 0 );
764794 Gia_ManForEachObjVec ( vAnds , p , pObj , i )
@@ -776,17 +806,29 @@ Gia_Man_t * Gia_ManDupDivideOne( Gia_Man_t * p, Vec_Int_t * vCis, Vec_Int_t * vA
776806 pNew -> vMapping = vMapping ;
777807 return pNew ;
778808}
779- Vec_Ptr_t * Gia_ManDupDivide ( Gia_Man_t * p , Vec_Wec_t * vCis , Vec_Wec_t * vAnds , Vec_Wec_t * vCos , char * pScript , int nProcs , int TimeOut )
809+ Vec_Ptr_t * Gia_ManDupDivide ( Gia_Man_t * p , Vec_Wec_t * vCis , Vec_Wec_t * vAnds , Vec_Wec_t * vCos , char * pScript , int nProcs , int TimeOut , int fDelayOpt )
780810{
811+ // compute direct and reverse level
812+ Vec_Int_t * vLevels [2 ] = {NULL };
813+ if ( fDelayOpt ) {
814+ int Levels [2 ];
815+ Levels [0 ] = Gia_ManLevelNum ( p );
816+ ABC_SWAP ( Vec_Int_t * , vLevels [0 ], p -> vLevels );
817+ Levels [1 ] = Gia_ManLevelRNum ( p );
818+ ABC_SWAP ( Vec_Int_t * , vLevels [1 ], p -> vLevels );
819+ assert ( Levels [0 ] == Levels [1 ] );
820+ }
781821 Vec_Ptr_t * vAigs = Vec_PtrAlloc ( Vec_WecSize (vCis ) ); int i ;
782822 for ( i = 0 ; i < Vec_WecSize (vCis ); i ++ )
783823 {
784824 Gia_ManCollectNodes ( p , Vec_WecEntry (vCis , i ), Vec_WecEntry (vAnds , i ), Vec_WecEntry (vCos , i ) );
785- Vec_PtrPush ( vAigs , Gia_ManDupDivideOne (p , Vec_WecEntry (vCis , i ), Vec_WecEntry (vAnds , i ), Vec_WecEntry (vCos , i )) );
825+ Vec_PtrPush ( vAigs , Gia_ManDupDivideOne (p , Vec_WecEntry (vCis , i ), Vec_WecEntry (vAnds , i ), Vec_WecEntry (vCos , i ), vLevels , p -> nLevels ) );
786826 }
787827 //Gia_ManStochSynthesis( vAigs, pScript );
788828 Vec_Int_t * vGains = Gia_StochProcess ( vAigs , pScript , nProcs , TimeOut , 0 );
789829 Vec_IntFree ( vGains );
830+ Vec_IntFreeP ( & vLevels [0 ] );
831+ Vec_IntFreeP ( & vLevels [1 ] );
790832 return vAigs ;
791833}
792834Gia_Man_t * Gia_ManDupStitch ( Gia_Man_t * p , Vec_Wec_t * vCis , Vec_Wec_t * vAnds , Vec_Wec_t * vCos , Vec_Ptr_t * vAigs , int fHash )
@@ -982,7 +1024,7 @@ Vec_Wec_t * Gia_ManStochOutputs( Gia_Man_t * p, Vec_Wec_t * vAnds )
9821024 SeeAlso []
9831025
9841026***********************************************************************/
985- void Gia_ManStochSyn ( int nSuppMax , int nMaxSize , int nIters , int TimeOut , int Seed , int fVerbose , char * pScript , int nProcs )
1027+ void Gia_ManStochSyn ( int nSuppMax , int nMaxSize , int nIters , int TimeOut , int Seed , int fVerbose , char * pScript , int nProcs , int fDelayOpt )
9861028{
9871029 abctime nTimeToStop = TimeOut ? Abc_Clock () + TimeOut * CLOCKS_PER_SEC : 0 ;
9881030 abctime clkStart = Abc_Clock ();
@@ -1008,7 +1050,7 @@ void Gia_ManStochSyn( int nSuppMax, int nMaxSize, int nIters, int TimeOut, int S
10081050 Vec_Wec_t * vAnds = Gia_ManStochNodes ( pGia , nMaxSize , Abc_Random (0 ) & 0x7FFFFFFF );
10091051 Vec_Wec_t * vIns = Gia_ManStochInputs ( pGia , vAnds );
10101052 Vec_Wec_t * vOuts = Gia_ManStochOutputs ( pGia , vAnds );
1011- Vec_Ptr_t * vAigs = Gia_ManDupDivide ( pGia , vIns , vAnds , vOuts , pScript , nProcs , TimeOut );
1053+ Vec_Ptr_t * vAigs = Gia_ManDupDivide ( pGia , vIns , vAnds , vOuts , pScript , nProcs , TimeOut , fDelayOpt );
10121054 Gia_Man_t * pNew = Gia_ManDupStitchMap ( pGia , vIns , vAnds , vOuts , vAigs );
10131055 int fMapped = Gia_ManHasMapping (pGia ) && Gia_ManHasMapping (pNew );
10141056 Abc_FrameUpdateGia ( Abc_FrameGetGlobalFrame (), pNew );
@@ -1039,9 +1081,9 @@ void Gia_ManStochSyn( int nSuppMax, int nMaxSize, int nIters, int TimeOut, int S
10391081 extern Gia_Man_t * Gia_ManDupInsertWindows ( Gia_Man_t * p , Vec_Ptr_t * vvIns , Vec_Ptr_t * vvOuts , Vec_Ptr_t * vAigs );
10401082 abctime clk = Abc_Clock ();
10411083 Gia_Man_t * pGia = Gia_ManDup ( Abc_FrameReadGia (Abc_FrameGetGlobalFrame ()) ); Gia_ManStaticFanoutStart (pGia );
1042- Vec_Ptr_t * vAigs = Gia_ManExtractPartitions ( pGia , i , nSuppMax , & vIns , & vOuts , & vNodes , fOverlap );
1084+ Vec_Ptr_t * vAigs = Gia_ManExtractPartitions ( pGia , i , nSuppMax , & vIns , & vOuts , & vNodes , fOverlap , fDelayOpt );
10431085 Vec_Int_t * vGains = Gia_StochProcess ( vAigs , pScript , nProcs , TimeOut , 0 );
1044- int nPartsInit = fOverlap ? Gia_ManFilterPartitions ( pGia , vIns , vNodes , vOuts , vAigs , vGains ) : Vec_PtrSize (vIns );
1086+ int nPartsInit = fOverlap ? Gia_ManFilterPartitions ( pGia , vIns , vNodes , vOuts , vAigs , vGains , fDelayOpt ) : Vec_PtrSize (vIns );
10451087 Gia_Man_t * pNew = Gia_ManDupInsertWindows ( pGia , vIns , vOuts , vAigs ); Gia_ManStaticFanoutStop (pGia );
10461088 Abc_FrameUpdateGia ( Abc_FrameGetGlobalFrame (), pNew );
10471089 if ( fVerbose )
0 commit comments