📄 cvrespresso.c
字号:
if ( pMvcDcset && method != 7 ) { pDcset = Cvr_CoverDerivePsfFromMvc(pMvcDcset); } else { pDcset = sf_new(1, cube.size); } pDcset->wsize = pOnset->wsize; pDcset->sf_size = pOnset->sf_size; #ifdef DEBUG_ESPRESSO printf("\nONSET:\n"); _PsetFamilyPrint(stdout, pOnset,1); printf("\nDCSET:\n"); _PsetFamilyPrint(stdout, pDcset,1);#endif switch(method) { case 0: /* SIMP_ESPRESSO: */ if (pDcset->sf_size==0||pDcset->count==0) { pOffset = complement(cube1list(pOnset)); } else { pOffset = complement(cube2list(pOnset, pDcset)); } if ( !fSparse ) { skip_make_sparse = 1; } else { skip_make_sparse = 0; } pOnset = espresso(pOnset, pDcset, pOffset); sf_free(pOffset); pOffset = NULL; break; case 1: /* SIMP_NOCOMP: */ pOnset = minimize(pOnset, pDcset, 0); /* NOCOMP */ break; case 2: /* SIMP_SNOCOMP: */ pOnset = minimize(pOnset, pDcset, 1); /* SNOCOMP */ break; case 3: /* SIMP_DCSIMP: */ pOnset = minimize(pOnset, pDcset, 2); /* DCSIMP */ break; case 4: /* SIMP_EXACT: */ pOnset = minimize_exact(pOnset, pDcset, NIL(set_family_t), 1); break; case 5: /* SIMP_EXACT_LITS: */ pOnset = minimize_exact_literals(pOnset, pDcset, NIL(set_family_t), 1); break; case 7: /* SIMP_SIMPLE: */ { int i; for (i = 0; i < cube.num_vars; i++) { pOnset = d1merge( pOnset, i ); } pOnset = sf_contain( pOnset ); break; } default: {} } #ifdef DEBUG_ESPRESSO printf("\nRESULT:\n"); _PsetFamilyPrint(stdout, pOnset,1);#endif /* convert results back to mvc covers */ pMvcNew = Cvr_CoverDeriveMvcFromPsf(pMvcOnset->pMem, pOnset); sf_free(pOnset); sf_free(pDcset); if ( fCubeAllocated ) { Cvr_CoverEspressoSetdown(pVm); } return pMvcNew;}/**Function******************************************************************** Synopsis [] Description [derive the complement of a binary output Mvc cover] SideEffects [] SeeAlso []******************************************************************************/Mvc_Cover_t *Cvr_CoverComplement( Vm_VarMap_t *pVm, Mvc_Cover_t *pMvc ) { bool fCubeAllocated; pset_family psfOnset, psfOffset; Mvc_Cover_t *pCmpl; if (pMvc == NULL) return NULL; fCubeAllocated = (cube.fullset == NULL); if ( fCubeAllocated ) { Cvr_CoverEspressoSetup(pVm); } psfOnset = Cvr_CoverDerivePsfFromMvc(pMvc); psfOffset = complement(cube1list(psfOnset)); pCmpl = Cvr_CoverDeriveMvcFromPsf(pMvc->pMem, psfOffset); sf_free(psfOnset); sf_free(psfOffset); if ( fCubeAllocated ) { Cvr_CoverEspressoSetdown(pVm); } return pCmpl;}/**Function******************************************************************** Synopsis [clean up temporarily allocated cube memory] Description [normally called while quitting mvsis] SideEffects [] SeeAlso []******************************************************************************/voidCvr_CubeCleanUp( void ) { if ( fCvrCubeAllocated ) { FREE( cube.part_size ); FREE( cube.first_part ); FREE( cube.last_part ); FREE( cube.first_word ); FREE( cube.last_word ); FREE( cube.var_mask ); FREE( cube.sparse ); FREE( cube.temp ); } return;}/**Function******************************************************************** Synopsis [Free cubes] Description [Free cubes but not the arrays.] SideEffects [] SeeAlso []******************************************************************************/boolCvr_CoverEspressoSpecial( Cvr_Cover_t *pCvr ) { bool fTaut; int i, nVal, iTaut; Mvc_Cover_t * pMvcTaut; fTaut = FALSE; nVal = Vm_VarMapReadValuesOutNum( pCvr->pVm ); for ( i = 0; i < nVal; ++i ) { if ( pCvr->ppCovers[i] ) { if ( Mvc_CoverIsTautology( pCvr->ppCovers[i] ) ) { pMvcTaut = pCvr->ppCovers[i]; fTaut = TRUE; iTaut = i; } } } if ( fTaut ) { for ( i = 0; i < nVal; ++i ) { if ( pCvr->ppCovers[i] && i != iTaut ) { Mvc_CoverFree( pCvr->ppCovers[i] ); pCvr->ppCovers[i] = Mvc_CoverAlloc(pMvcTaut->pMem, pMvcTaut->nBits); /* allocate an empty cover */ } } } return fTaut;}/*---------------------------------------------------------------------------*//* Definition of static functions *//*---------------------------------------------------------------------------*//**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso []******************************************************************************/pset_family *Cvr_CoverDerivePsfFromMvcVector(Mvc_Cover_t **ppMvc, int nCovers){ int i; pset_family *pFam; if (nCovers == 0) return NULL; pFam = ALLOC(pset_family, nCovers); for (i=0; i<nCovers; ++i) { if (ppMvc[i]) pFam[i] = Cvr_CoverDerivePsfFromMvc(ppMvc[i]); else pFam[i] = NULL; } return pFam;}/**Function******************************************************************** Synopsis [] Description [assume the global cube structure has been set up.] SideEffects [] SeeAlso []******************************************************************************/pset_family Cvr_CoverDerivePsfFromMvc(Mvc_Cover_t *pMvc){ Mvc_Cube_t *pMvcCube; pset_family pFam; pset pSet; int nCubes, nWords, nBits, i; if (pMvc==NULL) return NULL; if ( Mvc_CoverIsEmpty(pMvc) ) { pFam = sf_new(0, cube.size); return pFam; } if ( Mvc_CoverIsTautology(pMvc) ) { pFam = sf_new(1, cube.size); pSet = GETSET(pFam, pFam->count++); set_copy( pSet, cube.fullset ); return pFam; } nCubes = Mvc_CoverReadCubeNum(pMvc); pFam = sf_new((nCubes+1), cube.size); nWords = Mvc_CoverReadWordNum(pMvc); nBits = Mvc_CoverReadBitNum(pMvc); Mvc_CoverForEachCube( pMvc, pMvcCube ) { pSet = GETSET(pFam, pFam->count++); PUTLOOP(pSet, nWords); PUTSIZE(pSet, nBits); i = nWords; do pSet[i] = pMvcCube->pData[i-1]; while (--i > 0); set_and(pSet, pSet, cube.fullset); } return pFam;}/**Function******************************************************************** Synopsis [Free cubes] Description [Free cubes but not the arrays.] SideEffects [] SeeAlso []******************************************************************************/Mvc_Cover_t **Cvr_CoverDeriveMvcFromPsfVector(Mvc_Manager_t *pMem, pset_family *ppCovers, int nCovers){ int i; Mvc_Cover_t **ppMvc; if (nCovers == 0) return NULL; ppMvc = ALLOC(Mvc_Cover_t *, nCovers); for (i=0; i<nCovers; ++i) { ppMvc[i] = Cvr_CoverDeriveMvcFromPsf(pMem, ppCovers[i]); } return ppMvc;}/**Function******************************************************************** Synopsis [Free cubes] Description [Free cubes but not the arrays.] SideEffects [] SeeAlso []******************************************************************************/Mvc_Cover_t *Cvr_CoverDeriveMvcFromPsf(Mvc_Manager_t *pMem, pset_family pCover){ Mvc_Cube_t *pMvcCube; Mvc_Cover_t *pMvcCover; pset pLast, pThis; int nCubes, nWords, nBits, i; if (pCover==NULL) return NULL; if ( pCover->count==0 || pCover->sf_size==0 ) { pMvcCover = Mvc_CoverAlloc(pMem, cube.size); return pMvcCover; } nCubes = pCover->count; nWords = pCover->wsize; nBits = pCover->sf_size; pMvcCover = Mvc_CoverAlloc(pMem, nBits); foreach_set( pCover, pLast, pThis) { pMvcCube = Mvc_CubeAlloc(pMvcCover); i = nWords; do pMvcCube->pData[i-2] = pThis[i-1]; while (--i > 1); //pMvcCube->pData[nWords-2] |= (~cube.fullset[nWords-1]); Mvc_CoverAddCubeTail (pMvcCover, pMvcCube); } return pMvcCover;}/**Function******************************************************************** Synopsis [setup the global cdata structure from ESPRESSO] Description [setup the global cdata structure from ESPRESSO] SideEffects [] SeeAlso []******************************************************************************/voidCvrSetupCdata( struct cube_struct *pCube){ //CvrSetdownCdata(); cdata.part_zeros = ALLOC(int, pCube->size); cdata.var_zeros = ALLOC(int, pCube->num_vars); cdata.parts_active = ALLOC(int, pCube->num_vars); cdata.is_unate = ALLOC(int, pCube->num_vars);} /**Function******************************************************************** Synopsis [setdown the global cdata structure from ESPRESSO] Description [setdown the global cdata structure from ESPRESSO] SideEffects []
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -