📄 ntkiprint.c
字号:
/**CFile**************************************************************** FileName [ntkiPrint.c] PackageName [MVSIS 2.0: Multi-valued logic synthesis system.] Synopsis [All the printing procedures for stats/ios/values, etc.] Author [MVSIS Group] Affiliation [UC Berkeley] Date [Ver. 1.0. Started - February 1, 2003.] Revision [$Id: ntkiPrint.c,v 1.3 2003/05/27 23:14:33 alanmi Exp $]***********************************************************************/#include "ntkiInt.h"/////////////////////////////////////////////////////////////////////////// DECLARATIONS ///////////////////////////////////////////////////////////////////////////static char * Ntk_NodePrintLiteral( Mvc_Cube_t * pCube, int iLit, Ntk_Node_t ** ppFanins, int * pValuesFirst );static void Ntk_NodePrintUpdatePos( FILE * pFile, int * pPos, char * pName );static char * Ntk_NodeGetNamePrintableInt( pNode );/////////////////////////////////////////////////////////////////////////// FUNCTION DEFITIONS ////////////////////////////////////////////////////////////////////////////**Function************************************************************* Synopsis [Print stats command.] Description [Reports the vital statistics about the network: (1) the number of PI/PO nodes; (2) the number of internal nodes; (3) the number of inputs in all nodes; (4) the number of BDD nodes in all local functions.] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NetworkPrintStats( FILE * pFile, Ntk_Network_t * pNet, bool fComputeCvr, bool fComputeMvr, bool fShort ){ Ntk_Node_t * pNode; Cvr_Cover_t * pCvr; Mvr_Relation_t * pMvr; int nTotalFanins; int nTotalValues; int nTotalCubes; int nTotalLitsSop; int nTotalLitsFt; int nTotalBddNodes; int nNodesWithCvr; int nNodesWithMvr; int nNodesInternal; double RatioWithCvr; double RatioWithMvr; // statistics nTotalFanins = 0; nTotalValues = 0; nTotalCubes = 0; nTotalLitsSop = 0; nTotalLitsFt = 0; nTotalBddNodes = 0; // nodes nNodesWithCvr = 0; nNodesWithMvr = 0; nNodesInternal = Ntk_NetworkReadNodeIntNum(pNet); // go through all the nodes Ntk_NetworkForEachNode( pNet, pNode ) { // count the number of fanins and values nTotalFanins += Ntk_NodeReadFaninNum(pNode); nTotalValues += pNode->nValues; // count the Cvr based parameters if ( fComputeCvr ) pCvr = Ntk_NodeGetFuncCvr( pNode ); else pCvr = Ntk_NodeReadFuncCvr( pNode ); if ( pCvr ) { nNodesWithCvr++; nTotalLitsSop += Cvr_CoverReadLitSopNum( pCvr ); nTotalLitsFt += Cvr_CoverReadLitFacNum( pCvr ); // use CST cover nTotalCubes += Cvr_CoverReadCubeNum( pCvr ); } // count the Mvr based parameters if ( fComputeMvr ) pMvr = Ntk_NodeGetFuncMvr( pNode ); else pMvr = Ntk_NodeReadFuncMvr( pNode ); if ( pMvr ) { nNodesWithMvr++; nTotalBddNodes += Mvr_RelationGetNodes(pMvr); } } RatioWithCvr = 100.0 * nNodesWithCvr / nNodesInternal; RatioWithMvr = 100.0 * nNodesWithMvr / nNodesInternal; // report the statistics if ( fShort ) { // use the short form fprintf( pFile, "%s:", pNet->pName ); fprintf( pFile, " ci/co = %d/%d", Ntk_NetworkReadCiNum(pNet), Ntk_NetworkReadCoNum(pNet) ); fprintf( pFile, " lat = %d", Ntk_NetworkReadLatchNum(pNet) ); fprintf( pFile, " nd = %d", Ntk_NetworkReadNodeIntNum(pNet) ); fprintf( pFile, " cube = %d", nTotalCubes ); fprintf( pFile, " ff-lit = %d", nTotalLitsFt ); fprintf( pFile, " lev = %d", Ntk_NetworkGetNumLevels(pNet) ); fprintf( pFile, "\n" ); } else { fprintf( pFile, "%-4s:", pNet->pName ); fprintf( pFile, " ci = %d", Ntk_NetworkReadCiNum(pNet) ); fprintf( pFile, " co = %d", Ntk_NetworkReadCoNum(pNet) ); fprintf( pFile, " node = %d", Ntk_NetworkReadNodeIntNum(pNet) ); fprintf( pFile, " latch = %d", Ntk_NetworkReadLatchNum(pNet) ); fprintf( pFile, " level = %d", Ntk_NetworkGetNumLevels(pNet) ); fprintf( pFile, "\n" ); fprintf( pFile, "SOP (%5.1f%%):", RatioWithCvr ); fprintf( pFile, " cubes = %d", nTotalCubes ); fprintf( pFile, " lits = %d", nTotalLitsSop ); fprintf( pFile, " lits(ff) = %d", nTotalLitsFt ); fprintf( pFile, "\n" ); fprintf( pFile, "MDD (%5.1f%%):", RatioWithMvr ); fprintf( pFile, " nodes(bdd) = %d", nTotalBddNodes ); fprintf( pFile, "\n" ); }}/**Function************************************************************* Synopsis [Print stats command for one node.] Description [] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NodePrintStats(FILE *fp, Ntk_Node_t *node, bool cvr, bool mvr){ Cvr_Cover_t * pCvr; Mvr_Relation_t * pMvr; fprintf(fp, "%s\t", Ntk_NodeGetNamePrintableInt(node)); switch ( Ntk_NodeReadType(node) ) { case MV_NODE_CI: fprintf(fp, "(combinational input)\n"); break; case MV_NODE_CO: fprintf(fp, "(combinational output)\n"); break; case MV_NODE_INT: fprintf(fp, "%3d inputs", Ntk_NodeReadFaninNum(node)); fprintf(fp, "%3d vals", node->nValues); if (cvr) pCvr = Ntk_NodeGetFuncCvr(node); else pCvr = Ntk_NodeReadFuncCvr(node); if (pCvr) { fprintf(fp, "%5d cubes", Cvr_CoverReadCubeNum(pCvr)); fprintf(fp, "%6d lits", Cvr_CoverReadLitSopNum(pCvr)); fprintf(fp, "%6d ff-lits", Cvr_CoverReadLitFacNum(pCvr)); } if (mvr) pMvr = Ntk_NodeGetFuncMvr(node); else pMvr = Ntk_NodeReadFuncMvr(node); if (pMvr) fprintf(fp, "%5d BDD nodes", Mvr_RelationGetNodes(pMvr)); fprintf(fp, "\n"); break; case MV_NODE_NONE: abort(); }}/**Function************************************************************* Synopsis [print_io command for the network and the nodes.] Description [] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NetworkPrintIo( FILE * pFile, Ntk_Network_t * pNet, int nNodes ){ Ntk_Node_t * pNode, * pFanin, * pFanout; Ntk_Pin_t * pPin; int i; if ( nNodes == 0 ) { // this code will work only if the new CIs/ COs are not added // during the network processing fprintf( pFile, "Combinational inputs: " ); // Ntk_NetworkForEachCi( pNet, pNode )// fprintf( pFile, " %s", Ntk_NodeGetNamePrintableInt(pNode) ); for ( i = 1; i < pNet->nIds; i++ ) { pNode = pNet->pId2Node[i]; if ( pNode == NULL ) continue; if ( pNode->Type == MV_NODE_CI ) fprintf( pFile, " %s", Ntk_NodeGetNamePrintableInt(pNode) ); else break; } fprintf( pFile, "\n" ); fprintf( pFile, "Combinational outputs:" ); // Ntk_NetworkForEachCo( pNet, pNode )// fprintf( pFile, " %s", Ntk_NodeGetNamePrintableInt(pNode) ); for ( ; i < pNet->nIds; i++ ) { pNode = pNet->pId2Node[i]; if ( pNode == NULL ) continue; if ( pNode->Type == MV_NODE_CO ) fprintf( pFile, " %s", Ntk_NodeGetNamePrintableInt(pNode) ); else break; } fprintf( pFile, "\n" ); } else { Ntk_NetworkForEachNodeSpecial( pNet, pNode ) { fprintf( pFile, "%s:\n", Ntk_NodeGetNamePrintableInt(pNode) ); fprintf( pFile, " Fanins: ", Ntk_NodeGetNamePrintableInt(pNode) ); Ntk_NodeForEachFanin( pNode, pPin, pFanin ) fprintf( pFile, " %s", Ntk_NodeGetNamePrintableInt(pFanin) ); fprintf( pFile, "\n" ); fprintf( pFile, " Fanouts:" ); Ntk_NodeForEachFanout( pNode, pPin, pFanout ) if ( !Ntk_NodeIsCo(pFanout) ) fprintf( pFile, " %s", Ntk_NodeGetNamePrintableInt(pFanout) ); fprintf( pFile, "\n" ); } }}/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NetworkPrintValue( FILE * pFile, Ntk_Network_t * pNet, int nNodes ){ Ntk_Node_t * pNode; int LenghtMax, LenghtCur; int nColumns, iNode; if ( nNodes == 1 ) { Ntk_NodePrintValue( pFile, pNet->pOrder ); return; } // get the longest name LenghtMax = 0; Ntk_NetworkForEachNodeSpecial( pNet, pNode ) if ( !Ntk_NodeIsCo(pNode) && !Ntk_NodeIsCoFanin(pNode) ) { LenghtCur = strlen( Ntk_NodeGetNamePrintableInt(pNode) ); if ( LenghtMax < LenghtCur ) LenghtMax = LenghtCur; } // decide how many columns to print nColumns = 80 / (LenghtMax + 9); // print the node names iNode = 0; Ntk_NetworkForEachNodeSpecial( pNet, pNode ) if ( !Ntk_NodeIsCo(pNode) && !Ntk_NodeIsCoFanin(pNode) ) { fprintf( pFile, "%*s:%5d", LenghtMax, Ntk_NodeGetNamePrintableInt(pNode), Ntk_NetworkGetNodeValueSop(pNode) ); if ( ++iNode % nColumns == 0 ) fprintf( pFile, "\n" ); else fprintf( pFile, " " ); } if ( iNode % nColumns ) fprintf( pFile, "\n" ); }/**Function************************************************************* Synopsis [Prints the factored form of the node.] Description [] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NodePrintValue( FILE * pFile, Ntk_Node_t * pNode ){ char * pName; if ( pNode == NULL ) return; // check the situation when the node's value is trivial pName = Ntk_NodeGetNamePrintableInt(pNode); if ( Ntk_NodeIsCi(pNode) ) { fprintf( pFile, "%10s: combinational input\n", pName ); return; } if ( Ntk_NodeIsCo(pNode) || Ntk_NodeIsCoFanin(pNode) ) { fprintf( pFile, "%10s: combinational output\n", pName ); return; } // print fprintf( pFile, "%10s: %3d\n", pName, Ntk_NetworkGetNodeValueSop(pNode) );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -