ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
sswLcorr.c
Go to the documentation of this file.
1
20
21#include "sswInt.h"
22//#include "bar.h"
23
25
26
30
34
47{
48 Aig_Obj_t * pObj, * pObjFraig;
49 unsigned * pInfo;
50 int i;
51 // transfer simulation information
52 Aig_ManForEachCi( p->pAig, pObj, i )
53 {
54 pObjFraig = Ssw_ObjFrame( p, pObj, 0 );
55 if ( pObjFraig == Aig_ManConst0(p->pFrames) )
56 {
57 Ssw_SmlObjAssignConst( p->pSml, pObj, 0, 0 );
58 continue;
59 }
60 assert( !Aig_IsComplement(pObjFraig) );
61 assert( Aig_ObjIsCi(pObjFraig) );
62 pInfo = (unsigned *)Vec_PtrEntry( p->vSimInfo, Aig_ObjCioId(pObjFraig) );
63 Ssw_SmlObjSetWord( p->pSml, pObj, pInfo[0], 0, 0 );
64 }
65}
66
79{
80 int RetValue1, RetValue2;
81 abctime clk = Abc_Clock();
82 // transfer PI simulation information from storage
84 // simulate internal nodes
86 // check equivalence classes
87 RetValue1 = Ssw_ClassesRefineConst1( p->ppClasses, 1 );
88 RetValue2 = Ssw_ClassesRefine( p->ppClasses, 1 );
89 // prepare simulation info for the next round
90 Vec_PtrCleanSimInfo( p->vSimInfo, 0, 1 );
91 p->nPatterns = 0;
92 p->nSimRounds++;
93p->timeSimSat += Abc_Clock() - clk;
94 return RetValue1 > 0 || RetValue2 > 0;
95}
96
109{
110 Aig_Obj_t * pObj;
111 unsigned * pInfo;
112 int i, nVarNum, Value;
113 Vec_PtrForEachEntry( Aig_Obj_t *, p->pMSat->vUsedPis, pObj, i )
114 {
115 nVarNum = Ssw_ObjSatNum( p->pMSat, pObj );
116 assert( nVarNum > 0 );
117 Value = sat_solver_var_value( p->pMSat->pSat, nVarNum );
118 if ( Value == 0 )
119 continue;
120 pInfo = (unsigned *)Vec_PtrEntry( p->vSimInfo, Aig_ObjCioId(pObj) );
121 Abc_InfoSetBit( pInfo, p->nPatterns );
122 }
123}
124
137{
138 Aig_Obj_t * pObjNew;
139 assert( !Aig_IsComplement(pObj) );
140 if ( Ssw_ObjFrame( p, pObj, 0 ) )
141 return;
142 assert( Aig_ObjIsNode(pObj) );
143 Ssw_ManBuildCone_rec( p, Aig_ObjFanin0(pObj) );
144 Ssw_ManBuildCone_rec( p, Aig_ObjFanin1(pObj) );
145 pObjNew = Aig_And( p->pFrames, Ssw_ObjChild0Fra(p, pObj, 0), Ssw_ObjChild1Fra(p, pObj, 0) );
146 Ssw_ObjSetFrame( p, pObj, 0, pObjNew );
147}
148
161{
162 Aig_Obj_t * pObjFraig, * pObjReprFraig, * pObjLi;
163 int RetValue;
164 abctime clk;
165 assert( Aig_ObjIsCi(pObj) );
166 assert( Aig_ObjIsCi(pObjRepr) || Aig_ObjIsConst1(pObjRepr) );
167 // check if it makes sense to skip some calls
168 if ( p->nCallsCount > 100 && p->nCallsUnsat < p->nCallsSat )
169 {
170 if ( ++p->nCallsDelta < 0 )
171 return;
172 }
173 p->nCallsDelta = 0;
174clk = Abc_Clock();
175 // get the fraiged node
176 pObjLi = Saig_ObjLoToLi( p->pAig, pObj );
177 Ssw_ManBuildCone_rec( p, Aig_ObjFanin0(pObjLi) );
178 pObjFraig = Ssw_ObjChild0Fra( p, pObjLi, 0 );
179 // get the fraiged representative
180 if ( Aig_ObjIsCi(pObjRepr) )
181 {
182 pObjLi = Saig_ObjLoToLi( p->pAig, pObjRepr );
183 Ssw_ManBuildCone_rec( p, Aig_ObjFanin0(pObjLi) );
184 pObjReprFraig = Ssw_ObjChild0Fra( p, pObjLi, 0 );
185 }
186 else
187 pObjReprFraig = Ssw_ObjFrame( p, pObjRepr, 0 );
188p->timeReduce += Abc_Clock() - clk;
189 // if the fraiged nodes are the same, return
190 if ( Aig_Regular(pObjFraig) == Aig_Regular(pObjReprFraig) )
191 return;
192 p->nRecycleCalls++;
193 p->nCallsCount++;
194
195 // check equivalence of the two nodes
196 if ( (pObj->fPhase == pObjRepr->fPhase) != (Aig_ObjPhaseReal(pObjFraig) == Aig_ObjPhaseReal(pObjReprFraig)) )
197 {
198 p->nPatterns++;
199 p->nStrangers++;
200 p->fRefined = 1;
201 }
202 else
203 {
204 RetValue = Ssw_NodesAreEquiv( p, Aig_Regular(pObjReprFraig), Aig_Regular(pObjFraig) );
205 if ( RetValue == 1 ) // proved equivalence
206 {
207 p->nCallsUnsat++;
208 return;
209 }
210 if ( RetValue == -1 ) // timed out
211 {
212 Ssw_ClassesRemoveNode( p->ppClasses, pObj );
213 p->nCallsUnsat++;
214 p->fRefined = 1;
215 return;
216 }
217 else // disproved equivalence
218 {
219 Ssw_SmlAddPattern( p, pObjRepr, pObj );
220 p->nPatterns++;
221 p->nCallsSat++;
222 p->fRefined = 1;
223 }
224 }
225}
226
239{
240// Bar_Progress_t * pProgress = NULL;
241 Vec_Ptr_t * vClass;
242 Aig_Obj_t * pObj, * pRepr, * pTemp;
243 int i, k;
244
245 // start the timeframe
246 p->pFrames = Aig_ManStart( Aig_ManObjNumMax(p->pAig) );
247 // map constants and PIs
248 Ssw_ObjSetFrame( p, Aig_ManConst1(p->pAig), 0, Aig_ManConst1(p->pFrames) );
249 Saig_ManForEachPi( p->pAig, pObj, i )
250 Ssw_ObjSetFrame( p, pObj, 0, Aig_ObjCreateCi(p->pFrames) );
251
252 // implement equivalence classes
253 Saig_ManForEachLo( p->pAig, pObj, i )
254 {
255 pRepr = Aig_ObjRepr( p->pAig, pObj );
256 if ( pRepr == NULL )
257 {
258 pTemp = Aig_ObjCreateCi(p->pFrames);
259 pTemp->pData = pObj;
260 }
261 else
262 pTemp = Aig_NotCond( Ssw_ObjFrame(p, pRepr, 0), pRepr->fPhase ^ pObj->fPhase );
263 Ssw_ObjSetFrame( p, pObj, 0, pTemp );
264 }
265 Aig_ManSetCioIds( p->pFrames );
266
267 // prepare simulation info
268 assert( p->vSimInfo == NULL );
269 p->vSimInfo = Vec_PtrAllocSimInfo( Aig_ManCiNum(p->pFrames), 1 );
270 Vec_PtrCleanSimInfo( p->vSimInfo, 0, 1 );
271
272 // go through the registers
273// if ( p->pPars->fVerbose )
274// pProgress = Bar_ProgressStart( stdout, Aig_ManRegNum(p->pAig) );
275 vClass = Vec_PtrAlloc( 100 );
276 p->fRefined = 0;
277 p->nCallsCount = p->nCallsSat = p->nCallsUnsat = 0;
278 Saig_ManForEachLo( p->pAig, pObj, i )
279 {
280// if ( p->pPars->fVerbose )
281// Bar_ProgressUpdate( pProgress, i, NULL );
282 // consider the case of constant candidate
283 if ( Ssw_ObjIsConst1Cand( p->pAig, pObj ) )
284 Ssw_ManSweepLatchOne( p, Aig_ManConst1(p->pAig), pObj );
285 else
286 {
287 // consider the case of equivalence class
288 Ssw_ClassesCollectClass( p->ppClasses, pObj, vClass );
289 if ( Vec_PtrSize(vClass) == 0 )
290 continue;
291 // try to prove equivalences in this class
292 Vec_PtrForEachEntry( Aig_Obj_t *, vClass, pTemp, k )
293 if ( Aig_ObjRepr(p->pAig, pTemp) == pObj )
294 {
295 Ssw_ManSweepLatchOne( p, pObj, pTemp );
296 if ( p->nPatterns == 32 )
297 break;
298 }
299 }
300 // resimulate
301 if ( p->nPatterns == 32 )
303 // attempt recycling the SAT solver
304 if ( p->pPars->nSatVarMax &&
305 p->pMSat->nSatVars > p->pPars->nSatVarMax &&
306 p->nRecycleCalls > p->pPars->nRecycleCalls )
307 {
308 p->nVarsMax = Abc_MaxInt( p->nVarsMax, p->pMSat->nSatVars );
309 p->nCallsMax = Abc_MaxInt( p->nCallsMax, p->pMSat->nSolverCalls );
310 Ssw_SatStop( p->pMSat );
311 p->pMSat = Ssw_SatStart( 0 );
312 p->nRecycles++;
313 p->nRecycleCalls = 0;
314 }
315 }
316// ABC_PRT( "reduce", p->timeReduce );
317// Aig_TableProfile( p->pFrames );
318// Abc_Print( 1, "And gates = %d\n", Aig_ManNodeNum(p->pFrames) );
319 // resimulate
320 if ( p->nPatterns > 0 )
322 // cleanup
323 Vec_PtrFree( vClass );
324// if ( p->pPars->fVerbose )
325// Bar_ProgressStop( pProgress );
326
327 // cleanup
328// Ssw_ClassesCheck( p->ppClasses );
329 return p->fRefined;
330}
331
335
336
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Aig_ManSetCioIds(Aig_Man_t *p)
Definition aigUtil.c:978
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition aig.h:393
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition aigOper.c:104
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition aigMan.c:47
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigObj.c:45
Cube * p
Definition exorList.c:222
#define Saig_ManForEachLo(p, pObj, i)
Definition saig.h:96
#define Saig_ManForEachPi(p, pObj, i)
Definition saig.h:91
int Ssw_ClassesRefineConst1(Ssw_Cla_t *p, int fRecursive)
Definition sswClass.c:1119
void Ssw_ClassesCollectClass(Ssw_Cla_t *p, Aig_Obj_t *pRepr, Vec_Ptr_t *vClass)
Definition sswClass.c:328
void Ssw_ClassesRemoveNode(Ssw_Cla_t *p, Aig_Obj_t *pObj)
Definition sswClass.c:448
int Ssw_ClassesRefine(Ssw_Cla_t *p, int fRecursive)
Definition sswClass.c:1034
void Ssw_SatStop(Ssw_Sat_t *p)
Definition sswCnf.c:81
ABC_NAMESPACE_IMPL_START Ssw_Sat_t * Ssw_SatStart(int fPolarFlip)
DECLARATIONS ///.
Definition sswCnf.c:45
typedefABC_NAMESPACE_HEADER_START struct Ssw_Man_t_ Ssw_Man_t
INCLUDES ///.
Definition sswInt.h:47
void Ssw_SmlSimulateOneFrame(Ssw_Sml_t *p)
Definition sswSim.c:1117
void Ssw_SmlObjSetWord(Ssw_Sml_t *p, Aig_Obj_t *pObj, unsigned Word, int iWord, int iFrame)
Definition sswSim.c:603
int Ssw_NodesAreEquiv(Ssw_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew)
DECLARATIONS ///.
Definition sswSat.c:45
void Ssw_SmlObjAssignConst(Ssw_Sml_t *p, Aig_Obj_t *pObj, int fConst1, int iFrame)
Definition sswSim.c:560
ABC_NAMESPACE_IMPL_START void Ssw_ManSweepTransfer(Ssw_Man_t *p)
DECLARATIONS ///.
Definition sswLcorr.c:46
int Ssw_ManSweepLatch(Ssw_Man_t *p)
Definition sswLcorr.c:238
void Ssw_ManBuildCone_rec(Ssw_Man_t *p, Aig_Obj_t *pObj)
Definition sswLcorr.c:136
int Ssw_ManSweepResimulate(Ssw_Man_t *p)
Definition sswLcorr.c:78
void Ssw_ManSweepLatchOne(Ssw_Man_t *p, Aig_Obj_t *pObjRepr, Aig_Obj_t *pObj)
Definition sswLcorr.c:160
void Ssw_SmlAddPattern(Ssw_Man_t *p, Aig_Obj_t *pRepr, Aig_Obj_t *pCand)
Definition sswLcorr.c:108
void * pData
Definition aig.h:87
unsigned int fPhase
Definition aig.h:78
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55