/**Function************************************************************* Synopsis [Insert the last Lat on the edge.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Seq_NodeCompareLats( Abc_Obj_t * pObj1, int Edge1, Abc_Obj_t * pObj2, int Edge2 ) { Seq_Lat_t * pRing1, * pRing2, * pLat1, * pLat2; int i, nLatches1, nLatches2; nLatches1 = Seq_NodeCountLats( pObj1, Edge1 ); nLatches2 = Seq_NodeCountLats( pObj2, Edge2 ); if ( nLatches1 != nLatches2 ) return 0; pRing1 = Seq_NodeGetRing( pObj1, Edge1 ); pRing2 = Seq_NodeGetRing( pObj2, Edge2 ); for ( i = 0, pLat1 = pRing1, pLat2 = pRing2; i < nLatches1; i++, pLat1 = pLat1->pNext, pLat2 = pLat2->pNext ) if ( Seq_LatInit(pLat1) != Seq_LatInit(pLat2) ) return 0; return 1; }
/**Function************************************************************* Synopsis [Insert the last Lat on the edge.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Seq_NodeDupLats( Abc_Obj_t * pObjNew, Abc_Obj_t * pObj, int Edge ) { Seq_Lat_t * pRing, * pLat; int i, nLatches; pRing = Seq_NodeGetRing( pObj, Edge ); if ( pRing == NULL ) return; nLatches = Seq_NodeCountLats( pObj, Edge ); for ( i = 0, pLat = pRing; i < nLatches; i++, pLat = pLat->pNext ) Seq_NodeInsertLast( pObjNew, Edge, Seq_LatInit(pLat) ); }
/**Function************************************************************* Synopsis [Delete the last Lat on the edge.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Abc_InitType_t Seq_NodeDeleteLast( Abc_Obj_t * pObj, int Edge ) { Abc_InitType_t Init; Seq_Lat_t * pLat, * pRing, * pPrev, * pNext; pRing = Seq_NodeGetRing( pObj, Edge ); pLat = Seq_LatPrev( pRing ); // consider the last latch if ( pLat->pNext == pLat ) Seq_NodeSetRing( pObj, Edge, NULL ); else { pPrev = Seq_LatPrev( pLat ); pNext = Seq_LatNext( pLat ); Seq_LatSetPrev( pNext, pPrev ); Seq_LatSetNext( pPrev, pNext ); } Init = Seq_LatInit( pLat ); Seq_NodeRecycleLat( pObj, pLat ); Seq_ObjAddFaninL( pObj, Edge, -1 ); return Init; }
/**Function************************************************************* Synopsis [Maps virtual latches into real latches.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Abc_Obj_t * Seq_NtkShareLatches_rec( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj, Seq_Lat_t * pRing, int nLatch, stmm_table * tLatchMap ) { Abc_Obj_t * pLatch, * pFanin; Abc_InitType_t Init; unsigned Key; if ( nLatch == 0 ) return pObj; assert( pRing->pLatch == NULL ); // get the latch on the previous level pFanin = Seq_NtkShareLatches_rec( pNtk, pObj, Seq_LatNext(pRing), nLatch - 1, tLatchMap ); // get the initial state Init = Seq_LatInit( pRing ); // check if the latch with this initial state exists Key = Seq_NtkShareLatchesKey( pFanin, Init ); if ( stmm_lookup( tLatchMap, (char *)Key, (char **)&pLatch ) ) return pRing->pLatch = pLatch; // does not exist if ( Init != ABC_INIT_DC ) { // check if the don't-care exists Key = Seq_NtkShareLatchesKey( pFanin, ABC_INIT_DC ); if ( stmm_lookup( tLatchMap, (char *)Key, (char **)&pLatch ) ) // yes { // update the table stmm_delete( tLatchMap, (char **)&Key, (char **)&pLatch ); Key = Seq_NtkShareLatchesKey( pFanin, Init ); stmm_insert( tLatchMap, (char *)Key, (char *)pLatch ); // change don't-care to the given value pLatch->pData = (void *)Init; return pRing->pLatch = pLatch; } // add the latch with this value pLatch = Abc_NtkCreateLatch( pNtk ); pLatch->pData = (void *)Init; Abc_ObjAddFanin( pLatch, pFanin ); // add it to the table Key = Seq_NtkShareLatchesKey( pFanin, Init ); stmm_insert( tLatchMap, (char *)Key, (char *)pLatch ); return pRing->pLatch = pLatch; } // the init value is the don't-care // check if care values exist Key = Seq_NtkShareLatchesKey( pFanin, ABC_INIT_ZERO ); if ( stmm_lookup( tLatchMap, (char *)Key, (char **)&pLatch ) ) { Seq_LatSetInit( pRing, ABC_INIT_ZERO ); return pRing->pLatch = pLatch; } Key = Seq_NtkShareLatchesKey( pFanin, ABC_INIT_ONE ); if ( stmm_lookup( tLatchMap, (char *)Key, (char **)&pLatch ) ) { Seq_LatSetInit( pRing, ABC_INIT_ONE ); return pRing->pLatch = pLatch; } // create the don't-care latch pLatch = Abc_NtkCreateLatch( pNtk ); pLatch->pData = (void *)ABC_INIT_DC; Abc_ObjAddFanin( pLatch, pFanin ); // add it to the table Key = Seq_NtkShareLatchesKey( pFanin, ABC_INIT_DC ); stmm_insert( tLatchMap, (char *)Key, (char *)pLatch ); return pRing->pLatch = pLatch; }