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

📄 ntkiprint.c

📁 主要进行大规模的电路综合
💻 C
📖 第 1 页 / 共 3 页
字号:
    // set the flexibility    bRel = Mvr_RelationReadRel( pMvr );    Mvr_RelationWriteRel( pMvr, bFlex );    Ntk_NodePrintMvr( pFile, pNode );    Mvr_RelationWriteRel( pMvr, bRel );}/**Function*************************************************************  Synopsis    [Prints the node cover in positional notation.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Ntk_NodePrintCvr( FILE * pFile, Ntk_Node_t * pNode, bool fPrintDefault, bool fPrintPositional ){    Ntk_Node_t ** pFanins;    Cvr_Cover_t * pCvr;    Vm_VarMap_t * pVm;    char * pNameOut;    Mvc_Cover_t ** pCovers;    int nInputs, Pos, i;    // get the output name    pNameOut = Ntk_NodeGetNamePrintableInt( pNode );    // the node may be CO, if its fanin is a CI or an internal node without CO name    if ( pNode->Type == MV_NODE_CO )    {        if ( fPrintPositional )            return;        for ( i = 1; i < pNode->nValues; i++ )        {            Ntk_NodePrintOutputName( pFile, pNameOut, pNode->nValues, i );            fprintf( pFile, "%s", Ntk_NodeGetNamePrintableInt( Ntk_NodeReadFaninNode(pNode,0) ) );            if ( pNode->nValues > 2 )                fprintf( pFile, "{%d}", i );            fprintf( pFile, "\n" );            return;        }    }    // get the cover    pVm  = Ntk_NodeReadFuncVm(pNode);    pCvr = Ntk_NodeGetFuncCvr(pNode);    pCovers = Cvr_CoverReadIsets( pCvr );    nInputs = Ntk_NodeReadFaninNum(pNode);    // save the output name    pNameOut = util_strsav( pNameOut );    // get the fanins    pFanins = pNode->pNet->pArray1;    Ntk_NodeReadFanins( pNode, pFanins );    // iterate through the i-sets    for ( i = 0; i < pNode->nValues; i++ )        if ( pCovers[i] )        {            Pos = Ntk_NodePrintOutputName( pFile, pNameOut, pNode->nValues, i );            if ( fPrintPositional )                Ntk_NodePrintCvrPositional( pFile, pVm, pCovers[i], nInputs );            else                Ntk_NodePrintCvrLiterals( pFile, pVm, pFanins, pCovers[i], nInputs, &Pos );            fprintf( pFile, "\n" );        }        else if ( fPrintDefault )        {            Pos = Ntk_NodePrintOutputName( pFile, pNameOut, pNode->nValues, i );            fprintf( pFile, "<default> " );            Pos += 10;                        pCovers[i] = Ntk_NodeComputeDefault( pNode );            if ( fPrintPositional )                Ntk_NodePrintCvrPositional( pFile, pVm, pCovers[i], nInputs );            else                Ntk_NodePrintCvrLiterals( pFile, pVm, pFanins, pCovers[i], nInputs, &Pos );            fprintf( pFile, "\n" );                        Mvc_CoverFree( pCovers[i] );            pCovers[i] = NULL;        }    FREE( pNameOut );}/**Function*************************************************************  Synopsis    [Prints the node cover in positional notation.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Ntk_NodePrintCvrPositional( FILE * pFile, Vm_VarMap_t * pVm, Mvc_Cover_t * Cover, int nVars ){    Mvc_Cube_t * pCube;    int * pValuesFirst;    int FirstCube;    int i, v;    if ( Mvc_CoverIsEmpty(Cover) )    {        for ( i = 0; i < 15; i++ )            fprintf( pFile, " " );        fprintf( pFile, "Constant 0" );        return;    }    if ( Mvc_CoverIsTautology(Cover) )    {        for ( i = 0; i < 15; i++ )            fprintf( pFile, " " );        fprintf( pFile, "Constant 1" );        return;    }    pValuesFirst = Vm_VarMapReadValuesFirstArray(pVm);    FirstCube = 1;    Mvc_CoverForEachCube( Cover, pCube )    {        fprintf( pFile, "\n" );        for ( i = 0; i < 15; i++ )            fprintf( pFile, " " );        for ( i = 0; i < nVars; i++ )        {            // print this literal            fprintf( pFile, " " );            for ( v = pValuesFirst[i]; v < pValuesFirst[i+1]; v++ )                if ( Mvc_CubeBitValue( pCube,  v ) )                    fprintf( pFile, "1" );                else                    fprintf( pFile, "0" );        }    }}/**Function*************************************************************  Synopsis    [Prints the node cover in positional notation.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Ntk_NodePrintCvrLiterals( FILE * pFile, Vm_VarMap_t * pVm,     Ntk_Node_t * pFanins[], Mvc_Cover_t * Cover, int nVars, int * pPos ){    Mvc_Cube_t * pCube;    bool fFirstCube, fFirstLit;    int * pValuesFirst;    char * pName;    int i, v;    if ( Mvc_CoverIsEmpty(Cover) )    {        fprintf( pFile, " Constant 0" );        return;    }    if ( Mvc_CoverIsTautology(Cover) )    {        fprintf( pFile, " Constant 1" );        return;    }    pValuesFirst = Vm_VarMapReadValuesFirstArray(pVm);    fFirstCube = 1;    Mvc_CoverForEachCube( Cover, pCube )    {        if ( fFirstCube )            fFirstCube = 0;        else        {            fprintf( pFile, " + " );            (*pPos) += 3;        }        fFirstLit = 1;        for ( i = 0; i < nVars; i++ )        {            // check if this literal is full            for ( v = pValuesFirst[i]; v < pValuesFirst[i+1]; v++ )                if ( !Mvc_CubeBitValue( pCube,  v ) )                    break;            if ( v == pValuesFirst[i+1] )                continue;            // print space between literals            if ( fFirstLit )                fFirstLit = 0;            else            {                fprintf( pFile, " " );                (*pPos) += 1;            }            // print this literal            pName = Ntk_NodePrintLiteral( pCube, i, pFanins, pValuesFirst );            Ntk_NodePrintUpdatePos( pFile, pPos, pName );            // print            fprintf( pFile, "%s", pName );            (*pPos) += strlen(pName);        }    }}/**Function*************************************************************  Synopsis    [Prints one literal.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/char * Ntk_NodePrintLiteral( Mvc_Cube_t * pCube, int iLit, Ntk_Node_t ** ppFanins, int * pValuesFirst ){    static char Buffer[500];    char Value[10];    bool fFirstValue;    int Val0, Val1;    int v;    fFirstValue = 1;    if ( pValuesFirst[iLit+1] - pValuesFirst[iLit] == 2 )    {        Val0 = Mvc_CubeBitValue( pCube,  pValuesFirst[iLit]   );        Val1 = Mvc_CubeBitValue( pCube,  pValuesFirst[iLit]+1 );        assert( (Val0 ^ Val1) == 1 );        sprintf( Buffer, "%s", Ntk_NodeGetNamePrintableInt(ppFanins[iLit]) );        if ( Val0 )            strcat( Buffer, "\'" );    }    else    {        sprintf( Buffer, "%s{", Ntk_NodeGetNamePrintableInt(ppFanins[iLit]) );        for ( v = pValuesFirst[iLit]; v < pValuesFirst[iLit+1]; v++ )            if ( Mvc_CubeBitValue( pCube,  v ) )            {                if ( fFirstValue )                    fFirstValue = 0;                else                    strcat( Buffer, "," );                sprintf( Value, "%d", v - pValuesFirst[iLit] );                strcat( Buffer, Value );            }        strcat( Buffer, "}" );    }    return Buffer;}/**Function*************************************************************  Synopsis    []  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Ntk_NodePrintUpdatePos( FILE * pFile, int * pPos, char * pName ){    int i;    if ( *pPos + strlen(pName) < 76 )        return;    fprintf( pFile, "\n" );    for ( i = 0; i < 10; i++ )        fprintf( pFile, " " );    *pPos = 10;}/**Function*************************************************************  Synopsis    [Wraps the output names into braces {} like in SIS.]  Description [The braces do not counts as characters in the name.  They are ohly used to distinquish the CO node names from all other   names in the network.]                 SideEffects []  SeeAlso     []***********************************************************************/char * Ntk_NodeGetNamePrintableInt( Ntk_Node_t * pNode ){    static char NameInt[500];    Ntk_Node_t * pNodeCo;    if ( Ntk_NodeIsCo(pNode) )    {        sprintf( NameInt, "{%s}", Ntk_NodeGetNamePrintable(pNode) );        return NameInt;    }    if ( pNodeCo = Ntk_NodeHasCoName(pNode) )    {        sprintf( NameInt, "{%s}", Ntk_NodeGetNamePrintable(pNodeCo) );        return NameInt;    }    return Ntk_NodeGetNamePrintable(pNode);}/**Function*************************************************************  Synopsis    [Starts the printout for a factored form or cover.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/int Ntk_NodePrintOutputName( FILE * pFile, char * pNameOut, int nValuesOut, int iSet ){    char Buffer[500];    char Value[10];    sprintf( Buffer, "%s", pNameOut? pNameOut: "?" );    if ( nValuesOut > 2 )    {        sprintf( Value, "{%d} ", iSet );        strcat( Buffer, Value );    }    else    {        sprintf( Value, "%s", (iSet==0)? "\'": " " );        strcat( Buffer, Value );    }    fprintf( pFile, "%8s: ", Buffer );    return 10;}///////////////////////////////////////////////////////////////////////////                       END OF FILE                                ///////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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