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

📄 ioreadnode.c

📁 主要进行大规模的电路综合
💻 C
📖 第 1 页 / 共 3 页
字号:
        // read the values of this literal        if ( Io_ReadNodeBlifMvCoverCubeLiteral( p, v, pPhase, pEqual1, pEqual2, pPart ) )            return 1;        // if it is the output variable, stop (the phase is already assigned)        if ( v == pVm->nVarsIn )            break;        // if it is =construct, do not change the cube        if ( *pEqual1 != -1 )            continue;                // set the values of this literal in the cube        for ( i = 0; i < pVm->pValues[v]; i++ )            if ( pPhase[i] == '-' )                Mvc_CubeBitRemove( pCube, pVm->pValuesFirst[v] + i );    }//printf( "\n" );    assert( iValue == Vm_VarMapReadValuesNum(pVm) );    return 0;}/**Function*************************************************************  Synopsis    [Reads the next part of the cube.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/char * Io_ReadNodeBlifMvCoverCubePart( char * pLine, char ** pPart ){    char * pCur;    // skip the spaces at the beginning    pCur = Io_ReadNodeBlifMvSkipSpaces( pLine );    if ( *pCur == 0 )        return NULL;    // assign the part, which begins here    *pPart = pCur;    // test what is the first symbol in this line    if ( *pCur == '-' )        pCur++;    else if ( *pCur == '=' )    {        pCur = Io_ReadNodeBlifMvSkipSpaces( pCur + 1 );        if ( pCur == NULL )            return NULL;        pCur = Io_ReadNodeBlifMvSkipNonSpaces( pCur );        if ( pCur == NULL )            return NULL;    }    else if ( *pCur == '(' || *pCur == '{' )    {        pCur = Io_ReadNodeBlifMvScrollToBrace( pCur );        if ( pCur == NULL )            return NULL;        assert( *pCur == ')' || *pCur == '}' );        pCur++;    }    else  // symbolic name or value number    {        pCur = Io_ReadNodeBlifMvSkipNonSpaces( pCur );        if ( pCur == NULL )            return NULL;    }    assert( *pCur == ' ' || *pCur == '\0' );    *pCur  = '\0';    return pCur + 1;}/**Function*************************************************************  Synopsis    [Skips all the space chars in the string.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/char * Io_ReadNodeBlifMvSkipSpaces( char * pStr ){    while ( *pStr && (*pStr == ' ' || *pStr == '\t') )        pStr++;    return pStr;}/**Function*************************************************************  Synopsis    [Skips all the non-space chars in the string.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/char * Io_ReadNodeBlifMvSkipNonSpaces( char * pStr ){    while ( *pStr && *pStr != ' ' && *pStr != '\t' )        pStr++;    return pStr;}/**Function*************************************************************  Synopsis    [Scrolls to the corresponding closing brace.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/char * Io_ReadNodeBlifMvScrollToBrace( char * pStr ){    int BraceRound = 0, BraceCurly = 0;    assert( *pStr == '(' || *pStr == '{' );    while ( *pStr )    {        if ( *pStr == '(' )            BraceRound++;        else if ( *pStr == ')' )            BraceRound--;        else if ( *pStr == '{' )            BraceCurly++;        else if ( *pStr == '}' )            BraceCurly--;        if ( BraceRound == 0 && BraceCurly == 0 )            return pStr;        pStr++;    }    return NULL;}/**Function*************************************************************  Synopsis    [Reads the MV literal.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/int Io_ReadNodeBlifMvCoverCubeLiteral( Io_Read_t * p, int Lit, char * pPhase, int * pEqual1, int * pEqual2, char * pString  ){    Ntk_Node_t * pNode, * pFanin;    Ntk_Pin_t * pPin;    Vm_VarMap_t * pVm;    int i, iFanin, Value, ValueStart, ValueStop;    char * pTemp;    // initialize the important pointers    pNode   = p->pNodeCur;    pVm    = Fnc_FunctionReadVm( Ntk_NodeReadFunc(pNode) );    if ( *pString == '=' )    {        pString = Io_ReadNodeBlifMvSkipSpaces( pString + 1 );        Ntk_NodeForEachFaninWithIndex( pNode, pPin, pFanin, iFanin )        {            if ( strcmp( Ntk_NodeReadName(pFanin), pString ) == 0 )            {                if ( *pEqual1 != -1 )                {                    sprintf( p->sError, "The =construct appears twice in this line." );                    Io_ReadPrintErrorMessage( p );                    return 1;                }                if ( Lit == iFanin )                {                    sprintf( p->sError, "The =construct relates the same variable." );                    Io_ReadPrintErrorMessage( p );                    return 1;                }                if ( pVm->pValues[iFanin] != pVm->pValues[Lit] )                {                    sprintf( p->sError, "The =construct relates variables with different number of values." );                    Io_ReadPrintErrorMessage( p );                    return 1;                }                if ( iFanin < Lit )                {                    *pEqual1 = iFanin;                    *pEqual2 = Lit;                }                else                 {                    *pEqual1 = Lit;                    *pEqual2 = iFanin;                }                return 0;            }        }        sprintf( p->sError, "The =construct refers to \"%s\", not a fanin of the node.", pString );        Io_ReadPrintErrorMessage( p );        return 1;    }    if ( *pString == '-' )    {        for ( i = 0; i < pVm->pValues[Lit]; i++ )            pPhase[i] = '1';        return 0;    }    // consider three cases    // this is an interval of values    if ( *pString == '{' )    {        pTemp = strtok( pString + 1, " -}\t" );        ValueStart = Io_ReadNodeBlifMvCoverCubeLiteralValue( p, Lit, pTemp );        if ( ValueStart == -1 )            return 1;        pTemp = strtok( NULL, " -}\t" );        ValueStop = Io_ReadNodeBlifMvCoverCubeLiteralValue( p, Lit, pTemp );        if ( ValueStop == -1 )            return 1;        for ( i = ValueStart; i <= ValueStop; i++ )            pPhase[i] = '1';        return 0;    }    // this is a set of values    if ( *pString == '(' )    {        int nTokens = 0, i;        // split the line into tokens        pTemp = strtok( pString + 1, ",)" );        do p->pTokens[nTokens++] = pTemp;        while ( pTemp = strtok( NULL, ",)" ) );        // call parsing of each token        for ( i = 0; i < nTokens; i++ )            if ( Io_ReadNodeBlifMvCoverCubeLiteral( p, Lit, pPhase, pEqual1, pEqual2, p->pTokens[i] ) )                return 1;        return 0;    }    // this is a value    Value = Io_ReadNodeBlifMvCoverCubeLiteralValue( p, Lit, pString );    if ( Value == -1 )        return 1;    pPhase[Value] = '1';    return 0;}/**Function*************************************************************  Synopsis    [Reads the value.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/int Io_ReadNodeBlifMvCoverCubeLiteralValue( Io_Read_t * p, int Lit, char * pString ){    Ntk_Node_t * pNode;    Vm_VarMap_t * pVm;    Io_Node_t * pIoNode;    Io_Var_t * pVar;    char * pNodeName;    int Value, i;    // initialize the important pointers    pNode   = p->pNodeCur;    pIoNode = (Io_Node_t *)Ntk_NodeReadData(pNode);    pVm    = Fnc_FunctionReadVm( Ntk_NodeReadFunc(pNode) );    // get the pointer to the fanin var if present    assert( Lit <= Ntk_NodeReadFaninNum(pNode) );    if ( Lit < Ntk_NodeReadFaninNum(pNode) )        pNodeName = Ntk_NodeReadName( Ntk_NodeReadFaninNode(pNode, Lit) );    else        pNodeName = Ntk_NodeReadName( pNode );    if ( p->tName2Var && st_lookup( p->tName2Var, pNodeName, (char **)&pVar ) )    {        // check if any of the symbolic value names of this var apply        for ( i = 0; i < pVar->nValues; i++ )            if ( strcmp( pVar->pValueNames[i], pString ) == 0 )                return i;        if ( i == pVar->nValues )        {            sprintf( p->sError, "No symbolic value for \"%s\" among those of node \"%s\".",                pString, pNodeName );            Io_ReadPrintErrorMessage( p );            return -1;        }    }    // try to read it as a number    if ( pString[0] < '0' || pString[0] > '9' )    {        sprintf( p->sError, "Cannot read numeric value (%s) of node \"%s\".", pString, pNodeName );        Io_ReadPrintErrorMessage( p );        return -1;    }    Value = atoi( pString );    // see if the value applies    if ( Value >= pVm->pValues[Lit] )    {        sprintf( p->sError, "The value (%s) is out of range [0; %d].", pString, pVm->pValues[Lit]-1 );        Io_ReadPrintErrorMessage( p );        return -1;    }    return Value;}///////////////////////////////////////////////////////////////////////////                       END OF FILE                                ///////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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