⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mvcutils.c

📁 主要进行大规模的电路综合
💻 C
📖 第 1 页 / 共 2 页
字号:
    // go through the cubes of both covers    pCubeNew = Mvc_CoverReadCubeHead(pCoverNew);    Mvc_CoverForEachCube( pCoverOld, pCubeOld )    {        if ( pCubeOld->pData[iWordOld] & (1<<iBitOld) )            pCubeNew->pData[iWordNew] |= (1<<iBitNew);        else            pCubeNew->pData[iWordNew] &= ~(1<<iBitNew);  // added by wjiang        pCubeNew = Mvc_CubeReadNext( pCubeNew );    }}/**Function*************************************************************  Synopsis    []  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Mvc_CoverInverse( Mvc_Cover_t * pCover ){    Mvc_Cube_t * pCube;    // complement the cubes    Mvc_CoverForEachCube( pCover, pCube )        Mvc_CubeBitNot( pCube );}/**Function*************************************************************  Synopsis    [This function dups the cover and removes DC literals from cubes.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/Mvc_Cover_t * Mvc_CoverRemoveDontCareLits( Mvc_Cover_t * pCover ){    Mvc_Cover_t * pCoverNew;    Mvc_Cube_t * pCube;    pCoverNew = Mvc_CoverDup( pCover );    Mvc_CoverForEachCube( pCoverNew, pCube )        Mvc_CubeBitRemoveDcs( pCube );    return pCoverNew;}/**Function*************************************************************  Synopsis    [Returns the cofactor w.r.t. to a binary var.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/Mvc_Cover_t * Mvc_CoverCofactor( Mvc_Cover_t * p, int iValue, int iValueOther ){    Mvc_Cover_t * pCover;    Mvc_Cube_t * pCube, * pCubeCopy;    // clone the cover    pCover = Mvc_CoverClone( p );    // copy the cube list    Mvc_CoverForEachCube( p, pCube )        if ( Mvc_CubeBitValue( pCube, iValue ) )        {            pCubeCopy = Mvc_CubeDup( pCover, pCube );            Mvc_CoverAddCubeTail( pCover, pCubeCopy );            Mvc_CubeBitInsert( pCubeCopy, iValueOther );        }    return pCover;}/**Function*************************************************************  Synopsis    [Returns the cover, in which the binary var is complemented.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/Mvc_Cover_t * Mvc_CoverFlipVar( Mvc_Cover_t * p, int iValue0, int iValue1 ){    Mvc_Cover_t * pCover;    Mvc_Cube_t * pCube, * pCubeCopy;    int Value0, Value1, Temp;    assert( iValue0 + 1 == iValue1 ); // should be adjacent    // clone the cover    pCover = Mvc_CoverClone( p );    // copy the cube list    Mvc_CoverForEachCube( p, pCube )    {        pCubeCopy = Mvc_CubeDup( pCover, pCube );        Mvc_CoverAddCubeTail( pCover, pCubeCopy );        // get the bits        Value0 = Mvc_CubeBitValue( pCubeCopy, iValue0 );        Value1 = Mvc_CubeBitValue( pCubeCopy, iValue1 );        // if both bits are one, nothing to swap        if ( Value0 && Value1 )            continue;        // cannot be both zero because they belong to the same var        assert( Value0 || Value1 );         // swap the bits        Temp   = Value0;        Value0 = Value1;        Value1 = Temp;        // set the bits after the swap        if ( Value0 )            Mvc_CubeBitInsert( pCubeCopy, iValue0 );        else            Mvc_CubeBitRemove( pCubeCopy, iValue0 );        if ( Value1 )            Mvc_CubeBitInsert( pCubeCopy, iValue1 );        else            Mvc_CubeBitRemove( pCubeCopy, iValue1 );    }    return pCover;}/**Function*************************************************************  Synopsis    [Returns the cover derived by universal quantification.]  Description [Returns the cover computed by universal quantification  as follows: CoverNew = Univ(B) [Cover & (A==B)]. Removes the second   binary var from the support (given by values iValueB0 and iValueB1).   Leaves the first binary variable (given by values iValueA0 and iValueA1)   in the support.]                 SideEffects []  SeeAlso     []***********************************************************************/Mvc_Cover_t * Mvc_CoverUnivQuantify( Mvc_Cover_t * p,     int iValueA0, int iValueA1, int iValueB0, int iValueB1 ){    Mvc_Cover_t * pCover;    Mvc_Cube_t * pCube, * pCubeCopy;    int ValueA0, ValueA1, ValueB0, ValueB1;    // clone the cover    pCover = Mvc_CoverClone( p );    // copy the cube list    Mvc_CoverForEachCube( p, pCube )    {        // get the bits        ValueA0 = Mvc_CubeBitValue( pCube, iValueA0 );        ValueA1 = Mvc_CubeBitValue( pCube, iValueA1 );        ValueB0 = Mvc_CubeBitValue( pCube, iValueB0 );        ValueB1 = Mvc_CubeBitValue( pCube, iValueB1 );        // cannot be both zero because they belong to the same var        assert( ValueA0 || ValueA1 );         assert( ValueB0 || ValueB1 );         // if the values of this var are different, do not add the cube        if ( ValueA0 != ValueB0 && ValueA1 != ValueB1 )            continue;        // create the cube        pCubeCopy = Mvc_CubeDup( pCover, pCube );        Mvc_CoverAddCubeTail( pCover, pCubeCopy );        // insert 1's into for the first var, if both have this value        if ( ValueA0 && ValueB0 )            Mvc_CubeBitInsert( pCubeCopy, iValueA0 );        else            Mvc_CubeBitRemove( pCubeCopy, iValueA0 );        if ( ValueA1 && ValueB1 )            Mvc_CubeBitInsert( pCubeCopy, iValueA1 );        else            Mvc_CubeBitRemove( pCubeCopy, iValueA1 );                    // insert 1's into for the second var (the cover does not depend on it)        Mvc_CubeBitInsert( pCubeCopy, iValueB0 );        Mvc_CubeBitInsert( pCubeCopy, iValueB1 );    }    return pCover;}/**Function*************************************************************  Synopsis    [Derives the cofactors of the cover.]  Description [Derives the cofactors w.r.t. a variable and also cubes  that do not depend on this variable.]                 SideEffects []  SeeAlso     []***********************************************************************/Mvc_Cover_t ** Mvc_CoverCofactors( Mvc_Data_t * pData, Mvc_Cover_t * pCover, int iVar ){    Mvc_Cover_t ** ppCofs;    Mvc_Cube_t * pCube, * pCubeNew;    int i, nValues, iValueFirst, Res;    // start the covers for cofactors    iValueFirst = Vm_VarMapReadValuesFirst(pData->pVm, iVar);    nValues = Vm_VarMapReadValues(pData->pVm, iVar);    ppCofs = ALLOC( Mvc_Cover_t *, nValues + 1 );    for ( i = 0; i <= nValues; i++ )        ppCofs[i] = Mvc_CoverClone( pCover );    // go through the cubes    Mvc_CoverForEachCube( pCover, pCube )    {        // if the literal if a full literal, add it to last "cofactor"        Mvc_CubeBitEqualUnderMask( Res, pCube, pData->ppMasks[iVar], pData->ppMasks[iVar] );        if ( Res )        {            pCubeNew = Mvc_CubeDup(pCover, pCube);            Mvc_CoverAddCubeTail( ppCofs[nValues], pCubeNew );            continue;        }        // otherwise, add it to separate values        for ( i = 0; i < nValues; i++ )            if ( Mvc_CubeBitValue( pCube, iValueFirst + i ) )            {                pCubeNew = Mvc_CubeDup(pCover, pCube);                Mvc_CubeBitOr( pCubeNew, pCubeNew, pData->ppMasks[iVar] );                Mvc_CoverAddCubeTail( ppCofs[i], pCubeNew );            }    }    return ppCofs;}/**Function*************************************************************  Synopsis    [Count the cubes with non-trivial literals with the given value.]  Description [The data and the cover are given (pData, pCover). Also given   are the variable number and the number of a value of this variable.  This procedure returns the number of cubes having a non-trivial literal  of this variable that have the given value present.]                 SideEffects []  SeeAlso     []***********************************************************************/int Mvr_CoverCountLitsWithValue( Mvc_Data_t * pData, Mvc_Cover_t * pCover, int iVar, int iValue ){    Mvc_Cube_t * pCube;    int iValueFirst, Res, Counter;    Counter = 0;    iValueFirst = Vm_VarMapReadValuesFirst( pData->pVm, iVar );    Mvc_CoverForEachCube( pCover, pCube )    {        // check if the given literal is the full literal        Mvc_CubeBitEqualUnderMask( Res, pCube, pData->ppMasks[iVar], pData->ppMasks[iVar] );        if ( Res )            continue;        // this literal is not a full literal; check if it has this value        Counter += Mvc_CubeBitValue( pCube, iValueFirst + iValue );    }    return Counter;}/**Function*************************************************************  Synopsis    [Creates the expanded cover.]  Description [The original cover is expanded by adding some variables.  These variables are the additional variables in pVmNew, compared to  pCvr->pVm. The resulting cover is the same as the original one, except  that it contains the additional variables present as full literals  in every cube.]                 SideEffects []  SeeAlso     []***********************************************************************/Mvc_Cover_t * Mvc_CoverCreateExpanded( Mvc_Cover_t * pCover, Vm_VarMap_t * pVmNew ){    Mvc_Cover_t * pCoverNew;    Mvc_Cube_t * pCube, * pCubeNew;    int i, iLast, iLastNew;    // create the new cover    pCoverNew = Mvc_CoverAlloc( pCover->pMem, Vm_VarMapReadValuesInNum(pVmNew) );    // get the cube composed of extra bits    Mvc_CoverAllocateMask( pCoverNew );    Mvc_CubeBitClean( pCoverNew->pMask );    for ( i = pCover->nBits; i < pCoverNew->nBits; i++ )        Mvc_CubeBitInsert( pCoverNew->pMask, i );    // get the indexes of the last words in both covers    iLast    = pCover->nWords?    pCover->nWords - 1: 0;    iLastNew = pCoverNew->nWords? pCoverNew->nWords - 1: 0;    // create the cubes of the new cover    Mvc_CoverForEachCube( pCover, pCube )    {        pCubeNew = Mvc_CubeAlloc( pCoverNew );        Mvc_CubeBitClean( pCubeNew );        // copy the bits (cannot immediately use Mvc_CubeBitCopy,         // because covers have different numbers of bits)        Mvc_CubeSetLast( pCubeNew, iLast );        Mvc_CubeBitCopy( pCubeNew, pCube );        Mvc_CubeSetLast( pCubeNew, iLastNew );        // add the extra bits        Mvc_CubeBitOr( pCubeNew, pCubeNew, pCoverNew->pMask );        // add the cube to the new cover        Mvc_CoverAddCubeTail( pCoverNew, pCubeNew );    }    return pCoverNew;}///////////////////////////////////////////////////////////////////////////                       END OF FILE                                ///////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -