FUNCTION DEFINITIONS ///.
Description [Variables p go first, followed by variable x. The number of parameters is nPars. The miter is in pNtk. The miter expresses EQUALITY of the implementation and spec.]
65{
66 Abc_Ntk_t * pNtkVer, * pNtkSyn, * pNtkSyn2, * pNtkTemp;
68 abctime clkTotal = Abc_Clock(), clkS, clkV;
69 int nIters, nInputs, RetValue, fFound = 0;
70
71 assert( Abc_NtkIsStrash(pNtk) );
72 assert( Abc_NtkIsComb(pNtk) );
73 assert( Abc_NtkPoNum(pNtk) == 1 );
74 assert( nPars > 0 && nPars < Abc_NtkPiNum(pNtk) );
75
76 nInputs = Abc_NtkPiNum(pNtk) - nPars;
77
78 if ( fDumpCnf )
79 {
80
81
85 Vec_Int_t * vVarMap, * vForAlls, * vExists;
87 char * pFileName;
88 int i, Entry;
89
90 vVarMap = Vec_IntStart( pCnf->
nVars );
92 if ( i < nPars )
93 Vec_IntWriteEntry( vVarMap, pCnf->
pVarNums[Aig_ObjId(pObj)], 1 );
94
95 vForAlls = Vec_IntAlloc( nPars );
96 vExists = Vec_IntAlloc( Abc_NtkPiNum(pNtk) - nPars );
98 if ( Entry )
99 Vec_IntPush( vForAlls, i );
100 else
101 Vec_IntPush( vExists, i );
102
107 Vec_IntFree( vForAlls );
108 Vec_IntFree( vExists );
109 Vec_IntFree( vVarMap );
110 printf( "The 2QBF formula was written into file \"%s\".\n", pFileName );
111 return;
112 }
113
114
115 vPiValues = Vec_IntStart( Abc_NtkPiNum(pNtk) );
116
117
118 {
119 int i;
120 srand( time(NULL) );
121 for ( i = nPars; i < Abc_NtkPiNum(pNtk); i++ )
122 Vec_IntWriteEntry( vPiValues, i, rand() & 1 );
123 }
124
125 Abc_NtkVectorClearPars( vPiValues, nPars );
127 if ( fVerbose )
128 {
129 printf( "Iter %2d : ", 0 );
130 printf( "AIG = %6d ", Abc_NtkNodeNum(pNtkSyn) );
131 Abc_NtkVectorPrintVars( pNtk, vPiValues, nPars );
132 printf( "\n" );
133 }
134
135
136 for ( nIters = 0; nIters < nItersMax; nIters++ )
137 {
138
139clkS = Abc_Clock();
140
141 RetValue =
Abc_NtkDSat( pNtkSyn, (ABC_INT64_T)0, (ABC_INT64_T)0, 0, 0, 0, 1, 0, 0, 0 );
142clkS = Abc_Clock() - clkS;
143 if ( RetValue == 0 )
144 Abc_NtkModelToVector( pNtkSyn, vPiValues );
145 if ( RetValue == 1 )
146 {
147 break;
148 }
149 if ( RetValue == -1 )
150 {
151 printf( "Synthesis timed out.\n" );
152 break;
153 }
154
155
156
157 Abc_NtkVectorClearVars( pNtk, vPiValues, nPars );
159
160 Abc_ObjXorFaninC( Abc_NtkPo(pNtkVer,0), 0 );
161
162
163clkV = Abc_Clock();
165clkV = Abc_Clock() - clkV;
166 if ( RetValue == 0 )
167 Abc_NtkModelToVector( pNtkVer, vPiValues );
169 if ( RetValue == 1 )
170 {
171 fFound = 1;
172 break;
173 }
174 if ( RetValue == -1 )
175 {
176 printf( "Verification timed out.\n" );
177 break;
178 }
179
180
181
182 Abc_NtkVectorClearPars( vPiValues, nPars );
184
188
189 if ( fVerbose )
190 {
191 printf( "Iter %2d : ", nIters+1 );
192 printf( "AIG = %6d ", Abc_NtkNodeNum(pNtkSyn) );
193 Abc_NtkVectorPrintVars( pNtk, vPiValues, nPars );
194 printf( " " );
196
197 }
198 }
200
201 if ( fFound )
202 {
203 int nZeros = Vec_IntCountZero( vPiValues );
204 printf( "Parameters: " );
205 Abc_NtkVectorPrintPars( vPiValues, nPars );
206 printf( " Statistics: 0=%d 1=%d\n", nZeros, nPars - nZeros );
207 printf( "Solved after %d iterations. ", nIters );
208 }
209 else if ( nIters == nItersMax )
210 printf( "Quit after %d iterations. ", nItersMax );
211 else
212 printf( "Implementation does not exist. " );
213 ABC_PRT(
"Total runtime", Abc_Clock() - clkTotal );
214 Vec_IntFree( vPiValues );
215}
int Abc_NtkDSat(Abc_Ntk_t *pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int nLearnedStart, int nLearnedDelta, int nLearnedPerce, int fAlignPol, int fAndOuts, int fNewSolver, int fVerbose)
ABC_DLL Abc_Ntk_t * Abc_NtkMiterCofactor(Abc_Ntk_t *pNtk, Vec_Int_t *vPiValues)
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL int Abc_NtkMiterSat(Abc_Ntk_t *pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fVerbose, ABC_INT64_T *pNumConfs, ABC_INT64_T *pNumInspects)
FUNCTION DEFINITIONS ///.
ABC_DLL Abc_Ntk_t * Abc_NtkMiterAnd(Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int fOr, int fCompl2)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
struct Aig_Obj_t_ Aig_Obj_t
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Cnf_Dat_t * Cnf_Derive(Aig_Man_t *pAig, int nOutputs)
struct Cnf_Dat_t_ Cnf_Dat_t
void Cnf_DataFree(Cnf_Dat_t *p)
void Cnf_DataWriteIntoFile(Cnf_Dat_t *p, char *pFileName, int fReadable, Vec_Int_t *vForAlls, Vec_Int_t *vExists)
Aig_Man_t * Abc_NtkToDar(Abc_Ntk_t *pNtk, int fExors, int fRegisters)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.