@@ -1257,7 +1257,7 @@ Vec_Str_t * Gia_ManRetimableF( Gia_Man_t * p, int * pRst, int * pSet, int * pEna
12571257 int * pNode = Vec_IntEntryP ( vTemps , 3 * i );
12581258 pStops [i ] = (char )1 ;
12591259 if ( pFan0 [0 ] != -1 && pFan0 [0 ] == pFan1 [0 ] && pFan0 [1 ] == pFan1 [1 ] && pFan0 [2 ] == pFan1 [2 ] )
1260- pStops [i ] = (char )0 , pNode [0 ] = pFan0 [0 ], pNode [1 ] = pFan0 [1 ], pNode [2 ] = pFan0 [2 ];
1260+ pStops [i ] = (char )0 , pNode [0 ] = pFan0 [0 ], pNode [1 ] = pFan0 [1 ], pNode [2 ] = pFan0 [2 ];
12611261 }
12621262 Vec_IntFree ( vTemps );
12631263 return vStops ;
@@ -1266,32 +1266,37 @@ Vec_Str_t * Gia_ManRetimableB( Gia_Man_t * p, int * pRst, int * pSet, int * pEna
12661266{
12671267 Vec_Str_t * vStops = Vec_StrStart ( Gia_ManObjNum (p ) );
12681268 Vec_Int_t * vTemps = Vec_IntStartFull ( 3 * Gia_ManObjNum (p ) );
1269- Gia_Obj_t * pObj , * pObjRi , * pObjRo ; int i , n ;
1269+ Gia_Obj_t * pObj , * pObjRi , * pObjRo ; int i , n , iFanout ;
12701270 char * pStops = Vec_StrArray (vStops );
12711271 assert ( Gia_ManRegNum (p ) > 0 );
12721272 Gia_ManForEachRiRo ( p , pObjRi , pObjRo , i ) {
1273- Vec_IntWriteEntry ( vTemps , 3 * Gia_ObjFaninId0p (p , pObjRi ) + 0 , pRst [i ] );
1274- Vec_IntWriteEntry ( vTemps , 3 * Gia_ObjFaninId0p (p , pObjRi ) + 1 , pSet [i ] );
1275- Vec_IntWriteEntry ( vTemps , 3 * Gia_ObjFaninId0p (p , pObjRi ) + 2 , pEna [i ] );
1273+ Vec_IntWriteEntry ( vTemps , 3 * Gia_ObjId (p , pObjRi ) + 0 , pRst [i ] );
1274+ Vec_IntWriteEntry ( vTemps , 3 * Gia_ObjId (p , pObjRi ) + 1 , pSet [i ] );
1275+ Vec_IntWriteEntry ( vTemps , 3 * Gia_ObjId (p , pObjRi ) + 2 , pEna [i ] );
12761276 }
1277+ Gia_ManStaticFanoutStart ( p );
12771278 Gia_ManForEachAndReverse ( p , pObj , i ) {
1278- int iFans [2 ] = { Gia_ObjFaninId0 (pObj , i ), Gia_ObjFaninId1 (pObj , i ) };
1279- int * pFans [2 ] = { Vec_IntEntryP ( vTemps , 3 * iFans [0 ] ), Vec_IntEntryP ( vTemps , 3 * iFans [1 ] ) };
1279+ int * pFan0 = Vec_IntEntryP ( vTemps , 3 * Gia_ObjFanoutId (p , i , 0 ) );
12801280 int * pNode = Vec_IntEntryP ( vTemps , 3 * i );
1281- if ( pNode [0 ] == -1 )
1281+ pStops [i ] = (char )1 ;
1282+ if ( pFan0 [0 ] == -1 )
12821283 continue ;
1283- for ( n = 0 ; n < 2 ; n ++ )
1284- if ( pFans [n ][0 ] == -1 )
1285- pStops [iFans [n ]] = (char )1 , pFans [n ][0 ] = pNode [0 ], pFans [n ][1 ] = pNode [1 ], pFans [n ][2 ] = pNode [2 ];
1286- else if ( pFans [n ][0 ] != pNode [0 ] || pFans [n ][1 ] != pNode [1 ] || pFans [n ][2 ] != pNode [2 ] )
1287- pStops [iFans [n ]] = (char )0 ;
1284+ Gia_ObjForEachFanoutStaticId ( p , i , iFanout , n ) {
1285+ int * pFan1 = Vec_IntEntryP ( vTemps , 3 * iFanout );
1286+ if ( pFan1 [0 ] == -1 || pFan0 [0 ] != pFan1 [0 ] || pFan0 [1 ] != pFan1 [1 ] || pFan0 [2 ] != pFan1 [2 ] )
1287+ break ;
1288+ }
1289+ if ( n < Gia_ObjFanoutNum (p , pObj ) )
1290+ continue ;
1291+ pStops [i ] = (char )0 , pNode [0 ] = pFan0 [0 ], pNode [1 ] = pFan0 [1 ], pNode [2 ] = pFan0 [2 ];
12881292 }
1289- pStops [0 ] = (char )0 ;
1290- Gia_ManForEachCi ( p , pObj , i )
1291- pStops [Gia_ObjId (p , pObj )] = (char )0 ;
1292- Gia_ManForEachAnd ( p , pObj , i )
1293- pStops [i ] = (char )!pStops [i ];
1294- Vec_IntFree ( vTemps );
1293+ Gia_ManStaticFanoutStop ( p );
1294+ Vec_IntFree ( vTemps );
1295+ Gia_ManForEachRiRo ( p , pObjRi , pObjRo , i ) {
1296+ if ( Gia_ObjIsAnd (Gia_ManObj (p , Abc_Lit2Var (pRst [i ]))) ) pStops [Abc_Lit2Var (pRst [i ])] = 1 ;
1297+ if ( Gia_ObjIsAnd (Gia_ManObj (p , Abc_Lit2Var (pSet [i ]))) ) pStops [Abc_Lit2Var (pSet [i ])] = 1 ;
1298+ if ( Gia_ObjIsAnd (Gia_ManObj (p , Abc_Lit2Var (pEna [i ]))) ) pStops [Abc_Lit2Var (pEna [i ])] = 1 ;
1299+ }
12951300 return vStops ;
12961301}
12971302
@@ -1306,18 +1311,42 @@ Vec_Str_t * Gia_ManRetimableB( Gia_Man_t * p, int * pRst, int * pSet, int * pEna
13061311 SeeAlso []
13071312
13081313***********************************************************************/
1309- void Abc_FrameSetRetimingData ( Abc_Frame_t * pAbc , int * pRst , int * pSet , int * pEna )
1314+ void Abc_FrameRemapLits ( int * pLits , int nLits , Vec_Int_t * vMap )
1315+ {
1316+ for ( int i = 0 ; i < nLits ; i ++ )
1317+ pLits [i ] = Abc_Lit2LitL ( Vec_IntArray (vMap ), pLits [i ] );
1318+ }
1319+ void Abc_FrameSetRetimingData ( Abc_Frame_t * pAbc , int * pRst , int * pSet , int * pEna , int nRegs )
13101320{
13111321 Gia_Man_t * pGia ;
1322+ int * pRstNew = ABC_CALLOC ( int , nRegs );
1323+ int * pSetNew = ABC_CALLOC ( int , nRegs );
1324+ int * pEnaNew = ABC_CALLOC ( int , nRegs );
13121325 if ( pAbc == NULL )
13131326 printf ( "ABC framework is not initialized by calling Abc_Start()\n" );
13141327 pGia = Abc_FrameReadGia ( pAbc );
13151328 if ( pGia == NULL )
13161329 printf ( "Current network in ABC framework is not defined.\n" );
1330+ else {
1331+ assert ( nRegs == Gia_ManRegNum (pGia ) );
1332+ memmove ( pRstNew , pRst , sizeof (int )* nRegs );
1333+ memmove ( pSetNew , pSet , sizeof (int )* nRegs );
1334+ memmove ( pEnaNew , pEna , sizeof (int )* nRegs );
1335+ }
1336+ if ( pAbc -> vCopyMiniAig == NULL )
1337+ printf ( "Mapping of MiniAig nodes is not available.\n" );
1338+ else {
1339+ Abc_FrameRemapLits ( pRstNew , nRegs , pAbc -> vCopyMiniAig );
1340+ Abc_FrameRemapLits ( pSetNew , nRegs , pAbc -> vCopyMiniAig );
1341+ Abc_FrameRemapLits ( pEnaNew , nRegs , pAbc -> vCopyMiniAig );
1342+ }
13171343 assert ( pGia -> vStopsF == NULL );
13181344 assert ( pGia -> vStopsB == NULL );
1319- pGia -> vStopsF = Gia_ManRetimableF ( pGia , pRst , pSet , pEna );
1320- pGia -> vStopsB = Gia_ManRetimableB ( pGia , pRst , pSet , pEna );
1345+ pGia -> vStopsF = Gia_ManRetimableF ( pGia , pRstNew , pSetNew , pEnaNew );
1346+ pGia -> vStopsB = Gia_ManRetimableB ( pGia , pRstNew , pSetNew , pEnaNew );
1347+ ABC_FREE ( pRstNew );
1348+ ABC_FREE ( pSetNew );
1349+ ABC_FREE ( pEnaNew );
13211350}
13221351
13231352////////////////////////////////////////////////////////////////////////
0 commit comments