abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mfsGia.c File Reference
#include "mfsInt.h"
#include "aig/gia/giaAig.h"

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int Gia_ObjChild0Copy (Aig_Obj_t *pObj)
 DECLARATIONS ///. More...
 
static int Gia_ObjChild1Copy (Aig_Obj_t *pObj)
 
Gia_Man_tGia_ManCreateResubMiter (Aig_Man_t *p)
 FUNCTION DEFINITIONS ///. More...
 
void Abc_NtkMfsConstructGia (Mfs_Man_t *p)
 
void Abc_NtkMfsDeconstructGia (Mfs_Man_t *p)
 
void Abc_NtkMfsResimulate (Gia_Man_t *p, Vec_Int_t *vCex)
 
int Abc_NtkMfsTryResubOnceGia (Mfs_Man_t *p, int *pCands, int nCands)
 

Function Documentation

void Abc_NtkMfsConstructGia ( Mfs_Man_t p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 120 of file mfsGia.c.

121 {
122  int nBTLimit = 500;
123  // prepare AIG
124  assert( p->pGia == NULL );
125  p->pGia = Gia_ManCreateResubMiter( p->pAigWin );
126  // prepare AIG
127  Gia_ManCreateRefs( p->pGia );
128  Gia_ManCleanMark0( p->pGia );
129  Gia_ManCleanMark1( p->pGia );
130  Gia_ManFillValue ( p->pGia ); // maps nodes into trail ids
131  Gia_ManCleanPhase( p->pGia );
132  // prepare solver
133  p->pTas = Tas_ManAlloc( p->pGia, nBTLimit );
134  p->vCex = Tas_ReadModel( p->pTas );
135  p->vGiaLits = Vec_PtrAlloc( 100 );
136 }
Tas_Man_t * Tas_ManAlloc(Gia_Man_t *pAig, int nBTLimit)
Definition: giaCTas.c:187
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition: giaUtil.c:715
void Gia_ManCleanPhase(Gia_Man_t *p)
Definition: giaUtil.c:431
void Gia_ManCleanMark0(Gia_Man_t *p)
Definition: giaUtil.c:215
void Gia_ManCleanMark1(Gia_Man_t *p)
Definition: giaUtil.c:272
Aig_Man_t * pAigWin
Definition: mfsInt.h:87
void Gia_ManFillValue(Gia_Man_t *p)
Definition: giaUtil.c:328
Vec_Int_t * Tas_ReadModel(Tas_Man_t *p)
Definition: giaCTas.c:250
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
Gia_Man_t * Gia_ManCreateResubMiter(Aig_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: mfsGia.c:53
void Abc_NtkMfsDeconstructGia ( Mfs_Man_t p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 150 of file mfsGia.c.

151 {
152  assert( p->pGia != NULL );
153  Gia_ManStop( p->pGia ); p->pGia = NULL;
154  Tas_ManStop( p->pTas ); p->pTas = NULL;
155  Vec_PtrFree( p->vGiaLits );
156 }
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
void Tas_ManStop(Tas_Man_t *p)
Definition: giaCTas.c:223
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Abc_NtkMfsResimulate ( Gia_Man_t p,
Vec_Int_t vCex 
)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 169 of file mfsGia.c.

170 {
171  Gia_Obj_t * pObj;
172  int i, Entry;
173 // Gia_ManCleanMark1( p );
174  Gia_ManConst0(p)->fMark1 = 0;
175  Gia_ManForEachCi( p, pObj, i )
176  pObj->fMark1 = 0;
177 // pObj->fMark1 = Gia_ManRandom(0);
178  Vec_IntForEachEntry( vCex, Entry, i )
179  {
180  pObj = Gia_ManCi( p, Gia_Lit2Var(Entry) );
181  pObj->fMark1 = !Gia_LitIsCompl(Entry);
182  }
183  Gia_ManForEachAnd( p, pObj, i )
184  pObj->fMark1 = (Gia_ObjFanin0(pObj)->fMark1 ^ Gia_ObjFaninC0(pObj)) &
185  (Gia_ObjFanin1(pObj)->fMark1 ^ Gia_ObjFaninC1(pObj));
186  Gia_ManForEachCo( p, pObj, i )
187  pObj->fMark1 = Gia_ObjFanin0(pObj)->fMark1 ^ Gia_ObjFaninC0(pObj);
188 }
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static Gia_Obj_t * Gia_ManCi(Gia_Man_t *p, int v)
Definition: gia.h:403
unsigned fMark1
Definition: gia.h:84
Definition: gia.h:75
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Abc_NtkMfsTryResubOnceGia ( Mfs_Man_t p,
int *  pCands,
int  nCands 
)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 204 of file mfsGia.c.

205 {
206  int fVeryVerbose = 0;
207  int fUseGia = 1;
208  unsigned * pData;
209  int i, iVar, status, iOut;
210  clock_t clk = clock();
211  p->nSatCalls++;
212 // return -1;
213  assert( p->pGia != NULL );
214  assert( p->pTas != NULL );
215  // convert to literals
216  Vec_PtrClear( p->vGiaLits );
217  // create the first four literals
218  Vec_PtrPush( p->vGiaLits, Gia_ObjChild0(Gia_ManPo(p->pGia, 0)) );
219  Vec_PtrPush( p->vGiaLits, Gia_ObjChild0(Gia_ManPo(p->pGia, 1)) );
220  Vec_PtrPush( p->vGiaLits, Gia_ObjChild0(Gia_ManPo(p->pGia, 2)) );
221  Vec_PtrPush( p->vGiaLits, Gia_ObjChild0(Gia_ManPo(p->pGia, 3)) );
222  for ( i = 0; i < nCands; i++ )
223  {
224  // get the output number
225  iOut = Gia_Lit2Var(pCands[i]) - 2 * p->pCnf->nVars;
226  // write the literal
227  Vec_PtrPush( p->vGiaLits, Gia_ObjChild0(Gia_ManPo(p->pGia, 4 + iOut)) );
228  }
229  // perform SAT solving
230  status = Tas_ManSolveArray( p->pTas, p->vGiaLits );
231  if ( status == -1 )
232  {
233  p->nTimeOuts++;
234  if ( fVeryVerbose )
235  printf( "t" );
236 // p->nSatUndec++;
237 // p->nConfUndec += p->Pars.nBTThis;
238 // Cec_ManSatAddToStore( vCexStore, NULL, i ); // timeout
239 // p->timeSatUndec += clock() - clk;
240  }
241  else if ( status == 1 )
242  {
243  if ( fVeryVerbose )
244  printf( "u" );
245 // p->nSatUnsat++;
246 // p->nConfUnsat += p->Pars.nBTThis;
247 // p->timeSatUnsat += clock() - clk;
248  }
249  else
250  {
251  p->nSatCexes++;
252  if ( fVeryVerbose )
253  printf( "s" );
254 // p->nSatSat++;
255 // p->nConfSat += p->Pars.nBTThis;
256 // Gia_SatVerifyPattern( pAig, pRoot, vCex, vVisit );
257 // Cec_ManSatAddToStore( vCexStore, vCex, i );
258 // p->timeSatSat += clock() - clk;
259 
260  // resimulate the counter-example
261  Abc_NtkMfsResimulate( p->pGia, Tas_ReadModel(p->pTas) );
262 
263  if ( fUseGia )
264  {
265 /*
266  int Val0 = Gia_ManPo(p->pGia, 0)->fMark1;
267  int Val1 = Gia_ManPo(p->pGia, 1)->fMark1;
268  int Val2 = Gia_ManPo(p->pGia, 2)->fMark1;
269  int Val3 = Gia_ManPo(p->pGia, 3)->fMark1;
270  assert( Val0 == 1 );
271  assert( Val1 == 1 );
272  assert( Val2 == 1 );
273  assert( Val3 == 1 );
274 */
275  // store the counter-example
276  Vec_IntForEachEntry( p->vProjVarsSat, iVar, i )
277  {
278  pData = (unsigned *)Vec_PtrEntry( p->vDivCexes, i );
279  iOut = iVar - 2 * p->pCnf->nVars;
280 // if ( !Gia_ManPo( p->pGia, 4 + iOut )->fMark1 ) // remove 0s!!!
281  if ( Gia_ManPo( p->pGia, 4 + iOut )->fMark1 ) // remove 0s!!! - rememeber complemented attribute
282  {
283  assert( Aig_InfoHasBit(pData, p->nCexes) );
284  Aig_InfoXorBit( pData, p->nCexes );
285  }
286  }
287  p->nCexes++;
288  }
289 
290  }
291  return status;
292 }
int Tas_ManSolveArray(Tas_Man_t *p, Vec_Ptr_t *vObjs)
Definition: giaCTas.c:1423
static Gia_Obj_t * Gia_ObjChild0(Gia_Obj_t *pObj)
Definition: gia.h:457
Vec_Int_t * vProjVarsSat
Definition: mfsInt.h:65
static Gia_Obj_t * Gia_ManPo(Gia_Man_t *p, int v)
Definition: gia.h:406
int nVars
Definition: cnf.h:59
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
unsigned fMark1
Definition: gia.h:84
void Abc_NtkMfsResimulate(Gia_Man_t *p, Vec_Int_t *vCex)
Definition: mfsGia.c:169
Vec_Int_t * Tas_ReadModel(Tas_Man_t *p)
Definition: giaCTas.c:250
int nSatCalls
Definition: mfsInt.h:70
Vec_Ptr_t * vDivCexes
Definition: mfsInt.h:67
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int nCexes
Definition: mfsInt.h:69
int nSatCexes
Definition: mfsInt.h:71
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
Cnf_Dat_t * pCnf
Definition: mfsInt.h:88
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int nTimeOuts
Definition: mfsInt.h:114
Gia_Man_t* Gia_ManCreateResubMiter ( Aig_Man_t p)

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Derives the resubstitution miter as an GIA.]

Description []

SideEffects []

SeeAlso []

Definition at line 53 of file mfsGia.c.

54 {
55  Gia_Man_t * pNew;//, * pTemp;
56  Aig_Obj_t * pObj;
57  int i, * pOuts0, * pOuts1;
58  Aig_ManSetPioNumbers( p );
59  // create the new manager
60  pNew = Gia_ManStart( Aig_ManObjNum(p) );
61  pNew->pName = Gia_UtilStrsav( p->pName );
62  pNew->pSpec = Gia_UtilStrsav( p->pSpec );
63  Gia_ManHashAlloc( pNew );
64  // create the objects
65  pOuts0 = ABC_ALLOC( int, Aig_ManPoNum(p) );
66  Aig_ManForEachObj( p, pObj, i )
67  {
68  if ( Aig_ObjIsAnd(pObj) )
69  pObj->iData = Gia_ManHashAnd( pNew, Gia_ObjChild0Copy(pObj), Gia_ObjChild1Copy(pObj) );
70  else if ( Aig_ObjIsPi(pObj) )
71  pObj->iData = Gia_ManAppendCi( pNew );
72  else if ( Aig_ObjIsPo(pObj) )
73  pOuts0[ Aig_ObjPioNum(pObj) ] = Gia_ObjChild0Copy(pObj);
74  else if ( Aig_ObjIsConst1(pObj) )
75  pObj->iData = 1;
76  else
77  assert( 0 );
78  }
79  // create the objects
80  pOuts1 = ABC_ALLOC( int, Aig_ManPoNum(p) );
81  Aig_ManForEachObj( p, pObj, i )
82  {
83  if ( Aig_ObjIsAnd(pObj) )
84  pObj->iData = Gia_ManHashAnd( pNew, Gia_ObjChild0Copy(pObj), Gia_ObjChild1Copy(pObj) );
85  else if ( Aig_ObjIsPi(pObj) )
86  pObj->iData = Gia_ManAppendCi( pNew );
87  else if ( Aig_ObjIsPo(pObj) )
88  pOuts1[ Aig_ObjPioNum(pObj) ] = Gia_ObjChild0Copy(pObj);
89  else if ( Aig_ObjIsConst1(pObj) )
90  pObj->iData = 1;
91  else
92  assert( 0 );
93  }
94  // add the outputs
95  Gia_ManAppendCo( pNew, pOuts0[0] );
96  Gia_ManAppendCo( pNew, pOuts1[0] );
97  Gia_ManAppendCo( pNew, pOuts0[1] );
98  Gia_ManAppendCo( pNew, Gia_LitNot(pOuts1[1]) );
99  for ( i = 2; i < Aig_ManPoNum(p); i++ )
100  Gia_ManAppendCo( pNew, Gia_LitNot( Gia_ManHashXor(pNew, pOuts0[i], pOuts1[i]) ) );
101  Gia_ManHashStop( pNew );
102  ABC_FREE( pOuts0 );
103  ABC_FREE( pOuts1 );
104 // pNew = Gia_ManCleanup( pTemp = pNew );
105 // Gia_ManStop( pTemp );
106  return pNew;
107 }
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Gia_ManHashXor(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:658
static int Aig_ManObjNum(Aig_Man_t *p)
Definition: aig.h:258
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Gia_ObjChild1Copy(Aig_Obj_t *pObj)
Definition: mfsGia.c:32
char * pName
Definition: gia.h:97
char * pSpec
Definition: gia.h:98
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
Definition: aig.h:69
int iData
Definition: aig.h:88
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
static ABC_NAMESPACE_IMPL_START int Gia_ObjChild0Copy(Aig_Obj_t *pObj)
DECLARATIONS ///.
Definition: mfsGia.c:31
#define ABC_FREE(obj)
Definition: abc_global.h:232
Definition: gia.h:95
#define assert(ex)
Definition: util_old.h:213
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition: giaHash.c:99
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
static int Aig_ObjIsAnd(Aig_Obj_t *pObj)
Definition: aig.h:278
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
static ABC_NAMESPACE_IMPL_START int Gia_ObjChild0Copy ( Aig_Obj_t pObj)
inlinestatic

DECLARATIONS ///.

CFile****************************************************************

FileName [mfsGia.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [The good old minimization with complete don't-cares.]

Synopsis [Experimental code based on the new AIG package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - July 29, 2009.]

Revision [

Id:
mfsGia.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 31 of file mfsGia.c.

31 { return Gia_LitNotCond( Aig_ObjFanin0(pObj)->iData, Aig_ObjFaninC0(pObj) ); }
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static int Gia_ObjChild1Copy ( Aig_Obj_t pObj)
inlinestatic

Definition at line 32 of file mfsGia.c.

32 { return Gia_LitNotCond( Aig_ObjFanin1(pObj)->iData, Aig_ObjFaninC1(pObj) ); }
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307