📄 ntkidefault.c
字号:
else { fail("SimpAcceptResult: Wrong acceptance criterion\n"); } if (fAccepted || nNew < nOld) return TRUE; else return FALSE;}/**Function************************************************************* Synopsis [Forces the node to have a default value.] Description [This function does not reduce the befavior of the node.] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NodeForceDefault( Ntk_Node_t * pNode ){ Cvr_Cover_t * pCvr; Mvr_Relation_t * pMvr; // check the case when the cover is present // and the default value is already set pCvr = Ntk_NodeReadFuncCvr( pNode ); if ( pCvr && Cvr_CoverReadDefault(pCvr) >= 0 ) return; // get the relation pMvr = Ntk_NodeGetFuncMvr( pNode ); if ( Mvr_RelationReadMark(pMvr) ) { // the don't-care was computed and added to the node fprintf( Ntk_NodeReadMvsisOut(pNode), "Local MV relation of node \"%s\" is not well-defined. Don't-care is assumed.\n", Ntk_NodeGetNamePrintable(pNode) ); Mvr_RelationCleanMark( pMvr ); // in this case, there is no way of assigning the default value // without reducing behavior return; } // if the relation is ND, forcing the default value will reduce behavior if ( Mvr_RelationIsND(pMvr) ) return; // get the cover pCvr = Ntk_NodeGetFuncCvr( pNode ); // if the default value was already set while deriving Cvr, skip if ( Cvr_CoverReadDefault(pCvr) >= 0 ) return; // derive the default value Cvr_CoverResetDefault( pCvr );}/**Function************************************************************* Synopsis [Get the acceptable type for the network.] Description [] SideEffects [] SeeAlso []***********************************************************************/int Ntk_NetworkGetAcceptType( Ntk_Network_t * pNet ){ char * sValue; int iCost; sValue = Cmd_FlagReadByName( pNet->pMvsis, "cost" ); if ( sValue ) iCost = atoi( sValue ); else iCost = 2; return iCost;}/**Function************************************************************* Synopsis [Computes and returns the default cover.] Description [] SideEffects [] SeeAlso []***********************************************************************/Mvc_Cover_t * Ntk_NodeComputeDefault( Ntk_Node_t * pNode ){ Mvr_Relation_t * pMvr; DdNode ** pbIsets; Mvc_Cover_t * pCover; int nInputs, Default; Default = Cvr_CoverReadDefault( Ntk_NodeGetFuncCvr(pNode) ); if ( Default < 0 ) return NULL; // get the relation pMvr = Ntk_NodeGetFuncMvr( pNode ); // get the i-sets (the cofs w.r.t. the output var) nInputs = Ntk_NodeReadFaninNum(pNode); pbIsets = ALLOC( DdNode *, pNode->nValues ); Mvr_RelationCofactorsDerive( pMvr, pbIsets, nInputs, pNode->nValues ); // derive the cover for the default i-set pCover = Fnc_FunctionDeriveSopFromMdd( Ntk_NodeReadManMvc(pNode), pMvr, pbIsets[Default], pbIsets[Default], nInputs ); // deref the value codes Mvr_RelationCofactorsDeref( pMvr, pbIsets, nInputs, pNode->nValues ); free( pbIsets ); return pCover;}/**Function************************************************************* Synopsis [Computes the factored form of the default value.] Description [] SideEffects [] SeeAlso []***********************************************************************/Ft_Node_t * Ntk_NodeFactorDefault( Ntk_Node_t * pNode ){ Ft_Tree_t * pTree; Mvc_Cover_t * pMvcDef; Cvr_Cover_t * pCvr; int Default; // if there is no default value // there is no need for factoring the default value pCvr = Ntk_NodeGetFuncCvr(pNode); Default = Cvr_CoverReadDefault( pCvr ); if ( Default < 0 ) return NULL; // if the default value has already been factored, get it pTree = Cvr_CoverFactor( pCvr ); assert( pTree->pRoots[Default] == NULL ); if ( pTree->pDefault ) return pTree->pDefault; // otherwise, factor the default value // get the default i-set pMvcDef = Ntk_NodeComputeDefault(pNode); // factor this i-set pTree->pDefault = Ft_Factor( pTree, pMvcDef ); // remove the default cover Mvc_CoverFree( pMvcDef ); // return the default value FF return pTree->pDefault;}/**Function************************************************************* Synopsis [Resets the default using FFs.] Description [Uses the factored form to compute the complement of a cover. Tries to phase assign the node using the cover.] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NetworkFfResetDefault( Ntk_Network_t * pNet, bool fVerbose ){ Ntk_Node_t * pNode; int AcceptType; // get the type of the current cost function AcceptType = Ntk_NetworkGetAcceptType( pNet ); // go through the nodes and set the defaults Ntk_NetworkForEachNode( pNet, pNode ) Ntk_NodeFfResetDefault( pNode, AcceptType, fVerbose );}/**Function************************************************************* Synopsis [Resets the default using FFs.] Description [Uses the factored form to compute the complement of a cover. Tries to phase assign the node using the cover.] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NodeFfResetDefault( Ntk_Node_t * pNode, int AcceptType, bool fVerbose ){ Cvr_Cover_t * pCvr; Ft_Tree_t * pTree; Mvc_Cover_t ** ppIsets; int DefValue; int nCubesBefore; int nCubesAfter; if ( pNode->nValues != 2 ) return; pCvr = Ntk_NodeGetFuncCvr( pNode ); pTree = Cvr_CoverFactor( pCvr ); ppIsets = Cvr_CoverReadIsets( pCvr ); DefValue = Cvr_CoverReadDefault( pCvr ); if ( DefValue < 0 ) return; // compute the default cover by complementing the non-default cover // compare nCubesBefore = Mvc_CoverReadCubeNum(ppIsets[DefValue ^ 1]); nCubesAfter = Ft_UnfactorCount( pTree, DefValue ^ 1, 1 ); if ( fVerbose ) { fprintf( Ntk_NodeReadMvsisOut(pNode), "%5s : ", Ntk_NodeGetNamePrintable(pNode) ); fprintf( Ntk_NodeReadMvsisOut(pNode), "Def = %d ", DefValue ); fprintf( Ntk_NodeReadMvsisOut(pNode), "Non-def cubes = %4d ", nCubesBefore ); fprintf( Ntk_NodeReadMvsisOut(pNode), "Def compl cubes = %5d ", nCubesAfter ); } if ( nCubesBefore <= nCubesAfter ) // no improvement { if ( fVerbose ) fprintf( Ntk_NodeReadMvsisOut(pNode), "\n" ); } else // there is some improvement { if ( fVerbose ) fprintf( Ntk_NodeReadMvsisOut(pNode), "Accept\n" ); Mvc_CoverFree( ppIsets[DefValue ^ 1] ); ppIsets[DefValue ^ 1] = NULL; ppIsets[DefValue ] = Ft_Unfactor( Ntk_NodeReadManMvc(pNode), pTree, DefValue ^ 1, 1 );// ppIsets[DefValue ] = NULL;// ppIsets[DefValue ^ 1] = Ft_Unfactor( Ntk_NodeReadManMvc(pNode), pTree, DefValue ^ 1, 1 ); Cvr_CoverFreeFactor( pCvr ); }}/////////////////////////////////////////////////////////////////////////// END OF FILE ///////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -