📄 ntkiprint.c
字号:
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NetworkPrintRange( FILE * pFile, Ntk_Network_t * pNet, int nNodes ){ Ntk_Node_t * pNode; int LenghtMax, LenghtCur; int nColumns, iNode; if ( nNodes == 1 ) { Ntk_NodePrintRange( pFile, pNet->pOrder ); return; } // get the longest name LenghtMax = 0; Ntk_NetworkForEachNodeSpecial( pNet, pNode ) { LenghtCur = strlen( Ntk_NodeGetNamePrintableInt(pNode) ); if ( LenghtMax < LenghtCur ) LenghtMax = LenghtCur; } // decide how many columns to print nColumns = 80 / (LenghtMax + 7); // print the node names iNode = 0; Ntk_NetworkForEachNodeSpecial( pNet, pNode ) { fprintf( pFile, "%*s:%3d", LenghtMax, Ntk_NodeGetNamePrintableInt(pNode), pNode->nValues ); 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_NodePrintRange( 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); // print fprintf( pFile, "%10s: %3d", pName, pNode->nValues ); if ( Ntk_NodeIsCi(pNode) ) fprintf( pFile, " <combinational input>\n", pName ); if ( Ntk_NodeIsCo(pNode) || Ntk_NodeIsCoFanin(pNode) ) fprintf( pFile, " <combinational output>\n", pName ); fprintf( pFile, "\n" );}/**Function************************************************************* Synopsis [Prints the factored form of the node.] Description [] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NodePrintFactor( FILE * pFile, Ntk_Node_t * pNode ){ Ntk_Node_t * pFanin; Ft_Tree_t * pTree; Vm_VarMap_t * pVm; char ** pNamesIn; int nVarsIn, i; // the node may be CO, if its fanin is a CI or an internal node without CO name if ( pNode->Type == MV_NODE_CO ) { for ( i = 1; i < pNode->nValues; i++ ) { Ntk_NodePrintOutputName( pFile, Ntk_NodeGetNamePrintableInt(pNode), pNode->nValues, i ); fprintf( pFile, "%s", Ntk_NodeGetNamePrintableInt( Ntk_NodeReadFaninNode(pNode,0) ) ); if ( pNode->nValues > 2 ) fprintf( pFile, "{%d}", i ); fprintf( pFile, "\n" ); return; } } pVm = Ntk_NodeReadFuncVm( pNode ); nVarsIn = Vm_VarMapReadVarsInNum( pVm ); // get the names of the input variables pNamesIn = ALLOC( char *, nVarsIn ); for ( i = 0; i < nVarsIn; i++ ) { pFanin = Ntk_NodeReadFaninNode( pNode, i ); pNamesIn[i] = util_strsav( Ntk_NodeGetNamePrintableInt(pFanin) ); } pTree = Cvr_CoverFactor( Ntk_NodeGetFuncCvr( pNode ) ); Ft_TreePrint( pFile, pTree, pNamesIn, Ntk_NodeGetNamePrintableInt(pNode) ); for ( i = 0; i < nVarsIn; i++ ) FREE( pNamesIn[i] ); FREE( pNamesIn );}/**Function************************************************************* Synopsis [Prints the nodes by levels.] Description [] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NetworkPrintLevel( FILE * pFile, Ntk_Network_t * pNet, int nNodes, int fFromOutputs ){ Ntk_Node_t ** ppNodes; Ntk_Node_t * pNode; int nLevels, Pos, i; int LevelStart, LevelStop; char * pName; if ( nNodes == 0 ) nLevels = Ntk_NetworkLevelize( pNet, fFromOutputs ); else { // collect the nodes into the array i = 0; ppNodes = ALLOC( Ntk_Node_t *, nNodes ); Ntk_NetworkForEachNodeSpecial( pNet, pNode ) ppNodes[i++] = pNode; // levelize starting from the nodes nLevels = Ntk_NetworkLevelizeNodes( ppNodes, nNodes, fFromOutputs ); FREE( ppNodes ); } // print nodes by level LevelStart = fFromOutputs? 0: 1; LevelStop = fFromOutputs? nLevels + 1: nLevels + 2; for ( i = LevelStart; i < LevelStop; i++ ) { if ( Ntk_NetworkReadOrderByLevel( pNet, i ) == NULL ) continue; fprintf( pFile, " %2d: ", i + fFromOutputs - 1 ); Pos = 8; Ntk_NetworkForEachNodeSpecialByLevel( pNet, i, pNode ) { if ( Ntk_NodeIsCo(pNode) ) continue; pName = Ntk_NodeGetNamePrintableInt( pNode ); if ( Pos + strlen(pName) > 78 ) { fprintf( pFile, "\n" ); fprintf( pFile, " " ); Pos = 8; } fprintf( pFile, "%s ", pName ); Pos += strlen(pName) + 1; } fprintf( pFile, "\n" ); }}/**Function************************************************************* Synopsis [Prints the list of ND nodes of the current network.] Description [] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NetworkPrintNd( FILE * pFile, Ntk_Network_t * pNet ){ Mvc_Data_t * pData; Cvr_Cover_t * pCvr; Ntk_Node_t * pNode; int nNodes, Default; Mvc_Cover_t ** ppIsets, * pMvcTemp; // count the ND nodes nNodes = 0; Ntk_NetworkStartSpecial( pNet ); Ntk_NetworkForEachNode( pNet, pNode ) { pCvr = Ntk_NodeReadFuncCvr( pNode ); if ( pCvr ) { // get any cover of pCvrFshift Default = Cvr_CoverReadDefault(pCvr); ppIsets = Cvr_CoverReadIsets(pCvr); pMvcTemp = (Default != 0)? ppIsets[0]: ppIsets[1]; // get the MV data for the new man pData = Mvc_CoverDataAlloc( Ntk_NodeReadFuncVm(pNode), pMvcTemp ); if ( Cvr_CoverIsND( pData, pCvr ) ) { Ntk_NetworkAddToSpecial( pNode ); nNodes++; } Mvc_CoverDataFree( pData, pMvcTemp ); } else { if ( Mvr_RelationIsND( Ntk_NodeGetFuncMvr(pNode) ) ) { Ntk_NetworkAddToSpecial( pNode ); nNodes++; } } } Ntk_NetworkStopSpecial( pNet ); if ( nNodes == 0 ) fprintf( pFile, "There are no ND nodes in this network.\n" ); else { fprintf( pFile, "There are %d ND nodes in this network:\n", nNodes ); Ntk_NetworkForEachNodeSpecial( pNet, pNode ) fprintf( pFile, " %s", Ntk_NodeGetNamePrintable(pNode) ); fprintf( pFile, "\n" ); } Ntk_NetworkResetSpecial( pNet );}/**Function************************************************************* Synopsis [Prints the node MV relation as K-map.] Description [] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NodePrintMvr( FILE * pFile, Ntk_Node_t * pNode ){ Ntk_Pin_t * pPin; Ntk_Node_t * pFanin; int nFanins; char ** pInputNames; int i; if ( pNode->Type != MV_NODE_INT ) return; // get the input variable names nFanins = Ntk_NodeReadFaninNum(pNode); pInputNames = ALLOC( char *, nFanins + 1 ); Ntk_NodeForEachFaninWithIndex( pNode, pPin, pFanin, i ) pInputNames[i] = util_strsav( Ntk_NodeGetNamePrintableInt( pFanin ) ); pInputNames[nFanins] = util_strsav( Ntk_NodeGetNamePrintableInt( pNode ) ); // print the K-map Mvr_RelationPrintKmap( pFile, Ntk_NodeGetFuncMvr(pNode), pInputNames ); for ( i = 0; i <= nFanins; i++ ) FREE( pInputNames[i] ); FREE( pInputNames );}/**Function************************************************************* Synopsis [Prints the node MV relation as K-map.] Description [] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NodePrintFlex( FILE * pFile, Ntk_Node_t * pNode, Mvr_Relation_t * pFlex ){ Ntk_Pin_t * pPin; Ntk_Node_t * pFanin; int nFanins; char ** pInputNames; int i; if ( pNode->Type != MV_NODE_INT ) return; // get the input variable names nFanins = Ntk_NodeReadFaninNum(pNode); pInputNames = ALLOC( char *, nFanins + 1 ); Ntk_NodeForEachFaninWithIndex( pNode, pPin, pFanin, i ) pInputNames[i] = util_strsav( Ntk_NodeGetNamePrintableInt( pFanin ) ); pInputNames[nFanins] = util_strsav( Ntk_NodeGetNamePrintableInt( pNode ) ); // print the K-map Mvr_RelationPrintKmap( pFile, pFlex, pInputNames ); for ( i = 0; i <= nFanins; i++ ) FREE( pInputNames[i] ); FREE( pInputNames );}/**Function************************************************************* Synopsis [Prints the flexibility of the node as K-map.] Description [The flexibility is expressed using the same MV relation parameters as the node's MV relation.] SideEffects [] SeeAlso []***********************************************************************/void Ntk_NodePrintMvrFlex( FILE * pFile, Ntk_Node_t * pNode, DdNode * bFlex ){ Mvr_Relation_t * pMvr; DdNode * bRel; // get the relation pMvr = Ntk_NodeReadFuncMvr( pNode );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -