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

📄 fxuselect.c

📁 主要进行大规模的电路综合
💻 C
📖 第 1 页 / 共 2 页
字号:
/**CFile****************************************************************  FileName    [fxuSelect.c]  PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]  Synopsis    [Procedures to select the best divisor/complement pair.]  Author      [MVSIS Group]    Affiliation [UC Berkeley]  Date        [Ver. 1.0. Started - February 1, 2003.]  Revision    [$Id: fxuSelect.c,v 1.5 2003/05/27 23:15:56 alanmi Exp $]***********************************************************************/#include "fxuInt.h"///////////////////////////////////////////////////////////////////////////                        DECLARATIONS                              ///////////////////////////////////////////////////////////////////////////#define MAX_SIZE_LOOKAHEAD      20static int Fxu_MatrixFindComplement( Fxu_Matrix * p, int iVar );static Fxu_Double * Fxu_MatrixFindComplementSingle( Fxu_Matrix * p, Fxu_Single * pSingle );static Fxu_Single * Fxu_MatrixFindComplementDouble2( Fxu_Matrix * p, Fxu_Double * pDouble );static Fxu_Double * Fxu_MatrixFindComplementDouble4( Fxu_Matrix * p, Fxu_Double * pDouble );Fxu_Double * Fxu_MatrixFindDouble( Fxu_Matrix * p,      int piVarsC1[], int piVarsC2[], int nVarsC1, int nVarsC2 );void Fxu_MatrixGetDoubleVars( Fxu_Matrix * p, Fxu_Double * pDouble,     int piVarsC1[], int piVarsC2[], int * pnVarsC1, int * pnVarsC2 );///////////////////////////////////////////////////////////////////////////                     FUNCTION DEFITIONS                           ////////////////////////////////////////////////////////////////////////////**Function*************************************************************  Synopsis    [Selects the best pair (Single,Double) and returns their weight.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/int Fxu_Select( Fxu_Matrix * p, Fxu_Single ** ppSingle, Fxu_Double ** ppDouble ){    // the top entries    Fxu_Single * pSingles[MAX_SIZE_LOOKAHEAD];    Fxu_Double * pDoubles[MAX_SIZE_LOOKAHEAD];    // the complements    Fxu_Double * pSCompl[MAX_SIZE_LOOKAHEAD];    Fxu_Single * pDComplS[MAX_SIZE_LOOKAHEAD];    Fxu_Double * pDComplD[MAX_SIZE_LOOKAHEAD];    Fxu_Pair * pPair;    int nSingles;    int nDoubles;    int i;    int WeightBest;    int WeightCur;    int iNum, fBestS;    // collect the top entries from the queues    for ( nSingles = 0; nSingles < MAX_SIZE_LOOKAHEAD; nSingles++ )    {        pSingles[nSingles] = Fxu_HeapSingleGetMax( p->pHeapSingle );        if ( pSingles[nSingles] == NULL )            break;    }    // put them back into the queue    for ( i = 0; i < nSingles; i++ )        if ( pSingles[i] )            Fxu_HeapSingleInsert( p->pHeapSingle, pSingles[i] );            // the same for doubles    // collect the top entries from the queues    for ( nDoubles = 0; nDoubles < MAX_SIZE_LOOKAHEAD; nDoubles++ )    {        pDoubles[nDoubles] = Fxu_HeapDoubleGetMax( p->pHeapDouble );        if ( pDoubles[nDoubles] == NULL )            break;    }    // put them back into the queue    for ( i = 0; i < nDoubles; i++ )        if ( pDoubles[i] )            Fxu_HeapDoubleInsert( p->pHeapDouble, pDoubles[i] );    // for each single, find the complement double (if any)    for ( i = 0; i < nSingles; i++ )        if ( pSingles[i] )            pSCompl[i] = Fxu_MatrixFindComplementSingle( p, pSingles[i] );    // for each double, find the complement single or double (if any)    for ( i = 0; i < nDoubles; i++ )        if ( pDoubles[i] )        {            pPair = pDoubles[i]->lPairs.pHead;            if ( pPair->nLits1 == 1 && pPair->nLits2 == 1 )            {                pDComplS[i] = Fxu_MatrixFindComplementDouble2( p, pDoubles[i] );                pDComplD[i] = NULL;            }//            else if ( pPair->nLits1 == 2 && pPair->nLits2 == 2 )//            {//                pDComplS[i] = NULL;//                pDComplD[i] = Fxu_MatrixFindComplementDouble4( p, pDoubles[i] );//            }            else            {                pDComplS[i] = NULL;                pDComplD[i] = NULL;            }        }    // select the best pair    WeightBest = -1;    for ( i = 0; i < nSingles; i++ )    {        WeightCur = pSingles[i]->Weight;        if ( pSCompl[i] )        {            // add the weight of the double            WeightCur += pSCompl[i]->Weight;            // there is no need to implement this double, so...            pPair      = pSCompl[i]->lPairs.pHead;            WeightCur += pPair->nLits1 + pPair->nLits2;        }        if ( WeightBest < WeightCur )        {            WeightBest = WeightCur;            *ppSingle = pSingles[i];            *ppDouble = pSCompl[i];            fBestS = 1;            iNum = i;        }    }    for ( i = 0; i < nDoubles; i++ )    {        WeightCur = pDoubles[i]->Weight;        if ( pDComplS[i] )        {            // add the weight of the single            WeightCur += pDComplS[i]->Weight;            // there is no need to implement this double, so...            pPair      = pDoubles[i]->lPairs.pHead;            WeightCur += pPair->nLits1 + pPair->nLits2;        }        if ( WeightBest < WeightCur )        {            WeightBest = WeightCur;            *ppSingle = pDComplS[i];            *ppDouble = pDoubles[i];            fBestS = 0;            iNum = i;        }    }/*    // print the statistics    printf( "\n" );    for ( i = 0; i < nSingles; i++ )    {        printf( "Single #%d: Weight = %3d. ", i, pSingles[i]->Weight );        printf( "Compl: " );        if ( pSCompl[i] == NULL )            printf( "None." );        else            printf( "D  Weight = %3d  Sum = %3d",                 pSCompl[i]->Weight, pSCompl[i]->Weight + pSingles[i]->Weight );        printf( "\n" );    }    printf( "\n" );    for ( i = 0; i < nDoubles; i++ )    {        printf( "Double #%d: Weight = %3d. ", i, pDoubles[i]->Weight );        printf( "Compl: " );        if ( pDComplS[i] == NULL && pDComplD[i] == NULL )            printf( "None." );        else if ( pDComplS[i] )            printf( "S  Weight = %3d  Sum = %3d",                 pDComplS[i]->Weight, pDComplS[i]->Weight + pDoubles[i]->Weight );        else if ( pDComplD[i] )            printf( "D  Weight = %3d  Sum = %3d",                 pDComplD[i]->Weight, pDComplD[i]->Weight + pDoubles[i]->Weight );        printf( "\n" );    }    if ( WeightBest == -1 )        printf( "Selected NONE\n" );    else    {        printf( "Selected = %s.  ", fBestS? "S": "D" );        printf( "Number = %d.  ", iNum );        printf( "Weight = %d.\n", WeightBest );    }    printf( "\n" );*/    return WeightBest;}/**Function*************************************************************  Synopsis    []  Description []                 SideEffects []  SeeAlso     []***********************************************************************/Fxu_Double * Fxu_MatrixFindComplementSingle( Fxu_Matrix * p, Fxu_Single * pSingle ){    int * pValue2Node = p->pValue2Node;    int iVar1,  iVar2;    int iVar1C, iVar2C;    // get the variables of this single div    iVar1  = pSingle->pVar1->iVar;    iVar2  = pSingle->pVar2->iVar;    iVar1C = Fxu_MatrixFindComplement( p, iVar1 );    iVar2C = Fxu_MatrixFindComplement( p, iVar2 );    if ( iVar1C == -1 || iVar2C == -1 )        return NULL;    assert( iVar1C < iVar2C );    return Fxu_MatrixFindDouble( p, &iVar1C, &iVar2C, 1, 1 );}/**Function*************************************************************  Synopsis    []  Description []                 SideEffects []  SeeAlso     []***********************************************************************/Fxu_Single * Fxu_MatrixFindComplementDouble2( Fxu_Matrix * p, Fxu_Double * pDouble ){    int * pValue2Node = p->pValue2Node;    int piVarsC1[10], piVarsC2[10];    int nVarsC1, nVarsC2;    int iVar1,  iVar2, iVarTemp;    int iVar1C, iVar2C;    Fxu_Single * pSingle;    // get the variables of this double div    Fxu_MatrixGetDoubleVars( p, pDouble, piVarsC1, piVarsC2, &nVarsC1, &nVarsC2 );    assert( nVarsC1 == 1 );    assert( nVarsC2 == 1 );    iVar1 = piVarsC1[0];    iVar2 = piVarsC2[0];    assert( iVar1 < iVar2 );    iVar1C = Fxu_MatrixFindComplement( p, iVar1 );    iVar2C = Fxu_MatrixFindComplement( p, iVar2 );    if ( iVar1C == -1 || iVar2C == -1 )        return NULL;     // go through the queque and find this one//    assert( iVar1C < iVar2C );    if ( iVar1C > iVar2C )    {        iVarTemp = iVar1C;        iVar1C = iVar2C;        iVar2C = iVarTemp;    }    Fxu_MatrixForEachSingle( p, pSingle )        if ( pSingle->pVar1->iVar == iVar1C && pSingle->pVar2->iVar == iVar2C )            return pSingle;    return NULL;}/**Function*************************************************************  Synopsis    []  Description []                 SideEffects []  SeeAlso     []***********************************************************************/Fxu_Double * Fxu_MatrixFindComplementDouble4( Fxu_Matrix * p, Fxu_Double * pDouble ){    int * pValue2Node = p->pValue2Node;    int piVarsC1[10], piVarsC2[10];    int nVarsC1, nVarsC2;    int iVar11,  iVar12,  iVar21,  iVar22;    int iVar11C, iVar12C, iVar21C, iVar22C;    int RetValue;

⌨️ 快捷键说明

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