ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* Synopsis [Converts old ABC network into new ABC network.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Nwk_Man_t * Abc_NtkToNtkNew( Abc_Ntk_t * pNtk ) { Vec_Ptr_t * vNodes; Nwk_Man_t * pNtkNew; Nwk_Obj_t * pObjNew; Abc_Obj_t * pObj, * pFanin; int i, k; if ( !Abc_NtkIsLogic(pNtk) ) { fprintf( stdout, "This is not a logic network.\n" ); return 0; } // convert into the AIG if ( !Abc_NtkToAig(pNtk) ) { fprintf( stdout, "Converting to AIGs has failed.\n" ); return 0; } assert( Abc_NtkHasAig(pNtk) ); // construct the network pNtkNew = Nwk_ManAlloc(); pNtkNew->pName = Extra_UtilStrsav( pNtk->pName ); pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec ); Abc_NtkForEachCi( pNtk, pObj, i ) pObj->pCopy = (Abc_Obj_t *)Nwk_ManCreateCi( pNtkNew, Abc_ObjFanoutNum(pObj) ); vNodes = Abc_NtkDfs( pNtk, 1 ); Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i ) { pObjNew = Nwk_ManCreateNode( pNtkNew, Abc_ObjFaninNum(pObj), Abc_ObjFanoutNum(pObj) ); Abc_ObjForEachFanin( pObj, pFanin, k ) Nwk_ObjAddFanin( pObjNew, (Nwk_Obj_t *)pFanin->pCopy ); pObjNew->pFunc = Hop_Transfer( (Hop_Man_t *)pNtk->pManFunc, pNtkNew->pManHop, (Hop_Obj_t *)pObj->pData, Abc_ObjFaninNum(pObj) ); pObj->pCopy = (Abc_Obj_t *)pObjNew; }
/**Function************************************************************* Synopsis [Derives GIA manager using special pins to denote box boundaries.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Gia_Man_t * Abc_NtkTestPinDeriveGia( Abc_Ntk_t * pNtk, int fWhiteBoxOnly, int fVerbose ) { Gia_Man_t * pTemp; Gia_Man_t * pGia = NULL; Vec_Ptr_t * vNodes; Abc_Obj_t * pObj, * pFanin; int i, k, iPinLit = 0; // prepare logic network assert( Abc_NtkIsLogic(pNtk) ); Abc_NtkToAig( pNtk ); // construct GIA Abc_NtkFillTemp( pNtk ); pGia = Gia_ManStart( Abc_NtkObjNumMax(pNtk) ); Gia_ManHashAlloc( pGia ); // create primary inputs Abc_NtkForEachCi( pNtk, pObj, i ) pObj->iTemp = Gia_ManAppendCi(pGia); // create internal nodes in a topologic order from white boxes vNodes = Abc_NtkDfs( pNtk, 0 ); Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i ) { // input side if ( !fWhiteBoxOnly || Abc_NodeIsWhiteBox(pObj) ) { // create special pintype for this node iPinLit = Gia_ManAppendPinType( pGia, 1 ); // create input pins Abc_ObjForEachFanin( pObj, pFanin, k ) pFanin->iTemp = Gia_ManAppendAnd( pGia, pFanin->iTemp, iPinLit ); } // perform GIA construction pObj->iTemp = Abc_NtkTestTimNodeStrash( pGia, pObj ); // output side if ( !fWhiteBoxOnly || Abc_NodeIsWhiteBox(pObj) ) { // create special pintype for this node iPinLit = Gia_ManAppendPinType( pGia, 1 ); // create output pins pObj->iTemp = Gia_ManAppendAnd( pGia, pObj->iTemp, iPinLit ); } } Vec_PtrFree( vNodes ); // create primary outputs Abc_NtkForEachCo( pNtk, pObj, i ) pObj->iTemp = Gia_ManAppendCo( pGia, Abc_ObjFanin0(pObj)->iTemp ); // finalize GIA Gia_ManHashStop( pGia ); Gia_ManSetRegNum( pGia, 0 ); // clean up GIA pGia = Gia_ManCleanup( pTemp = pGia ); Gia_ManStop( pTemp ); return pGia; }
/**Function************************************************************* Synopsis [Converts the network to MUXes.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Abc_NtkBddToMuxesPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew ) { ProgressBar * pProgress; Abc_Obj_t * pNode, * pNodeNew; Vec_Ptr_t * vNodes; int i; // perform conversion in the topological order vNodes = Abc_NtkDfs( pNtk, 0 ); pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize ); Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i ) { Extra_ProgressBarUpdate( pProgress, i, NULL ); // convert one node assert( Abc_ObjIsNode(pNode) ); pNodeNew = Abc_NodeBddToMuxes( pNode, pNtkNew ); // mark the old node with the new one assert( pNode->pCopy == NULL ); pNode->pCopy = pNodeNew; }
/**Function************************************************************* Synopsis [Starts the simulation manager.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Sym_Man_t * Sym_ManStart( Abc_Ntk_t * pNtk, int fVerbose ) { Sym_Man_t * p; int i, v; // start the manager p = ALLOC( Sym_Man_t, 1 ); memset( p, 0, sizeof(Sym_Man_t) ); p->pNtk = pNtk; p->vNodes = Abc_NtkDfs( pNtk, 0 ); p->nInputs = Abc_NtkCiNum(p->pNtk); p->nOutputs = Abc_NtkCoNum(p->pNtk); // internal simulation information p->nSimWords = SIM_NUM_WORDS(p->nInputs); p->vSim = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), p->nSimWords, 0 ); // symmetry info for each output p->vMatrSymms = Vec_PtrStart( p->nOutputs ); p->vMatrNonSymms = Vec_PtrStart( p->nOutputs ); p->vPairsTotal = Vec_IntStart( p->nOutputs ); p->vPairsSym = Vec_IntStart( p->nOutputs ); p->vPairsNonSym = Vec_IntStart( p->nOutputs ); for ( i = 0; i < p->nOutputs; i++ ) { p->vMatrSymms->pArray[i] = Extra_BitMatrixStart( p->nInputs ); p->vMatrNonSymms->pArray[i] = Extra_BitMatrixStart( p->nInputs ); } // temporary patterns p->uPatRand = ALLOC( unsigned, p->nSimWords ); p->uPatCol = ALLOC( unsigned, p->nSimWords ); p->uPatRow = ALLOC( unsigned, p->nSimWords ); p->vVarsU = Vec_IntStart( 100 ); p->vVarsV = Vec_IntStart( 100 ); // compute supports p->vSuppFun = Sim_ComputeFunSupp( pNtk, fVerbose ); p->vSupports = Vec_VecStart( p->nOutputs ); for ( i = 0; i < p->nOutputs; i++ ) for ( v = 0; v < p->nInputs; v++ ) if ( Sim_SuppFunHasVar( p->vSuppFun, i, v ) ) Vec_VecPush( p->vSupports, i, (void *)v ); return p; }
/**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 ); }
/**Function************************************************************* Synopsis [Computes symmetries for a single output function.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Sim_SymmsStructCompute( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMatrs, Vec_Ptr_t * vSuppFun ) { Vec_Ptr_t * vNodes; Abc_Obj_t * pTemp; int * pMap, i; assert( Abc_NtkCiNum(pNtk) + 10 < (1<<16) ); // get the structural support pNtk->vSupps = Sim_ComputeStrSupp( pNtk ); // set elementary info for the CIs Abc_NtkForEachCi( pNtk, pTemp, i ) SIM_SET_SYMMS( pTemp, Vec_IntAlloc(0) ); // create the map of CI ids into their numbers pMap = Sim_SymmsCreateMap( pNtk ); // collect the nodes in the TFI cone of this output vNodes = Abc_NtkDfs( pNtk, 0 ); Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pTemp, i ) { // if ( Abc_NodeIsConst(pTemp) ) // continue; Sim_SymmsStructComputeOne( pNtk, pTemp, pMap ); }
ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Vec_Ptr_t * Abc_NtkAssignIDs( Abc_Ntk_t * pNtk ) { Vec_Ptr_t * vNodes; Abc_Obj_t * pObj; int i; vNodes = Abc_NtkDfs( pNtk, 0 ); Abc_NtkCleanCopy( pNtk ); Abc_NtkForEachCi( pNtk, pObj, i ) pObj->iTemp = i; Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i ) pObj->iTemp = Abc_NtkCiNum(pNtk) + i; Abc_NtkForEachCo( pNtk, pObj, i ) pObj->iTemp = Abc_NtkCiNum(pNtk) + Vec_PtrSize(vNodes) + i; return vNodes; }
// get the largest number of values nValuesMax = 2; Abc_NtkForEachNet( pNtk, pObj, i ) { nValues = Abc_ObjMvVarNum(pObj); if ( nValuesMax < nValues ) nValuesMax = nValues; } nBits = Extra_Base2Log( nValuesMax ); pBits = ABC_ALLOC( Abc_Obj_t *, nBits ); // clean the node copy fields Abc_NtkCleanCopy( pNtk ); // collect the nodes vNodes = Abc_NtkDfs( pNtk, 0 ); // start the network pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 ); // duplicate the name and the spec pNtkNew->pName = Extra_UtilStrsav( pNtk->pName ); // pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pName ); nCount1 = nCount2 = 0; // encode the CI nets Abc_NtkIncrementTravId( pNtk ); if ( fUsePositional ) { Abc_NtkForEachCi( pNtk, pObj, i ) { if ( !Abc_ObjIsPi(pObj) )
ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* Synopsis [Starts the simulation manager.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Sym_Man_t * Sym_ManStart( Abc_Ntk_t * pNtk, int fVerbose ) { Sym_Man_t * p; int i, v; // start the manager p = ABC_ALLOC( Sym_Man_t, 1 ); memset( p, 0, sizeof(Sym_Man_t) ); p->pNtk = pNtk; p->vNodes = Abc_NtkDfs( pNtk, 0 ); p->nInputs = Abc_NtkCiNum(p->pNtk); p->nOutputs = Abc_NtkCoNum(p->pNtk); // internal simulation information p->nSimWords = SIM_NUM_WORDS(p->nInputs); p->vSim = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), p->nSimWords, 0 ); // symmetry info for each output p->vMatrSymms = Vec_PtrStart( p->nOutputs ); p->vMatrNonSymms = Vec_PtrStart( p->nOutputs ); p->vPairsTotal = Vec_IntStart( p->nOutputs ); p->vPairsSym = Vec_IntStart( p->nOutputs ); p->vPairsNonSym = Vec_IntStart( p->nOutputs ); for ( i = 0; i < p->nOutputs; i++ ) { p->vMatrSymms->pArray[i] = Extra_BitMatrixStart( p->nInputs ); p->vMatrNonSymms->pArray[i] = Extra_BitMatrixStart( p->nInputs ); } // temporary patterns p->uPatRand = ABC_ALLOC( unsigned, p->nSimWords ); p->uPatCol = ABC_ALLOC( unsigned, p->nSimWords ); p->uPatRow = ABC_ALLOC( unsigned, p->nSimWords ); p->vVarsU = Vec_IntStart( 100 ); p->vVarsV = Vec_IntStart( 100 ); // compute supports p->vSuppFun = Sim_ComputeFunSupp( pNtk, fVerbose ); p->vSupports = Vec_VecStart( p->nOutputs ); for ( i = 0; i < p->nOutputs; i++ ) for ( v = 0; v < p->nInputs; v++ ) if ( Sim_SuppFunHasVar( p->vSuppFun, i, v ) ) Vec_VecPush( p->vSupports, i, (void *)(ABC_PTRUINT_T)v ); return p; }
ABC_NAMESPACE_IMPL_START // For description of Binary BLIF format, refer to "abc/src/aig/bbl/bblif.h" //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// /**Fnction************************************************************* Synopsis [Construct manager from the ABC network.] Description [In the ABC network each object has a unique integer ID. This ID is used when we construct objects of the BBLIF manager corresponding to each object of the ABC network. The objects can be added to the manager in any order (although below they are added in the topological order), but by the time fanin/fanout connections are created, corresponding objects are already constructed. In the end the checking procedure is called.] SideEffects [] SeeAlso [] ***********************************************************************/ Bbl_Man_t * Bbl_ManFromAbc( Abc_Ntk_t * pNtk ) { Bbl_Man_t * p; Vec_Ptr_t * vNodes; Abc_Obj_t * pObj, * pFanin; int i, k; assert( Abc_NtkIsSopLogic(pNtk) ); // start the data manager p = Bbl_ManStart( Abc_NtkName(pNtk) ); // collect internal nodes to be added vNodes = Abc_NtkDfs( pNtk, 0 ); // create combinational inputs Abc_NtkForEachCi( pNtk, pObj, i ) Bbl_ManCreateObject( p, BBL_OBJ_CI, Abc_ObjId(pObj), 0, NULL ); // create internal nodes Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i ) Bbl_ManCreateObject( p, BBL_OBJ_NODE, Abc_ObjId(pObj), Abc_ObjFaninNum(pObj), (char *)pObj->pData ); // create combinational outputs Abc_NtkForEachCo( pNtk, pObj, i ) Bbl_ManCreateObject( p, BBL_OBJ_CO, Abc_ObjId(pObj), 1, NULL ); // create fanin/fanout connections for internal nodes Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i ) Abc_ObjForEachFanin( pObj, pFanin, k ) Bbl_ManAddFanin( p, Abc_ObjId(pObj), Abc_ObjId(pFanin) ); // create fanin/fanout connections for combinational outputs Abc_NtkForEachCo( pNtk, pObj, i ) Abc_ObjForEachFanin( pObj, pFanin, k ) Bbl_ManAddFanin( p, Abc_ObjId(pObj), Abc_ObjId(pFanin) ); Vec_PtrFree( vNodes ); // sanity check Bbl_ManCheck( p ); return p; }