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

📄 fmsflex.c

📁 主要进行大规模的电路综合
💻 C
📖 第 1 页 / 共 2 页
字号:
    Cudd_Deref( bFunc );    return pMvrLoc;}/**Function*************************************************************  Synopsis    [Get the flexibility in the global space.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/DdNode * fmsFlexComputeGlobal( Fms_Manager_t * pMan, Sh_Network_t * pNet ){    DdManager * dd = pMan->dd;    Vm_VarMap_t * pVm;    DdNode * bFunc, * bFuncZ;    DdNode * bRel, * bCond, * bTemp;    Sh_Node_t * pNode;    int * pValues, * pValuesFirst;    int i, v, iValue, nVarsOut;    Extra_OperationTimeoutSet( 100 );    // get parameters    pVm          = pNet->pVmR;    nVarsOut     = Vm_VarMapReadVarsInNum( pVm );    pValues      = Vm_VarMapReadValuesArray( pVm );    pValuesFirst = Vm_VarMapReadValuesFirstArray( pVm );    // create the containment condition    bRel = b1;   Cudd_Ref( bRel );    iValue = 0;    for ( i = 0; i < nVarsOut; i++ )    {        for ( v = 0; v < pValues[i]; v++ )        {            // get the node            pNode = pNet->ppOutputs[pValuesFirst[i] + v];            // get the global BDD of the cut network            bFunc  = pMan->pbGlos[pValuesFirst[i] + v];             bFuncZ = Fm_DataGetNodeGlo( pNode );            // if this is the same BDD, this output does not depend on the cut var            if ( bFunc == bFuncZ )                continue;            // get the condition  (bFuncZ => bFunc)//            bCond = Cudd_bddOr( dd, Cudd_Not(bFuncZ), bFunc ); Cudd_Ref( bCond );            bCond = Extra_bddAnd( dd, bFuncZ, Cudd_Not(bFunc) );              if ( bCond == NULL )            {                Cudd_RecursiveDeref( dd, bRel );                Extra_OperationTimeoutReset();                return NULL;            }            bCond = Cudd_Not( bCond );            Cudd_Ref( bCond );             // multiply this condition by the general condition            bRel = Extra_bddAnd( dd, bTemp = bRel, bCond );                 if ( bRel == NULL )            {                Cudd_RecursiveDeref( dd, bTemp );                Cudd_RecursiveDeref( dd, bCond );                Extra_OperationTimeoutReset();                return NULL;            }            Cudd_Ref( bRel );            Cudd_RecursiveDeref( dd, bTemp );            Cudd_RecursiveDeref( dd, bCond );        }    }    Extra_OperationTimeoutReset();    // at this point, the general condition is ready    // compose the special variables//    bRel = fmsFlexComposeSpecials( pMan, bTemp = bRel, pVmxGlo, pNet ); Cudd_Ref( bRel );//    Cudd_RecursiveDeref( dd, bTemp );    Cudd_Deref( bRel );    return bRel;}/**Function*************************************************************  Synopsis    [Get the MV relation of the node in the global space.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/DdNode * fmsFlexDeriveGlobalRelation( Fms_Manager_t * pMan, Sh_Network_t * pNet ){    assert( 0 );    // does not work because we do not store the global BDDs of the cut node    return NULL;}/**Function*************************************************************  Synopsis    [Get the flexibility in the local space.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/Mvr_Relation_t * fmsFlexComputeLocal( Fms_Manager_t * pMan,      DdNode * bFlexGlo, Sh_Network_t * pNet, Mvr_Relation_t * pMvr ){    Mvr_Relation_t * pMvrLoc;    DdManager * ddGlo;      // bFlexGlo is expressed using this manager    DdManager * ddLoc;      // the resulting relation uses this manager    DdNode ** pbFuncs;    DdNode * bCube, * bDontCare;    DdNode * bTemp, * bImage, * bRel;    int * pPermute;    int nFuncs, i;    int clk, clkP;clkP = clock();    // get the global and local BDD managers    ddGlo = pMan->dd;    ddLoc = Mvr_ManagerReadDdLoc( pMan->pManMvr );    // shortcut to the binary image if the problem is binary    if ( pMan->fBinary )    {        // collect the global BDDs of the fanins        nFuncs = pNet->nInputsCore/2;        assert( nFuncs == Vm_VarMapReadVarsInNum( Vmx_VarMapReadVm(pMan->pVmxLoc) ) );        pbFuncs = ALLOC( DdNode *, nFuncs );        for ( i = 0; i < nFuncs; i++ )            pbFuncs[i] = Fm_DataGetNodeGlo( pNet->ppInputsCore[2*i+1] );        bCube     = Vmx_VarMapCharCubeOutput( ddGlo, pMan->pVmxGlo ); Cudd_Ref( bCube );        bDontCare = Cudd_bddUnivAbstract( ddGlo, bFlexGlo, bCube );   Cudd_Ref( bDontCare );//PRB( ddGlo, bFlexGlo );//PRB( ddGlo, bDontCare );clk = clock();        // compute the binary image of the care set        bImage = Fm_ImageCompute( ddGlo, Cudd_Not(bDontCare), pbFuncs, nFuncs,                     pMan->pbVars1, 100 );         Cudd_Ref( bImage );        bImage = Cudd_Not( bImage );clk = clock() - clk;        Cudd_RecursiveDeref( ddGlo, bDontCare );        Cudd_RecursiveDeref( ddGlo, bCube );    }    else    {        // collect the global BDDs of the fanins        nFuncs = pNet->nInputsCore;        assert( nFuncs == Vm_VarMapReadValuesInNum( Vmx_VarMapReadVm(pMan->pVmxLoc) ) );        pbFuncs = ALLOC( DdNode *, nFuncs );        for ( i = 0; i < nFuncs; i++ )            pbFuncs[i] = Fm_DataGetNodeGlo( pNet->ppInputsCore[i] );        // compute the MV imageclk = clock();        bImage = Fm_ImageMvCompute( ddGlo, Cudd_Not(bFlexGlo), pbFuncs, nFuncs,                     pMan->pVmxGlo, pMan->pVmxLoc, pMan->pbVars1, 100 );         Cudd_Ref( bImage );        bImage = Cudd_Not( bImage );clk = clock() - clk;    }//PRB( ddGlo, bImage );    // transfer from the FM's own global manager into the MVR's local manager    pPermute = fmsFlexCreatePermMap( pMan );    bImage = Extra_TransferPermute( ddGlo, ddLoc, bTemp = bImage, pPermute );    Cudd_Ref( bImage );    Cudd_RecursiveDeref( ddGlo, bTemp );    FREE( pPermute );    FREE( pbFuncs );//PRB( ddLoc, bImage );    if ( pMan->fBinary )    {        int * pTransMap;        // remap the cofactors to the new variable map        pTransMap = ALLOC( int, pNet->nInputsCore/2 + 1 );        for ( i = 0; i < pNet->nInputsCore/2 + 1; i++ )            pTransMap[i] = i;        // remap the original relation to use the same variable map        bRel = Mvr_RelationRemap( pMvr, Mvr_RelationReadRel(pMvr),             Mvr_RelationReadVmx(pMvr), pMan->pVmxLoc, pTransMap );        Cudd_Ref( bRel );        FREE( pTransMap );        // add the care set back to the don't-care        bImage = Cudd_bddOr( ddLoc, bTemp = bImage, bRel ); Cudd_Ref( bImage );        Cudd_RecursiveDeref( ddLoc, bTemp );        Cudd_RecursiveDeref( ddLoc, bRel );    }//PRB( ddLoc, bImage );    // create the relation    pMvrLoc = Mvr_RelationCreate( pMan->pManMvr, pMan->pVmxLoc, bImage );     Cudd_Deref( bImage );    // reorder the relation    Mvr_RelationReorder( pMvrLoc );clkP = clock() - clkP - clk;timeImage     += clk;timeImagePrep += clkP;    return pMvrLoc;}/**Function*************************************************************  Synopsis    [Composes the special node functions.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/int * fmsFlexCreatePermMap( Fms_Manager_t * pMan ){    DdManager * dd = pMan->dd;    int * pPermute, * pBitOrder, * pBitsFirst;    int i, iVar, nBits;    int nVarsIn;    // allocate the permutation map    pPermute = ALLOC( int, dd->size );    for ( i = 0; i < dd->size; i++ )        pPermute[i] = -1;    // get the parameters    pBitsFirst = Vmx_VarMapReadBitsFirst( pMan->pVmxLoc );    nVarsIn    = Vm_VarMapReadVarsInNum( Vmx_VarMapReadVm(pMan->pVmxLoc) );    // add the input variables    iVar = 0;    for ( i = 0; i < pBitsFirst[nVarsIn]; i++ )//        pPermute[dd->size/2 + i] = iVar++;        pPermute[pMan->nVars0 + i] = iVar++;    // get the parameters    pBitOrder  = Vmx_VarMapReadBitsOrder( pMan->pVmxGlo );    pBitsFirst = Vmx_VarMapReadBitsFirst( pMan->pVmxGlo );    nVarsIn    = Vm_VarMapReadVarsInNum( Vmx_VarMapReadVm(pMan->pVmxGlo) );    nBits      = Vmx_VarMapReadBitsNum( pMan->pVmxGlo );    // add the output variables    for ( i = pBitsFirst[nVarsIn]; i < nBits; i++ )        pPermute[pBitOrder[i]] = iVar++;    return pPermute;}/**Function*************************************************************  Synopsis    [Composes one MV variable.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/DdNode * fmsFlexRemap( DdManager * dd, DdNode * bFlex,     DdNode * pbFuncs[], DdNode * pbCodes[], int nValues, DdNode * bCubeChar ){    DdNode * bCof, * bComp, * bRes, * bTemp;    int i;    bRes = b0;   Cudd_Ref( bRes );    for ( i = 0; i < nValues; i++ )    {        bCof  = Cudd_bddAndAbstract( dd, bFlex, pbCodes[i], bCubeChar ); Cudd_Ref( bCof );        bComp = Cudd_bddAnd( dd, bCof, pbFuncs[i] );                     Cudd_Ref( bComp );        bRes  = Cudd_bddOr( dd, bTemp = bRes, bComp );                   Cudd_Ref( bRes );        Cudd_RecursiveDeref( dd, bCof );        Cudd_RecursiveDeref( dd, bComp );        Cudd_RecursiveDeref( dd, bTemp );    }    Cudd_Deref( bRes );    return bRes;}/**Function*************************************************************  Synopsis    [Composes one MV variable.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/DdNode * fmsFlexConvolve( DdManager * dd, DdNode * pbFuncs[], DdNode * pbCodes[], int nValues ){    DdNode * bComp, * bRes, * bTemp;    int i;    bRes = b0;   Cudd_Ref( bRes );    for ( i = 0; i < nValues; i++ )    {        bComp = Cudd_bddAnd( dd, pbFuncs[i], pbCodes[i] );   Cudd_Ref( bComp );        bRes  = Cudd_bddOr( dd, bTemp = bRes, bComp );       Cudd_Ref( bRes );        Cudd_RecursiveDeref( dd, bComp );        Cudd_RecursiveDeref( dd, bTemp );    }    Cudd_Deref( bRes );    return bRes;}/**Function*************************************************************  Synopsis    [This procedure transfers from the set output to normal outputs.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/DdNode * fmsFlexTransferFromSetOutputs( Fms_Manager_t * pMan, DdNode * bFlexGlo ){    Vm_VarMap_t * pVm, * pVmInit;    DdManager * dd;    DdNode ** pbFuncs;    DdNode ** pbCodes;    DdNode * bResult;    int nVarsIn, nValuesIn, nBits, i;    int * pBitsFirst;    assert( pMan->pVmxGloS );    // get the parameters    dd         = pMan->dd;    pVmInit    = Vmx_VarMapReadVm( pMan->pVmxGlo );    pVm        = Vmx_VarMapReadVm( pMan->pVmxGloS );    nVarsIn    = Vm_VarMapReadVarsInNum( pVm );    nValuesIn  = Vm_VarMapReadValuesInNum( pVm );    nBits      = Vmx_VarMapReadBitsNum( pMan->pVmxGloS );    pBitsFirst = Vmx_VarMapReadBitsFirst( pMan->pVmxGloS );    assert( nBits - pBitsFirst[nVarsIn] == Vm_VarMapReadValuesOutNum(pVmInit) );    // set up the vector-compose problem    pbFuncs = ALLOC( DdNode *, dd->size );    for ( i = 0; i < dd->size; i++ )        pbFuncs[i] = dd->vars[i];    // encode the variables of the normal map (to get codes for the set vars)    pbCodes  = Vmx_VarMapEncodeMap( dd, pMan->pVmxGlo );    // modify by setting the composition relations    for ( i = pBitsFirst[nVarsIn]; i < nBits; i++ )        pbFuncs[i] = pbCodes[nValuesIn + (i - pBitsFirst[nVarsIn])];    // perform the composition    bResult = Cudd_bddVectorCompose( dd, bFlexGlo, pbFuncs );  Cudd_Ref( bResult );    // deref the codes    Vmx_VarMapEncodeDeref( dd, pMan->pVmxGlo, pbCodes );    FREE( pbFuncs );    Cudd_Deref( bResult );    return bResult;}/**Function*************************************************************  Synopsis    []  Description []                 SideEffects []  SeeAlso     []***********************************************************************/int fmsFlexGetGlobalBddSize( Sh_Network_t * pNet ){    DdNode ** pbFuncs;    int nNodes, i;    pbFuncs = ALLOC( DdNode *, pNet->nOutputs );    for ( i = 0; i < pNet->nOutputs; i++ )        pbFuncs[i] = Fm_DataGetNodeGlo( pNet->ppOutputs[i] );    nNodes = Cudd_SharingSize( pbFuncs, pNet->nOutputs );    FREE( pbFuncs );    return nNodes;}///////////////////////////////////////////////////////////////////////////                       END OF FILE                                ///////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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