abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
saigConstr.c File Reference
#include "saig.h"
#include "sat/cnf/cnf.h"
#include "sat/bsat/satSolver.h"
#include "bool/kit/kit.h"
#include "aig/ioa/ioa.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Saig_DetectConstrCollectSuper_rec (Aig_Obj_t *pObj, Vec_Ptr_t *vSuper)
 DECLARATIONS ///. More...
 
Vec_Ptr_tSaig_DetectConstrCollectSuper (Aig_Obj_t *pObj)
 
Vec_Ptr_tSaig_ManDetectConstrCheckCont (Vec_Ptr_t *vSuper, Vec_Ptr_t *vSuper2)
 
int Saig_ManDetectConstr (Aig_Man_t *p, int iOut, Vec_Ptr_t **pvOuts, Vec_Ptr_t **pvCons)
 
int Saig_ManDupCompare (Aig_Obj_t **pp1, Aig_Obj_t **pp2)
 
Aig_Man_tSaig_ManDupUnfoldConstrs (Aig_Man_t *pAig)
 
Aig_Man_tSaig_ManDupFoldConstrs (Aig_Man_t *pAig, Vec_Int_t *vConstrs)
 
void Saig_ManFoldConstrTest (Aig_Man_t *pAig)
 
int Saig_ManDetectConstrTest (Aig_Man_t *p)
 

Function Documentation

Vec_Ptr_t* Saig_DetectConstrCollectSuper ( Aig_Obj_t pObj)

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

Synopsis [Collects the supergate.]

Description []

SideEffects []

SeeAlso []

Definition at line 109 of file saigConstr.c.

110 {
111  Vec_Ptr_t * vSuper;
112  assert( !Aig_IsComplement(pObj) );
113  assert( Aig_ObjIsAnd(pObj) );
114  vSuper = Vec_PtrAlloc( 4 );
117  return vSuper;
118 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_ObjChild1(Aig_Obj_t *pObj)
Definition: aig.h:311
ABC_NAMESPACE_IMPL_START void Saig_DetectConstrCollectSuper_rec(Aig_Obj_t *pObj, Vec_Ptr_t *vSuper)
DECLARATIONS ///.
Definition: saigConstr.c:85
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjIsAnd(Aig_Obj_t *pObj)
Definition: aig.h:278
ABC_NAMESPACE_IMPL_START void Saig_DetectConstrCollectSuper_rec ( Aig_Obj_t pObj,
Vec_Ptr_t vSuper 
)

DECLARATIONS ///.

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

FileName [saigConstr.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Sequential AIG package.]

Synopsis [Structural constraint detection.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

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

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Collects the supergate.]

Description []

SideEffects []

SeeAlso []

Definition at line 85 of file saigConstr.c.

86 {
87  // if the new node is complemented or a PI, another gate begins
88  if ( Aig_IsComplement(pObj) || !Aig_ObjIsNode(pObj) )//|| (Aig_ObjRefs(pObj) > 1) )
89  {
90  Vec_PtrPushUnique( vSuper, Aig_Not(pObj) );
91  return;
92  }
93  // go through the branches
96 }
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
static int Vec_PtrPushUnique(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:656
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_Not(Aig_Obj_t *p)
Definition: aig.h:247
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static Aig_Obj_t * Aig_ObjChild1(Aig_Obj_t *pObj)
Definition: aig.h:311
ABC_NAMESPACE_IMPL_START void Saig_DetectConstrCollectSuper_rec(Aig_Obj_t *pObj, Vec_Ptr_t *vSuper)
DECLARATIONS ///.
Definition: saigConstr.c:85
int Saig_ManDetectConstr ( Aig_Man_t p,
int  iOut,
Vec_Ptr_t **  pvOuts,
Vec_Ptr_t **  pvCons 
)

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

Synopsis [Detects constraints using structural methods.]

Description []

SideEffects []

SeeAlso []

assert( !Aig_IsComplement(pObj) );

Definition at line 158 of file saigConstr.c.

159 {
160  Vec_Ptr_t * vSuper, * vSuper2 = NULL, * vUnique;
161  Aig_Obj_t * pObj, * pObj2, * pFlop;
162  int i, nFlops, RetValue;
163  assert( iOut >= 0 && iOut < Saig_ManPoNum(p) );
164  *pvOuts = NULL;
165  *pvCons = NULL;
166  pObj = Aig_ObjChild0( Aig_ManCo(p, iOut) );
167  if ( pObj == Aig_ManConst0(p) )
168  {
169  vUnique = Vec_PtrStart( 1 );
170  Vec_PtrWriteEntry( vUnique, 0, Aig_ManConst1(p) );
171  *pvOuts = vUnique;
172  *pvCons = Vec_PtrAlloc( 0 );
173  return -1;
174  }
175  if ( Aig_IsComplement(pObj) || !Aig_ObjIsNode(pObj) )
176  {
177  printf( "The output is not an AND.\n" );
178  return 0;
179  }
180  vSuper = Saig_DetectConstrCollectSuper( pObj );
181  assert( Vec_PtrSize(vSuper) >= 2 );
182  nFlops = 0;
183  Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pObj, i )
184  nFlops += Saig_ObjIsLo( p, Aig_Regular(pObj) );
185  if ( nFlops == 0 )
186  {
187  printf( "There is no flop outputs.\n" );
188  Vec_PtrFree( vSuper );
189  return 0;
190  }
191  // try flops
192  vUnique = NULL;
193  Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pObj, i )
194  {
195  pFlop = Aig_Regular( pObj );
196  if ( !Saig_ObjIsLo(p, pFlop) )
197  continue;
198  pFlop = Saig_ObjLoToLi( p, pFlop );
199  pObj2 = Aig_ObjChild0( pFlop );
200  if ( !Aig_IsComplement(pObj2) || !Aig_ObjIsNode(Aig_Regular(pObj2)) )
201  continue;
202  vSuper2 = Saig_DetectConstrCollectSuper( Aig_Regular(pObj2) );
203  // every node in vSuper2 should appear in vSuper
204  vUnique = Saig_ManDetectConstrCheckCont( vSuper, vSuper2 );
205  if ( vUnique != NULL )
206  {
207 /// assert( !Aig_IsComplement(pObj) );
208  // assert( Vec_PtrFind( vSuper2, pObj ) >= 0 );
209  if ( Aig_IsComplement(pObj) )
210  {
211  printf( "Special flop input is complemented.\n" );
212  Vec_PtrFreeP( &vUnique );
213  Vec_PtrFree( vSuper2 );
214  break;
215  }
216  if ( Vec_PtrFind( vSuper2, pObj ) == -1 )
217  {
218  printf( "Cannot find special flop about the inputs of OR gate.\n" );
219  Vec_PtrFreeP( &vUnique );
220  Vec_PtrFree( vSuper2 );
221  break;
222  }
223  // remove the flop output
224  Vec_PtrRemove( vSuper2, pObj );
225  break;
226  }
227  Vec_PtrFree( vSuper2 );
228  }
229  Vec_PtrFree( vSuper );
230  if ( vUnique == NULL )
231  {
232  printf( "There is no structural constraints.\n" );
233  return 0;
234  }
235  // vUnique contains unique entries
236  // vSuper2 contains the supergate
237  printf( "Output %d : Structural analysis found %d original properties and %d constraints.\n",
238  iOut, Vec_PtrSize(vUnique), Vec_PtrSize(vSuper2) );
239  // remember the number of constraints
240  RetValue = Vec_PtrSize(vSuper2);
241  // make the AND of properties
242 // Vec_PtrFree( vUnique );
243 // Vec_PtrFree( vSuper2 );
244  *pvOuts = vUnique;
245  *pvCons = vSuper2;
246  return RetValue;
247 }
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
Vec_Ptr_t * Saig_DetectConstrCollectSuper(Aig_Obj_t *pObj)
Definition: saigConstr.c:109
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Saig_ManPoNum(Aig_Man_t *p)
Definition: saig.h:74
static int Saig_ObjIsLo(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: saig.h:84
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Aig_Obj_t * Saig_ObjLoToLi(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: saig.h:86
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static Aig_Obj_t * Aig_ManConst0(Aig_Man_t *p)
Definition: aig.h:263
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Vec_PtrFind(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:694
static void Vec_PtrRemove(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:714
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static void Vec_PtrFreeP(Vec_Ptr_t **p)
Definition: vecPtr.h:240
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Vec_Ptr_t * Saig_ManDetectConstrCheckCont(Vec_Ptr_t *vSuper, Vec_Ptr_t *vSuper2)
Definition: saigConstr.c:132
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Vec_Ptr_t* Saig_ManDetectConstrCheckCont ( Vec_Ptr_t vSuper,
Vec_Ptr_t vSuper2 
)

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

Synopsis [Returns NULL if not contained, or array with unique entries.]

Description [Returns NULL if vSuper2 is not contained in vSuper. Otherwise returns the array of entries in vSuper that are not found in vSuper2.]

SideEffects []

SeeAlso []

Definition at line 132 of file saigConstr.c.

133 {
134  Vec_Ptr_t * vUnique;
135  Aig_Obj_t * pObj, * pObj2;
136  int i;
137  Vec_PtrForEachEntry( Aig_Obj_t *, vSuper2, pObj2, i )
138  if ( Vec_PtrFind( vSuper, pObj2 ) == -1 )
139  return 0;
140  vUnique = Vec_PtrAlloc( 100 );
141  Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pObj, i )
142  if ( Vec_PtrFind( vSuper2, pObj ) == -1 )
143  Vec_PtrPush( vUnique, pObj );
144  return vUnique;
145 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrFind(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:694
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Saig_ManDetectConstrTest ( Aig_Man_t p)

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

Synopsis [Experiment with the above procedure.]

Description []

SideEffects []

SeeAlso []

Definition at line 469 of file saigConstr.c.

470 {
471  Vec_Ptr_t * vOuts, * vCons;
472  int RetValue = Saig_ManDetectConstr( p, 0, &vOuts, &vCons );
473  Vec_PtrFreeP( &vOuts );
474  Vec_PtrFreeP( &vCons );
475  return RetValue;
476 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Saig_ManDetectConstr(Aig_Man_t *p, int iOut, Vec_Ptr_t **pvOuts, Vec_Ptr_t **pvCons)
Definition: saigConstr.c:158
static void Vec_PtrFreeP(Vec_Ptr_t **p)
Definition: vecPtr.h:240
int Saig_ManDupCompare ( Aig_Obj_t **  pp1,
Aig_Obj_t **  pp2 
)

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

Synopsis [Procedure used for sorting nodes by ID.]

Description []

SideEffects []

SeeAlso []

Definition at line 261 of file saigConstr.c.

262 {
263  int Diff = Aig_ObjToLit(*pp1) - Aig_ObjToLit(*pp2);
264  if ( Diff < 0 )
265  return -1;
266  if ( Diff > 0 )
267  return 1;
268  return 0;
269 }
static int Aig_ObjToLit(Aig_Obj_t *pObj)
Definition: aig.h:321
Aig_Man_t* Saig_ManDupFoldConstrs ( Aig_Man_t pAig,
Vec_Int_t vConstrs 
)

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

Synopsis [Duplicates the AIG while folding in the constraints.]

Description []

SideEffects []

SeeAlso []

Definition at line 379 of file saigConstr.c.

380 {
381  Aig_Man_t * pAigNew;
382  Aig_Obj_t * pMiter, * pFlopOut, * pFlopIn, * pObj;
383  int Entry, i;
384  assert( Saig_ManRegNum(pAig) > 0 );
385  // start the new manager
386  pAigNew = Aig_ManStart( Aig_ManNodeNum(pAig) );
387  pAigNew->pName = Abc_UtilStrsav( pAig->pName );
388  // map the constant node
389  Aig_ManConst1(pAig)->pData = Aig_ManConst1( pAigNew );
390  // create variables for PIs
391  Aig_ManForEachCi( pAig, pObj, i )
392  pObj->pData = Aig_ObjCreateCi( pAigNew );
393  // add internal nodes of this frame
394  Aig_ManForEachNode( pAig, pObj, i )
395  pObj->pData = Aig_And( pAigNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
396 
397  // OR the constraint outputs
398  pMiter = Aig_ManConst0( pAigNew );
399  Vec_IntForEachEntry( vConstrs, Entry, i )
400  {
401  assert( Entry > 0 && Entry < Saig_ManPoNum(pAig) );
402  pObj = Aig_ManCo( pAig, Entry );
403  pMiter = Aig_Or( pAigNew, pMiter, Aig_ObjChild0Copy(pObj) );
404  }
405  // create additional flop
406  pFlopOut = Aig_ObjCreateCi( pAigNew );
407  pFlopIn = Aig_Or( pAigNew, pMiter, pFlopOut );
408 
409  // create primary output
410  Saig_ManForEachPo( pAig, pObj, i )
411  {
412  pMiter = Aig_And( pAigNew, Aig_ObjChild0Copy(pObj), Aig_Not(pFlopIn) );
413  Aig_ObjCreateCo( pAigNew, pMiter );
414  }
415 
416  // transfer to register outputs
417  Saig_ManForEachLi( pAig, pObj, i )
418  Aig_ObjCreateCo( pAigNew, Aig_ObjChild0Copy(pObj) );
419  // create additional flop
420  Aig_ObjCreateCo( pAigNew, pFlopIn );
421 
422  Aig_ManSetRegNum( pAigNew, Aig_ManRegNum(pAig)+1 );
423  Aig_ManCleanup( pAigNew );
424  Aig_ManSeqCleanup( pAigNew );
425  return pAigNew;
426 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
static int Saig_ManPoNum(Aig_Man_t *p)
Definition: saig.h:74
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
int Aig_ManSeqCleanup(Aig_Man_t *p)
Definition: aigScl.c:158
void * pData
Definition: aig.h:87
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
static Aig_Obj_t * Aig_ManConst0(Aig_Man_t *p)
Definition: aig.h:263
static Aig_Obj_t * Aig_Not(Aig_Obj_t *p)
Definition: aig.h:247
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
Definition: aigMan.c:438
#define Saig_ManForEachLi(p, pObj, i)
Definition: saig.h:98
static Aig_Obj_t * Aig_ObjChild1Copy(Aig_Obj_t *pObj)
Definition: aig.h:313
Aig_Obj_t * Aig_Or(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:259
Definition: aig.h:69
static Aig_Obj_t * Aig_ObjChild0Copy(Aig_Obj_t *pObj)
Definition: aig.h:312
static int Saig_ManRegNum(Aig_Man_t *p)
Definition: saig.h:77
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define Saig_ManForEachPo(p, pObj, i)
Definition: saig.h:93
#define assert(ex)
Definition: util_old.h:213
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
Aig_Man_t* Saig_ManDupUnfoldConstrs ( Aig_Man_t pAig)

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

Synopsis [Duplicates the AIG while unfolding constraints.]

Description []

SideEffects []

SeeAlso []

Definition at line 282 of file saigConstr.c.

283 {
284  Vec_Ptr_t * vOutsAll, * vConsAll;
285  Vec_Ptr_t * vOuts, * vCons, * vCons0;
286  Aig_Man_t * pAigNew;
287  Aig_Obj_t * pMiter, * pObj;
288  int i, k, RetValue;
289  // detect constraints for each output
290  vOutsAll = Vec_PtrAlloc( Saig_ManPoNum(pAig) );
291  vConsAll = Vec_PtrAlloc( Saig_ManPoNum(pAig) );
292  Saig_ManForEachPo( pAig, pObj, i )
293  {
294  RetValue = Saig_ManDetectConstr( pAig, i, &vOuts, &vCons );
295  if ( RetValue == 0 )
296  {
297  Vec_PtrFreeP( &vOuts );
298  Vec_PtrFreeP( &vCons );
299  Vec_VecFree( (Vec_Vec_t *)vOutsAll );
300  Vec_VecFree( (Vec_Vec_t *)vConsAll );
301  return Aig_ManDupDfs( pAig );
302  }
303  Vec_PtrSort( vOuts, (int (*)(void))Saig_ManDupCompare );
304  Vec_PtrSort( vCons, (int (*)(void))Saig_ManDupCompare );
305  Vec_PtrPush( vOutsAll, vOuts );
306  Vec_PtrPush( vConsAll, vCons );
307  }
308  // check if constraints are compatible
309  vCons0 = (Vec_Ptr_t *)Vec_PtrEntry( vConsAll, 0 );
310  Vec_PtrForEachEntry( Vec_Ptr_t *, vConsAll, vCons, i )
311  if ( Vec_PtrSize(vCons) )
312  vCons0 = vCons;
313  Vec_PtrForEachEntry( Vec_Ptr_t *, vConsAll, vCons, i )
314  {
315  // Constant 0 outputs are always compatible (vOuts stores the negation)
316  vOuts = (Vec_Ptr_t *)Vec_PtrEntry( vOutsAll, i );
317  if ( Vec_PtrSize(vOuts) == 1 && (Aig_Obj_t *)Vec_PtrEntry( vOuts, 0 ) == Aig_ManConst1(pAig) )
318  continue;
319  if ( !Vec_PtrEqual(vCons0, vCons) )
320  break;
321  }
322  if ( i < Vec_PtrSize(vConsAll) )
323  {
324  printf( "Collected constraints are not compatible.\n" );
325  Vec_VecFree( (Vec_Vec_t *)vOutsAll );
326  Vec_VecFree( (Vec_Vec_t *)vConsAll );
327  return Aig_ManDupDfs( pAig );
328  }
329 
330  // start the new manager
331  pAigNew = Aig_ManStart( Aig_ManNodeNum(pAig) );
332  pAigNew->pName = Abc_UtilStrsav( pAig->pName );
333  // map the constant node
334  Aig_ManConst1(pAig)->pData = Aig_ManConst1( pAigNew );
335  // create variables for PIs
336  Aig_ManForEachCi( pAig, pObj, i )
337  pObj->pData = Aig_ObjCreateCi( pAigNew );
338  // add internal nodes of this frame
339  Aig_ManForEachNode( pAig, pObj, i )
340  pObj->pData = Aig_And( pAigNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
341  // transform each output
342  Vec_PtrForEachEntry( Vec_Ptr_t *, vOutsAll, vOuts, i )
343  {
344  // AND the outputs
345  pMiter = Aig_ManConst1( pAigNew );
346  Vec_PtrForEachEntry( Aig_Obj_t *, vOuts, pObj, k )
347  pMiter = Aig_And( pAigNew, pMiter, Aig_Not(Aig_ObjRealCopy(pObj)) );
348  Aig_ObjCreateCo( pAigNew, pMiter );
349  }
350  // add constraints
351  pAigNew->nConstrs = Vec_PtrSize(vCons0);
352  Vec_PtrForEachEntry( Aig_Obj_t *, vCons0, pObj, i )
353  Aig_ObjCreateCo( pAigNew, Aig_ObjRealCopy(pObj) );
354  // transfer to register outputs
355  Saig_ManForEachLi( pAig, pObj, i )
356  Aig_ObjCreateCo( pAigNew, Aig_ObjChild0Copy(pObj) );
357 // Vec_PtrFreeP( &vOuts );
358 // Vec_PtrFreeP( &vCons );
359  Vec_VecFree( (Vec_Vec_t *)vOutsAll );
360  Vec_VecFree( (Vec_Vec_t *)vConsAll );
361 
362  Aig_ManSetRegNum( pAigNew, Aig_ManRegNum(pAig) );
363  Aig_ManCleanup( pAigNew );
364  Aig_ManSeqCleanup( pAigNew );
365  return pAigNew;
366 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static int Saig_ManPoNum(Aig_Man_t *p)
Definition: saig.h:74
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
int Aig_ManSeqCleanup(Aig_Man_t *p)
Definition: aigScl.c:158
void * pData
Definition: aig.h:87
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
Aig_Man_t * Aig_ManDupDfs(Aig_Man_t *p)
Definition: aigDup.c:563
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
static void Vec_PtrSort(Vec_Ptr_t *p, int(*Vec_PtrSortCompare)()) ___unused
Definition: vecPtr.h:851
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static Aig_Obj_t * Aig_Not(Aig_Obj_t *p)
Definition: aig.h:247
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
static Aig_Obj_t * Aig_ObjRealCopy(Aig_Obj_t *pObj)
Definition: aig.h:320
int Saig_ManDetectConstr(Aig_Man_t *p, int iOut, Vec_Ptr_t **pvOuts, Vec_Ptr_t **pvCons)
Definition: saigConstr.c:158
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
Definition: aigMan.c:438
#define Saig_ManForEachLi(p, pObj, i)
Definition: saig.h:98
if(last==0)
Definition: sparse_int.h:34
static Aig_Obj_t * Aig_ObjChild1Copy(Aig_Obj_t *pObj)
Definition: aig.h:313
Definition: aig.h:69
static Aig_Obj_t * Aig_ObjChild0Copy(Aig_Obj_t *pObj)
Definition: aig.h:312
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
int Saig_ManDupCompare(Aig_Obj_t **pp1, Aig_Obj_t **pp2)
Definition: saigConstr.c:261
static void Vec_PtrFreeP(Vec_Ptr_t **p)
Definition: vecPtr.h:240
#define Saig_ManForEachPo(p, pObj, i)
Definition: saig.h:93
static int Vec_PtrEqual(Vec_Ptr_t *p1, Vec_Ptr_t *p2)
Definition: vecPtr.h:808
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
void Saig_ManFoldConstrTest ( Aig_Man_t pAig)

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

Synopsis [Tests the above two procedures.]

Description []

SideEffects []

SeeAlso []

Definition at line 440 of file saigConstr.c.

441 {
442  Aig_Man_t * pAig1, * pAig2;
443  Vec_Int_t * vConstrs;
444  // unfold constraints
445  pAig1 = Saig_ManDupUnfoldConstrs( pAig );
446  // create the constraint list
447  vConstrs = Vec_IntStartNatural( Saig_ManPoNum(pAig1) );
448  Vec_IntRemove( vConstrs, 0 );
449  // fold constraints back
450  pAig2 = Saig_ManDupFoldConstrs( pAig1, vConstrs );
451  Vec_IntFree( vConstrs );
452  // compare the two AIGs
453  Ioa_WriteAiger( pAig2, "test.aig", 0, 0 );
454  Aig_ManStop( pAig1 );
455  Aig_ManStop( pAig2 );
456 }
Aig_Man_t * Saig_ManDupUnfoldConstrs(Aig_Man_t *pAig)
Definition: saigConstr.c:282
static int Saig_ManPoNum(Aig_Man_t *p)
Definition: saig.h:74
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
static Vec_Int_t * Vec_IntStartNatural(int nSize)
Definition: bblif.c:192
void Ioa_WriteAiger(Aig_Man_t *pMan, char *pFileName, int fWriteSymbols, int fCompact)
Definition: ioaWriteAig.c:446
static int Vec_IntRemove(Vec_Int_t *p, int Entry)
Definition: vecInt.h:915
Aig_Man_t * Saig_ManDupFoldConstrs(Aig_Man_t *pAig, Vec_Int_t *vConstrs)
Definition: saigConstr.c:379
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235