void Dar_BalanceUniqify( Aig_Obj_t * pObj, Vec_Ptr_t * vNodes, int fExor ) { Aig_Obj_t * pTemp, * pTempNext; int i, k; // sort the nodes by their literal Vec_PtrSort( vNodes, (int (*)())Dar_ObjCompareLits ); // remove duplicates k = 0; Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pTemp, i ) { if ( i + 1 == Vec_PtrSize(vNodes) ) { Vec_PtrWriteEntry( vNodes, k++, pTemp ); break; } pTempNext = (Aig_Obj_t *)Vec_PtrEntry( vNodes, i+1 ); if ( !fExor && pTemp == Aig_Not(pTempNext) ) // pos_lit & neg_lit = 0 { Vec_PtrClear( vNodes ); return; } if ( pTemp != pTempNext ) // save if different Vec_PtrWriteEntry( vNodes, k++, pTemp ); else if ( fExor ) // in case of XOR, remove identical i++; } Vec_PtrShrink( vNodes, k ); // check that there is no duplicates pTemp = (Aig_Obj_t *)Vec_PtrEntry( vNodes, 0 ); Vec_PtrForEachEntryStart( Aig_Obj_t *, vNodes, pTempNext, i, 1 ) { assert( pTemp != pTempNext ); pTemp = pTempNext; } }
/**Function************************************************************* Synopsis [Finds the left bound on the next candidate to be paired.] Description [The nodes in the array are in the decreasing order of levels. The last node in the array has the smallest level. By default it would be paired with the next node on the left. However, it may be possible to pair it with some other node on the left, in such a way that the new node is shared. This procedure finds the index of the left-most node, which can be paired with the last node.] SideEffects [] SeeAlso [] ***********************************************************************/ int Dar_BalanceFindLeft( Vec_Ptr_t * vSuper ) { Aig_Obj_t * pObjRight, * pObjLeft; int Current; // if two or less nodes, pair with the first if ( Vec_PtrSize(vSuper) < 3 ) return 0; // set the pointer to the one before the last Current = Vec_PtrSize(vSuper) - 2; pObjRight = (Aig_Obj_t *)Vec_PtrEntry( vSuper, Current ); // go through the nodes to the left of this one for ( Current--; Current >= 0; Current-- ) { // get the next node on the left pObjLeft = (Aig_Obj_t *)Vec_PtrEntry( vSuper, Current ); // if the level of this node is different, quit the loop if ( Aig_ObjLevel(Aig_Regular(pObjLeft)) != Aig_ObjLevel(Aig_Regular(pObjRight)) ) break; } Current++; // get the node, for which the equality holds pObjLeft = (Aig_Obj_t *)Vec_PtrEntry( vSuper, Current ); assert( Aig_ObjLevel(Aig_Regular(pObjLeft)) == Aig_ObjLevel(Aig_Regular(pObjRight)) ); return Current; }
/**Function************************************************************* Synopsis [Maps the function by the best cofactoring.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ If_Obj_t * Lpk_MapTreeMux_rec( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj_t ** ppLeaves ) { unsigned * pCof0 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 0 ); unsigned * pCof1 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 1 ); If_Obj_t * pObj0, * pObj1; Kit_DsdNtk_t * ppNtks[2]; int iBestVar; assert( nVars > 3 ); p->fCalledOnce = 1; // cofactor w.r.t. the best variable iBestVar = Lpk_MapTreeBestCofVar( p, pTruth, nVars, pCof0, pCof1 ); if ( iBestVar == -1 ) return NULL; // decompose the functions ppNtks[0] = Kit_DsdDecompose( pCof0, nVars ); ppNtks[1] = Kit_DsdDecompose( pCof1, nVars ); if ( p->pPars->fVeryVerbose ) { printf( "Cofactoring w.r.t. var %c (%d -> %d+%d supp vars):\n", 'a'+iBestVar, nVars, Kit_TruthSupportSize(pCof0, nVars), Kit_TruthSupportSize(pCof1, nVars) ); Kit_DsdPrintExpanded( ppNtks[0] ); Kit_DsdPrintExpanded( ppNtks[1] ); } // map the DSD structures pObj0 = Lpk_MapTree_rec( p, ppNtks[0], ppLeaves, ppNtks[0]->Root, NULL ); pObj1 = Lpk_MapTree_rec( p, ppNtks[1], ppLeaves, ppNtks[1]->Root, NULL ); Kit_DsdNtkFree( ppNtks[0] ); Kit_DsdNtkFree( ppNtks[1] ); return If_ManCreateMux( p->pIfMan, pObj0, pObj1, ppLeaves[iBestVar] ); }
/**Function************************************************************* Synopsis [Returns the probability of POs being 1 under rand seq sim.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Ssw_ManProfileConstraints( Aig_Man_t * p, int nWords, int nFrames, int fVerbose ) { Vec_Ptr_t * vInfo; Vec_Int_t * vProbs, * vProbs2; Aig_Obj_t * pObj, * pObjLi; unsigned * pInfo, * pInfo0, * pInfo1, * pInfoMask, * pInfoMask2; int i, w, f, RetValue = 1, clk = clock(); if ( fVerbose ) printf( "Simulating %d nodes and %d flops for %d frames with %d words... ", Aig_ManNodeNum(p), Aig_ManRegNum(p), nFrames, nWords ); Aig_ManRandom( 1 ); vInfo = Vec_PtrAllocSimInfo( Aig_ManObjNumMax(p)+2, nWords ); Vec_PtrCleanSimInfo( vInfo, 0, nWords ); vProbs = Vec_IntStart( Saig_ManPoNum(p) ); vProbs2 = Vec_IntStart( Saig_ManPoNum(p) ); // start the constant pInfo = (unsigned *)Vec_PtrEntry( vInfo, Aig_ObjId(Aig_ManConst1(p)) ); for ( w = 0; w < nWords; w++ ) pInfo[w] = ~0; // start the flop inputs Saig_ManForEachLi( p, pObj, i ) { pInfo = (unsigned *)Vec_PtrEntry( vInfo, Aig_ObjId(pObj) ); for ( w = 0; w < nWords; w++ ) pInfo[w] = 0; }
int Cba_PtrMemoryNtk( Vec_Ptr_t * vNtk ) { int nBytes = (int)Vec_PtrMemory(vNtk); nBytes += Cba_PtrMemoryArray( (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 1) ); nBytes += Cba_PtrMemoryArray( (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 2) ); nBytes += Cba_PtrMemoryArrayArray( (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 3) ); nBytes += Cba_PtrMemoryArrayArray( (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 4) ); return nBytes; }
void Cba_PtrDumpBoxVerilog( FILE * pFile, Vec_Ptr_t * vBox ) { char * pName; int i; fprintf( pFile, " %s", (char *)Vec_PtrEntry(vBox, 0) ); fprintf( pFile, " %s (", (char *)Vec_PtrEntry(vBox, 1) ); // write intance name in Verilog Vec_PtrForEachEntryStart( char *, vBox, pName, i, 2 ) fprintf( pFile, ".%s(%s)%s", pName, (char *)Vec_PtrEntry(vBox, i+1), i < Vec_PtrSize(vBox) - 2 ? ", ":"" ), i++; fprintf( pFile, ");\n" ); }
void Cba_PtrDumpBoxBlif( FILE * pFile, Vec_Ptr_t * vBox ) { char * pName; int i; fprintf( pFile, ".subckt" ); fprintf( pFile, " %s", (char *)Vec_PtrEntry(vBox, 0) ); //fprintf( pFile, " %s", (char *)Vec_PtrEntry(vBox, 1) ); // do not write intance name in BLIF Vec_PtrForEachEntryStart( char *, vBox, pName, i, 2 ) fprintf( pFile, " %s=%s", pName, (char *)Vec_PtrEntry(vBox, i+1) ), i++; fprintf( pFile, "\n" ); }
/**Function************************************************************* Synopsis [Moves closer to the end the node that is best for sharing.] Description [If there is no node with sharing, randomly chooses one of the legal nodes.] SideEffects [] SeeAlso [] ***********************************************************************/ void Dar_BalancePermute( Aig_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, int fExor ) { Aig_Obj_t * pObj1, * pObj2, * pObj3, * pGhost; int RightBound, i; // get the right bound RightBound = Vec_PtrSize(vSuper) - 2; assert( LeftBound <= RightBound ); if ( LeftBound == RightBound ) return; // get the two last nodes pObj1 = (Aig_Obj_t *)Vec_PtrEntry( vSuper, RightBound + 1 ); pObj2 = (Aig_Obj_t *)Vec_PtrEntry( vSuper, RightBound ); if ( Aig_Regular(pObj1) == p->pConst1 || Aig_Regular(pObj2) == p->pConst1 || Aig_Regular(pObj1) == Aig_Regular(pObj2) ) return; // find the first node that can be shared for ( i = RightBound; i >= LeftBound; i-- ) { pObj3 = (Aig_Obj_t *)Vec_PtrEntry( vSuper, i ); if ( Aig_Regular(pObj3) == p->pConst1 ) { Vec_PtrWriteEntry( vSuper, i, pObj2 ); Vec_PtrWriteEntry( vSuper, RightBound, pObj3 ); return; } if ( Aig_Regular(pObj1) == Aig_Regular(pObj3) ) { if ( pObj3 == pObj2 ) return; Vec_PtrWriteEntry( vSuper, i, pObj2 ); Vec_PtrWriteEntry( vSuper, RightBound, pObj3 ); return; } pGhost = Aig_ObjCreateGhost( p, pObj1, pObj3, fExor? AIG_OBJ_EXOR : AIG_OBJ_AND ); if ( Aig_TableLookup( p, pGhost ) ) { if ( pObj3 == pObj2 ) return; Vec_PtrWriteEntry( vSuper, i, pObj2 ); Vec_PtrWriteEntry( vSuper, RightBound, pObj3 ); return; } } /* // we did not find the node to share, randomize choice { int Choice = Aig_ManRandom(0) % (RightBound - LeftBound + 1); pObj3 = Vec_PtrEntry( vSuper, LeftBound + Choice ); if ( pObj3 == pObj2 ) return; Vec_PtrWriteEntry( vSuper, LeftBound + Choice, pObj2 ); Vec_PtrWriteEntry( vSuper, RightBound, pObj3 ); } */ }
/**Function************************************************************* Synopsis [Computes and adds all single-cube divisors to storage.] Description [This procedure should be called once when the matrix is already contructed before the process of logic extraction begins..] SideEffects [] SeeAlso [] ***********************************************************************/ void Fxu_MatrixComputeSingles( Fxu_Matrix * p, int fUse0, int nSingleMax ) { Fxu_Var * pVar; Vec_Ptr_t * vSingles; int i, k; // set the weight limit p->nWeightLimit = 1 - fUse0; // iterate through columns in the matrix and collect single-cube divisors vSingles = Vec_PtrAlloc( 10000 ); Fxu_MatrixForEachVariable( p, pVar ) Fxu_MatrixComputeSinglesOneCollect( p, pVar, vSingles ); p->nSingleTotal = Vec_PtrSize(vSingles) / 3; // check if divisors should be filtered if ( Vec_PtrSize(vSingles) > nSingleMax ) { int * pWeigtCounts, nDivCount, Weight, i, c;; assert( Vec_PtrSize(vSingles) % 3 == 0 ); // count how many divisors have the given weight pWeigtCounts = ABC_ALLOC( int, 1000 ); memset( pWeigtCounts, 0, sizeof(int) * 1000 ); for ( i = 2; i < Vec_PtrSize(vSingles); i += 3 ) { Weight = (int)(ABC_PTRUINT_T)Vec_PtrEntry(vSingles, i); if ( Weight >= 999 ) pWeigtCounts[999]++; else pWeigtCounts[Weight]++; } // select the bound on the weight (above this bound, singles will be included) nDivCount = 0; for ( c = 999; c >= 0; c-- ) { nDivCount += pWeigtCounts[c]; if ( nDivCount >= nSingleMax ) break; } ABC_FREE( pWeigtCounts ); // collect singles with the given costs k = 0; for ( i = 2; i < Vec_PtrSize(vSingles); i += 3 ) { Weight = (int)(ABC_PTRUINT_T)Vec_PtrEntry(vSingles, i); if ( Weight < c ) continue; Vec_PtrWriteEntry( vSingles, k++, Vec_PtrEntry(vSingles, i-2) ); Vec_PtrWriteEntry( vSingles, k++, Vec_PtrEntry(vSingles, i-1) ); Vec_PtrWriteEntry( vSingles, k++, Vec_PtrEntry(vSingles, i) ); if ( k/3 == nSingleMax ) break; } Vec_PtrShrink( vSingles, k ); // adjust the weight limit p->nWeightLimit = c; }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Io_ReadBlifReorderFormalNames( Vec_Ptr_t * vTokens, Mio_Gate_t * pGate ) { Mio_Pin_t * pGatePin; char * pName, * pNamePin; int i, k, nSize, Length; nSize = Vec_PtrSize(vTokens); if ( nSize - 3 != Mio_GateReadInputs(pGate) ) return 0; // check if the names are in order for ( pGatePin = Mio_GateReadPins(pGate), i = 0; pGatePin; pGatePin = Mio_PinReadNext(pGatePin), i++ ) { pNamePin = Mio_PinReadName(pGatePin); Length = strlen(pNamePin); pName = (char *)Vec_PtrEntry(vTokens, i+2); if ( !strncmp( pNamePin, pName, Length ) && pName[Length] == '=' ) continue; break; } if ( i == nSize - 3 ) return 1; // reorder the pins for ( pGatePin = Mio_GateReadPins(pGate), i = 0; pGatePin; pGatePin = Mio_PinReadNext(pGatePin), i++ ) { pNamePin = Mio_PinReadName(pGatePin); Length = strlen(pNamePin); for ( k = 2; k < nSize; k++ ) { pName = (char *)Vec_PtrEntry(vTokens, k); if ( !strncmp( pNamePin, pName, Length ) && pName[Length] == '=' ) { Vec_PtrPush( vTokens, pName ); break; } } } pNamePin = Mio_GateReadOutName(pGate); Length = strlen(pNamePin); for ( k = 2; k < nSize; k++ ) { pName = (char *)Vec_PtrEntry(vTokens, k); if ( !strncmp( pNamePin, pName, Length ) && pName[Length] == '=' ) { Vec_PtrPush( vTokens, pName ); break; } } if ( Vec_PtrSize(vTokens) - nSize != nSize - 2 ) return 0; Vec_PtrForEachEntryStart( char *, vTokens, pName, k, nSize ) Vec_PtrWriteEntry( vTokens, k - nSize + 2, pName ); Vec_PtrShrink( vTokens, nSize ); return 1; }
void Cba_PtrDumpModuleBlif( FILE * pFile, Vec_Ptr_t * vNtk ) { fprintf( pFile, ".model %s\n", (char *)Vec_PtrEntry(vNtk, 0) ); fprintf( pFile, ".inputs" ); Cba_PtrDumpSignalsBlif( pFile, (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 1), 0 ); fprintf( pFile, "\n" ); fprintf( pFile, ".outputs" ); Cba_PtrDumpSignalsBlif( pFile, (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 2), 1 ); fprintf( pFile, "\n" ); assert( Vec_PtrSize((Vec_Ptr_t *)Vec_PtrEntry(vNtk, 3)) == 0 ); // no nodes; only boxes Cba_PtrDumpBoxesBlif( pFile, (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 4) ); fprintf( pFile, ".end\n\n" ); }
/**Function************************************************************* Synopsis [Returns PI arrival time.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ float Aig_TManGetPiArrival( Aig_TMan_t * p, int iPi ) { Aig_TBox_t * pBox; Aig_TObj_t * pObj; float DelayMax; int i; assert( iPi < p->nPis ); if ( p->pPis[iPi].iObj2Box < 0 ) return p->pPis[iPi].timeOffset; pBox = Vec_PtrEntry( p->vBoxes, p->pPis[iPi].iObj2Box ); // check if box timing is updated if ( pBox->TravId == p->nTravIds ) return p->pPis[iPi].timeOffset; pBox->TravId = p->nTravIds; // update box timing DelayMax = -1.0e+20F; for ( i = 0; i < pBox->nOutputs; i++ ) { pObj = p->pPos + pBox->Inouts[pBox->nInputs+i]; DelayMax = AIG_MAX( DelayMax, pObj->timeActual + pObj->timeOffset ); } for ( i = 0; i < pBox->nInputs; i++ ) { pObj = p->pPis + pBox->Inouts[i]; pObj->timeActual = DelayMax + pObj->timeOffset; } return p->pPis[iPi].timeActual; }
// insert the PO nodes into the table Abc_NtkForEachPo( pNtk, pObj, i ) { p->nTried++; p->nAdded++; pObj = Abc_ObjFanin0(pObj); pTruth = Vec_PtrEntry( p->vTtNodes, pObj->Id ); // add the resulting truth table to the hash table ppSpot = Abc_NtkRecTableLookup( p, pTruth, p->nVars ); assert( pObj->pEquiv == NULL ); assert( pObj->pCopy == NULL ); if ( *ppSpot == NULL ) { p->nAddedFuncs++; *ppSpot = pObj; } else { pObj->pEquiv = (*ppSpot)->pEquiv; (*ppSpot)->pEquiv = (Hop_Obj_t *)pObj; if ( !Abc_NtkRecAddCutCheckCycle_rec(*ppSpot, pObj) ) printf( "Loop!\n" ); } }
ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* Synopsis [Returns the pointer to the linked list of cuts.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Cut_Cut_t * Cut_NodeReadCutsNew( Cut_Man_t * p, int Node ) { if ( Node >= p->vCutsNew->nSize ) return NULL; return (Cut_Cut_t *)Vec_PtrEntry( p->vCutsNew, Node ); }
static inline int Pdr_ObjSatVar2FindOrAdd( Pdr_Man_t * p, int k, Aig_Obj_t * pObj ) { Vec_Int_t * vId2Vars = p->pvId2Vars + Aig_ObjId(pObj); assert( p->pCnf2->pObj2Count[Aig_ObjId(pObj)] >= 0 ); if ( Vec_IntSize(vId2Vars) == 0 ) Vec_IntGrow(vId2Vars, 2 * k + 1); if ( Vec_IntGetEntry(vId2Vars, k) == 0 ) { sat_solver * pSat = Pdr_ManSolver(p, k); Vec_Int_t * vVar2Ids = (Vec_Int_t *)Vec_PtrEntry(&p->vVar2Ids, k); int iVarNew = Vec_IntSize( vVar2Ids ); assert( iVarNew > 0 ); Vec_IntPush( vVar2Ids, Aig_ObjId(pObj) ); Vec_IntWriteEntry( vId2Vars, k, iVarNew << 2 ); sat_solver_setnvars( pSat, iVarNew + 1 ); if ( k == 0 && Saig_ObjIsLo(p->pAig, pObj) ) // initialize the register output { int Lit = toLitCond( iVarNew, 1 ); int RetValue = sat_solver_addclause( pSat, &Lit, &Lit + 1 ); assert( RetValue == 1 ); (void) RetValue; sat_solver_compress( pSat ); } } return Vec_IntEntry( vId2Vars, k ); }
/**Function************************************************************* Synopsis [Computes truth table of the cut.] Description [The returned pointer should be used immediately.] SideEffects [] SeeAlso [] ***********************************************************************/ unsigned * Aig_ManCutTruth( Aig_Obj_t * pRoot, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vNodes, Vec_Ptr_t * vTruthElem, Vec_Ptr_t * vTruthStore ) { Aig_Obj_t * pObj; int i, nWords; assert( Vec_PtrSize(vLeaves) <= Vec_PtrSize(vTruthElem) ); assert( Vec_PtrSize(vNodes) <= Vec_PtrSize(vTruthStore) ); assert( Vec_PtrSize(vNodes) == 0 || pRoot == Vec_PtrEntryLast(vNodes) ); // assign elementary truth tables Vec_PtrForEachEntry( vLeaves, pObj, i ) pObj->pData = Vec_PtrEntry( vTruthElem, i ); // compute truths for other nodes nWords = Aig_TruthWordNum( Vec_PtrSize(vLeaves) ); Vec_PtrForEachEntry( vNodes, pObj, i ) pObj->pData = Aig_ManCutTruthOne( pObj, Vec_PtrEntry(vTruthStore, i), nWords ); return pRoot->pData; }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Abc_NtkBmcReport( Ivy_Man_t * pMan, Ivy_Man_t * pFrames, Ivy_Man_t * pFraig, Vec_Ptr_t * vMapping, int nFrames ) { Ivy_Obj_t * pFirst1, * pFirst2 = NULL, * pFirst3 = NULL; int i, f, nIdMax, Prev2, Prev3; nIdMax = Ivy_ManObjIdMax(pMan); // check what is the number of nodes in each frame Prev2 = Prev3 = 0; for ( f = 0; f < nFrames; f++ ) { Ivy_ManForEachNode( pMan, pFirst1, i ) { pFirst2 = Ivy_Regular( (Ivy_Obj_t *)Vec_PtrEntry(vMapping, f * nIdMax + pFirst1->Id) ); if ( Ivy_ObjIsConst1(pFirst2) || pFirst2->Type == 0 ) continue; pFirst3 = Ivy_Regular( pFirst2->pEquiv ); if ( Ivy_ObjIsConst1(pFirst3) || pFirst3->Type == 0 ) continue; break; } assert(pFirst2); assert(pFirst3); if ( f ) printf( "Frame %3d : Strash = %5d Fraig = %5d\n", f, pFirst2->Id - Prev2, pFirst3->Id - Prev3 ); Prev2 = pFirst2->Id; Prev3 = pFirst3->Id; }
/**Function************************************************************* Synopsis [Computes supports of the partitions.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Vec_Ptr_t * Llb_ImgSupports( Aig_Man_t * p, Vec_Ptr_t * vDdMans, Vec_Int_t * vStart, Vec_Int_t * vStop, int fAddPis, int fVerbose ) { Vec_Ptr_t * vSupps; Vec_Int_t * vOne; Aig_Obj_t * pObj; DdManager * dd; DdNode * bSupp, * bTemp; int i, Entry, nSize; nSize = Cudd_ReadSize( (DdManager *)Vec_PtrEntry( vDdMans, 0 ) ); vSupps = Vec_PtrAlloc( 100 ); // create initial vOne = Vec_IntStart( nSize ); Vec_IntForEachEntry( vStart, Entry, i ) Vec_IntWriteEntry( vOne, Entry, 1 ); Vec_PtrPush( vSupps, vOne ); // create intermediate Vec_PtrForEachEntry( DdManager *, vDdMans, dd, i ) { vOne = Vec_IntStart( nSize ); bSupp = Cudd_Support( dd, dd->bFunc ); Cudd_Ref( bSupp ); for ( bTemp = bSupp; bTemp != Cudd_ReadOne(dd); bTemp = cuddT(bTemp) ) Vec_IntWriteEntry( vOne, bTemp->index, 1 ); Cudd_RecursiveDeref( dd, bSupp ); Vec_PtrPush( vSupps, vOne ); }
static inline void Saig_ManSimInfoSet( Vec_Ptr_t * vSimInfo, Aig_Obj_t * pObj, int iFrame, int Value ) { unsigned * pInfo = (unsigned *)Vec_PtrEntry( vSimInfo, Aig_ObjId(pObj) ); assert( Value >= SAIG_ZER && Value <= SAIG_UND ); Value ^= Saig_ManSimInfoGet( vSimInfo, pObj, iFrame ); pInfo[iFrame >> 4] ^= (Value << ((iFrame & 15) << 1)); }
/**Function************************************************************* Synopsis [Reproduces script "compress2".] Description [Consumes the input AIG to reduce memory usage.] SideEffects [] SeeAlso [] ***********************************************************************/ Aig_Man_t * Dar_ManChoiceNewAig( Aig_Man_t * pAig, Dch_Pars_t * pPars ) { // extern Aig_Man_t * Dch_DeriveTotalAig( Vec_Ptr_t * vAigs ); extern Aig_Man_t * Dch_ComputeChoices( Aig_Man_t * pAig, Dch_Pars_t * pPars ); int fVerbose = pPars->fVerbose; Aig_Man_t * pMan, * pTemp; Vec_Ptr_t * vAigs; Vec_Ptr_t * vPios; void * pManTime; char * pName, * pSpec; int i; abctime clk; clk = Abc_Clock(); vAigs = Dar_ManChoiceSynthesis( pAig, 1, 1, pPars->fPower, fVerbose ); pPars->timeSynth = Abc_Clock() - clk; // swap the first and last network // this should lead to the primary choice being "better" because of synthesis // (it is also important when constructing choices) pMan = (Aig_Man_t *)Vec_PtrPop( vAigs ); Vec_PtrPush( vAigs, Vec_PtrEntry(vAigs,0) ); Vec_PtrWriteEntry( vAigs, 0, pMan ); // derive the total AIG pMan = Dch_DeriveTotalAig( vAigs ); // cleanup Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pTemp, i ) Aig_ManStop( pTemp ); Vec_PtrFree( vAigs ); // compute choices pMan = Dch_ComputeChoices( pTemp = pMan, pPars ); Aig_ManStop( pTemp ); // save useful things pManTime = pAig->pManTime; pAig->pManTime = NULL; pName = Abc_UtilStrsav( pAig->pName ); pSpec = Abc_UtilStrsav( pAig->pSpec ); // create guidence vPios = Aig_ManOrderPios( pMan, pAig ); Aig_ManStop( pAig ); // reconstruct the network pMan = Aig_ManDupDfsGuided( pTemp = pMan, vPios ); Aig_ManStop( pTemp ); Vec_PtrFree( vPios ); // reset levels pMan->pManTime = pManTime; Aig_ManChoiceLevel( pMan ); // copy names ABC_FREE( pMan->pName ); ABC_FREE( pMan->pSpec ); pMan->pName = pName; pMan->pSpec = pSpec; return pMan; }
// collect the results for the COs; Abc_NtkForEachCo( pNtk, pTemp, i ) { //printf( "Output %d:\n", i ); pTemp = Abc_ObjFanin0(pTemp); if ( Abc_ObjIsCi(pTemp) || Abc_AigNodeIsConst(pTemp) ) continue; Sim_SymmsTransferToMatrix( (Extra_BitMat_t *)Vec_PtrEntry(vMatrs, i), SIM_READ_SYMMS(pTemp), (unsigned *)Vec_PtrEntry(vSuppFun, i) ); }
// set the PI map Saig_ManForEachPi( p, pObj, i ) { if ( piFirst[i] == -1 ) continue; if ( piFirst[i] == piLast[i] ) { vMap = (Vec_Int_t *)Vec_PtrEntry( vMaps, piFirst[i] ); Vec_IntWriteEntry( vMap, pObj->Id, 2 ); continue; } // set support for all in between for ( k = piFirst[i]; k <= piLast[i]; k++ ) { vMap = (Vec_Int_t *)Vec_PtrEntry( vMaps, k ); Vec_IntWriteEntry( vMap, pObj->Id, 1 ); } }
static void printVecPtrOfString( Vec_Ptr_t *vec ) { int i; for( i=0; i< Vec_PtrSize( vec ); i++ ) { printf("vec[%d] = %s\n", i, (char *)Vec_PtrEntry(vec, i) ); } }
/**Function************************************************************* Synopsis [Initializes registers to the ternary state.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Saig_SynchSetConstant1( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWords ) { Aig_Obj_t * pObj; unsigned * pSim; int w; pObj = Aig_ManConst1( pAig ); pSim = (unsigned *)Vec_PtrEntry( vSimInfo, pObj->Id ); for ( w = 0; w < nWords; w++ ) pSim[w] = 0x55555555; }
/**Function************************************************************* Synopsis [Initializes registers to the ternary state.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Saig_SynchInitRegsTernary( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWords ) { Aig_Obj_t * pObj; unsigned * pSim; int i, w; Saig_ManForEachLo( pAig, pObj, i ) { pSim = (unsigned *)Vec_PtrEntry( vSimInfo, pObj->Id ); for ( w = 0; w < nWords; w++ ) pSim[w] = 0xffffffff; }
/**Function************************************************************* Synopsis [Implements the function.] Description [Returns the node implementing this function.] SideEffects [] SeeAlso [] ***********************************************************************/ Abc_Obj_t * Lpk_Implement_rec( Lpk_Man_t * pMan, Abc_Ntk_t * pNtk, Vec_Ptr_t * vLeaves, Lpk_Fun_t * pFun ) { Abc_Obj_t * pFanin, * pRes; int i; // prepare the leaves of the function for ( i = 0; i < (int)pFun->nVars; i++ ) { pFanin = (Abc_Obj_t *)Vec_PtrEntry( vLeaves, pFun->pFanins[i] ); if ( !Abc_ObjIsComplement(pFanin) ) Lpk_Implement_rec( pMan, pNtk, vLeaves, (Lpk_Fun_t *)pFanin ); pFanin = (Abc_Obj_t *)Vec_PtrEntry( vLeaves, pFun->pFanins[i] ); assert( Abc_ObjIsComplement(pFanin) ); } // construct the function pRes = Lpk_ImplementFun( pMan, pNtk, vLeaves, pFun ); // replace the function Vec_PtrWriteEntry( vLeaves, pFun->Id, Abc_ObjNot(pRes) ); Lpk_FunFree( pFun ); return pRes; }
SC_LibForEachWireLoadSel( p, pWLS, i ) { Vec_StrPutS( vOut, pWLS->pName ); Vec_StrPutI( vOut, Vec_FltSize(pWLS->vAreaFrom) ); for ( j = 0; j < Vec_FltSize(pWLS->vAreaFrom); j++) { Vec_StrPutF( vOut, Vec_FltEntry(pWLS->vAreaFrom, j) ); Vec_StrPutF( vOut, Vec_FltEntry(pWLS->vAreaTo, j) ); Vec_StrPutS( vOut, (char *)Vec_PtrEntry(pWLS->vWireLoadModel, j) ); } }
ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* Synopsis [Implements the function.] Description [Returns the node implementing this function.] SideEffects [] SeeAlso [] ***********************************************************************/ Abc_Obj_t * Lpk_ImplementFun( Lpk_Man_t * pMan, Abc_Ntk_t * pNtk, Vec_Ptr_t * vLeaves, Lpk_Fun_t * p ) { extern Hop_Obj_t * Kit_TruthToHop( Hop_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory ); unsigned * pTruth; Abc_Obj_t * pObjNew; int i; if ( p->fMark ) pMan->nMuxes++; else pMan->nDsds++; // create the new node pObjNew = Abc_NtkCreateNode( pNtk ); for ( i = 0; i < (int)p->nVars; i++ ) Abc_ObjAddFanin( pObjNew, Abc_ObjRegular((Abc_Obj_t *)Vec_PtrEntry(vLeaves, p->pFanins[i])) ); Abc_ObjSetLevel( pObjNew, Abc_ObjLevelNew(pObjNew) ); // assign the node's function pTruth = Lpk_FunTruth(p, 0); if ( p->nVars == 0 ) { pObjNew->pData = Hop_NotCond( Hop_ManConst1((Hop_Man_t *)pNtk->pManFunc), !(pTruth[0] & 1) ); return pObjNew; } if ( p->nVars == 1 ) { pObjNew->pData = Hop_NotCond( Hop_ManPi((Hop_Man_t *)pNtk->pManFunc, 0), (pTruth[0] & 1) ); return pObjNew; } // create the logic function pObjNew->pData = Kit_TruthToHop( (Hop_Man_t *)pNtk->pManFunc, pTruth, p->nVars, NULL ); return pObjNew; }
/**Function************************************************************* Synopsis [Returns 1 if simulation does not filter out this candidate.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Cgt_SimulationFilter( Cgt_Man_t * p, Aig_Obj_t * pCandPart, Aig_Obj_t * pMiterPart ) { unsigned * pInfoCand, * pInfoMiter; int w, nWords = Aig_BitWordNum( p->nPatts ); pInfoCand = (unsigned *)Vec_PtrEntry( p->vPatts, Aig_ObjId(Aig_Regular(pCandPart)) ); pInfoMiter = (unsigned *)Vec_PtrEntry( p->vPatts, Aig_ObjId(pMiterPart) ); // C => !M -- true is the same as C & M -- false if ( !Aig_IsComplement(pCandPart) ) { for ( w = 0; w < nWords; w++ ) if ( pInfoCand[w] & pInfoMiter[w] ) return 0; } else { for ( w = 0; w < nWords; w++ ) if ( ~pInfoCand[w] & pInfoMiter[w] ) return 0; } return 1; }
/**Function************************************************************* Synopsis [Derive BDD of the characteristic function.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ DdNode * Abc_ResBuildBdd( Abc_Ntk_t * pNtk, DdManager * dd ) { Vec_Ptr_t * vNodes, * vBdds, * vLocals; Abc_Obj_t * pObj, * pFanin; DdNode * bFunc, * bPart, * bTemp, * bVar; int i, k; assert( Abc_NtkIsSopLogic(pNtk) ); assert( Abc_NtkCoNum(pNtk) <= 3 ); vBdds = Vec_PtrStart( Abc_NtkObjNumMax(pNtk) ); Abc_NtkForEachCi( pNtk, pObj, i ) Vec_PtrWriteEntry( vBdds, Abc_ObjId(pObj), Cudd_bddIthVar(dd, i) ); // create internal node BDDs vNodes = Abc_NtkDfs( pNtk, 0 ); vLocals = Vec_PtrAlloc( 6 ); Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i ) { if ( Abc_ObjFaninNum(pObj) == 0 ) { bFunc = Cudd_NotCond( Cudd_ReadOne(dd), Abc_SopIsConst0((char *)pObj->pData) ); Cudd_Ref( bFunc ); Vec_PtrWriteEntry( vBdds, Abc_ObjId(pObj), bFunc ); continue; } Vec_PtrClear( vLocals ); Abc_ObjForEachFanin( pObj, pFanin, k ) Vec_PtrPush( vLocals, Vec_PtrEntry(vBdds, Abc_ObjId(pFanin)) ); bFunc = Abc_ConvertSopToBdd( dd, (char *)pObj->pData, (DdNode **)Vec_PtrArray(vLocals) ); Cudd_Ref( bFunc ); Vec_PtrWriteEntry( vBdds, Abc_ObjId(pObj), bFunc ); } Vec_PtrFree( vLocals ); // create char function bFunc = Cudd_ReadOne( dd ); Cudd_Ref( bFunc ); Abc_NtkForEachCo( pNtk, pObj, i ) { bVar = Cudd_bddIthVar( dd, i + Abc_NtkCiNum(pNtk) ); bTemp = (DdNode *)Vec_PtrEntry( vBdds, Abc_ObjFaninId0(pObj) ); bPart = Cudd_bddXnor( dd, bTemp, bVar ); Cudd_Ref( bPart ); bFunc = Cudd_bddAnd( dd, bTemp = bFunc, bPart ); Cudd_Ref( bFunc ); Cudd_RecursiveDeref( dd, bTemp ); Cudd_RecursiveDeref( dd, bPart ); }