📄 mvrprint.c
字号:
// get var map (currently, not used) pVarMap = ALLOC( int, nInputs ); for ( i = 0; i < nInputs; i++ ) pVarMap[i] = i; //////////////////////////////////////////////////////////////////// // decide where the line will be bold and where it will be normal // the valuedness of the last var in the horizontal vars group if ( nVarsHor == 0 ) HoriInterval = 1; else HoriInterval = pVm->pValues[ pVarMap[nVarsHor-1] ]; for ( a = 0; a <= nCellsHor; a++ ) if ( a % HoriInterval == 0 ) // should be bold HoriLineType[a] = 1; else // should be normal HoriLineType[a] = 0; if ( nVarsVer == 0 ) VertInterval = 1; else { // the valuedness of the last var in the vertical vars group VertInterval = pVm->pValues[ pVarMap[nInputs-1] ]; for ( b = 0; b <= nCellsVer; b++ ) if ( b % VertInterval == 0 ) // should be bold VertLineType[b] = 1; else // should be normal VertLineType[b] = 0; } //////////////////////////////////////////////////////////////////// // print the title line fprintf( pFile, "MV Relation of Node <%s>.\n", pVarNames[nInputs] ); //////////////////////////////////////////////////////////////////// // print variable names// fprintf( pFile, "\n" ); for ( w = 0; w < nVarsVer; w++ ) fprintf( pFile, "%s ", pVarNames[ pVarMap[nVarsHor + w] ] ); fprintf( pFile, "\\ " ); for ( w = 0; w < nVarsHor; w++ ) fprintf( pFile, "%s ", pVarNames[ pVarMap[w] ] ); fprintf( pFile, "\n" ); //////////////////////////////////////////////////////////////////// // print horizontal digits if ( nVarsHor ) { Divisor = nCellsHor/pVm->pValues[ pVarMap[0] ]; DivisorPrev = -1; for ( d = 0; d < nVarsHor; d++ ) { for ( p = 0; p < nSkipSpaces+PartSkip; p++, printf(" ") ); for ( n = 0; n < nCellsHor; n++ ) { if ( DivisorPrev == -1 ) fprintf( pFile, "%d", n/Divisor ); else fprintf( pFile, "%d", (n%DivisorPrev)/Divisor ); for ( p = 0; p < IntervalSkip-1; p++, printf(" ") ); } DivisorPrev = Divisor; if ( d < nVarsHor-1 ) Divisor /= pVm->pValues[ pVarMap[1+d] ]; fprintf( pFile, "\n" ); } } //////////////////////////////////////////////////////////////////// // print the upper line for ( p = 0; p < nSkipSpaces; p++, printf(" ") ); fprintf( pFile, "%c", DOUBLE_TOP_LEFT ); for ( s = 0; s < nCellsHor; s++ ) { for ( p = 0; p < IntervalSkip-1; p++, fprintf( pFile, "%c", DOUBLE_HORIZONTAL ) ); if ( s != nCellsHor-1 ) if ( HoriLineType[s+1] ) fprintf( pFile, "%c", D_JOINS_D_HOR_BOT ); else fprintf( pFile, "%c", S_JOINS_D_HOR_BOT ); } fprintf( pFile, "%c", DOUBLE_TOP_RIGHT ); fprintf( pFile, "\n" ); //////////////////////////////////////////////////////////////////// // print the map pbCubes = Vmx_VarMapEncodeMap( dd, pMvr->pVmx ); bCubeInputs = Vmx_VarMapCharCubeInput( dd, pMvr->pVmx ); Cudd_Ref( bCubeInputs ); for ( v = 0; v < nCellsVer; v++ ) { if ( nVarsVer ) { // print horizontal digits VertProd = nCellsVer/pVm->pValues[ pVarMap[nVarsHor] ]; VertRemain = v; for ( n = 0; n < nVarsVer; n++ ) { VertVarValues[n] = VertRemain / VertProd; VertRemain = VertRemain % VertProd; fprintf( pFile, "%d", VertVarValues[n] ); if ( n < nVarsVer-1 ) VertProd /= pVm->pValues[ pVarMap[nVarsHor+n+1] ]; } } fprintf( pFile, " "); // find vertical cube bCubeVer = b1; Cudd_Ref( bCubeVer ); for ( n = 0; n < nVarsVer; n++ ) { iValue = pVm->pValuesFirst[ pVarMap[nVarsHor+n] ] + VertVarValues[n]; bCubeVer = Cudd_bddAnd( dd, bTemp = bCubeVer, pbCubes[iValue] ); Cudd_Ref( bCubeVer ); Cudd_RecursiveDeref( dd, bTemp ); } // print text line fprintf( pFile, "%c", DOUBLE_VERTICAL ); for ( h = 0; h < nCellsHor; h++ ) { if ( nVarsHor ) { Divisor = nCellsHor/pVm->pValues[ pVarMap[0] ]; DivisorPrev = -1; for ( d = 0; d < nVarsHor; d++ ) { if ( DivisorPrev == -1 ) HoriVarValues[d] = h/Divisor; else HoriVarValues[d] = (h%DivisorPrev)/Divisor; DivisorPrev = Divisor; if ( d < nVarsHor-1 ) Divisor /= pVm->pValues[ pVarMap[1+d] ]; } // find vertical cube bCubeHor = b1; Cudd_Ref( bCubeHor ); for ( n = 0; n < nVarsHor; n++ ) { iValue = pVm->pValuesFirst[ pVarMap[n] ] + HoriVarValues[n]; bCubeHor = Cudd_bddAnd( dd, bTemp = bCubeHor, pbCubes[iValue] ); Cudd_Ref( bCubeHor ); Cudd_RecursiveDeref( dd, bTemp ); } } else { bCubeHor = b1; Cudd_Ref( bCubeHor ); } bCube = Cudd_bddAnd( dd, bCubeHor, bCubeVer ); Cudd_Ref( bCube ); bValueSet = Cudd_bddAndAbstract( dd, pMvr->bRel, bCube, bCubeInputs ); Cudd_Ref( bValueSet ); Cudd_RecursiveDeref( dd, bCube ); Cudd_RecursiveDeref( dd, bCubeHor );//PRB( dd, bValueSet ); // go through all possible values of this set fprintf( pFile, " "); for ( i = 0; i < nOutputValues; i++ ) { iValue = pVm->pValuesFirst[nInputs] + i; if ( Cudd_bddLeq( dd, pbCubes[iValue], bValueSet ) ) fprintf( pFile, "%d", i % 10 ); else fprintf( pFile, "%c", '-' ); } Cudd_RecursiveDeref( dd, bValueSet ); fprintf( pFile, " "); if ( h != nCellsHor-1 ) if ( HoriLineType[h+1] ) fprintf( pFile, "%c", DOUBLE_VERTICAL ); else fprintf( pFile, "%c", SINGLE_VERTICAL ); } fprintf( pFile, "%c", DOUBLE_VERTICAL ); fprintf( pFile, "\n" ); Cudd_RecursiveDeref( dd, bCubeVer ); // print separator line if ( v != nCellsVer-1 ) { for ( p = 0; p < nSkipSpaces; p++, printf(" ") ); if ( VertLineType[v+1] ) { fprintf( pFile, "%c", D_JOINS_D_VER_RIGHT ); for ( s = 0; s < nCellsHor; s++ ) { for ( p = 0; p < IntervalSkip-1; p++, fprintf( pFile, "%c", DOUBLE_HORIZONTAL ) ); if ( s != nCellsHor-1 ) if ( HoriLineType[s+1] ) fprintf( pFile, "%c", DOUBLES_CROSS ); else fprintf( pFile, "%c", S_VER_CROSS_D_HOR ); } fprintf( pFile, "%c", D_JOINS_D_VER_LEFT ); } else { fprintf( pFile, "%c", S_JOINS_D_VER_RIGHT ); for ( s = 0; s < nCellsHor; s++ ) { for ( p = 0; p < IntervalSkip-1; p++, fprintf( pFile, "%c", SINGLE_HORIZONTAL ) ); if ( s != nCellsHor-1 ) if ( HoriLineType[s+1] ) fprintf( pFile, "%c", S_HOR_CROSS_D_VER ); else fprintf( pFile, "%c", SINGLES_CROSS ); } fprintf( pFile, "%c", S_JOINS_D_VER_LEFT ); } fprintf( pFile, "\n" ); } } Vmx_VarMapEncodeDeref( dd, pMvr->pVmx, pbCubes ); Cudd_RecursiveDeref( dd, bCubeInputs ); //////////////////////////////////////////////////////////////////// // print the lower line for ( p = 0; p < nSkipSpaces; p++, printf(" ") ); fprintf( pFile, "%c", DOUBLE_BOT_LEFT ); for ( s = 0; s < nCellsHor; s++ ) { for ( p = 0; p < IntervalSkip-1; p++, fprintf( pFile, "%c", DOUBLE_HORIZONTAL ) ); if ( s != nCellsHor-1 ) if ( HoriLineType[s+1] ) fprintf( pFile, "%c", D_JOINS_D_HOR_TOP ); else fprintf( pFile, "%c", S_JOINS_D_HOR_TOP ); } fprintf( pFile, "%c", DOUBLE_BOT_RIGHT ); fprintf( pFile, "\n" ); //////////////////////////////////////////////////////////////////// // deref FREE( pVarMap ); if ( !fUserNames ) { for ( i = 0; i <= pVm->nVarsIn; i++ ) FREE( pVarNames[i] ); FREE( pVarNames ); }}/**Function************************************************************* Synopsis [Create a good partition of MV variables.] Description [] SideEffects [] SeeAlso []***********************************************************************/int Mvr_RelationFindPartition( Mvr_Relation_t * pMvr ){ Vm_VarMap_t * pVm; int nValueProdHor; int nValueProd; int nOutputValues; int HorLimit; int i; // the number of output values nOutputValues = Vm_VarMapReadValuesOutput( pMvr->pVmx->pVm ); // the limit on the number of horizontal cells HorLimit = 80 / (nOutputValues + 3) - 1; pVm = Mvr_RelationReadVm( pMvr ); assert( pVm->nVarsIn >= 0 ); if ( pVm->nVarsIn == 0 ) return 0; if ( pVm->nVarsIn < 3 ) return 1; // get the product of all values nValueProd = 1; for ( i = 0; i < pVm->nVarsIn; i++ ) nValueProd *= pVm->pValues[i]; nValueProdHor = 1; for ( i = 0; i < pVm->nVarsIn; i++ ) { nValueProdHor *= pVm->pValues[i]; if ( nValueProdHor > HorLimit ) return i; if ( nValueProdHor > 2*(nValueProd / nValueProdHor) ) return i; if ( i == pVm->nVarsIn - 1 ) return i; } return -1;}/////////////////////////////////////////////////////////////////////////// END OF FILE ///////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -