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

📄 simpfull.c

📁 主要进行大规模的电路综合
💻 C
📖 第 1 页 / 共 3 页
字号:
    if (pSimp->stCi != NULL) {        st_free_table(pSimp->stCi);    }    if (pSimp->pCodc != NULL) {        Cudd_RecursiveDeref(pInfo->ddmg, pSimp->pCodc);    }    /* Mspf belongs to the local manager! */    nFanins = Ntk_NodeReadFaninNum(pNode);    dd = Ntk_NetworkReadManDdLoc ( pInfo->network );    if ((nFanins > 0) && (!Ntk_NodeIsCi(pNode))) {        if (pSimp->lMspf != NULL) {            for (i=0; i<nFanins; ++i) {                if (pSimp->lMspf[i]) {                    Cudd_RecursiveDeref(dd, pSimp->lMspf[i]);                }            }            FREE(pSimp->lMspf);        }    }    FREE(pSimp);    Simp_DaemonSetNodeData(pNode, NULL);        /* release global BDD */    SimpNodeFreeGlo( pNode, pInfo );        return;}/**Function********************************************************************  Synopsis    [Free global BDD]  Description []  SideEffects []  SeeAlso     []******************************************************************************/voidSimpNodeFreeGlo ( Ntk_Node_t *pNode, Simp_Info_t *pInfo ){    int i,nValues;    DdNode **pbFuncs;    pbFuncs = Ntk_NodeReadFuncGlo( pNode );    nValues = Ntk_NodeReadValueNum( pNode );    if ( pbFuncs ) {                Ntk_NodeWriteFuncGlo( pNode, NULL );        for ( i = 0; i < nValues; i++ )            Cudd_RecursiveDeref( pInfo->ddmg, pbFuncs[i] );        FREE( pbFuncs );    }}/**Function********************************************************************  Synopsis    [Recursively compute a reverse topological order.]  Description [Given the same topological level, the nodes with large PI  support set is ordered first. A new array is returned, which should be freed  by the user.]  SideEffects []  SeeAlso     []******************************************************************************/voidSimpBfsOrderRecur(    Simp_Info_t *pInfo,    sarray_t *   aLevelThis,    sarray_t *   aLevelAll,    st_table *   stFoutCount,    int          iLevels) {    int i,j,num;    sarray_t     *aLevelNext;    Ntk_Node_t  *pTmp1, *pTmp2;    Ntk_Pin_t   *pPin;    Simp_Node_t *pSimp;    char        *dummy;        aLevelNext = sarray_alloc( Ntk_Node_t *, aLevelThis->size );    sarray_insert_last_safe( Ntk_Node_t *, aLevelAll, aLevelThis );        for (i=0; i < aLevelThis->num; i++) {                pTmp1 = sarray_fetch(Ntk_Node_t *, aLevelThis, i);        if (Ntk_NodeIsCi(pTmp1)) continue;                pSimp = Simp_DaemonGetNodeData(pTmp1);                Ntk_NodeForEachFaninWithIndex( pTmp1, pPin, pTmp2, j ) {            if (Ntk_NodeReadFanoutNum(pTmp2) == 1) {                sarray_insert_last_safe( Ntk_Node_t *, aLevelNext, pTmp2 );                continue;            }                        if (!st_lookup(stFoutCount, (char *) pTmp2, &dummy)) {                /*printf("{%3s}\tfanout[%5s(%2d/%2d)]\tnout[%2d]\tcount[ 1]\n",                       Ntk_NodeGetNamePrintable(pTmp2),                       Ntk_NodeGetNamePrintable(pTmp1),j,                       Ntk_NodeReadFaninNum(pTmp1),                       Ntk_NodeReadFanoutNum(pTmp2)); */                (void) st_insert(stFoutCount, (char*)pTmp2, (char*) 1);            }            else {                num = (int)dummy; num++;                /* printf("{%3s}\tfanout[%5s(%2d/%2d)]\tnout[%2d]\tcount[%2d]\n",                       Ntk_NodeGetNamePrintable(pTmp2),                       Ntk_NodeGetNamePrintable(pTmp1),j,                       Ntk_NodeReadFaninNum(pTmp1),                       Ntk_NodeReadFanoutNum(pTmp2),num); */                if (num != Ntk_NodeReadFanoutNum(pTmp2)) {                    (void) st_delete(stFoutCount, (char**)&pTmp2, &dummy);                    (void) st_insert(stFoutCount, (char*)pTmp2, (char*) num);                    /* printf("\n"); */                }                else {                    /* all fanout nodes have been visited */                    (void) st_delete(stFoutCount, (char**)&pTmp2, &dummy);                    sarray_insert_last_safe( Ntk_Node_t *, aLevelNext, pTmp2 );                    /* printf("\t{%s} next level\n",                       Ntk_NodeGetNamePrintable(pTmp2)); */                }            }        }    }        iLevels++;    if ( aLevelNext->num > 0) {        SimpBfsOrderRecur( pInfo, aLevelNext, aLevelAll, stFoutCount, iLevels );    } else {        sarray_free( aLevelNext );    }        return;}/**Function********************************************************************  Synopsis    [Propagate the badness down until no bad node is discovered.]  Description [Assume the node given is a badnode.]  SideEffects []  SeeAlso     []******************************************************************************/voidSimpProcessOrphanRecur(    Ntk_Node_t *tnode) {    int flag;    Ntk_Node_t  *fanin, *fanout;    Ntk_Pin_t   *pPin1, *pPin2;    Simp_Node_t *pSimp, *pSimp2;        if (Ntk_NodeIsCi(tnode)) return;        pSimp = Simp_DaemonGetNodeData(tnode);    if (!pSimp->fBadnode) return;        /* recursively propagate orphaness */    Ntk_NodeForEachFanin(tnode, pPin1, fanin) {        if ( Ntk_NodeIsCi( fanin )) continue;                /* if all parents are orphans, it becomes an orphan */        flag = -1;        Ntk_NodeForEachFanout( fanin, pPin2, fanout) {                        /* if fanout to CO, for sure not an orphan */            if ( Ntk_NodeIsCo( fanout ) ) {                flag=1; break;            }                        /* otherwise check orphanness of fanouts */            pSimp2 = Simp_DaemonGetNodeData(fanout);            if ( !(pSimp2->fBadnode) ) {                flag=1; break;            }        }        if (flag<0) {            pSimp2 = Simp_DaemonGetNodeData(fanin);            pSimp2->fBadnode = TRUE;            SimpProcessOrphanRecur(fanin);        }    }    return;}/**Function********************************************************************  Synopsis    [return 1 if a node is orphan]  Description [a node is orphan if it has not fanout or all fanouts are orphans]  SideEffects []  SeeAlso     []******************************************************************************/boolSimpNodeIsOrphan( Ntk_Node_t *pNode, Simp_Node_t *pSimp ) {    Ntk_Node_t  *pFanout;    Ntk_Pin_t   *pPin;    Simp_Node_t *pSimpFanout;        if ( pSimp->fBadnode || Ntk_NodeReadFanoutNum(pNode) < 1 )        return TRUE;        Ntk_NodeForEachFanout( pNode, pPin, pFanout ) {        if ( Ntk_NodeIsCo( pFanout ) )            return FALSE;        pSimpFanout = Simp_DaemonGetNodeData( pFanout );        if ( !pSimpFanout->fBadnode )            return FALSE;    }    return TRUE;}/**Function********************************************************************  Synopsis    [Compare the support size of two nodes.]  Description []  SideEffects []  SeeAlso     []******************************************************************************/intSimpNodeSupportCompare(    char **pn1,    char **pn2) {    if (pn1==NULL) {        if (pn2==NULL) return 0;        else return 1;    }    if (pn2==NULL) return -1;    if ( SimpNodeSupportNum((Ntk_Node_t *)(*pn1)) <         SimpNodeSupportNum((Ntk_Node_t *)(*pn2))) return 1;    else if ( SimpNodeSupportNum((Ntk_Node_t*)(*pn1)) >              SimpNodeSupportNum((Ntk_Node_t*)(*pn2))) return -1;    else return 0;}/**Function********************************************************************  Synopsis    [Update the MDD with the new logic function]  Description [This is called after minimization is performed on the  node. If complete flexibility is used in the minimization, one would need to  update all the nodes in the transitive fanout cone to reflect the change,  because their ODC set is no longer valid.]  SideEffects []  SeeAlso     []******************************************************************************/voidSimpNodeUpdate(    Ntk_Node_t *pNode,    Simp_Info_t *pInfo){    DdNode ** pbFuncs;        /* rebuild the global BDD only when the old node is replaced;       also, CO nodes always have the same (or less) global function    */    if ( !Ntk_NodeIsCoFanin( pNode ) ) {                SimpNodeFreeGlo( pNode, pInfo );        pbFuncs = Ntk_NodeGlobalMdd( pInfo->ddmg, pNode );        Ntk_NodeWriteFuncGlo( pNode, pbFuncs );    }    return;}/**Function********************************************************************  Synopsis    [Compute the support in terms of combinational input nodes]  Description [return NULL if the support is null]  SideEffects []  SeeAlso     []******************************************************************************/st_table *SimpNodeSupportCi(    Ntk_Network_t *pNet,    Ntk_Node_t    *pNode) {    int        nSup;    st_table   *stCi;    Ntk_Node_t *tnode;        if (pNode==NULL) return NULL;    if (Ntk_NodeReadNetwork(pNode)==NULL) return NULL;        nSup = Ntk_NetworkComputeNodeSupport(pNet, &pNode, 1);    if (nSup < 1) {        return NULL;    }        stCi = st_init_table(st_ptrcmp, st_ptrhash);    Ntk_NetworkForEachNodeSpecial(pNet, tnode) {        st_insert(stCi, (char *)tnode, NULL);    }    return stCi;}/**Function********************************************************************  Synopsis    [Return the number of PI support nodes.]  Description []  SideEffects []  SeeAlso     []******************************************************************************/intSimpNodeSupportNum(    Ntk_Node_t *node) {    Simp_Node_t *pSimp;    if ( Ntk_NodeIsCi( node ) ) return 0;    pSimp = Simp_DaemonGetNodeData(node);    if (pSimp && pSimp->stCi)         return st_count(pSimp->stCi);    return 0;}

⌨️ 快捷键说明

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