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

📄 wnstrash.c

📁 主要进行大规模的电路综合
💻 C
📖 第 1 页 / 共 2 页
字号:
            pTree->pRoots[i] = NULL;    // check if there is a default    for ( i = 0; i < pTree->nRoots; i++ )        if ( pTree->pRoots[i] == NULL )        { // build NOR of other i-sets            // get the signature of this value set            Signature = (FT_MV_MASK(pTree->nRoots) ^ (1<<i));            // build OR gate            pShNode = Wn_WindowStrashNodeOr( pMan, pTree,                 (Sh_Node_t **)pTree->uRootData, Signature, pTree->nRoots );            shNodeRef( pShNode );            // complement            pShNode = Sh_Not( pShNode );            // save            pTree->uRootData[i] = (unsigned)pShNode;        }    // remove the temporary default value FF     // it is still stored internally in the tree    if ( DefValue >= 0 )        pTree->pRoots[DefValue] = NULL;}/**Function*************************************************************  Synopsis    [Recursive implementation of the above.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/Sh_Node_t * Wn_WindowStrashNode_rec( Sh_Manager_t * pMan,     Ft_Tree_t * pTree, Ft_Node_t * pFtNode, Sh_Node_t * ppShInputs[] ){    Sh_Node_t * pNode1, * pNode2, * pNode;        if ( pFtNode->Type == FT_NODE_LEAF )    {        int iValueFirst;          // find the first value of this var        iValueFirst = Vm_VarMapReadValuesFirst( pTree->pVm, pFtNode->VarNum );        if ( pFtNode->nValues == 2 )        {            if ( pFtNode->uData == 1 )            {                pNode = ppShInputs[iValueFirst];                assert( pNode );                assert( Sh_Regular(pNode)->Num != 1000000 );                assert( Sh_Regular(pNode)->pOne != Sh_Regular(pNode)->pTwo || Sh_Regular(pNode)->pOne == Sh_Regular(pNode)->pTwo );                return pNode;            }            else if ( pFtNode->uData == 2 )            {                pNode = ppShInputs[iValueFirst + 1];                assert( pNode );                assert( Sh_Regular(pNode)->Num != 1000000 );                assert( Sh_Regular(pNode)->pOne != Sh_Regular(pNode)->pTwo || Sh_Regular(pNode)->pOne == Sh_Regular(pNode)->pTwo );                return pNode;            }            assert( 0 );        }        else // MV literal (signature is in pFtNode->uData)            return Wn_WindowStrashNodeOr( pMan, pTree,                 ppShInputs + iValueFirst, pFtNode->uData, pFtNode->nValues );    }    if ( pFtNode->Type == FT_NODE_AND )    {        pNode1 = Wn_WindowStrashNode_rec( pMan, pTree, pFtNode->pOne, ppShInputs );         shNodeRef( pNode1 );        pNode2 = Wn_WindowStrashNode_rec( pMan, pTree, pFtNode->pTwo, ppShInputs );         shNodeRef( pNode2 );        pNode = Sh_NodeAnd( pMan, pNode1, pNode2 ); shNodeRef( pNode );        Sh_NodeRecursiveDeref( pNode1 );        Sh_NodeRecursiveDeref( pNode2 );        shNodeDeref( pNode );        assert( Sh_Regular(pNode)->Num != 1000000 );        assert( Sh_Regular(pNode)->pOne != Sh_Regular(pNode)->pTwo || Sh_Regular(pNode)->pOne == Sh_Regular(pNode)->pTwo );        return pNode;    }    if ( pFtNode->Type == FT_NODE_OR )    {        pNode1 = Wn_WindowStrashNode_rec( pMan, pTree, pFtNode->pOne, ppShInputs );         shNodeRef( pNode1 );        pNode2 = Wn_WindowStrashNode_rec( pMan, pTree, pFtNode->pTwo, ppShInputs );         shNodeRef( pNode2 );        pNode = Sh_NodeOr( pMan, pNode1, pNode2 ); shNodeRef( pNode );        Sh_NodeRecursiveDeref( pNode1 );        Sh_NodeRecursiveDeref( pNode2 );        shNodeDeref( pNode );        assert( Sh_Regular(pNode)->Num != 1000000 );        assert( Sh_Regular(pNode)->pOne != Sh_Regular(pNode)->pTwo || Sh_Regular(pNode)->pOne == Sh_Regular(pNode)->pTwo );        return pNode;    }    if ( pFtNode->Type == FT_NODE_0 )        return Sh_Not( Sh_ManagerReadConst1( pMan ) );    if ( pFtNode->Type == FT_NODE_1 )        return Sh_ManagerReadConst1( pMan );    assert( 0 ); // unknown node type    return NULL;}/**Function*************************************************************  Synopsis    [Creates the cascade of OR gates.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/Sh_Node_t * Wn_WindowStrashNodeOr( Sh_Manager_t * pMan, Ft_Tree_t * pTree,     Sh_Node_t * ppShInputs[], unsigned Signature, int nNodes ){    Sh_Node_t * pNode1, * pNode2, * pTemp;    int i;    assert( nNodes >= 2 );    pNode1 = NULL;    for ( i = 0; i < nNodes; i++ )        if ( Signature & (1<<i) )        {            if ( pNode1 == NULL )            {                pNode1 = ppShInputs[i];   shNodeRef( pNode1 );                assert( pNode1 );            }            else            {                pNode2 = ppShInputs[i];   shNodeRef( pNode2 );                assert( pNode2 );                pNode1 = Sh_NodeOr( pMan, pTemp = pNode1, pNode2 ); shNodeRef( pNode1 );                Sh_NodeRecursiveDeref( pTemp );                Sh_NodeRecursiveDeref( pNode2 );            }        }    assert( pNode1 );    assert( Sh_Regular(pNode1)->Num != 1000000 );    assert( Sh_Regular(pNode1)->pOne != Sh_Regular(pNode1)->pTwo || Sh_Regular(pNode1)->pOne == Sh_Regular(pNode1)->pTwo );    shNodeDeref( pNode1 );    return pNode1;}/**Function*************************************************************  Synopsis    [Creates the cascade of OR gates.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Wn_WindowStrashNodeDeref( Ntk_Node_t * pNode ){    Ft_Tree_t * pTree;    Cvr_Cover_t * pCvr;    int i;    // get the factored form of this node    pCvr = Ntk_NodeGetFuncCvr( pNode );    pTree = Cvr_CoverFactor( pCvr );    // check if there is a defaul    for ( i = 0; i < pTree->nRoots; i++ )    {        Sh_NodeRecursiveDeref( (Sh_Node_t *)pTree->uRootData[i] );        pTree->uRootData[i] = 0;    }}/**Function*************************************************************  Synopsis    [Adds a unique AND gate for each output of each FF.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Wn_WindowStrashAddUnique( Sh_Manager_t * pMan, Ntk_Node_t * pNode ){    Cvr_Cover_t * pCvr;    Ft_Tree_t * pTree;    Sh_Node_t * pShNode;    int k;    pCvr = Ntk_NodeGetFuncCvr( pNode );    pTree = Cvr_CoverFactor( pCvr );    assert( pTree->nRoots == pNode->nValues );    for ( k = 0; k < pNode->nValues; k++ )    {        // get the node from the root data        pShNode = (Sh_Node_t *)pTree->uRootData[k];        assert( pShNode );        // duplicate the node by inserting a unique one into the table        pTree->uRootData[k] = (unsigned)Sh_TableInsertUnique( pMan, pShNode );    }}/**Function*************************************************************  Synopsis    [Prints the roots of the nodes after strashing.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Wn_WindowStrashPrint( Sh_Manager_t * pMan, Wn_Window_t * pWnd ){    Ntk_Node_t * pNode;    Ntk_NetworkForEachNodeSpecial( pWnd->pNet, pNode )    {        printf( "NODE %3s : \n", Ntk_NodeGetNamePrintable(pNode) );        printf( "\n" );        Wn_WindowStrashPrintOne( pMan, pNode );        printf( "\n" );    }}/**Function*************************************************************  Synopsis    [Prints the roots of the nodes after strashing.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Wn_WindowStrashPrintOne( Sh_Manager_t * pMan, Ntk_Node_t * pNode ){    Sh_Node_t * ppNodes[32];    Cvr_Cover_t * pCvr;    Ft_Tree_t * pTree;    int k;    pCvr = Ntk_NodeGetFuncCvr( pNode );    pTree = Cvr_CoverFactor( pCvr );    assert( pTree->nRoots == pNode->nValues );    for ( k = 0; k < pNode->nValues; k++ )        ppNodes[k] = (Sh_Node_t *)pTree->uRootData[k];    Sh_NodePrintArray( ppNodes, pNode->nValues );}/**Function*************************************************************  Synopsis    [Recursively strashs the window.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Wn_WindowStrashCoreConstruct_rec( Sh_Manager_t * pMan, Ntk_Node_t * pNode, Wn_Window_t * pWnd ){    Ntk_Node_t * pFanin;    Ntk_Pin_t * pPin;    Ntk_Node_t ** ppNodes;    Sh_Node_t ** ppShInputs;    int nNodes, nValuesIn;    if ( Wn_WindowStrashCoreNodeIsStrashed(pNode) )        return;    // makes sure that the fanins are already strashed    Ntk_NodeForEachFanin( pNode, pPin, pFanin )        if ( !Wn_WindowStrashCoreNodeIsStrashed(pFanin) )            Wn_WindowStrashCoreConstruct_rec( pMan, pFanin, pWnd );    // collect fanins into array    ppNodes = pNode->pNet->pArray1;    nNodes = Ntk_NodeReadFanins( pNode, ppNodes );    // set the input Sh_Nodes    nValuesIn = Vm_VarMapReadValuesInNum( Ntk_NodeReadFuncVm(pNode) );    ppShInputs = (Sh_Node_t **)pNode->pNet->pArray2;    Wn_WindowStrashCollect( pMan, pWnd->pVmL, ppNodes, nNodes, ppShInputs, nValuesIn );    // strash the node    Wn_WindowStrashNode( pMan, pNode, ppShInputs );}/**Function*************************************************************  Synopsis    [Recursively cleans the TFO of the traces of strashing.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Wn_WindowStrashCoreClean( Sh_Manager_t * pMan, Ntk_Node_t * pNode ){    // start the trav-id for this traversal    Ntk_NetworkIncrementTravId( pNode->pNet );    // start from the node    Wn_WindowStrashCoreClean_rec( pNode );}/**Function*************************************************************  Synopsis    [Recursively cleans the TFO of the traces of strashing.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Wn_WindowStrashCoreClean_rec( Ntk_Node_t * pNode ){    Ntk_Node_t * pFanout;    Ntk_Pin_t * pPin;    if ( Ntk_NodeIsCo(pNode) )        return;    if ( Ntk_NodeIsTravIdCurrent(pNode) ) // visited node        return;    // mark the node as visited    Ntk_NodeSetTravIdCurrent(pNode);    // call recursively for the fanouts    Ntk_NodeForEachFanout( pNode, pPin, pFanout )        Wn_WindowStrashCoreClean_rec( pFanout );    // clean the node    Wn_WindowStrashCoreCleanStrashings( pNode );}/**Function*************************************************************  Synopsis    [Cleans the traces of strashing.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Wn_WindowStrashCoreCleanStrashings( Ntk_Node_t * pNode ){    Cvr_Cover_t * pCvr;    Ft_Tree_t * pTree;    int k;    pCvr = Ntk_NodeGetFuncCvr( pNode );    pTree = Cvr_CoverFactor( pCvr );    assert( pTree->nRoots == pNode->nValues );    for ( k = 0; k < pNode->nValues; k++ )        pTree->uRootData[k] = 0;}/**Function*************************************************************  Synopsis    [Detect if the traces of strashing are present.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/bool Wn_WindowStrashCoreNodeIsStrashed( Ntk_Node_t * pNode ){    Cvr_Cover_t * pCvr;    Ft_Tree_t * pTree;    int k;    if ( Ntk_NodeIsCi(pNode) )        return 1;    pCvr = Ntk_NodeGetFuncCvr( pNode );    pTree = Cvr_CoverFactor( pCvr );    assert( pTree->nRoots == pNode->nValues );    for ( k = 0; k < pNode->nValues; k++ )        if ( pTree->uRootData[k] == 0 )            return 0;    return 1;}/**Function*************************************************************  Synopsis    [Cleans strashing that may have been attached to the nodes.]  Description []                 SideEffects []  SeeAlso     []***********************************************************************/void Wn_WindowStrashClean( Wn_Window_t * pWnd ){    Ntk_Node_t * pNode;    Ntk_NetworkForEachNode( pWnd->pNet, pNode )        Wn_WindowStrashCoreCleanStrashings( pNode );}///////////////////////////////////////////////////////////////////////////                       END OF FILE                                ///////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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