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

📄 ntknodecol.c

📁 主要进行大规模的电路综合
💻 C
📖 第 1 页 / 共 2 页
字号:
{    Vm_Manager_t * pManVm;    Vm_VarMap_t * pVm;    Ntk_Node_t * pTopN, * pTopF, * pNodeCur, * pNodeNew;    Ntk_Node_t ** pInputsN, ** pInputsF;    int nInputsN, nInputsF;    int * pVarValues, nVars;     int iTopN, iTopF, iNode, iNodePos;    int CompValue, i;    // collect the fanins of pNode    nInputsN = Ntk_NodeReadFaninNum( pNode );    assert( nInputsN > 0 );    pInputsN = pNode->pNet->pArray1;     Ntk_NodeReadFanins( pNode, pInputsN );    // make sure the fanins are ordered    for ( i = 1; i < nInputsN; i++ )    {        assert( Ntk_NodeCompareByNameAndId( pInputsN + i-1, pInputsN + i ) < 0 );    }    // collect the fanins of pFanin    nInputsF = Ntk_NodeReadFaninNum( pFanin );    assert( nInputsF >= 0 );    pInputsF = pNode->pNet->pArray2;     Ntk_NodeReadFanins( pFanin, pInputsF );    // make sure the fanins are ordered    for ( i = 1; i < nInputsF; i++ )    {        assert( Ntk_NodeCompareByNameAndId( pInputsF + i-1, pInputsF + i ) < 0 );    }    // create the new node    pNodeNew = Ntk_NodeCreate( pNode->pNet, NULL, MV_NODE_INT, pNode->nValues );    // get temp storage for the array of fanin values    pVarValues = Vm_VarMapGetStorageArray1( Ntk_NodeReadFuncVm(pNode) );    // clean the inverse array    for ( i = 0; i <= nInputsN + nInputsF; i++ )        pTransMapNInv[i] = -1;    // the output node of pFanin is one of the fanins of pNode    iNode = Ntk_NodeReadFaninIndex( pNode, pFanin );    assert( iNode != -1 );    // sort through the fanins of pNode and pFanin    pTopN = pInputsN[0];    pTopF = nInputsF? pInputsF[0]: NULL;    iTopN = 1;    iTopF = nInputsF? 1: 0;    nVars = 0;    while ( pTopN || pTopF )    {        // compare the topmost fanin of the two nodes        if ( pTopN == NULL )            CompValue = -1;        else if ( pTopF == NULL )             CompValue = 1;        else            CompValue = Ntk_NodeCompareByNameAndId( &pTopF, &pTopN );        // use the comparison to create the merged fanin list        if ( CompValue < 0 ) // pTopF is in pFanin and not in pNode        {//            assert( Ntk_NodeReadFaninIndex( pNode,  pTopF ) == -1 );//            assert( Ntk_NodeReadFaninIndex( pFanin, pTopF ) != -1 );            // set the current node            pNodeCur = pTopF;            // add to the translation map from pFanin into pNodeNew            pTransMapF[ iTopF-1 ] = nVars;            // get the next fanin in pFanin            pTopF = (iTopF == nInputsF)? NULL: pInputsF[iTopF++];        }        else if ( CompValue == 0 ) // the same fanin (pTopF==pTopN) is in both lists        {//            assert( Ntk_NodeReadFaninIndex( pNode,  pTopF ) != -1 );//            assert( Ntk_NodeReadFaninIndex( pFanin, pTopF ) != -1 );            // set the current node            pNodeCur = pTopF;            // set the translation map from pFanin into pNodeNew//          pTransMapN[ iTopN-1 ] = nVars;            pTransMapNInv[ nVars ] = iTopN-1;            pTransMapF[ iTopF-1 ] = nVars;            // get the next fanin in pFanin/pNode            pTopF = (iTopF == nInputsF)? NULL: pInputsF[iTopF++];            pTopN = (iTopN == nInputsN)? NULL: pInputsN[iTopN++];        }        else // pTopN is in pNode and not in pFanins        {//            assert( Ntk_NodeReadFaninIndex( pNode,  pTopN ) != -1 );//            assert( Ntk_NodeReadFaninIndex( pFanin, pTopN ) == -1 );            // set the current node            pNodeCur = pTopN;            // add to the translation map from pNode into pNodeNew//          pTransMapN[ iTopN-1 ] = nVars;            pTransMapNInv[ nVars ] = iTopN-1;            if ( iNode == iTopN-1 )                iNodePos = nVars;            // get the next fanin in pFanin            pTopN = (iTopN == nInputsN)? NULL: pInputsN[iTopN++];        }        // add this fanin to the fanin list in the new node        Ntk_NodeAddFanin( pNodeNew, pNodeCur );        // set the number of values of this fanin        pVarValues[ nVars ] = pNodeCur->nValues;        // increment the counter of all inputs processed        nVars++;    }    // treat the output nodes    // set the translation map for the output of pFanin    pTransMapF[ iTopF++ ] = iNodePos;    // the output node of pNode is the output of the resulting collapsed node    // set the translation map for the output of pNode//  pTransMapN[ iTopN++ ] = nVars;    pTransMapNInv[ nVars ] = iTopN++;    // set the number of output values of the collapsed node    pVarValues[ nVars ] = pNode->nValues;    // sanity checks    // the number of nodes processed in equal to the number of fanins    assert( iTopF == Ntk_NodeReadFaninNum(pFanin) + 1 );    assert( iTopN == Ntk_NodeReadFaninNum(pNode) + 1 );    // create the new variable map for the node    pManVm = Ntk_NetworkReadManVm( pNode->pNet );    pVm    = Vm_VarMapLookup( pManVm, nVars, 1, pVarValues );    Ntk_NodeWriteFuncVm( pNodeNew, pVm );    return pNodeNew;}/**Function*************************************************************  Synopsis    [Merges the fanins of the nodes.]  Description [This procedure looks at the fanins of pNode1 and pNode2  and performs the following tasks: (1) merges two ordered fanin lists   into one ordered list and creates the new node with this fanin list;  (2) creates a new variable map and attaches it to the new node;  (3) if variables pTransMapN1/pTransMapN2 are not NULL, this procedure  also assigns the "translation maps" for pNode1/pNode2 (an entry in the   translation map shows where the given fanin of pNode1/pNode2 goes  in the variable map of the new node).]                 SideEffects []  SeeAlso     []***********************************************************************/Ntk_Node_t * Ntk_NodeMakeCommonBase( Ntk_Node_t * pNode1, Ntk_Node_t * pNode2,      int * pTransMapN1, int * pTransMapN2 ){    Vm_Manager_t * pManVm;    Vm_VarMap_t * pVm;    Ntk_Node_t * pTopN1, * pTopN2, * pNodeCur, * pNodeNew;    Ntk_Node_t ** pInputsN1, ** pInputsN2;    int nInputsN1, nInputsN2;    int * pVarValues, nVars;     int iTopN1, iTopN2;    int CompValue, i;    // collect the fanins of pNode1    nInputsN1 = Ntk_NodeReadFaninNum( pNode1 );    pInputsN1 = pNode1->pNet->pArray1;     Ntk_NodeReadFanins( pNode1, pInputsN1 );    // make sure the fanins are ordered    for ( i = 1; i < nInputsN1; i++ )    {        assert( Ntk_NodeCompareByNameAndId( pInputsN1 + i-1, pInputsN1 + i ) < 0 );    }    // collect the fanins of pNode2    nInputsN2 = Ntk_NodeReadFaninNum( pNode2 );    pInputsN2 = pNode2->pNet->pArray2;     Ntk_NodeReadFanins( pNode2, pInputsN2 );    // make sure the fanins are ordered    for ( i = 1; i < nInputsN2; i++ )    {        assert( Ntk_NodeCompareByNameAndId( pInputsN2 + i-1, pInputsN2 + i ) < 0 );    }    // create the new node    pNodeNew = Ntk_NodeCreate( pNode1->pNet, NULL, MV_NODE_INT, -1 );    // get temp storage for the array of fanin values    pVarValues = Vm_VarMapGetStorageArray1( Ntk_NodeReadFuncVm(pNode1) );    // sort through the fanins of pNode1 and pNode2    pTopN1 = pInputsN1[0];    pTopN2 = pInputsN2[0];    iTopN1 = 0;  //changed by wjiang    iTopN2 = 0;  //changed by wjiang    nVars = 0;    while ( iTopN1 < nInputsN1 || iTopN2 < nInputsN2 )    {        // compare the topmost fanin of the two nodes        if ( iTopN1 == nInputsN1 )            CompValue = -1;        else if ( iTopN2 == nInputsN2 )             CompValue = 1;        else            CompValue = Ntk_NodeCompareByNameAndId( &pTopN2, &pTopN1 );        // use the comparison to create the merged fanin list        if ( CompValue < 0 ) // pTopN2 is in pNode2 and not in pNode1        {            // set the current node            pNodeCur = pTopN2;            // add to the translation map from pNode2 into pNodeNew            if ( pTransMapN2 )                pTransMapN2[ iTopN2 ] = nVars;            // get the next fanin in pNode2            pTopN2 = pInputsN2[++iTopN2]; //changed by wjiang        }        else if ( CompValue == 0 ) // the same fanin (pTopN2==pTopN1) is in both lists        {            // set the current node            pNodeCur = pTopN2;            // set the translation map from pNode2 into pNodeNew            if ( pTransMapN1 )                pTransMapN1[ iTopN1 ] = nVars;            if ( pTransMapN2 )                pTransMapN2[ iTopN2 ] = nVars;            // get the next fanin in pNode2/pNode1            pTopN2 = pInputsN2[++iTopN2]; //changed by wjiang            pTopN1 = pInputsN1[++iTopN1]; //changed by wjiang        }        else // pTopN1 is in pNode1 and not in pNode2s        {            // set the current node            pNodeCur = pTopN1;            // add to the translation map from pNode1 into pNodeNew            if ( pTransMapN1 )                pTransMapN1[ iTopN1 ] = nVars;            // get the next fanin in pNode2            pTopN1 = pInputsN1[++iTopN1]; //changed by wjiang        }        // add this fanin to the fanin list in the new node        Ntk_NodeAddFanin( pNodeNew, pNodeCur );        // set the number of values of this fanin        pVarValues[ nVars ] = pNodeCur->nValues;        // increment the counter of all inputs processed        nVars++;    }    // sanity checks    // the number of nodes processed in equal to the number of fanins    assert( iTopN1 == Ntk_NodeReadFaninNum(pNode1) );    assert( iTopN2 == Ntk_NodeReadFaninNum(pNode2) );        // output values is the same as the first node! (wjiang)    pVm = Ntk_NodeReadFuncVm(pNode1);    pVarValues[nVars] = Vm_VarMapReadValuesOutNum(pVm);    // create the new variable map for the node    pManVm = Ntk_NetworkReadManVm( pNode1->pNet );    pVm    = Vm_VarMapLookup( pManVm, nVars, 1, pVarValues );    Ntk_NodeWriteFuncVm( pNodeNew, pVm );    return pNodeNew;}///////////////////////////////////////////////////////////////////////////                       END OF FILE                                ///////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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