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

📄 ntki.c

📁 主要进行大规模的电路综合
💻 C
📖 第 1 页 / 共 5 页
字号:
                break;            default:                goto usage;        }    }    if ( pNet == NULL )    {        fprintf( pErr, "Empty network.\n" );        return 1;    }    // make sure the default is always present whenever possible    if ( fUseDefault )        Ntk_NetworkForceDefault( pNet );    else        Ntk_NetworkComputeDefault( pNet );    return 0;usage:    fprintf( pErr, "usage: default [-d] [-h]\n");    fprintf( pErr, "\t         adds/removes the default covers in determistic nodes\n" );      fprintf( pErr, "\t-d     : toggles adding/removing the default value [default = %s]\n", fUseDefault? "remove": "add" );    fprintf( pErr, "\t-h     : print the command usage\n");    return 1;       /* error exit */}/**Function*************************************************************  Synopsis    []  Description []                 SideEffects []  SeeAlso     []***********************************************************************/Ntk_CommandNetworkWindow( Mv_Frame_t * pMvsis, int argc, char ** argv ){    char pFileName[100];    FILE * pOut, * pErr;    Ntk_Network_t * pNet;    Ntk_Node_t * pNode;    int nNodes;    int nTfiLevels;    int nTfoLevels;    int fVerbose;    int fPrintAll;    int c;    pNet = Mv_FrameReadNet(pMvsis);    pOut = Mv_FrameReadOut(pMvsis);    pErr = Mv_FrameReadErr(pMvsis);     // set the defaults    nTfiLevels = 2;    nTfoLevels = 2;    fVerbose   = 0;    fPrintAll  = 0;    util_getopt_reset();    while ( (c = util_getopt(argc, argv, "ioahv")) != EOF )     {        switch (c)         {            case 'i':                if ( util_optind >= argc )                {                    fprintf( pErr, "Command line switch \"-i\" should be followed by an integer.\n" );                    goto usage;                }                nTfiLevels = atoi(argv[util_optind]);                util_optind++;                if ( nTfiLevels < 0 )                     goto usage;                break;            case 'o':                if ( util_optind >= argc )                {                    fprintf( pErr, "Command line switch \"-o\" should be followed by an integer.\n" );                    goto usage;                }                nTfoLevels = atoi(argv[util_optind]);                util_optind++;                if ( nTfoLevels < 0 )                     goto usage;                break;            case 'a':                fPrintAll ^= 1;                break;            case 'v':                fVerbose ^= 1;                break;            case 'h':                goto usage;                break;            default:                goto usage;        }    }    if ( pNet == NULL )    {        fprintf( pErr, "Empty network.\n" );        return 1;    }    if ( fPrintAll )    {        Ntk_NetworkForEachNode( pNet, pNode )        {            Wn_Window_t * pWnd, * pWndCore;            // create the core window from the linked list of node in pNet            pWndCore = Wn_WindowCreateFromNode( pNode );            // derive the container window for the core window            pWnd     = Wn_WindowDerive( pWndCore, nTfiLevels, nTfoLevels );            // print the stats            fprintf( Ntk_NetworkReadMvsisOut(pNet), "%5s  fi = %3d  fo = %3d :  lvs = %5d  rts = %5d  nds = %5d\n",                    Ntk_NodeGetNamePrintable(pNode),                    Ntk_NodeReadFaninNum(pNode),                   Ntk_NodeReadFanoutNum(pNode),                   Wn_WindowReadLeafNum(pWnd),                   Wn_WindowReadRootNum(pWnd),                   Wn_WindowReadNodeNum(pWnd) );            // delete the window            Wn_WindowDelete( pWnd );        }        return 0;    }    if ( util_optind == argc )    {        fprintf( pErr, "The list of nodes for extracting is not given.\n" );        return 1;    }    // collect the nodes    nNodes = Cmd_CommandGetNodes( pMvsis, argc-util_optind+1, argv+util_optind-1, 0 );    if ( nNodes == 0 )    {        fprintf( pErr, "The list of nodes to be extracted is empty.\n" );        return 1;    }    pNode = pNet->pOrder;    // the nodes to be merged are linked into the special linked list    if ( nTfiLevels > 0 || nTfoLevels > 0 )    {        Wn_Window_t * pWnd, * pWndCore;        // create the core window from the linked list of node in pNet        pWndCore = Wn_WindowCreateFromNodeArray( pNet );        // derive the container window for the core window        pWnd     = Wn_WindowDerive( pWndCore, nTfiLevels, nTfoLevels );        // collect the internal nodes of the container window        Wn_WindowCollectInternal( pWnd );        // put the nodes into the list        Ntk_NetworkCreateSpecialFromArray( pNet, Wn_WindowReadNodes(pWnd), Wn_WindowReadNodeNum(pWnd) );        // delete the window        Wn_WindowDelete( pWnd );    }    // create the name for the new file    if ( Ntk_NetworkIsBinary(pNet) )    {        sprintf( pFileName, "%s_%d_%s.blif", pNet->pName, nNodes,             Ntk_NodeGetNamePrintable(pNode) );        Ntk_SubnetworkWriteIntoFile( pNet, pFileName, 1 );    }    else    {        sprintf( pFileName, "%s_%d_%s.mv", pNet->pName, nNodes,             Ntk_NodeGetNamePrintable(pNode) );        Ntk_SubnetworkWriteIntoFile( pNet, pFileName, 0 );    }    return 0;usage:    fprintf( pErr, "usage: window [-i num] [-o num] [-a] [-h] <node_list>\n");    fprintf( pErr, "\t         carves out a window surrounding nodes in the list\n" );      fprintf( pErr, "\t-i num : the number of levels of the limited TFI [default = %d]\n", nTfiLevels );      fprintf( pErr, "\t-o num : the number of levels of the limited TFO [default = %d]\n", nTfoLevels );      fprintf( pErr, "\t-a     : print statistics about all windows [default = %s]\n", fPrintAll? "yes": "no" );    fprintf( pErr, "\t-h     : print the command usage\n");    return 1;       /* error exit */}/**Function*************************************************************  Synopsis    []  Description []                 SideEffects []  SeeAlso     []***********************************************************************/Ntk_CommandNetworkSweep( Mv_Frame_t * pMvsis, int argc, char ** argv ){    FILE * pOut, * pErr;    Ntk_Network_t * pNet;    int fSweepConsts;    int fSweepBuffers;    int fSweepIsets;    int fVerbose;    int c;    pNet = Mv_FrameReadNet(pMvsis);    pOut = Mv_FrameReadOut(pMvsis);    pErr = Mv_FrameReadErr(pMvsis);    // set the defaults    fSweepConsts  = 1;    fSweepBuffers = 1;    fSweepIsets   = 0;    fVerbose      = 0;    util_getopt_reset();    while ( (c = util_getopt(argc, argv, "cbivh")) != EOF )     {        switch (c)         {            case 'c':                fSweepConsts ^= 1;                break;            case 'b':                fSweepBuffers ^= 1;                break;            case 'i':                fSweepIsets ^= 1;                break;            case 'v':                fVerbose ^= 1;                break;            case 'h':                goto usage;                break;            default:                goto usage;        }    }    if ( pNet == NULL )    {        fprintf( pErr, "Empty network.\n" );        return 1;    }    Ntk_NetworkSweep( pNet, fSweepConsts, fSweepBuffers, fSweepIsets, fVerbose );    return 0;usage:    fprintf( pErr, "usage: sweep [-b] [-i] [-v] [-h]\n");    fprintf( pErr, "\t         simplifies the network by removing useless nodes\n");    fprintf( pErr, "\t-c     : toggle removing the constant nodes [default = %s]\n", fSweepConsts? "yes": "no" );      fprintf( pErr, "\t-b     : toggle removing the single-input nodes [default = %s]\n", fSweepBuffers? "yes": "no" );      fprintf( pErr, "\t-i     : toggle sweeping i-sets of the internal nodes [default = %s]\n", fSweepIsets? "yes": "no" );      fprintf( pErr, "\t-v     : print verbose information [default = %s]\n", fVerbose? "yes": "no" );      fprintf( pErr, "\t-h     : print the command usage\n");    return 1;       /* error exit */}/**Function*************************************************************  Synopsis    []  Description []                 SideEffects []  SeeAlso     []***********************************************************************/Ntk_CommandNetworkEliminate( Mv_Frame_t * pMvsis, int argc, char ** argv ){    FILE * pOut, * pErr;    Ntk_Network_t * pNet;    bool fVerbose;    bool fUseCostBdd;    int Value, nNodesElim, c;    int nCubeLimit;    int nFaninLimit;    pNet = Mv_FrameReadNet(pMvsis);    pOut = Mv_FrameReadOut(pMvsis);    pErr = Mv_FrameReadErr(pMvsis);    // set the defaults    nNodesElim  = 100000;    nCubeLimit  = 500;    nFaninLimit = 200;    Value       = -1;    fUseCostBdd = 0;    fVerbose    = 0;    util_getopt_reset();    while ( (c = util_getopt(argc, argv, "cflbvh")) != EOF )     {        switch (c)         {            case 'c':                if ( util_optind >= argc )                {                    fprintf( pErr, "Command line switch \"-c\" should be followed by an integer.\n" );                    goto usage;                }                nCubeLimit = atoi(argv[util_optind]);                util_optind++;                if ( nCubeLimit < 0 )                     goto usage;                break;            case 'f':                if ( util_optind >= argc )                {                    fprintf( pErr, "Command line switch \"-f\" should be followed by an integer.\n" );                    goto usage;                }                nFaninLimit = atoi(argv[util_optind]);                util_optind++;                if ( nFaninLimit < 0 )                     goto usage;                break;            case 'l':                if ( util_optind >= argc )                {                    fprintf( pErr, "Command line switch \"-l\" should be followed by an integer.\n" );                    goto usage;                }                nNodesElim = atoi(argv[util_optind]);                util_optind++;                if ( nNodesElim < 0 )                     goto usage;                break;            case 'b':                fUseCostBdd ^= 1;                break;            case 'v':                fVerbose ^= 1;                break;            case 'h':                goto usage;                break;            default:                goto usage;        }    }    if ( pNet == NULL )    {        fprintf( pErr, "Empty network.\n" );        return 1;    }    if ( util_optind == argc )    {        fprintf( pErr, "Elimination value is not given; %d is assumed.\n", Value );    }    else if ( util_optind == argc - 1 )    {        Value = atoi(argv[util_optind]);        if ( Value < -1 )        {            fprintf( pErr, "Elimination value is incorrect (%d).\n", Value );            goto usage;        }    }    else        goto usage;    // call the elimination procedure    Ntk_NetworkEliminate( pNet, nNodesElim, nCubeLimit, nFaninLimit, -Value, fUseCostBdd, fVerbose );    return 0;usage:    fprintf( pErr, "usage: eliminate [-c num] [-f num] [-l num] [-b] [-v] [-h] <value>\n" );    fprintf( pErr, "\t         selectively collapses the nodes into their fanouts\n" );      fprintf( pErr, "\t-c num : the cube limit (if more, skip the node) [default = %d]\n", nCubeLimit );    fprintf( pErr, "\t-f num : the fanin limit (if more, skip the node) [default = %d]\n", nFaninLimit );    fprintf( pErr, "\t-l num : the maximum number of nodes to eliminate [default = %d]\n", nNodesElim );    fprintf( pErr, "\t-b     : use BDDs nodes instead of FF literals as a cost [default = %s]\n", fUseCostBdd? "yes": "no" );      fprintf( pErr, "\t-v     : prints verbose information about elimination [default = %s]\n", fVerbose? "yes": "no" );      fprintf( pErr, "\t-h     : print the command usage\n");    fprintf( pErr, "\t<value>: the elimination value [default = %d]\n", Value );    return 1;       /* error exit */}/**Function*************************************************************  Synopsis    []  Description []                 SideEffects []  SeeAlso     []***********************************************************************/Ntk_CommandNetworkCollapse( Mv_Frame_t * pMvsis, int argc, char ** argv ){    FILE * pOut, * pErr;    Ntk_Network_t * pNet, * pNetNew;    Ntk_Node_t * pNode1, * pNode2;    int c;    int fVerbose;    pNet = Mv_FrameReadNet(pMvsis);    pOut = Mv_FrameReadOut(pMvsis);    pErr = Mv_FrameReadErr(pMvsis);    // set the defaults    fVerbose = 0;    util_getopt_reset();    while ( (c = util_getopt(argc, argv, "hv")) != EOF )     {        switch (c)         {            case 'h':                goto usage;                break;            case 'v':                fVerbose ^= 1;                break;            default:                goto usage;        }    }    if ( pNet == NULL )    {        fprintf( pErr, "Empty network.\n" );        return 1;    }    if ( argc == util_optind + 2 )     {        pNode1  = Ntk_NetworkCollectNodeByName( pNet, argv[util_optind],   0 );        pNode2  = Ntk_NetworkCollectNodeByName( pNet, argv[util_optind+1], 0 );        if ( !pNode1 || !pNode2 )            return 1;        if ( Ntk_NodeReadFaninIndex( pNode1, pNode2 ) != -1 )            Ntk_NetworkCollapseNodes( pNode1, pNode2 );        else if ( Ntk_NodeReadFaninIndex( pNode2, pNode1 ) != -1 )            Ntk_NetworkCollapseNodes( pNode2, pNode1 );        else        {            fprintf( pErr, "Nodes \"%s\" and \"%s\" are not fanin/fanout of each other.\n",                 Ntk_NodeGetNamePrintable(pNode1), Ntk_NodeGetNamePrintable(pNode2) );            return 1;        }    }    else if ( argc == util_optind )     {        // single level networks cannot be collapsed any further        if ( Ntk_NetworkGetNumLevels(pNet) < 2 )	        return 0;        // perform collapsing of the network        pNetNew = Ntk_NetworkCollapse( pNet, fVerbose );        if ( pNetNew == NULL )        {            fprintf( pErr, "Network collapse has failed!\n" );            return 1;        }        // replace the current network        Mv_FrameReplaceCurrentNetwork( pMvsis, pNetNew );    }    else if ( argc == util_optind + 1 ) 

⌨️ 快捷键说明

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