📄 ntkidefault.c
字号:
/**CFile**************************************************************** FileName [ntkiDefault.c] PackageName [MVSIS 2.0: Multi-valued logic synthesis system.] Synopsis [] Author [MVSIS Group] Affiliation [UC Berkeley] Date [Ver. 1.0. Started - February 1, 2003.] Revision [$Id: ntkiDefault.c,v 1.4 2003/05/27 23:14:31 alanmi Exp $]***********************************************************************/#include "ntkiInt.h"/////////////////////////////////////////////////////////////////////////// DECLARATIONS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// FUNCTION DEFITIONS ////////////////////////////////////////////////////////////////////////////**Function************************************************************* Synopsis [Minimizes the nodes in order to have a good default.] Description [Can reduce the behavior of the nodes.] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NetworkResetDefault( Ntk_Network_t * pNet ){ ProgressBar * pProgress; Ntk_Node_t * pNode; int AcceptType, nNodes; bool fVerbose = 0; // start the progress var if ( !fVerbose ) pProgress = Extra_ProgressBarStart( stdout, Ntk_NetworkReadNodeIntNum(pNet) ); // get the type of the current cost function AcceptType = Ntk_NetworkGetAcceptType( pNet ); // go through the nodes and set the defaults nNodes = 0; Ntk_NetworkForEachNode( pNet, pNode ) { Ntk_NodeResetDefault( pNode, AcceptType ); if ( ++nNodes % 5 == 0 && !fVerbose ) Extra_ProgressBarUpdate( pProgress, nNodes ); } if ( !fVerbose ) Extra_ProgressBarStop( pProgress );}/**Function************************************************************* Synopsis [Forces the internal nodes to have default cover whenever possible.] Description [Cannot reduce the behavior of the nodes.] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NetworkForceDefault( Ntk_Network_t * pNet ){ Ntk_Node_t * pNode; // go through the nodes and set the defaults Ntk_NetworkForEachNode( pNet, pNode ) Ntk_NodeForceDefault( pNode );}/**Function************************************************************* Synopsis [Computes the default cover of the internal nodes.] Description [Does not change the behavior of the nodes but increases the number of literals.] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NetworkComputeDefault( Ntk_Network_t * pNet ){ Ntk_Node_t * pNode; Cvr_Cover_t * pCvr; Mvc_Cover_t ** ppIsets; int DefValue; // go through the nodes and set the defaults Ntk_NetworkForEachNode( pNet, pNode ) { pCvr = Ntk_NodeReadFuncCvr( pNode ); ppIsets = Cvr_CoverReadIsets( pCvr ); DefValue = Cvr_CoverReadDefault( pCvr ); if ( DefValue >= 0 ) ppIsets[DefValue] = Ntk_NodeComputeDefault( pNode ); Cvr_CoverFreeFactor( pCvr ); }}/**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_NodeResetDefault( Ntk_Node_t * pNode, int AcceptType ){ FILE * pOutput; Cvr_Cover_t * pCvr, * pCvrMin; Mvr_Relation_t * pMvr; // get the output stream pOutput = Ntk_NodeReadMvsisOut(pNode); // force the default whenever possible Ntk_NodeForceDefault( pNode ); // get the current Mvr pMvr = Ntk_NodeGetFuncMvr( pNode );//fprintf( Ntk_NetworkReadMvsisOut(pNet), "Nodes in Mvr = %d\n", Mvr_RelationGetNodes(pMvr) );//if ( strcmp( pNode->lFanouts.pHead->pNode->pName, "pe2" ) == 0 )//{// int i = 0;//} // when Mvr is derived from Cvr, if the resulting Mvr is not well-defined // the don't-care minterms are added to all i-sets of Mvr // while the original Cvr is freed, because it is no longer valid // in this case, we do not derive another Cvr // therefore, we "read" it and not "get" it here pCvr = Ntk_NodeReadFuncCvr( pNode ); // minimize the relation with Espresso pCvrMin = Fnc_FunctionMinimizeCvr( Ntk_NodeReadManMvc(pNode), pMvr, 0 ); // espresso // if failed, try minimizing using ISOP if ( pCvrMin == NULL ) pCvrMin = Fnc_FunctionMinimizeCvr( Ntk_NodeReadManMvc(pNode), pMvr, 1 ); // isop // consider four situations depending on the present/absence of Cvr and CvrMin if ( pCvr && pCvrMin ) { // both Cvrs are avaible - choose the best one // compare the minimized relation with the original one if ( Ntk_NodeTestAcceptCvr( pCvr, pCvrMin, AcceptType, 0 ) ) { // accept the minimized node // this will remove Mvr and old Cvr Ntk_NodeSetFuncCvr( pNode, pCvrMin ); Ntk_NodeMakeMinimumBase( pNode ); } else { // reject the minimized node Cvr_CoverFree( pCvrMin ); } } else if ( pCvr ) { // only the old Cvr is available - leave it as it is } else if ( pCvrMin ) { // only the new Cvr is available - set it Ntk_NodeSetFuncCvr( pNode, pCvrMin ); Ntk_NodeMakeMinimumBase( pNode ); } else { // none of them is available fprintf( pOutput, "Failed to minimize MV SOP of node \"%s\" in the given resource limits.\n", Ntk_NodeGetNamePrintable(pNode) ); fprintf( pOutput, "Currently the node does not have MV SOP, only MV relation.\n" ); }}/**Function************************************************************* Synopsis [Decides whether to accept the node.] Description [] SideEffects [] SeeAlso []***********************************************************************/bool Ntk_NodeTestAcceptCvr( Cvr_Cover_t * pCvr, Cvr_Cover_t * pCvrMin, int AcceptType, bool fVerbose ){ int nOld, nNew; bool fAccepted=FALSE; if (pCvrMin==NULL || pCvr==NULL) { fail("SimpAcceptResult: empty covers.\n"); } if (AcceptType == 0) // SIMP_CUBE { nOld = Cvr_CoverReadCubeNum(pCvr); nNew = Cvr_CoverReadCubeNum(pCvrMin); if (nOld == nNew) { nOld = Cvr_CoverReadLitSopNum(pCvr); nNew = Cvr_CoverReadLitSopNum(pCvrMin); // use the number of leaf values as the final tie braker if (nOld == nNew) { nOld = -Cvr_CoverReadLeafValueNum(pCvr); nNew = -Cvr_CoverReadLeafValueNum(pCvrMin); } } } else if (AcceptType == 1) // SIMP_SOP_LIT { nOld = Cvr_CoverReadLitSopNum(pCvr); nNew = Cvr_CoverReadLitSopNum(pCvrMin); if (nOld == nNew) { nOld = Cvr_CoverReadLitFacNum(pCvr); nNew = Cvr_CoverReadLitFacNum(pCvrMin); // use the number of leaf values as the final tie braker if (nOld == nNew) { nOld = -Cvr_CoverReadLeafValueNum(pCvr); nNew = -Cvr_CoverReadLeafValueNum(pCvrMin); } } } else if (AcceptType == 2) // SIMP_FCT_LIT { nOld = Cvr_CoverReadLitFacNum(pCvr); nNew = Cvr_CoverReadLitFacNum(pCvrMin); if (nOld == nNew) { nOld = Cvr_CoverReadLitSopNum(pCvr); nNew = Cvr_CoverReadLitSopNum(pCvrMin); // use the number of leaf values as the final tie braker if (nOld == nNew) { nOld = -Cvr_CoverReadLeafValueNum(pCvr); nNew = -Cvr_CoverReadLeafValueNum(pCvrMin); } }//Ft_TreePrint( stdout, Cvr_CoverReadTree(pCvr), NULL, NULL );//Ft_TreePrint( stdout, Cvr_CoverReadTree(pCvrMin), NULL, NULL ); } else if (AcceptType == 3) // SIMP_ALWAYS { fAccepted = TRUE; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -