/**Function************************************************************* Synopsis [Starts the AIG manager.] Description [The argument of this procedure is a soft limit on the the number of nodes, or 0 if the limit is unknown.] SideEffects [] SeeAlso [] ***********************************************************************/ Aig_Man_t * Aig_ManStart( int nNodesMax ) { Aig_Man_t * p; if ( nNodesMax <= 0 ) nNodesMax = 10007; // start the manager p = ALLOC( Aig_Man_t, 1 ); memset( p, 0, sizeof(Aig_Man_t) ); // perform initializations p->nTravIds = 1; p->fCatchExor = 0; // allocate arrays for nodes p->vPis = Vec_PtrAlloc( 100 ); p->vPos = Vec_PtrAlloc( 100 ); p->vObjs = Vec_PtrAlloc( 1000 ); p->vBufs = Vec_PtrAlloc( 100 ); // prepare the internal memory manager p->pMemObjs = Aig_MmFixedStart( sizeof(Aig_Obj_t), nNodesMax ); // create the constant node p->pConst1 = Aig_ManFetchMemory( p ); p->pConst1->Type = AIG_OBJ_CONST1; p->pConst1->fPhase = 1; p->nObjs[AIG_OBJ_CONST1]++; // start the table p->nTableSize = Aig_PrimeCudd( nNodesMax ); p->pTable = ALLOC( Aig_Obj_t *, p->nTableSize ); memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize ); return p; }
/**Function************************************************************* Synopsis [Resizes the table.] Description [Typically this procedure should not be called.] SideEffects [] SeeAlso [] ***********************************************************************/ void Aig_TableResize( Aig_Man_t * p ) { Aig_Obj_t * pEntry, * pNext; Aig_Obj_t ** pTableOld, ** ppPlace; int nTableSizeOld, Counter, nEntries, i, clk; clk = clock(); // save the old table pTableOld = p->pTable; nTableSizeOld = p->nTableSize; // get the new table p->nTableSize = Aig_PrimeCudd( 2 * Aig_ManNodeNum(p) ); p->pTable = ALLOC( Aig_Obj_t *, p->nTableSize ); memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize ); // rehash the entries from the old table Counter = 0; for ( i = 0; i < nTableSizeOld; i++ ) for ( pEntry = pTableOld[i], pNext = pEntry? pEntry->pNext : NULL; pEntry; pEntry = pNext, pNext = pEntry? pEntry->pNext : NULL ) { // get the place where this entry goes in the table ppPlace = Aig_TableFind( p, pEntry ); assert( *ppPlace == NULL ); // should not be there // add the entry to the list *ppPlace = pEntry; pEntry->pNext = NULL; Counter++; } nEntries = Aig_ManNodeNum(p); assert( Counter == nEntries ); printf( "Increasing the structural table size from %6d to %6d. ", nTableSizeOld, p->nTableSize ); PRT( "Time", clock() - clk ); // replace the table and the parameters free( pTableOld ); }
/**Function************************************************************* Synopsis [Resizes the table.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Ntl_ManModelTableResize( Ntl_Man_t * p ) { Ntl_Mod_t ** pModTableNew, ** ppSpot, * pEntry, * pEntry2; int nModTableSizeNew, Counter, e, clk; clk = clock(); // get the new table size nModTableSizeNew = Aig_PrimeCudd( 3 * p->nModTableSize ); // allocate a new array pModTableNew = ABC_ALLOC( Ntl_Mod_t *, nModTableSizeNew ); memset( pModTableNew, 0, sizeof(Ntl_Mod_t *) * nModTableSizeNew ); // rehash entries Counter = 0; for ( e = 0; e < p->nModTableSize; e++ ) for ( pEntry = p->pModTable[e], pEntry2 = pEntry? pEntry->pNext : NULL; pEntry; pEntry = pEntry2, pEntry2 = pEntry? pEntry->pNext : NULL ) { ppSpot = pModTableNew + Ntl_HashString( pEntry->pName, nModTableSizeNew ); pEntry->pNext = *ppSpot; *ppSpot = pEntry; Counter++; } assert( Counter == p->nModEntries ); // printf( "Increasing the structural table size from %6d to %6d. ", p->nTableSize, nTableSizeNew ); // ABC_PRT( "Time", clock() - clk ); // replace the table and the parameters ABC_FREE( p->pModTable ); p->pModTable = pModTableNew; p->nModTableSize = nModTableSizeNew; }
/**Function************************************************************* Synopsis [Allocates simulation manager.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Aig_Tsi_t * Aig_TsiStart( Aig_Man_t * pAig ) { Aig_Tsi_t * p; p = (Aig_Tsi_t *)malloc( sizeof(Aig_Tsi_t) ); memset( p, 0, sizeof(Aig_Tsi_t) ); p->pAig = pAig; p->nWords = Aig_BitWordNum( 2*Aig_ManRegNum(pAig) ); p->vStates = Vec_PtrAlloc( 1000 ); p->pMem = Aig_MmFixedStart( sizeof(unsigned) * p->nWords + sizeof(unsigned *), 10000 ); p->nBins = Aig_PrimeCudd(TSI_MAX_ROUNDS/2); p->pBins = ALLOC( unsigned *, p->nBins ); memset( p->pBins, 0, sizeof(unsigned *) * p->nBins ); return p; }