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

📄 ntknode.c

📁 主要进行大规模的电路综合
💻 C
📖 第 1 页 / 共 2 页
字号:
  Synopsis    [Creates the collector node.]  Description [The collector node is the n-valued node, which has   n binary fanins, which are converted into the corresponding i-sets.  The fanins should be ordered.]                 SideEffects []  SeeAlso     []***********************************************************************/Ntk_Node_t * Ntk_NodeCreateCollector( Ntk_Network_t * pNet, Ntk_Node_t * ppFanins[], int nValues, int DefValue ){    Ntk_Node_t * pNode;    Fnc_Manager_t * pMan;    Mvr_Relation_t * pMvr;    int i;    // get the node    pNode = Ntk_NodeCreate( pNet, NULL, MV_NODE_INT, nValues );    // set the fanin (do not connect the fanout to the fanin)    for ( i = 0; i < nValues; i++ )        if ( ppFanins[i] )            Ntk_NodeAddFanin( pNode, ppFanins[i] );        else        {            assert( i == DefValue );        }    // get the functionality manager    pMan = Ntk_NodeReadMan( pNode );    // create the relation    pMvr = Mvr_RelationCreateCollector( Fnc_ManagerReadManMvr(pMan), Fnc_ManagerReadManVmx(pMan), Fnc_ManagerReadManVm(pMan), nValues, DefValue );    // set the variable map and the relation    Ntk_NodeWriteFuncVm( pNode, Mvr_RelationReadVm(pMvr) );    Ntk_NodeWriteFuncMvr( pNode, pMvr );    return pNode;}/**Function*************************************************************  Synopsis    [Creates the node with fanins being the network CIs.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/Ntk_Node_t * Ntk_NodeCreateFromNetwork( Ntk_Network_t * pNet, char ** psCiNames ){    Ntk_Node_t * pNodeNew, * pFanin;    int nCis, i;    // create a new node    pNodeNew = (Ntk_Node_t *)Ntk_NodeCreate( pNet, NULL, MV_NODE_INT, -1 );    // create the fanin list    if ( psCiNames )    {        nCis = Ntk_NetworkReadCiNum( pNet );        for ( i = 0; i < nCis; i++ )        {            pFanin = Ntk_NetworkFindNodeByName( pNet, psCiNames[i] );            assert( pFanin );            Ntk_NodeAddFanin( pNodeNew, pFanin );        }    }    else    {        Ntk_NetworkForEachCi( pNet, pFanin )            Ntk_NodeAddFanin( pNodeNew, pFanin );    }    return pNodeNew;}/**Function*************************************************************  Synopsis    [Duplicates the node.]  Description [Duplicates the node. Copies the fanin list but does not  create the fanout list. Copies the local function, assuming the same  manager is used.]                 SideEffects []  SeeAlso     []***********************************************************************/Ntk_Node_t * Ntk_NodeDup( Ntk_Network_t * pNetNew, Ntk_Node_t * pNode ){    Ntk_Node_t * pNodeNew, * pFanin;    Fnc_Function_t * pF, * pFNew;    Ntk_Pin_t * pPin;    if ( pNode == NULL )        return NULL;    // create a new node    pNodeNew = (Ntk_Node_t *)Ntk_NodeCreate( pNetNew, pNode->pName, pNode->Type, pNode->nValues );    // copy the subtype    pNodeNew->Subtype = pNode->Subtype;    // duplicate the fanin list    Ntk_NodeForEachFanin( pNode, pPin, pFanin )        Ntk_NodeAddFanin( pNodeNew, pFanin );    // copy the functionality    pF    = Ntk_NodeReadFunc( pNode );    pFNew = Ntk_NodeReadFunc( pNodeNew );    Fnc_FunctionDup( pNode->pNet->pMan, pNetNew->pMan, pF, pFNew );     // attach the new node to the temporary place in the node    pNode->pCopy = pNodeNew;    return pNodeNew;}/**Function*************************************************************  Synopsis    [Duplicates the node without functionality.]  Description [Duplicates the node. Copies the fanin list but does not  create the fanout list. Does not copy the local function.]                 SideEffects []  SeeAlso     []***********************************************************************/Ntk_Node_t * Ntk_NodeClone( Ntk_Network_t * pNetNew, Ntk_Node_t * pNode ){    Ntk_Node_t * pNodeNew, * pFanin;    Ntk_Pin_t * pPin;    if ( pNode == NULL )        return NULL;    // create a new node    pNodeNew = (Ntk_Node_t *)Ntk_NodeCreate( pNetNew, pNode->pName, pNode->Type, pNode->nValues );    // copy the subtype    pNodeNew->Subtype = pNode->Subtype;    // duplicate the fanin list    Ntk_NodeForEachFanin( pNode, pPin, pFanin )        Ntk_NodeAddFanin( pNodeNew, pFanin );    // attach the new node to the temporary place in the node    pNode->pCopy = pNodeNew;    return pNodeNew;}/**Function*************************************************************  Synopsis    [Replaces pNode by pNodeNew in the network.]  Description [This procedure replaces pNode by pNodeNew, and  updates the fanout structures of the fanins to point to pNodeNew  instead of pNode. This procedure disposes of pNodeNew.]                 SideEffects []  SeeAlso     []***********************************************************************/void Ntk_NodeReplace( Ntk_Node_t * pNode, Ntk_Node_t * pNodeNew ){    Fnc_Function_t * pF;    Ntk_Network_t * pNet;    Ntk_Pin_t * pPin, * pPin2;    Ntk_Node_t * pTemp;    assert( pNode->Type == MV_NODE_INT && pNodeNew->Type == MV_NODE_INT );//    assert( pNode->nValues == pNodeNew->nValues );//    assert( Ntk_NodeReadFanoutNum(pNode) > 0 );    assert( Ntk_NodeReadFanoutNum(pNodeNew) == 0 );    // set the new number of values    pNode->nValues = pNodeNew->nValues;    // delete the fanout structures of the fanins of "pNode"    pNet = pNode->pNet;    Ntk_NodeDeleteFaninFanout( pNet, pNode );    // dispose of the fanin pins of pNode    Ntk_NodeForEachFaninSafe( pNode, pPin, pPin2, pTemp )        memManFixedEntryRecycle( pNet->pManPin, (char *)pPin );    // transfer the fanin list and the functionality from pNodeNew to pNode    pNode->lFanins = pNodeNew->lFanins;    // no need to clean, because will be deallocated    // invalidate the old functionality    pF = Ntk_NodeReadFunc( pNode );    Fnc_FunctionClean( pF );     // invalidate all    // set the new functionality    Fnc_FunctionCopy( pNode->pF, pNodeNew->pF );    // no need to clean, because will be deallocated    // create the fanin fanout structures    Ntk_NodeAddFaninFanout( pNet, pNode );    // dispose of the node    FREE( pNodeNew->pF );    memManFixedEntryRecycle( pNet->pManNode, (char *)pNodeNew );}/**Function*************************************************************  Synopsis    []  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Ntk_NodeDelete( Ntk_Node_t * pNode ){ //   assert( pNode->pNet == NULL || pNode->Id < pNode->pNet->nIdsAlloc );    // deref the functionality    Fnc_FunctionDelete( pNode->pF );    // recycle the node    Ntk_NodeRecycle( pNode->pNet, pNode );}/**Function*************************************************************  Synopsis    []  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Ntk_NodeRecycle( Ntk_Network_t * pNet, Ntk_Node_t * pNode ){    Ntk_Pin_t * pPin, * pPin2;    Ntk_Node_t * pTemp;    Ntk_NodeForEachFaninSafe( pNode, pPin, pPin2, pTemp )        memManFixedEntryRecycle( pNet->pManPin, (char *)pPin );    Ntk_NodeForEachFanoutSafe( pNode, pPin, pPin2, pTemp )        memManFixedEntryRecycle( pNet->pManPin, (char *)pPin );    memManFixedEntryRecycle( pNet->pManNode, (char *)pNode );}/**Function********************************************************************  Synopsis    [a quick check on if the node is too large.]  Description [used in merge and simplify.]    SideEffects []  SeeAlso     []******************************************************************************/bool Ntk_NodeIsTooLarge( Ntk_Node_t * pNode ) {    Fnc_Function_t * pF;    Mvc_Cover_t ** pCovers;    Cvr_Cover_t * pCvr;    int nValues, nCubes, nBits, i;    if ( pNode == NULL )        return FALSE;    pF   = Ntk_NodeReadFunc( pNode );    pCvr = Fnc_FunctionReadCvr( pF );    pCovers = Cvr_CoverReadIsets( pCvr );    if ( pCovers == NULL )        return FALSE;    nValues = Ntk_NodeReadValueNum( pNode );    nBits   = Vm_VarMapReadValuesInNum( Fnc_FunctionReadVm(pF) );    for ( i = 0; i < nValues; i++ )    {        if ( pCovers[i] == NULL )            continue;        nCubes = Mvc_CoverReadCubeNum(pCovers[i]);        if ( nCubes >= 10  && nBits >= 90 ) return TRUE;        if ( nCubes >= 100 && nBits >= 60 ) return TRUE;        if ( nCubes >= 400 && nBits >= 50 ) return TRUE;        if ( nCubes >= 800 && nBits >= 30 ) return TRUE;        //if ( nCubes >= 900 && nBits >= 20 ) continue;    }    return FALSE;}/**Function*************************************************************  Synopsis    [Returns true if the node is the binary buffer.]  Description []                 SideEffects []  SeeAlso     [] ***********************************************************************/bool Ntk_NodeIsBinaryBuffer( Ntk_Node_t * pNode ){    Cvr_Cover_t * pCvr;    Mvc_Cover_t ** ppIsets;    Mvc_Cover_t * pCover;    if ( Ntk_NodeReadValueNum(pNode) != 2 )        return 0;    if ( Ntk_NodeReadFaninNum(pNode) != 1 )        return 0;    pCvr = Ntk_NodeReadFuncCvr(pNode);    if ( pCvr == NULL )        return 0;    ppIsets = Cvr_CoverReadIsets(pCvr);    pCover = ppIsets[1];    if ( pCover == NULL )        return 0;    return Mvc_CoverIsBinaryBuffer( pCover );}/**Function*************************************************************  Synopsis    [Returns 1 if the nodes are not in the TFI/TFO cones of each other.]  Description []                 SideEffects []  SeeAlso     [] ***********************************************************************/bool Ntk_NodesCanBeMerged( Ntk_Node_t * pNode1, Ntk_Node_t * pNode2 ){    Ntk_Node_t * pNodeSpec;    // get the TFI of pNode1    Ntk_NetworkComputeNodeTfi( pNode1->pNet, &pNode1, 1, 10000, 1, 1 );    // check if pNodes2 is among these nodes    Ntk_NetworkForEachNodeSpecial( pNode1->pNet, pNodeSpec )        if ( pNodeSpec == pNode2 )            return 0;    // go the same with the TFO of pNode1    Ntk_NetworkComputeNodeTfo( pNode1->pNet, &pNode1, 1, 10000, 1, 1 );    // check if pNodes2 is among these nodes    Ntk_NetworkForEachNodeSpecial( pNode1->pNet, pNodeSpec )        if ( pNodeSpec == pNode2 )            return 0;    return 1;}/**Function*************************************************************  Synopsis    [Determinizes the node.]  Description [Returns 1 if the node was determinized; 0 if it was  already deterministic.]                 SideEffects []  SeeAlso     [] ***********************************************************************/bool Ntk_NodeDeterminize( Ntk_Node_t * pNode ){    Mvr_Relation_t * pMvr;    pMvr = Ntk_NodeGetFuncMvr( pNode );    if ( Mvr_RelationDeterminize(pMvr) )    {        Ntk_NodeSetFuncMvr( pNode, pMvr );        return 1;    }    // otherwise, the node did not change, no need to update    return 0;}///////////////////////////////////////////////////////////////////////////                       END OF FILE                                ///////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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