/**Function************************************************************* Synopsis [Prepares the network for retiming.] Description [Hash latches into their number in the original network.] SideEffects [] SeeAlso [] ***********************************************************************/ st__table * Abc_NtkRetimePrepareLatches( Abc_Ntk_t * pNtk ) { st__table * tLatches; Abc_Obj_t * pLatch, * pLatchIn, * pLatchOut, * pFanin; int i, nOffSet = Abc_NtkBoxNum(pNtk) - Abc_NtkLatchNum(pNtk); // collect latches and remove CIs/COs tLatches = st__init_table( st__ptrcmp, st__ptrhash ); Abc_NtkForEachLatch( pNtk, pLatch, i ) { // map latch into its true number st__insert( tLatches, (char *)(ABC_PTRUINT_T)pLatch, (char *)(ABC_PTRUINT_T)(i-nOffSet) ); // disconnect LI pLatchIn = Abc_ObjFanin0(pLatch); pFanin = Abc_ObjFanin0(pLatchIn); Abc_ObjTransferFanout( pLatchIn, pFanin ); Abc_ObjDeleteFanin( pLatchIn, pFanin ); // disconnect LO pLatchOut = Abc_ObjFanout0(pLatch); pFanin = Abc_ObjFanin0(pLatchOut); if ( Abc_ObjFanoutNum(pLatchOut) > 0 ) Abc_ObjTransferFanout( pLatchOut, pFanin ); Abc_ObjDeleteFanin( pLatchOut, pFanin ); }
/**Function************************************************************* Synopsis [Destroys fanout/fanin relationship between the nodes.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Abc_ObjRemoveFanins( Abc_Obj_t * pObj ) { Vec_Int_t * vFaninsOld; Abc_Obj_t * pFanin; int k; // remove old fanins vFaninsOld = &pObj->vFanins; for ( k = vFaninsOld->nSize - 1; k >= 0; k-- ) { pFanin = Abc_NtkObj( pObj->pNtk, vFaninsOld->pArray[k] ); Abc_ObjDeleteFanin( pObj, pFanin ); } pObj->fCompl0 = 0; pObj->fCompl1 = 0; assert( vFaninsOld->nSize == 0 ); }
Abc_Ntk_t * My_Command_Associative(Abc_Ntk_t * pNtk) {// check abc.h and abcNtk.c(Abc_ntkDup, duplication) freeXXX //a new network to return printf("inside the My_Command_Associative\n"); Abc_Ntk_t * new_pNtk; Abc_Obj_t * pObj; int i, j,k,m; int changed = 0; //check partial nodes satisfying a certain associative law Abc_NtkForEachObj( pNtk, pObj, i) { //printf("Node ID: %d \n", Abc_ObjId(pObj)); //printf("FanInNum: %d \n",Abc_ObjFaninNum(pObj)); if(changed <1 && Abc_ObjFaninNum(pObj) == 2 && !Abc_ObjFaninC0(pObj) && !Abc_ObjFaninC1(pObj) ) { Abc_Obj_t * pFanin_0 = Abc_ObjFanin0(pObj); Abc_Obj_t * pFanin_1 = Abc_ObjFanin1(pObj); // (x*y)*z => x*(y*z) if(changed <1 && Abc_ObjFaninNum(pFanin_0) == 2 && !Abc_ObjFaninC0(pFanin_0) && !Abc_ObjFaninC1(pFanin_0) ) // (x*y)*z => x*(y*z) { printf("1st Condition, Node ID: %d\n",Abc_ObjId(pObj) ); printf("Abc_ObjFaninNum(pFanin_0): Node ID: %d\n",Abc_ObjId(pFanin_0) ); Abc_Obj_t * tempObj; Abc_Obj_t * pFanin_0_0 = Abc_ObjFanin0(pFanin_0); Abc_Obj_t * pFanin_0_1 = Abc_ObjFanin1(pFanin_0); Abc_Obj_t * NewParentNode = Abc_NtkDupObj(pNtk, pObj, 1); Abc_Obj_t * NewChildNode = Abc_NtkDupObj(pNtk, pFanin_0, 1); int FanoutNum = Abc_ObjFanoutNum(pObj); for (j=0; j<FanoutNum; j++) { tempObj = Abc_ObjFanout(pObj, j); Abc_ObjDeleteFanin( tempObj , pObj ); Abc_ObjAddFanin( tempObj, NewParentNode); } printf("ParentNode Created and connected\n" ); Abc_ObjAddFanin(NewParentNode,pFanin_0_0 ); Abc_ObjAddFanin( NewParentNode, NewChildNode ); Abc_ObjAddFanin( NewChildNode, pFanin_0_1); Abc_ObjAddFanin(NewChildNode,pFanin_1 ); printf("ChildNode Created and connected\n" ); printf("Abc_ObjFanoutNum(pFanin_0): %d\n",Abc_ObjFanoutNum(pFanin_0) ); if(Abc_ObjFanoutNum(pFanin_0)>1) { printf("pFanin_0 's FanOut > 1\n" ); } else { Abc_ObjForEachFanin(pFanin_0,tempObj, k ) { Abc_ObjDeleteFanin(pFanin_0,tempObj); } Abc_NtkDeleteObj(pFanin_0); } Abc_ObjForEachFanin(pObj,tempObj, k ) { Abc_ObjDeleteFanin(pObj,tempObj); }