ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
saigTempor.c
Go to the documentation of this file.
1
20
21#include "saig.h"
22#include "sat/bmc/bmc.h"
23
25
26
30
34
47{
48 Aig_Man_t * pFrames;
49 Aig_Obj_t * pObj, * pObjLi, * pObjLo;
50 int i, f;
51 // start the frames package
52 Aig_ManCleanData( pAig );
53 pFrames = Aig_ManStart( Aig_ManObjNumMax(pAig) * nFrames );
54 pFrames->pName = Abc_UtilStrsav( pAig->pName );
55 // initiliaze the flops
56 Saig_ManForEachLo( pAig, pObj, i )
57 pObj->pData = Aig_ManConst0(pFrames);
58 // for each timeframe
59 for ( f = 0; f < nFrames; f++ )
60 {
61 Aig_ManConst1(pAig)->pData = Aig_ManConst1(pFrames);
62 Saig_ManForEachPi( pAig, pObj, i )
63 pObj->pData = Aig_ObjCreateCi(pFrames);
64 Aig_ManForEachNode( pAig, pObj, i )
65 pObj->pData = Aig_And( pFrames, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
66 Aig_ManForEachCo( pAig, pObj, i )
67 pObj->pData = Aig_ObjChild0Copy(pObj);
68 Saig_ManForEachLiLo( pAig, pObjLi, pObjLo, i )
69 pObjLo->pData = pObjLi->pData;
70 }
71 // create POs for the flop inputs
72 Saig_ManForEachLi( pAig, pObj, i )
73 Aig_ObjCreateCo( pFrames, (Aig_Obj_t *)pObj->pData );
74 Aig_ManCleanup( pFrames );
75 return pFrames;
76}
77
78
91{
92 Aig_Man_t * pAigNew, * pFrames;
93 Aig_Obj_t * pObj, * pReset;
94 int i;
95 if ( pAig->nConstrs > 0 )
96 {
97 printf( "The AIG manager should have no constraints.\n" );
98 return NULL;
99 }
100 // create initialized timeframes
101 pFrames = Saig_ManTemporFrames( pAig, nFrames );
102 assert( Aig_ManCoNum(pFrames) == Aig_ManRegNum(pAig) );
103
104 // start the new manager
105 Aig_ManCleanData( pAig );
106 pAigNew = Aig_ManStart( Aig_ManNodeNum(pAig) );
107 pAigNew->pName = Abc_UtilStrsav( pAig->pName );
108 // map the constant node and primary inputs
109 Aig_ManConst1(pAig)->pData = Aig_ManConst1( pAigNew );
110 Saig_ManForEachPi( pAig, pObj, i )
111 pObj->pData = Aig_ObjCreateCi( pAigNew );
112
113 // insert initialization logic
114 Aig_ManConst1(pFrames)->pData = Aig_ManConst1( pAigNew );
115 Aig_ManForEachCi( pFrames, pObj, i )
116 pObj->pData = Aig_ObjCreateCi( pAigNew );
117 Aig_ManForEachNode( pFrames, pObj, i )
118 pObj->pData = Aig_And( pAigNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
119 Aig_ManForEachCo( pFrames, pObj, i )
120 pObj->pData = Aig_ObjChild0Copy(pObj);
121
122 // create reset latch (the first one among the latches)
123 pReset = Aig_ObjCreateCi( pAigNew );
124
125 // create flop output values
126 Saig_ManForEachLo( pAig, pObj, i )
127 pObj->pData = Aig_Mux( pAigNew, pReset, Aig_ObjCreateCi(pAigNew), (Aig_Obj_t *)Aig_ManCo(pFrames, i)->pData );
128 Aig_ManStop( pFrames );
129
130 // add internal nodes of this frame
131 Aig_ManForEachNode( pAig, pObj, i )
132 pObj->pData = Aig_And( pAigNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
133 // create primary outputs
134 Saig_ManForEachPo( pAig, pObj, i )
135 Aig_ObjCreateCo( pAigNew, Aig_ObjChild0Copy(pObj) );
136
137 // create reset latch (the first one among the latches)
138 Aig_ObjCreateCo( pAigNew, Aig_ManConst1(pAigNew) );
139 // create latch inputs
140 Saig_ManForEachLi( pAig, pObj, i )
141 Aig_ObjCreateCo( pAigNew, Aig_ObjChild0Copy(pObj) );
142
143 // finalize
144 Aig_ManCleanup( pAigNew );
145 Aig_ManSetRegNum( pAigNew, Aig_ManRegNum(pAig)+1 ); // + reset latch (011111...)
146 return pAigNew;
147}
148
161{
162 int Entry, i;
163 if ( vTemp == NULL )
164 return -1;
165 Vec_IntForEachEntryReverse( vTemp, Entry, i )
166 {
167 if ( i >= Limit )
168 continue;
169 if ( Entry )
170 return i;
171 }
172 return -1;
173}
174
186Aig_Man_t * Saig_ManTempor( Aig_Man_t * pAig, int nFrames, int TimeOut, int nConfLimit, int fUseBmc, int fUseTransSigs, int fVerbose, int fVeryVerbose )
187{
188 extern int Saig_ManPhasePrefixLength( Aig_Man_t * p, int fVerbose, int fVeryVerbose, Vec_Int_t ** pvTrans );
189
190 Vec_Int_t * vTransSigs = NULL;
191 int RetValue, nFramesFinished = -1;
192 assert( nFrames >= 0 );
193 if ( nFrames == 0 )
194 {
195 nFrames = Saig_ManPhasePrefixLength( pAig, fVerbose, fVeryVerbose, &vTransSigs );
196 if ( nFrames == 0 )
197 {
198 Vec_IntFreeP( &vTransSigs );
199 printf( "The leading sequence has length 0. Temporal decomposition is not performed.\n" );
200 return NULL;
201 }
202 if ( nFrames == 1 )
203 {
204 Vec_IntFreeP( &vTransSigs );
205 printf( "The leading sequence has length 1. Temporal decomposition is not performed.\n" );
206 return NULL;
207 }
208 if ( fUseTransSigs )
209 {
210 int Entry, i, iLast = -1;
211 Vec_IntForEachEntry( vTransSigs, Entry, i )
212 iLast = Entry ? i :iLast;
213 if ( iLast > 0 && iLast < nFrames )
214 {
215 Abc_Print( 1, "Reducing frame count from %d to %d to fit the last transient.\n", nFrames, iLast );
216 nFrames = iLast;
217 }
218 }
219 Abc_Print( 1, "Using computed frame number (%d).\n", nFrames );
220 }
221 else
222 Abc_Print( 1, "Using user-given frame number (%d).\n", nFrames );
223 // run BMC2
224 if ( fUseBmc )
225 {
226 RetValue = Saig_BmcPerform( pAig, 0, nFrames, 2000, TimeOut, nConfLimit, 0, fVerbose, 0, &nFramesFinished, 0, 0 );
227 if ( RetValue == 0 )
228 {
229 Vec_IntFreeP( &vTransSigs );
230 printf( "A cex found in the first %d frames.\n", nFrames );
231 return NULL;
232 }
233 if ( nFramesFinished + 1 < nFrames )
234 {
235 int iLastBefore = Vec_IntLastNonZeroBeforeLimit( vTransSigs, nFramesFinished );
236 if ( iLastBefore < 1 || !fUseTransSigs )
237 {
238 Vec_IntFreeP( &vTransSigs );
239 printf( "BMC for %d frames could not be completed. A cex may exist!\n", nFrames );
240 return NULL;
241 }
242 assert( iLastBefore < nFramesFinished );
243 printf( "BMC succeeded to frame %d. Adjusting frame count to be (%d) based on the last transient signal.\n", nFramesFinished, iLastBefore );
244 nFrames = iLastBefore;
245 }
246 }
247 Vec_IntFreeP( &vTransSigs );
248 return Saig_ManTemporDecompose( pAig, nFrames );
249}
250
254
256
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
Definition aigMan.c:438
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
#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
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition aigObj.c:66
Aig_Obj_t * Aig_Mux(Aig_Man_t *p, Aig_Obj_t *pC, Aig_Obj_t *p1, Aig_Obj_t *p0)
Definition aigOper.c:317
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition aigMan.c:47
#define Aig_ManForEachNode(p, pObj, i)
Definition aig.h:413
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
int Aig_ManCleanup(Aig_Man_t *p)
Definition aigMan.c:265
#define Aig_ManForEachCo(p, pObj, i)
Definition aig.h:398
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigObj.c:45
void Aig_ManCleanData(Aig_Man_t *p)
Definition aigUtil.c:205
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
int Saig_BmcPerform(Aig_Man_t *pAig, int nStart, int nFramesMax, int nNodesMax, int nTimeOut, int nConfMaxOne, int nConfMaxAll, int fVerbose, int fVerbOverwrite, int *piFrames, int fSilent, int fUseSatoko)
Definition bmcBmc2.c:811
Cube * p
Definition exorList.c:222
int Saig_ManPhasePrefixLength(Aig_Man_t *p, int fVerbose, int fVeryVerbose, Vec_Int_t **pvTrans)
Definition saigPhase.c:871
int Vec_IntLastNonZeroBeforeLimit(Vec_Int_t *vTemp, int Limit)
Definition saigTempor.c:160
Aig_Man_t * Saig_ManTemporDecompose(Aig_Man_t *pAig, int nFrames)
Definition saigTempor.c:90
ABC_NAMESPACE_IMPL_START Aig_Man_t * Saig_ManTemporFrames(Aig_Man_t *pAig, int nFrames)
DECLARATIONS ///.
Definition saigTempor.c:46
Aig_Man_t * Saig_ManTempor(Aig_Man_t *pAig, int nFrames, int TimeOut, int nConfLimit, int fUseBmc, int fUseTransSigs, int fVerbose, int fVeryVerbose)
Definition saigTempor.c:186
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
Definition saig.h:101
#define Saig_ManForEachLi(p, pObj, i)
Definition saig.h:98
#define Saig_ManForEachPo(p, pObj, i)
Definition saig.h:93
#define Saig_ManForEachLo(p, pObj, i)
Definition saig.h:96
#define Saig_ManForEachPi(p, pObj, i)
Definition saig.h:91
void * pData
Definition aig.h:87
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
#define Vec_IntForEachEntryReverse(vVec, pEntry, i)
Definition vecInt.h:62