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

📄 iowrite.c

📁 主要进行大规模的电路综合
💻 C
📖 第 1 页 / 共 2 页
字号:
    Io_WriteNetworkNodeFanins( pFile, pNode );    fprintf( pFile, "\n" );    // write the cubes    pCover = Fnc_FunctionGetCvr( Ntk_NodeReadMan(pNode), Ntk_NodeReadFunc(pNode) );    pVm    = Fnc_FunctionReadVm( Ntk_NodeReadFunc(pNode) );    assert( pVm = Cvr_CoverReadVm(pCover) );    if ( FileType == IO_FILE_BLIF )        Io_WriteNetworkNodeBlif( pFile, pVm, pCover );    else if ( FileType == IO_FILE_BLIF_MVS )        Io_WriteNetworkNodeBlifMvs( pFile, pVm, pCover );    else if ( FileType == IO_FILE_BLIF_MV )        Io_WriteNetworkNodeBlifMv( pFile, pVm, pCover );}/**Function*************************************************************  Synopsis    [Writes the primary input list in a nice sort of way.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Io_WriteNetworkNodeFanins( FILE * pFile, Ntk_Node_t * pNode ){    Ntk_Node_t * pFanin;    Ntk_Pin_t * pPin;    int LineLength;    int AddedLength;    int NameCounter;    char * pName;    LineLength  = 6;    NameCounter = 0;    Ntk_NodeForEachFanin( pNode, pPin, pFanin )    {        // get the fanin name        pName = Ntk_NodeGetNameLong(pFanin);        // get the line length after the fanin name is written        AddedLength = strlen(pName) + 1;        if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )        { // write the line extender            fprintf( pFile, " \\\n" );            // reset the line length            LineLength  = 0;            NameCounter = 0;        }        fprintf( pFile, " %s", pName );        LineLength += AddedLength;        NameCounter++;    }    // get the output name    pName = Ntk_NodeGetNameLong(pNode);    // get the line length after the output name is written    AddedLength = strlen(pName) + 1;    if ( NameCounter && LineLength + AddedLength > 75 )    { // write the line extender        fprintf( pFile, " \\\n" );        // reset the line length        LineLength  = 0;        NameCounter = 0;    }    fprintf( pFile, " %s", pName );}/**Function*************************************************************  Synopsis    [Write the buffer.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Io_WriteNetworkBuffer( FILE * pFile, Ntk_Node_t * pInput, Ntk_Node_t * pOutput, int FileType ){    int nValues;    int i, k;    assert( Ntk_NodeReadValueNum(pInput) == Ntk_NodeReadValueNum(pOutput) );    if ( FileType == IO_FILE_BLIF_MV )        fprintf( pFile, ".table" );    else        fprintf( pFile, ".names" );    fprintf( pFile, " %s", Ntk_NodeGetNameLong(pInput) );    fprintf( pFile, " %s", Ntk_NodeGetNameLong(pOutput) );    fprintf( pFile, "\n" );    if ( FileType == IO_FILE_BLIF )        fprintf( pFile, "1 1\n" );    else if ( FileType == IO_FILE_BLIF_MV )        fprintf( pFile, "- =%s\n", Ntk_NodeGetNameLong(pInput) );    else if ( FileType == IO_FILE_BLIF_MVS )    {        nValues = Ntk_NodeReadValueNum(pInput);        for ( i = 0; i < nValues; i++ )        {            fprintf( pFile, "    " );            for ( k = 0; k < nValues; k++ )                fprintf( pFile, "%c", (k != i)? '-': '0' + k % 10 );            fprintf( pFile, "  " );            for ( k = 0; k < nValues; k++ )                fprintf( pFile, "%c", (k != i)? '-': '0' + k % 10 );            fprintf( pFile, "\n" );        }    }}/**Function*************************************************************  Synopsis    [Write the cover as BLIF.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Io_WriteNetworkNodeBlif( FILE * pFile, Vm_VarMap_t * pVm, Cvr_Cover_t * pCover ){    Mvc_Cover_t ** pIsets;    Mvc_Cover_t * Cover;    int nValues, fPhase;    pIsets  = Cvr_CoverReadIsets( pCover );    nValues = Vm_VarMapReadValuesOutput(pVm);    if ( pIsets[1] == NULL )    {        fPhase = 0;        Cover = pIsets[0];    }    else    {        fPhase = 1;        Cover = pIsets[1];    }    // at this point, we may need to print both covers    // if the node is incompletely specified (not a standard BLIF)    // so far, we are simply printing the positive phase    // check if the cover is a constant    if ( Vm_VarMapReadVarsNum(pVm) == 1 )    {        if ( fPhase == 0 && Mvc_CoverReadCubeNum(Cover) == 0 ||              fPhase == 1 && Mvc_CoverReadCubeNum(Cover) == 1 )            fprintf( pFile, " 1\n" );        return;    }    Io_WriteNetworkNodeBlifCover( pFile, pVm, Cover, fPhase );}/**Function*************************************************************  Synopsis    [Write the cover as BLIF.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Io_WriteNetworkNodeBlifCover( FILE * pFile, Vm_VarMap_t * pVm, Mvc_Cover_t * Cover, int Value ){    Mvc_Cube_t * pCube;    int v;    int * pValues      = Vm_VarMapReadValuesArray(pVm);    int * pValuesFirst = Vm_VarMapReadValuesFirstArray(pVm);    int nVarsIn        = Vm_VarMapReadVarsInNum(pVm);    Mvc_CoverForEachCube( Cover, pCube )     {        // write the inputs        for ( v = 0; v < nVarsIn; v++ )            if ( Mvc_CubeBitValue(  pCube,  2*v ) )            {                if ( Mvc_CubeBitValue(  pCube,  2*v + 1 ) )                    fprintf( pFile, "%c", '-' );                else                     fprintf( pFile, "%c", '0' );            }            else             {                if ( Mvc_CubeBitValue(  pCube,  2*v + 1 ) )                    fprintf( pFile, "%c", '1' );                else                     fprintf( pFile, "%c", '?' );            }        // write the output        fprintf( pFile, " %d\n", Value );    }}/**Function*************************************************************  Synopsis    [Write the cover as BLIF-MVS.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Io_WriteNetworkNodeBlifMvs( FILE * pFile, Vm_VarMap_t * pVm, Cvr_Cover_t * pCover ){    Mvc_Cover_t ** pIsets;    int nValues, Default, i;    pIsets  = Cvr_CoverReadIsets( pCover );    nValues = Vm_VarMapReadValuesOutput(pVm);    Default = Cvr_CoverReadDefault( pCover );    for ( i = 0; i < nValues; i++ )        if ( pIsets[i] )            Io_WriteNetworkNodeBlifMvsCover( pFile, pVm, pIsets[i], i, Default, nValues );}/**Function*************************************************************  Synopsis    [Write the cover as BLIF-MVS.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Io_WriteNetworkNodeBlifMvsCover( FILE * pFile, Vm_VarMap_t * pVm, Mvc_Cover_t * Cover, int Value, int Default, int nOutputValues ){    Mvc_Cube_t * pCube;    int i, v;    int * pValues      = Vm_VarMapReadValuesArray(pVm);    int * pValuesFirst = Vm_VarMapReadValuesFirstArray(pVm);    int nVarsIn        = Vm_VarMapReadVarsInNum(pVm);    Mvc_CoverForEachCube( Cover, pCube )    {        // write space        fprintf( pFile, "   " );        // write the variables        for ( i = 0; i < nVarsIn; i++ )        {            // write space            fprintf( pFile, " " );            // write the input literal            for ( v = 0; v < pValues[i]; v++ )                if ( Mvc_CubeBitValue( pCube,  pValuesFirst[i] + v) )                     fprintf( pFile, "%d", v % 10 );                else                    fprintf( pFile, "%c", '-' );        }        // write space        fprintf( pFile, "  " );        // write the output literal        for ( v = 0; v < nOutputValues; v++ )            if ( v == Value )                fprintf( pFile, "%d", v % 10 );            else if ( v == Default )                fprintf( pFile, "%c", 'D' );            else                fprintf( pFile, "%c", '-' );        // write new line        fprintf( pFile, "\n" );    }}/**Function*************************************************************  Synopsis    [Write the cover as BLIF-MV.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Io_WriteNetworkNodeBlifMv( FILE * pFile, Vm_VarMap_t * pVm, Cvr_Cover_t * pCover ){    Mvc_Cover_t ** pIsets;    int nValues, Default, i;    nValues = Vm_VarMapReadValuesOutput(pVm);    pIsets  = Cvr_CoverReadIsets( pCover );    Default = Cvr_CoverReadDefault( pCover );    if ( Default >= 0 )        fprintf( pFile, ".default %d\n", Default );    for ( i = 0; i < nValues; i++ )        if ( pIsets[i] )            Io_WriteNetworkNodeBlifMvCover( pFile, pVm, pIsets[i], i );}/**Function*************************************************************  Synopsis    [Write the cover as BLIF-MV.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Io_WriteNetworkNodeBlifMvCover( FILE * pFile, Vm_VarMap_t * pVm, Mvc_Cover_t * Cover, int Value ){    Mvc_Cube_t * pCube;    int Counter, FirstValue;    int i, v;    int * pValues      = Vm_VarMapReadValuesArray(pVm);    int * pValuesFirst = Vm_VarMapReadValuesFirstArray(pVm);    int nVarsIn        = Vm_VarMapReadVarsInNum(pVm);    Mvc_CoverForEachCube( Cover, pCube )     {        // write the variables        for ( i = 0; i < nVarsIn; i++ )        {            // count the number of values in this literal            Counter  = 0;            for ( v = 0; v < pValues[i]; v++ )                if ( Mvc_CubeBitValue( pCube,  pValuesFirst[i] + v) )                     Counter++;            assert( Counter > 0 );            if ( Counter == pValues[i] )                fprintf( pFile, "- " );            else if ( Counter == 1 )            {                for ( v = 0; v < pValues[i]; v++ )                    if ( Mvc_CubeBitValue( pCube,  pValuesFirst[i] + v) )                         fprintf( pFile, "%d ", v );            }            else            {                fprintf( pFile, "(" );                FirstValue = 1;                for ( v = 0; v < pValues[i]; v++ )                    if ( Mvc_CubeBitValue( pCube,  pValuesFirst[i] + v) )                     {                        if ( FirstValue )                            FirstValue = 0;                        else                            fprintf( pFile, "," );                        fprintf( pFile, "%d", v );                    }                fprintf( pFile, ") " );            }        }        // write the output        if ( nVarsIn > 0 )            fprintf( pFile, " " );        fprintf( pFile, "%d\n", Value );    }}///////////////////////////////////////////////////////////////////////////                       END OF FILE                                ///////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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