ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
bmcCexDepth.c
Go to the documentation of this file.
1
20
21#include "bmc.h"
22
24
25
29
30extern Abc_Cex_t * Bmc_CexInnerStates( Gia_Man_t * p, Abc_Cex_t * pCex, Abc_Cex_t ** ppCexImpl, int fVerbose );
31extern Abc_Cex_t * Bmc_CexCareBits( Gia_Man_t * p, Abc_Cex_t * pCexState, Abc_Cex_t * pCexImpl, Abc_Cex_t * pCexEss, int fFindAll, int fVerbose );
32extern int Bmc_CexVerify( Gia_Man_t * p, Abc_Cex_t * pCex, Abc_Cex_t * pCexCare );
33
37
50{
51 Gia_Man_t * pNew, * pOne;
52 Gia_Obj_t * pObj, * pObjRo;
53 int i, k;
54 pNew = Gia_ManStart( Gia_ManObjNum(p) );
55 pNew->pName = Abc_UtilStrsav( p->pName );
56 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
57 Gia_ManHashAlloc( pNew );
58 Gia_ManConst0(p)->Value = 0;
59 for ( k = 0; k < nFrames; k++ )
60 Gia_ManForEachPi( p, pObj, i )
61 Gia_ManAppendCi( pNew );
62 Gia_ManForEachRo( p, pObj, i )
63 pObj->Value = Gia_ManAppendCi( pNew );
64 for ( k = 0; k < nFrames; k++ )
65 {
66 Gia_ManForEachPi( p, pObj, i )
67 pObj->Value = Gia_ManCiLit( pNew, (nFrames - 1 - k) * Gia_ManPiNum(p) + i );
68 Gia_ManForEachAnd( p, pObj, i )
69 pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
70 Gia_ManForEachRi( p, pObj, i )
71 pObj->Value = Gia_ObjFanin0Copy(pObj);
72 Gia_ManForEachRiRo( p, pObj, pObjRo, i )
73 pObjRo->Value = pObj->Value;
74 }
75 pObj = Gia_ManPo( p, 0 );
76 pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
77 Gia_ManHashStop( pNew );
78 pNew = Gia_ManCleanup( pOne = pNew );
79 Gia_ManStop( pOne );
80 return pNew;
81}
82
95{
96 Gia_Man_t * pNew, * pTemp;
97 int i, Limit = nFrames * Gia_ManPiNum(p);
98 pNew = Bmc_CexTargetEnlarge( p, nFrames );
99 for ( i = 0; i < Limit; i++ )
100 {
101 printf( "%3d : ", i );
102 if ( i % Gia_ManPiNum(p) == 0 )
103 Gia_ManPrintStats( pNew, NULL );
104 pNew = Gia_ManDupExist( pTemp = pNew, i );
105 Gia_ManStop( pTemp );
106 }
107 Gia_ManPrintStats( pNew, NULL );
108 pNew = Gia_ManDupLastPis( pTemp = pNew, Gia_ManRegNum(p) );
109 Gia_ManStop( pTemp );
110 Gia_ManPrintStats( pNew, NULL );
111 pTemp = Gia_ManDupAppendCones( p, &pNew, 1, 1 );
112 Gia_ManStop( pNew );
113 Gia_AigerWrite( pTemp, "miter3.aig", 0, 0, 0 );
114 return pTemp;
115}
116
129{
130 Gia_Man_t * pNew, * pTemp;
131 Gia_Obj_t * pObj, * pObjRo, * pObjRi;
132 int fCompl0, fCompl1;
133 int i, k, iBit;
134 assert( pCex->nRegs == 0 );
135 assert( pCex->nPis == Gia_ManCiNum(p) );
136 assert( fStart <= pCex->iFrame );
137 // start the manager
138 pNew = Gia_ManStart( 1000 );
139 pNew->pName = Abc_UtilStrsav( "unate" );
140 // set const0
141 Gia_ManConst0(p)->fMark0 = 0; // value
142 Gia_ManConst0(p)->fMark1 = 1; // care
143 Gia_ManConst0(p)->Value = ~0;
144 // set init state
145 Gia_ManForEachRi( p, pObj, k )
146 {
147 pObj->fMark0 = Abc_InfoHasBit( pCex->pData, pCex->nRegs + fStart * Gia_ManCiNum(p) + Gia_ManPiNum(p) + k );
148 pObj->fMark1 = 0;
149 pObj->Value = Abc_LitNotCond( Gia_ManAppendCi(pNew), !pObj->fMark0 );
150 }
151 Gia_ManHashAlloc( pNew );
152 iBit = pCex->nRegs + fStart * Gia_ManCiNum(p);
153 for ( i = fStart; i <= pCex->iFrame; i++ )
154 {
155 // primary inputs
156 Gia_ManForEachPi( p, pObj, k )
157 {
158 pObj->fMark0 = Abc_InfoHasBit( pCex->pData, iBit++ );
159 pObj->fMark1 = 1;
160 pObj->Value = ~0;
161 }
162 iBit += Gia_ManRegNum(p);
163 // transfer
164 Gia_ManForEachRiRo( p, pObjRi, pObjRo, k )
165 {
166 pObjRo->fMark0 = pObjRi->fMark0;
167 pObjRo->fMark1 = pObjRi->fMark1;
168 pObjRo->Value = pObjRi->Value;
169 }
170 // internal nodes
171 Gia_ManForEachAnd( p, pObj, k )
172 {
173 fCompl0 = Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj);
174 fCompl1 = Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj);
175 pObj->fMark0 = fCompl0 & fCompl1;
176 if ( pObj->fMark0 )
177 pObj->fMark1 = Gia_ObjFanin0(pObj)->fMark1 & Gia_ObjFanin1(pObj)->fMark1;
178 else if ( !fCompl0 && !fCompl1 )
179 pObj->fMark1 = Gia_ObjFanin0(pObj)->fMark1 | Gia_ObjFanin1(pObj)->fMark1;
180 else if ( !fCompl0 )
181 pObj->fMark1 = Gia_ObjFanin0(pObj)->fMark1;
182 else if ( !fCompl1 )
183 pObj->fMark1 = Gia_ObjFanin1(pObj)->fMark1;
184 else assert( 0 );
185 pObj->Value = ~0;
186 if ( pObj->fMark1 )
187 continue;
188 if ( pObj->fMark0 )
189 pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0(pObj)->Value, Gia_ObjFanin1(pObj)->Value );
190 else if ( !fCompl0 && !fCompl1 )
191 pObj->Value = Gia_ManHashOr( pNew, Gia_ObjFanin0(pObj)->Value, Gia_ObjFanin1(pObj)->Value );
192 else if ( !fCompl0 )
193 pObj->Value = Gia_ObjFanin0(pObj)->Value;
194 else if ( !fCompl1 )
195 pObj->Value = Gia_ObjFanin1(pObj)->Value;
196 else assert( 0 );
197 assert( pObj->Value > 0 );
198 }
199 // combinational outputs
200 Gia_ManForEachCo( p, pObj, k )
201 {
202 pObj->fMark0 = Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj);
203 pObj->fMark1 = Gia_ObjFanin0(pObj)->fMark1;
204 pObj->Value = Gia_ObjFanin0(pObj)->Value;
205 }
206 }
207 Gia_ManHashStop( pNew );
208 assert( iBit == pCex->nBits );
209 // create primary output
210 pObj = Gia_ManPo(p, pCex->iPo);
211 assert( pObj->fMark0 == 1 );
212 assert( pObj->fMark1 == 0 );
213 assert( pObj->Value > 0 );
214 Gia_ManAppendCo( pNew, pObj->Value );
215 // cleanup
216 pNew = Gia_ManCleanup( pTemp = pNew );
217 Gia_ManStop( pTemp );
218 return pNew;
219}
221{
222 Gia_Man_t * pNew, * pTemp;
223 Gia_Obj_t * pObj, * pObjRo, * pObjRi;
224 int fCompl0, fCompl1;
225 int i, k, iBit;
226 assert( pCex->nRegs == 0 );
227 assert( pCex->nPis == Gia_ManCiNum(p) );
228 assert( fStart <= pCex->iFrame );
229 // start the manager
230 pNew = Gia_ManStart( 1000 );
231 pNew->pName = Abc_UtilStrsav( "unate" );
232 // set const0
233 Gia_ManConst0(p)->fMark0 = 0; // value
234 Gia_ManConst0(p)->Value = 1;
235 // set init state
236 Gia_ManForEachRi( p, pObj, k )
237 {
238 pObj->fMark0 = Abc_InfoHasBit( pCex->pData, pCex->nRegs + fStart * Gia_ManCiNum(p) + Gia_ManPiNum(p) + k );
239 pObj->Value = Abc_LitNotCond( Gia_ManAppendCi(pNew), !pObj->fMark0 );
240 }
241 Gia_ManHashAlloc( pNew );
242 iBit = pCex->nRegs + fStart * Gia_ManCiNum(p);
243 for ( i = fStart; i <= pCex->iFrame; i++ )
244 {
245 // primary inputs
246 Gia_ManForEachPi( p, pObj, k )
247 {
248 pObj->fMark0 = Abc_InfoHasBit( pCex->pData, iBit++ );
249 pObj->Value = 1;
250 }
251 iBit += Gia_ManRegNum(p);
252 // transfer
253 Gia_ManForEachRiRo( p, pObjRi, pObjRo, k )
254 {
255 pObjRo->fMark0 = pObjRi->fMark0;
256 pObjRo->Value = pObjRi->Value;
257 }
258 // internal nodes
259 Gia_ManForEachAnd( p, pObj, k )
260 {
261 fCompl0 = Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj);
262 fCompl1 = Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj);
263 pObj->fMark0 = fCompl0 & fCompl1;
264 if ( pObj->fMark0 )
265 pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0(pObj)->Value, Gia_ObjFanin1(pObj)->Value );
266 else if ( !fCompl0 && !fCompl1 )
267 pObj->Value = Gia_ManHashOr( pNew, Gia_ObjFanin0(pObj)->Value, Gia_ObjFanin1(pObj)->Value );
268 else if ( !fCompl0 )
269 pObj->Value = Gia_ObjFanin0(pObj)->Value;
270 else if ( !fCompl1 )
271 pObj->Value = Gia_ObjFanin1(pObj)->Value;
272 else assert( 0 );
273 }
274 // combinational outputs
275 Gia_ManForEachCo( p, pObj, k )
276 {
277 pObj->fMark0 = Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj);
278 pObj->Value = Gia_ObjFanin0(pObj)->Value;
279 }
280 }
281 Gia_ManHashStop( pNew );
282 assert( iBit == pCex->nBits );
283 // create primary output
284 pObj = Gia_ManPo(p, pCex->iPo);
285 assert( pObj->fMark0 == 1 );
286 assert( pObj->Value > 0 );
287 Gia_ManAppendCo( pNew, pObj->Value );
288 // cleanup
289 pNew = Gia_ManCleanup( pTemp = pNew );
290 Gia_ManStop( pTemp );
291 return pNew;
292}
293
295{
296 Gia_Man_t * pNew, * pTemp;
297 Vec_Ptr_t * vCones;
298 abctime clk = Abc_Clock();
299 int i;
300 nFramesMax = Abc_MinInt( nFramesMax, pCex->iFrame );
301 printf( "Processing CEX in frame %d (max frames %d).\n", pCex->iFrame, nFramesMax );
302 vCones = Vec_PtrAlloc( nFramesMax );
303 for ( i = pCex->iFrame; i > pCex->iFrame - nFramesMax; i-- )
304 {
305 printf( "Frame %5d : ", i );
306 pNew = Bmc_CexBuildNetwork2_( p, pCex, i );
307 Gia_ManPrintStats( pNew, NULL );
308 Vec_PtrPush( vCones, pNew );
309 }
310 pNew = Gia_ManDupAppendCones( p, (Gia_Man_t **)Vec_PtrArray(vCones), Vec_PtrSize(vCones), 1 );
311 Gia_AigerWrite( pNew, "miter2.aig", 0, 0, 0 );
312//Bmc_CexDumpAogStats( pNew, Abc_Clock() - clk );
313 Vec_PtrForEachEntry( Gia_Man_t *, vCones, pTemp, i )
314 Gia_ManStop( pTemp );
315 Vec_PtrFree( vCones );
316 printf( "GIA with additional properties is written into \"miter2.aig\".\n" );
317// printf( "CE-induced network is written into file \"unate.aig\".\n" );
318 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
319// Gia_ManStop( pNew );
320 return pNew;
321}
322
323
335Gia_Man_t * Bmc_CexDepthTest( Gia_Man_t * p, Abc_Cex_t * pCex, int nFrames, int fVerbose )
336{
337 Gia_Man_t * pNew;
338 abctime clk = Abc_Clock();
339 Abc_Cex_t * pCexImpl = NULL;
340 Abc_Cex_t * pCexStates = Bmc_CexInnerStates( p, pCex, &pCexImpl, fVerbose );
341 Abc_Cex_t * pCexCare = Bmc_CexCareBits( p, pCexStates, pCexImpl, NULL, 1, fVerbose );
342// Abc_Cex_t * pCexEss, * pCexMin;
343
344 if ( !Bmc_CexVerify( p, pCex, pCexCare ) )
345 printf( "Counter-example care-set verification has failed.\n" );
346
347// pCexEss = Bmc_CexEssentialBits( p, pCexStates, pCexCare, fVerbose );
348// pCexMin = Bmc_CexCareBits( p, pCexStates, pCexImpl, pCexEss, 0, fVerbose );
349
350// if ( !Bmc_CexVerify( p, pCex, pCexMin ) )
351// printf( "Counter-example min-set verification has failed.\n" );
352
353// Bmc_CexDumpStats( p, pCex, pCexCare, pCexEss, pCexMin, Abc_Clock() - clk );
354
355 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
356 pNew = Bmc_CexBuildNetwork2Test( p, pCexStates, nFrames );
357// Bmc_CexPerformUnrollingTest( p, pCex );
358
359 Abc_CexFreeP( &pCexStates );
360 Abc_CexFreeP( &pCexImpl );
361 Abc_CexFreeP( &pCexCare );
362// Abc_CexFreeP( &pCexEss );
363// Abc_CexFreeP( &pCexMin );
364 return pNew;
365}
366
370
371
373
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Gia_Man_t * Bmc_CexTargetEnlarge(Gia_Man_t *p, int nFrames)
FUNCTION DEFINITIONS ///.
Definition bmcCexDepth.c:49
Abc_Cex_t * Bmc_CexCareBits(Gia_Man_t *p, Abc_Cex_t *pCexState, Abc_Cex_t *pCexImpl, Abc_Cex_t *pCexEss, int fFindAll, int fVerbose)
Gia_Man_t * Bmc_CexBuildNetwork2Test(Gia_Man_t *p, Abc_Cex_t *pCex, int nFramesMax)
Gia_Man_t * Bmc_CexDepthTest(Gia_Man_t *p, Abc_Cex_t *pCex, int nFrames, int fVerbose)
Gia_Man_t * Bmc_CexBuildNetwork2(Gia_Man_t *p, Abc_Cex_t *pCex, int fStart)
int Bmc_CexVerify(Gia_Man_t *p, Abc_Cex_t *pCex, Abc_Cex_t *pCexCare)
Gia_Man_t * Bmc_CexTarget(Gia_Man_t *p, int nFrames)
Definition bmcCexDepth.c:94
ABC_NAMESPACE_IMPL_START Abc_Cex_t * Bmc_CexInnerStates(Gia_Man_t *p, Abc_Cex_t *pCex, Abc_Cex_t **ppCexImpl, int fVerbose)
DECLARATIONS ///.
Gia_Man_t * Bmc_CexBuildNetwork2_(Gia_Man_t *p, Abc_Cex_t *pCex, int fStart)
Cube * p
Definition exorList.c:222
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
Gia_Man_t * Gia_ManDupAppendCones(Gia_Man_t *p, Gia_Man_t **ppCones, int nCones, int fOnlyRegs)
Definition giaDup.c:1305
#define Gia_ManForEachRo(p, pObj, i)
Definition gia.h:1252
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
Gia_Man_t * Gia_ManDupLastPis(Gia_Man_t *p, int nLastPis)
Definition giaDup.c:597
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition giaHash.c:105
#define Gia_ManForEachPi(p, pObj, i)
Definition gia.h:1248
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:621
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
Gia_Man_t * Gia_ManDupExist(Gia_Man_t *p, int iVar)
Definition giaDup.c:2012
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
#define Gia_ManForEachRiRo(p, pObjRi, pObjRo, i)
Definition gia.h:1256
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
Definition giaMan.c:495
#define Gia_ManForEachRi(p, pObj, i)
Definition gia.h:1254
void Gia_AigerWrite(Gia_Man_t *p, char *pFileName, int fWriteSymbols, int fCompact, int fWriteNewLine)
Definition giaAiger.c:1595
char * pSpec
Definition gia.h:100
char * pName
Definition gia.h:99
unsigned fMark1
Definition gia.h:86
unsigned Value
Definition gia.h:89
unsigned fMark0
Definition gia.h:81
void Abc_CexFreeP(Abc_Cex_t **p)
Definition utilCex.c:361
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
Definition utilCex.h:39
#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