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

📄 ioreadnode.c

📁 主要进行大规模的电路综合
💻 C
📖 第 1 页 / 共 3 页
字号:
            p->LineCur = k;            // parse the cube            if ( Io_ReadNodeBlifMvsCoverCube( p, p->pCube, &pPhase ) )            {                for ( i = 0; i < nValues; i++ )                    if ( pCovers[i] )                    {                        Mvc_CoverFree( pCovers[i] );                        pCovers[i] = NULL;                    }                return 1;            }            // allocate the covers            if ( fFirstTime )            {                fFirstTime = 0;                assert( strlen(pPhase) == (unsigned)nValues );                for ( i = 0; i < nValues; i++ )                    if ( pPhase[i] == 'D' )                        pCovers[i] = NULL;                    else                        pCovers[i] = Mvc_CoverAlloc( Fnc_ManagerReadManMvc(Mv_FrameReadMan(p->pMvsis)), pVm->nValuesIn );            }            // add the cube            for ( i = 0; i < nValues; i++ )                if ( pCovers[i] && pPhase[i] != '-' )                    Mvc_CoverAddDupCubeTail( pCovers[i], p->pCube );            // count the parsed line            LineCounter++;        }    // make sure the correct number of lines was read    assert( LineCounter == pIoNode->nLines );    return 0;}/**Function*************************************************************  Synopsis    []  Description []                 SideEffects []  SeeAlso     []***********************************************************************/int Io_ReadNodeBlifMvsCoverCube( Io_Read_t * p, Mvc_Cube_t * pCube, char ** pPhase ){    Ntk_Node_t * pNode;    Io_Node_t * pIoNode;    Vm_VarMap_t * pVm;     char * pLine, * pTemp;    int Length, v, i, iValue;    int nVars, nValuesIn;    // initialize important pointers    pNode     = p->pNodeCur;    pIoNode   = (Io_Node_t *)Ntk_NodeReadData(pNode);    pVm       = Ntk_NodeReadFuncVm(pNode);    nValuesIn = Vm_VarMapReadValuesInNum(pVm);    nVars     = Vm_VarMapReadVarsNum(pVm);    // get the line     pLine = p->pLines[p->LineCur];    // clean the cube    Mvc_CubeBitFill( pCube );    // get the next literal    pTemp = strtok( pLine, " \t" );    Length = strlen(pTemp);    // read the literals    iValue = 0;    assert( pVm->nVarsOut == 1 );    for ( v = 0; v < nVars; v++ )    {        // add to the total number of values        iValue += pVm->pValues[v];        if ( pTemp == NULL )        {            sprintf( p->sError, "The number of literals (%d) is less than the number of variables (%d).",                 v, nVars );            Io_ReadPrintErrorMessage( p );            return 1;        }        // compare the literal length        if ( Length != pVm->pValues[v] )        {            sprintf( p->sError, "Literal %d has size %d, not equal to the number of values (%d).",                v, Length, pVm->pValues[v] );            Io_ReadPrintErrorMessage( p );            return 1;        }        // if it is the output variable, assign the phase and stop        if ( v == nVars - 1 )        {            *pPhase = pTemp;            break;        }        // set the values of this literal in the cube        for ( i = 0; i < Length; i++ )            if ( pTemp[i] == '-' )                Mvc_CubeBitRemove( pCube, pVm->pValuesFirst[v] + i );        // get the next literal        pTemp = strtok( NULL, " \t" );        Length = strlen(pTemp);    }    assert( iValue == Vm_VarMapReadValuesNum(pVm) );    return 0;}/**Function*************************************************************  Synopsis    []  Description []                 SideEffects []  SeeAlso     []***********************************************************************/int Io_ReadNodeBlifMvCover( Io_Read_t * p, Mvc_Cover_t * pCovers[] ){    Ntk_Node_t * pNode;    Io_Node_t * pIoNode;    Vm_VarMap_t * pVm;     char * pPhase;    int Equal1, Equal2;    int nValuesOut, Default;    int LineCounter, i, v, k;    // initialize important pointers    pNode   = p->pNodeCur;    pIoNode = (Io_Node_t *)Ntk_NodeReadData(pNode);    pVm    = Fnc_FunctionReadVm( Ntk_NodeReadFunc(pNode) );    pPhase  = (char *)pVm->pMan->pArray1;    // get the number of values and the default    nValuesOut = Ntk_NodeReadValueNum(pNode);    Default = pIoNode->Default;    assert( nValuesOut == Vm_VarMapReadValuesOutput(pVm) );    // allocate the covers     for ( i = 0; i < nValuesOut; i++ )        if ( i == Default )            pCovers[i] = NULL;        else            pCovers[i] = Mvc_CoverAlloc( Fnc_ManagerReadManMvc(Mv_FrameReadMan(p->pMvsis)), pVm->nValuesIn );    if ( pIoNode->nLines )    {        // go through the cubes        LineCounter = 0;        for ( k = pIoNode->LineTable; p->pLines[k][0] != '.'; k++ )            if ( p->pLines[k][0] != '\0' )            {                // get the line number                p->LineCur = k;                // parse the cube                if ( Io_ReadNodeBlifMvCoverCube( p, p->pCube, pPhase, &Equal1, &Equal2 ) )                {                    for ( i = 0; i < nValuesOut; i++ )                        if ( pCovers[i] )                        {                            Mvc_CoverFree( pCovers[i] );                            pCovers[i] = NULL;                        }                    return 1;                }                // add the cube                if ( Equal1 == -1 )                { // there is no =construct                    // add the cube to the i-sets                    for ( i = 0; i < nValuesOut; i++ )                        if ( pCovers[i] && pPhase[i] != '-' )                            Mvc_CoverAddDupCubeTail( pCovers[i], p->pCube );                    LineCounter++;                    continue;                }                // add as many cubes as there are values of the given fanin node                // the values corresponding to this fanin are not currently set in the cube                assert( Equal1 >= 0 && Equal1 <= pVm->nVarsIn );                assert( Equal2 >= 0 && Equal2 <= pVm->nVarsIn );                assert( pVm->pValues[Equal1] == pVm->pValues[Equal2] );                assert( Equal1 < Equal2 );                                // remember the values saved in the literal (Equal1) of the cube                for ( v = 0; v < pVm->pValues[Equal1]; v++ )                    if ( Mvc_CubeBitValue( p->pCube, pVm->pValuesFirst[Equal1] + v ) )                        pPhase[v] = '1';                    else                        pPhase[v] = '-';                pPhase[v] = 0;                if ( Equal2 < pVm->nVarsIn )                { // the equality does not involve the output                    // remove all values belonging to the variables                    for ( v = 0; v < pVm->pValues[Equal1]; v++ )                        Mvc_CubeBitRemove( p->pCube, pVm->pValuesFirst[Equal1] + v );                    for ( v = 0; v < pVm->pValues[Equal2]; v++ )                        Mvc_CubeBitRemove( p->pCube, pVm->pValuesFirst[Equal2] + v );                    for ( v = 0; v < pVm->pValues[Equal1]; v++ )                        if ( pPhase[v] == '1' )                        {                             // add a new value                            Mvc_CubeBitInsert( p->pCube, pVm->pValuesFirst[Equal1] + v );                            Mvc_CubeBitInsert( p->pCube, pVm->pValuesFirst[Equal2] + v );                            // add the cube to all the related i-sets                            for ( i = 0; i < nValuesOut; i++ )                                if ( pCovers[i] && pPhase[i] != '-' )                                    Mvc_CoverAddDupCubeTail( pCovers[i], p->pCube );                            // remove previously added value to the var and the output                            Mvc_CubeBitRemove( p->pCube, pVm->pValuesFirst[Equal1] + v );                            Mvc_CubeBitRemove( p->pCube, pVm->pValuesFirst[Equal2] + v );                        }                }                else // the output is involved                {                    // remove all values belonging to the first variable                    for ( v = 0; v < pVm->pValues[Equal1]; v++ )                        Mvc_CubeBitRemove( p->pCube, pVm->pValuesFirst[Equal1] + v );                    for ( v = 0; v < pVm->pValues[Equal1]; v++ )                        if ( pPhase[v] == '1' )                        {                            // add a new value                            Mvc_CubeBitInsert( p->pCube, pVm->pValuesFirst[Equal1] + v );                            // add the cube to the corresponding i-set                            if ( pCovers[v] )                                 Mvc_CoverAddDupCubeTail( pCovers[v], p->pCube );                            // remove previously added value to the var and the output                            Mvc_CubeBitRemove( p->pCube, pVm->pValuesFirst[Equal1] + v );                       }                }                // count the number of lines                LineCounter++;            }        // make sure the correct number of lines was read        assert( LineCounter == pIoNode->nLines );    }    else    {        if ( Default < 0 )        {            p->LineCur = pIoNode->LineNames;            sprintf( p->sError, "The node has no default value and no cubes." );            Io_ReadPrintErrorMessage( p );            return 1;        }    }    return 0;}/**Function*************************************************************  Synopsis    [Reads one line of BLIF-MV table.]  Description [This function reads one line (Line) stored in the reading  manager (Io_Read_t). The variable map in the node shows the expected values  of the fanins. The result goes in Espresso cube (Set). The string pPhase is  set to point to the output literal. The two last variables (pEqual1, pEqual2),   if they are not -1, are the 0-based numbers of the (fanin or output) variables  which are connected by the equality relation (=construct).]                 SideEffects []  SeeAlso     []***********************************************************************/int Io_ReadNodeBlifMvCoverCube( Io_Read_t * p, Mvc_Cube_t * pCube, char * pPhase, int * pEqual1, int * pEqual2 ){    Ntk_Node_t * pNode;    Io_Node_t * pIoNode;    Vm_VarMap_t * pVm;     char * pLine, * pPart;    int nValues, iValue, v, i;    int nValuesIn, nVars;    // initialize important pointers    pNode     = p->pNodeCur;    pIoNode   = (Io_Node_t *)Ntk_NodeReadData(pNode);    pVm       = Ntk_NodeReadFuncVm(pNode);    nValuesIn = Vm_VarMapReadValuesInNum(pVm);    nVars     = Vm_VarMapReadVarsNum(pVm);    // get the line     pLine = p->pLines[p->LineCur];    // clean the cube    Mvc_CubeBitFill( pCube );    // get the number of output values    nValues = Ntk_NodeReadValueNum(pNode);    assert( nValues == Vm_VarMapReadValuesOutput(pVm) );    // clearn Equals    *pEqual1 = -1;    *pEqual2 = -1;    // get the literals    iValue = 0;    for ( v = 0; v <= pVm->nVarsIn; v++ )    {        // add to the total number of values        iValue += pVm->pValues[v];        // get the next part        pLine = Io_ReadNodeBlifMvCoverCubePart( pLine, &pPart );        if ( pPart == NULL )        {            sprintf( p->sError, "This line cannot be properly parsed." );            Io_ReadPrintErrorMessage( p );            return 1;        }        // set the value set to empty        for ( i = 0; i < pVm->pValues[v]; i++ )            pPhase[i] = '-';        pPhase[pVm->pValues[v]] = 0;

⌨️ 快捷键说明

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