00001
00021 #include "abc.h"
00022 #include "sim.h"
00023
00027
00031
00043 int Sim_ComputeTwoVarSymms( Abc_Ntk_t * pNtk, int fVerbose )
00044 {
00045 Sym_Man_t * p;
00046 Vec_Ptr_t * vResult;
00047 int Result;
00048 int i, clk, clkTotal = clock();
00049
00050 srand( 0xABC );
00051
00052
00053 p = Sym_ManStart( pNtk, fVerbose );
00054 p->nPairsTotal = p->nPairsRem = Sim_UtilCountAllPairs( p->vSuppFun, p->nSimWords, p->vPairsTotal );
00055 if ( fVerbose )
00056 printf( "Total = %8d. Sym = %8d. NonSym = %8d. Remaining = %8d.\n",
00057 p->nPairsTotal, p->nPairsSymm, p->nPairsNonSymm, p->nPairsRem );
00058
00059
00060 clk = clock();
00061 Sim_SymmsStructCompute( pNtk, p->vMatrSymms, p->vSuppFun );
00062 p->timeStruct = clock() - clk;
00063
00064 Sim_UtilCountPairsAll( p );
00065 p->nPairsSymmStr = p->nPairsSymm;
00066 if ( fVerbose )
00067 printf( "Total = %8d. Sym = %8d. NonSym = %8d. Remaining = %8d.\n",
00068 p->nPairsTotal, p->nPairsSymm, p->nPairsNonSymm, p->nPairsRem );
00069
00070
00071 for ( i = 1; i <= 1000; i++ )
00072 {
00073
00074 Sim_UtilSetRandom( p->uPatRand, p->nSimWords );
00075 Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
00076 if ( i % 50 != 0 )
00077 continue;
00078
00079 assert( Sim_UtilMatrsAreDisjoint( p ) );
00080
00081 Sim_UtilCountPairsAll( p );
00082 if ( i % 500 != 0 )
00083 continue;
00084 if ( fVerbose )
00085 printf( "Total = %8d. Sym = %8d. NonSym = %8d. Remaining = %8d.\n",
00086 p->nPairsTotal, p->nPairsSymm, p->nPairsNonSymm, p->nPairsRem );
00087 }
00088
00089
00090 for ( i = 1; Sim_SymmsGetPatternUsingSat( p, p->uPatRand ); i++ )
00091 {
00092
00093 Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
00094 Sim_XorBit( p->uPatRand, p->iVar1 );
00095 Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
00096 Sim_XorBit( p->uPatRand, p->iVar2 );
00097 Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
00098 Sim_XorBit( p->uPatRand, p->iVar1 );
00099 Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
00100 Sim_XorBit( p->uPatRand, p->iVar2 );
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 if ( i % 10 != 0 )
00111 continue;
00112
00113 assert( Sim_UtilMatrsAreDisjoint( p ) );
00114
00115 Sim_UtilCountPairsAll( p );
00116 if ( i % 50 != 0 )
00117 continue;
00118 if ( fVerbose )
00119 printf( "Total = %8d. Sym = %8d. NonSym = %8d. Remaining = %8d.\n",
00120 p->nPairsTotal, p->nPairsSymm, p->nPairsNonSymm, p->nPairsRem );
00121 }
00122
00123
00124 Sim_UtilCountPairsAll( p );
00125 if ( fVerbose )
00126 printf( "Total = %8d. Sym = %8d. NonSym = %8d. Remaining = %8d.\n",
00127 p->nPairsTotal, p->nPairsSymm, p->nPairsNonSymm, p->nPairsRem );
00128
00129
00130 Result = p->nPairsSymm;
00131 vResult = p->vMatrSymms;
00132 p->timeTotal = clock() - clkTotal;
00133
00134 Sym_ManStop( p );
00135 return Result;
00136 }
00137
00141
00142