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

Go to the source code of this file.

Data Structures

struct  Gia_IsoMan_t_
 

Macros

#define ISO_MASK   0xFF
 

Typedefs

typedef struct Gia_IsoMan_t_ Gia_IsoMan_t
 DECLARATIONS ///. More...
 

Functions

static unsigned Gia_IsoGetValue (Gia_IsoMan_t *p, int i)
 
static unsigned Gia_IsoGetItem (Gia_IsoMan_t *p, int i)
 
static void Gia_IsoSetValue (Gia_IsoMan_t *p, int i, unsigned v)
 
static void Gia_IsoSetItem (Gia_IsoMan_t *p, int i, unsigned v)
 
Gia_IsoMan_tGia_IsoManStart (Gia_Man_t *pGia)
 FUNCTION DEFINITIONS ///. More...
 
void Gia_IsoManStop (Gia_IsoMan_t *p)
 
void Gia_IsoManTransferUnique (Gia_IsoMan_t *p)
 
void Gia_IsoPrintClasses (Gia_IsoMan_t *p)
 
void Gia_IsoPrint (Gia_IsoMan_t *p, int Iter, abctime Time)
 
void Gia_IsoPrepare (Gia_IsoMan_t *p)
 
void Gia_IsoAssignUnique (Gia_IsoMan_t *p)
 
int Gia_IsoSort (Gia_IsoMan_t *p)
 
Vec_Ptr_tGia_IsoCollectCosClasses (Gia_IsoMan_t *p, int fVerbose)
 
static unsigned Gia_IsoUpdateValue (int Value, int fCompl)
 
static unsigned Gia_IsoUpdate (Gia_IsoMan_t *p, int Iter, int iObj, int fCompl)
 
void Gia_IsoSimulate (Gia_IsoMan_t *p, int Iter)
 
void Gia_IsoSimulateBack (Gia_IsoMan_t *p, int Iter)
 
void Gia_IsoAssignOneClass2 (Gia_IsoMan_t *p)
 
void Gia_IsoAssignOneClass3 (Gia_IsoMan_t *p)
 
void Gia_IsoAssignOneClass (Gia_IsoMan_t *p, int fVerbose)
 
void Gia_IsoReportTopmost (Gia_IsoMan_t *p)
 
void Gia_IsoRecognizeMuxes (Gia_Man_t *pGia)
 
Vec_Ptr_tGia_IsoDeriveEquivPos (Gia_Man_t *pGia, int fForward, int fVerbose)
 
int Gia_ObjCompareByValue (Gia_Obj_t **pp1, Gia_Obj_t **pp2)
 
void Gia_ManFindCaninicalOrder_rec (Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vAnds)
 
void Gia_ManFindCaninicalOrder (Gia_Man_t *p, Vec_Int_t *vCis, Vec_Int_t *vAnds, Vec_Int_t *vCos, Vec_Int_t **pvPiPerm)
 
Gia_Man_tGia_ManIsoCanonicize (Gia_Man_t *p, int fVerbose)
 
Vec_Str_tGia_ManIsoFindString (Gia_Man_t *p, int iPo, int fVerbose, Vec_Int_t **pvPiPerm)
 
int Vec_IntCountNonTrivial (Vec_Ptr_t *vEquivs, int *pnUsed)
 
Gia_Man_tGia_ManIsoReduce (Gia_Man_t *pInit, Vec_Ptr_t **pvPosEquivs, Vec_Ptr_t **pvPiPerms, int fEstimate, int fDualOut, int fVerbose, int fVeryVerbose)
 
void Gia_IsoTestOld (Gia_Man_t *p, int fVerbose)
 
Vec_Int_tGia_IsoTestGenPerm (int nPis)
 
void Gia_IsoTest (Gia_Man_t *p, Abc_Cex_t *pCex, int fVerbose)
 

Variables

static int s_256Primes [ISO_MASK+1]
 

Macro Definition Documentation

#define ISO_MASK   0xFF

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

FileName [giaIso.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Graph isomorphism.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 26 of file giaIso.c.

Typedef Documentation

typedef struct Gia_IsoMan_t_ Gia_IsoMan_t

DECLARATIONS ///.

Definition at line 67 of file giaIso.c.

Function Documentation

void Gia_IsoAssignOneClass ( Gia_IsoMan_t p,
int  fVerbose 
)

Definition at line 587 of file giaIso.c.

588 {
589  int i, k, iBegin0, iBegin, nSize, Shrink;
590  // find the classes with the highest level
591  assert( Vec_IntSize(p->vClasses) > 0 );
592  iBegin0 = Vec_IntEntry( p->vClasses, Vec_IntSize(p->vClasses) - 2 );
593  for ( i = Vec_IntSize(p->vClasses) - 2; i >= 0; i -= 2 )
594  {
595  iBegin = Vec_IntEntry( p->vClasses, i );
596  if ( p->pLevels[Gia_IsoGetItem(p, iBegin)] != p->pLevels[Gia_IsoGetItem(p, iBegin0)] )
597  break;
598  }
599  i += 2;
600  assert( i >= 0 );
601  // assign all classes starting with this one
602  for ( Shrink = i; i < Vec_IntSize(p->vClasses); i += 2 )
603  {
604  iBegin = Vec_IntEntry( p->vClasses, i );
605  nSize = Vec_IntEntry( p->vClasses, i + 1 );
606  for ( k = 0; k < nSize; k++ )
607  {
608  assert( p->pUniques[Gia_IsoGetItem(p, iBegin+k)] == 0 );
609  p->pUniques[Gia_IsoGetItem(p, iBegin+k)] = p->nUniques++;
610 // Gia_ManObj(p->pGia, Gia_IsoGetItem(p, iBegin+k))->Value += s_256Primes[0]; /// new addition!!!
611  p->nSingles++;
612  p->nEntries--;
613  }
614  if ( fVerbose )
615  printf( "Broke ties in class of size %d at level %d.\n", nSize, p->pLevels[Gia_IsoGetItem(p, iBegin)] );
616  }
617  Vec_IntShrink( p->vClasses, Shrink );
618 }
int * pUniques
Definition: giaIso.c:77
int nSingles
Definition: giaIso.c:73
static unsigned Gia_IsoGetItem(Gia_IsoMan_t *p, int i)
Definition: giaIso.c:94
int * pLevels
Definition: giaIso.c:76
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int nEntries
Definition: giaIso.c:74
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
Definition: bblif.c:435
#define assert(ex)
Definition: util_old.h:213
Vec_Int_t * vClasses
Definition: giaIso.c:82
int nUniques
Definition: giaIso.c:72
void Gia_IsoAssignOneClass2 ( Gia_IsoMan_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 512 of file giaIso.c.

513 {
514  int i, iBegin = -1, nSize = -1;
515  // find two variable class
516  assert( Vec_IntSize(p->vClasses) > 0 );
517  Vec_IntForEachEntryDouble( p->vClasses, iBegin, nSize, i )
518  {
519  if ( nSize == 2 )
520  break;
521  }
522  assert( nSize > 1 );
523 
524  if ( nSize == 2 )
525  {
526  assert( p->pUniques[Gia_IsoGetItem(p, iBegin)] == 0 );
527  p->pUniques[Gia_IsoGetItem(p, iBegin)] = p->nUniques++;
528  p->nSingles++;
529  p->nEntries--;
530 
531  assert( p->pUniques[Gia_IsoGetItem(p, iBegin+1)] == 0 );
532  p->pUniques[Gia_IsoGetItem(p, iBegin+1)] = p->nUniques++;
533  p->nSingles++;
534  p->nEntries--;
535  }
536  else
537  {
538  assert( p->pUniques[Gia_IsoGetItem(p, iBegin)] == 0 );
539  p->pUniques[Gia_IsoGetItem(p, iBegin)] = p->nUniques++;
540  p->nSingles++;
541  p->nEntries--;
542  }
543 
544  for ( ; i < Vec_IntSize(p->vClasses) - 2; i += 2 )
545  {
546  p->vClasses->pArray[i+0] = p->vClasses->pArray[i+2];
547  p->vClasses->pArray[i+1] = p->vClasses->pArray[i+3];
548  }
550 
551  printf( "Broke ties in class %d of size %d at level %d.\n", i/2, nSize, p->pLevels[Gia_IsoGetItem(p, iBegin)] );
552 }
int * pUniques
Definition: giaIso.c:77
int nSingles
Definition: giaIso.c:73
static unsigned Gia_IsoGetItem(Gia_IsoMan_t *p, int i)
Definition: giaIso.c:94
int * pLevels
Definition: giaIso.c:76
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition: vecInt.h:66
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int nEntries
Definition: giaIso.c:74
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
Definition: bblif.c:435
#define assert(ex)
Definition: util_old.h:213
Vec_Int_t * vClasses
Definition: giaIso.c:82
int nUniques
Definition: giaIso.c:72
void Gia_IsoAssignOneClass3 ( Gia_IsoMan_t p)

Definition at line 554 of file giaIso.c.

555 {
556  int iBegin, nSize;
557  // find the last class
558  assert( Vec_IntSize(p->vClasses) > 0 );
559  iBegin = Vec_IntEntry( p->vClasses, Vec_IntSize(p->vClasses) - 2 );
560  nSize = Vec_IntEntry( p->vClasses, Vec_IntSize(p->vClasses) - 1 );
562 
563  // assign the class
564  assert( nSize > 1 );
565  if ( nSize == 2 )
566  {
567  assert( p->pUniques[Gia_IsoGetItem(p, iBegin)] == 0 );
568  p->pUniques[Gia_IsoGetItem(p, iBegin)] = p->nUniques++;
569  p->nSingles++;
570  p->nEntries--;
571 
572  assert( p->pUniques[Gia_IsoGetItem(p, iBegin+1)] == 0 );
573  p->pUniques[Gia_IsoGetItem(p, iBegin+1)] = p->nUniques++;
574  p->nSingles++;
575  p->nEntries--;
576  }
577  else
578  {
579  assert( p->pUniques[Gia_IsoGetItem(p, iBegin)] == 0 );
580  p->pUniques[Gia_IsoGetItem(p, iBegin)] = p->nUniques++;
581  p->nSingles++;
582  p->nEntries--;
583  }
584  printf( "Broke ties in last class of size %d at level %d.\n", nSize, p->pLevels[Gia_IsoGetItem(p, iBegin)] );
585 }
int * pUniques
Definition: giaIso.c:77
int nSingles
Definition: giaIso.c:73
static unsigned Gia_IsoGetItem(Gia_IsoMan_t *p, int i)
Definition: giaIso.c:94
int * pLevels
Definition: giaIso.c:76
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int nEntries
Definition: giaIso.c:74
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
Definition: bblif.c:435
#define assert(ex)
Definition: util_old.h:213
Vec_Int_t * vClasses
Definition: giaIso.c:82
int nUniques
Definition: giaIso.c:72
void Gia_IsoAssignUnique ( Gia_IsoMan_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 265 of file giaIso.c.

266 {
267  int i, iBegin, nSize;
268  p->nSingles = 0;
269  Vec_IntClear( p->vClasses2 );
270  Vec_IntForEachEntryDouble( p->vClasses, iBegin, nSize, i )
271  {
272  if ( nSize == 1 )
273  {
274  assert( p->pUniques[Gia_IsoGetItem(p, iBegin)] == 0 );
275  p->pUniques[Gia_IsoGetItem(p, iBegin)] = p->nUniques++;
276  p->nSingles++;
277  }
278  else
279  {
280  Vec_IntPush( p->vClasses2, iBegin );
281  Vec_IntPush( p->vClasses2, nSize );
282  }
283  }
284  ABC_SWAP( Vec_Int_t *, p->vClasses, p->vClasses2 );
285  p->nEntries -= p->nSingles;
286 }
int * pUniques
Definition: giaIso.c:77
Vec_Int_t * vClasses2
Definition: giaIso.c:83
int nSingles
Definition: giaIso.c:73
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
static unsigned Gia_IsoGetItem(Gia_IsoMan_t *p, int i)
Definition: giaIso.c:94
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition: vecInt.h:66
int nEntries
Definition: giaIso.c:74
#define assert(ex)
Definition: util_old.h:213
Vec_Int_t * vClasses
Definition: giaIso.c:82
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
int nUniques
Definition: giaIso.c:72
Vec_Ptr_t* Gia_IsoCollectCosClasses ( Gia_IsoMan_t p,
int  fVerbose 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 386 of file giaIso.c.

387 {
388  Vec_Ptr_t * vGroups;
389  Vec_Int_t * vLevel;
390  Gia_Obj_t * pObj;
391  int i, k, iBegin, nSize;
392  // add singletons
393  vGroups = Vec_PtrAlloc( 1000 );
394  Gia_ManForEachPo( p->pGia, pObj, i )
395  if ( p->pUniques[Gia_ObjId(p->pGia, pObj)] > 0 )
396  {
397  vLevel = Vec_IntAlloc( 1 );
398  Vec_IntPush( vLevel, i );
399  Vec_PtrPush( vGroups, vLevel );
400  }
401 
402  // add groups
403  Vec_IntForEachEntryDouble( p->vClasses, iBegin, nSize, i )
404  {
405  for ( k = 0; k < nSize; k++ )
406  {
407  pObj = Gia_ManObj( p->pGia, Gia_IsoGetItem(p,iBegin+k) );
408  if ( Gia_ObjIsPo(p->pGia, pObj) )
409  break;
410  }
411  if ( k == nSize )
412  continue;
413  vLevel = Vec_IntAlloc( 8 );
414  for ( k = 0; k < nSize; k++ )
415  {
416  pObj = Gia_ManObj( p->pGia, Gia_IsoGetItem(p,iBegin+k) );
417  if ( Gia_ObjIsPo(p->pGia, pObj) )
418  Vec_IntPush( vLevel, Gia_ObjCioId(pObj) );
419  }
420  Vec_PtrPush( vGroups, vLevel );
421  }
422  // canonicize order
423  Vec_PtrForEachEntry( Vec_Int_t *, vGroups, vLevel, i )
424  Vec_IntSort( vLevel, 0 );
425  Vec_VecSortByFirstInt( (Vec_Vec_t *)vGroups, 0 );
426 // Vec_VecFree( (Vec_Vec_t *)vGroups );
427 // return NULL;
428  return vGroups;
429 }
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
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Gia_Man_t * pGia
Definition: giaIso.c:70
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static void Vec_IntSort(Vec_Int_t *p, int fReverse)
Definition: vecInt.h:1293
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
static unsigned Gia_IsoGetItem(Gia_IsoMan_t *p, int i)
Definition: giaIso.c:94
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
if(last==0)
Definition: sparse_int.h:34
static void Vec_VecSortByFirstInt(Vec_Vec_t *p, int fReverse)
Definition: vecVec.h:595
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition: vecInt.h:66
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static int Gia_ObjIsPo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:442
Vec_Int_t * vClasses
Definition: giaIso.c:82
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036
static int Gia_ObjCioId(Gia_Obj_t *pObj)
Definition: gia.h:411
Vec_Ptr_t* Gia_IsoDeriveEquivPos ( Gia_Man_t pGia,
int  fForward,
int  fVerbose 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 720 of file giaIso.c.

721 {
722  int nIterMax = 10000;
723  int nFixedPoint = 1;
724  Gia_IsoMan_t * p;
725  Vec_Ptr_t * vEquivs = NULL;
726  int fRefined, fRefinedAll;
727  int i, c;
728  abctime clk = Abc_Clock(), clkTotal = Abc_Clock();
729  assert( Gia_ManCiNum(pGia) > 0 );
730  assert( Gia_ManPoNum(pGia) > 0 );
731 
732  Gia_ManCleanValue( pGia );
733  p = Gia_IsoManStart( pGia );
734  Gia_IsoPrepare( p );
735  Gia_IsoAssignUnique( p );
736  p->timeStart = Abc_Clock() - clk;
737  if ( fVerbose )
738  Gia_IsoPrint( p, 0, Abc_Clock() - clkTotal );
739 
740 // Gia_IsoRecognizeMuxes( pGia );
741 
742  i = 0;
743  if ( fForward )
744  {
745  for ( c = 0; i < nIterMax && c < nFixedPoint+1; i++, c = fRefined ? 0 : c+1 )
746  {
747  clk = Abc_Clock(); Gia_IsoSimulate( p, i ); p->timeSim += Abc_Clock() - clk;
748  clk = Abc_Clock(); fRefined = Gia_IsoSort( p ); p->timeRefine += Abc_Clock() - clk;
749  if ( fVerbose )
750  Gia_IsoPrint( p, i+1, Abc_Clock() - clkTotal );
751  }
752  }
753  else
754  {
755  while ( Vec_IntSize(p->vClasses) > 0 )
756  {
757  for ( fRefinedAll = 1; i < nIterMax && fRefinedAll; )
758  {
759  fRefinedAll = 0;
760  for ( c = 0; i < nIterMax && c < nFixedPoint+1; i++, c = fRefined ? 0 : c+1 )
761  {
762  clk = Abc_Clock(); Gia_IsoSimulate( p, i ); p->timeSim += Abc_Clock() - clk;
763  clk = Abc_Clock(); fRefined = Gia_IsoSort( p ); p->timeRefine += Abc_Clock() - clk;
764  if ( fVerbose )
765  Gia_IsoPrint( p, i+1, Abc_Clock() - clkTotal );
766  fRefinedAll |= fRefined;
767  }
768  for ( c = 0; i < nIterMax && c < nFixedPoint+1; i++, c = fRefined ? 0 : c+1 )
769  {
770  clk = Abc_Clock(); Gia_IsoSimulateBack( p, i ); p->timeSim += Abc_Clock() - clk;
771  clk = Abc_Clock(); fRefined = Gia_IsoSort( p ); p->timeRefine += Abc_Clock() - clk;
772  if ( fVerbose )
773  Gia_IsoPrint( p, i+1, Abc_Clock() - clkTotal );
774  fRefinedAll |= fRefined;
775  }
776  }
777  if ( !fRefinedAll )
778  break;
779  }
780 
781 // Gia_IsoReportTopmost( p );
782 
783  while ( Vec_IntSize(p->vClasses) > 0 )
784  {
785  Gia_IsoAssignOneClass( p, fVerbose );
786  for ( fRefinedAll = 1; i < nIterMax && fRefinedAll; )
787  {
788  fRefinedAll = 0;
789  for ( c = 0; i < nIterMax && c < nFixedPoint; i++, c = fRefined ? 0 : c+1 )
790  {
791  clk = Abc_Clock(); Gia_IsoSimulateBack( p, i ); p->timeSim += Abc_Clock() - clk;
792  clk = Abc_Clock(); fRefined = Gia_IsoSort( p ); p->timeRefine += Abc_Clock() - clk;
793  if ( fVerbose )
794  Gia_IsoPrint( p, i+1, Abc_Clock() - clkTotal );
795  fRefinedAll |= fRefined;
796  }
797  for ( c = 0; i < nIterMax && c < nFixedPoint; i++, c = fRefined ? 0 : c+1 )
798  {
799  clk = Abc_Clock(); Gia_IsoSimulate( p, i ); p->timeSim += Abc_Clock() - clk;
800  clk = Abc_Clock(); fRefined = Gia_IsoSort( p ); p->timeRefine += Abc_Clock() - clk;
801  if ( fVerbose )
802  Gia_IsoPrint( p, i+1, Abc_Clock() - clkTotal );
803  fRefinedAll |= fRefined;
804 // if ( fRefined )
805 // printf( "Refinedment happened.\n" );
806  }
807  }
808  }
809 
810  if ( fVerbose )
811  Gia_IsoPrint( p, i+2, Abc_Clock() - clkTotal );
812  }
813 // Gia_IsoPrintClasses( p );
814  if ( fVerbose )
815  {
816  p->timeTotal = Abc_Clock() - clkTotal;
817  p->timeOther = p->timeTotal - p->timeStart - p->timeSim - p->timeRefine;
818  ABC_PRTP( "Start ", p->timeStart, p->timeTotal );
819  ABC_PRTP( "Simulate ", p->timeSim, p->timeTotal );
820  ABC_PRTP( "Refine ", p->timeRefine-p->timeSort, p->timeTotal );
821  ABC_PRTP( "Sort ", p->timeSort, p->timeTotal );
822  ABC_PRTP( "Other ", p->timeOther, p->timeTotal );
823  ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
824  }
825 
826  if ( Gia_ManPoNum(p->pGia) > 1 )
827  vEquivs = Gia_IsoCollectCosClasses( p, fVerbose );
829  Gia_IsoManStop( p );
830 
831  return vEquivs;
832 }
abctime timeStart
Definition: giaIso.c:85
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Gia_IsoAssignOneClass(Gia_IsoMan_t *p, int fVerbose)
Definition: giaIso.c:587
void Gia_IsoManStop(Gia_IsoMan_t *p)
Definition: giaIso.c:131
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Gia_Man_t * pGia
Definition: giaIso.c:70
int Gia_IsoSort(Gia_IsoMan_t *p)
Definition: giaIso.c:299
void Gia_ManCleanValue(Gia_Man_t *p)
Definition: giaUtil.c:310
static abctime Abc_Clock()
Definition: abc_global.h:279
void Gia_IsoAssignUnique(Gia_IsoMan_t *p)
Definition: giaIso.c:265
Gia_IsoMan_t * Gia_IsoManStart(Gia_Man_t *pGia)
FUNCTION DEFINITIONS ///.
Definition: giaIso.c:114
Vec_Ptr_t * Gia_IsoCollectCosClasses(Gia_IsoMan_t *p, int fVerbose)
Definition: giaIso.c:386
#define ABC_PRTP(a, t, T)
Definition: abc_global.h:223
void Gia_IsoPrint(Gia_IsoMan_t *p, int Iter, abctime Time)
Definition: giaIso.c:181
void Gia_IsoSimulate(Gia_IsoMan_t *p, int Iter)
Definition: giaIso.c:453
abctime timeOther
Definition: giaIso.c:89
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
void Gia_IsoSimulateBack(Gia_IsoMan_t *p, int Iter)
Definition: giaIso.c:480
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
void Gia_IsoManTransferUnique(Gia_IsoMan_t *p)
Definition: giaIso.c:142
#define assert(ex)
Definition: util_old.h:213
Vec_Int_t * vClasses
Definition: giaIso.c:82
ABC_INT64_T abctime
Definition: abc_global.h:278
void Gia_IsoPrepare(Gia_IsoMan_t *p)
Definition: giaIso.c:204
abctime timeSim
Definition: giaIso.c:86
abctime timeTotal
Definition: giaIso.c:90
abctime timeSort
Definition: giaIso.c:88
abctime timeRefine
Definition: giaIso.c:87
static unsigned Gia_IsoGetItem ( Gia_IsoMan_t p,
int  i 
)
inlinestatic

Definition at line 94 of file giaIso.c.

94 { return (unsigned)(p->pStoreW[i] >> 32); }
word * pStoreW
Definition: giaIso.c:78
static unsigned Gia_IsoGetValue ( Gia_IsoMan_t p,
int  i 
)
inlinestatic

Definition at line 93 of file giaIso.c.

93 { return (unsigned)(p->pStoreW[i]); }
word * pStoreW
Definition: giaIso.c:78
Gia_IsoMan_t* Gia_IsoManStart ( Gia_Man_t pGia)

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 114 of file giaIso.c.

115 {
116  Gia_IsoMan_t * p;
117  p = ABC_CALLOC( Gia_IsoMan_t, 1 );
118  p->pGia = pGia;
119  p->nObjs = Gia_ManObjNum( pGia );
120  p->nUniques = 1;
121  p->nEntries = p->nObjs;
122  // internal data
123  p->pLevels = ABC_CALLOC( int, p->nObjs );
124  p->pUniques = ABC_CALLOC( int, p->nObjs );
125  p->pStoreW = ABC_CALLOC( word, p->nObjs );
126  // class representation
127  p->vClasses = Vec_IntAlloc( p->nObjs/4 );
128  p->vClasses2 = Vec_IntAlloc( p->nObjs/4 );
129  return p;
130 }
int * pUniques
Definition: giaIso.c:77
Vec_Int_t * vClasses2
Definition: giaIso.c:83
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Gia_Man_t * pGia
Definition: giaIso.c:70
int * pLevels
Definition: giaIso.c:76
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int nObjs
Definition: giaIso.c:71
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
word * pStoreW
Definition: giaIso.c:78
int nEntries
Definition: giaIso.c:74
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Vec_Int_t * vClasses
Definition: giaIso.c:82
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
int nUniques
Definition: giaIso.c:72
void Gia_IsoManStop ( Gia_IsoMan_t p)

Definition at line 131 of file giaIso.c.

132 {
133  // class representation
134  Vec_IntFree( p->vClasses );
135  Vec_IntFree( p->vClasses2 );
136  // internal data
137  ABC_FREE( p->pLevels );
138  ABC_FREE( p->pUniques );
139  ABC_FREE( p->pStoreW );
140  ABC_FREE( p );
141 }
int * pUniques
Definition: giaIso.c:77
Vec_Int_t * vClasses2
Definition: giaIso.c:83
int * pLevels
Definition: giaIso.c:76
word * pStoreW
Definition: giaIso.c:78
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Int_t * vClasses
Definition: giaIso.c:82
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
void Gia_IsoManTransferUnique ( Gia_IsoMan_t p)

Definition at line 142 of file giaIso.c.

143 {
144  Gia_Obj_t * pObj;
145  int i;
146  // copy unique numbers into the nodes
147  Gia_ManForEachObj( p->pGia, pObj, i )
148  pObj->Value = p->pUniques[i];
149 }
Gia_Man_t * pGia
Definition: giaIso.c:70
Definition: gia.h:75
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition: gia.h:984
void Gia_IsoPrepare ( Gia_IsoMan_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 204 of file giaIso.c.

205 {
206  Gia_Obj_t * pObj;
207  int * pLevBegins, * pLevSizes;
208  int i, iObj, MaxLev = 0;
209  // assign levels
210  p->pLevels[0] = 0;
211  Gia_ManForEachCi( p->pGia, pObj, i )
212  p->pLevels[Gia_ObjId(p->pGia, pObj)] = 0;
213  Gia_ManForEachAnd( p->pGia, pObj, i )
214  p->pLevels[i] = 1 + Abc_MaxInt( p->pLevels[Gia_ObjFaninId0(pObj, i)], p->pLevels[Gia_ObjFaninId1(pObj, i)] );
215  Gia_ManForEachCo( p->pGia, pObj, i )
216  {
217  iObj = Gia_ObjId(p->pGia, pObj);
218  p->pLevels[iObj] = 1 + p->pLevels[Gia_ObjFaninId0(pObj, iObj)]; // "1 +" is different!
219  MaxLev = Abc_MaxInt( MaxLev, p->pLevels[Gia_ObjId(p->pGia, pObj)] );
220  }
221 
222  // count nodes on each level
223  pLevSizes = ABC_CALLOC( int, MaxLev+1 );
224  for ( i = 1; i < p->nObjs; i++ )
225  pLevSizes[p->pLevels[i]]++;
226  // start classes
227  Vec_IntClear( p->vClasses );
228  Vec_IntPush( p->vClasses, 0 );
229  Vec_IntPush( p->vClasses, 1 );
230  // find beginning of each level
231  pLevBegins = ABC_CALLOC( int, MaxLev+2 );
232  pLevBegins[0] = 1;
233  for ( i = 0; i <= MaxLev; i++ )
234  {
235  assert( pLevSizes[i] > 0 ); // we do not allow AIG with a const node and no PIs
236  Vec_IntPush( p->vClasses, pLevBegins[i] );
237  Vec_IntPush( p->vClasses, pLevSizes[i] );
238  pLevBegins[i+1] = pLevBegins[i] + pLevSizes[i];
239  }
240  assert( pLevBegins[MaxLev+1] == p->nObjs );
241  // put them into the structure
242  for ( i = 1; i < p->nObjs; i++ )
243  Gia_IsoSetItem( p, pLevBegins[p->pLevels[i]]++, i );
244  ABC_FREE( pLevBegins );
245  ABC_FREE( pLevSizes );
246 /*
247  // print the results
248  for ( i = 0; i < p->nObjs; i++ )
249  printf( "%3d : (%d,%d)\n", i, Gia_IsoGetItem(p, i), Gia_IsoGetValue(p, i) );
250  printf( "\n" );
251 */
252 }
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
Gia_Man_t * pGia
Definition: giaIso.c:70
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
Definition: gia.h:75
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
int * pLevels
Definition: giaIso.c:76
int nObjs
Definition: giaIso.c:71
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
static void Gia_IsoSetItem(Gia_IsoMan_t *p, int i, unsigned v)
Definition: giaIso.c:97
Vec_Int_t * vClasses
Definition: giaIso.c:82
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
void Gia_IsoPrint ( Gia_IsoMan_t p,
int  Iter,
abctime  Time 
)

Definition at line 181 of file giaIso.c.

182 {
183  printf( "Iter %4d : ", Iter );
184  printf( "Entries =%8d. ", p->nEntries );
185 // printf( "Classes =%8d. ", Vec_IntSize(p->vClasses)/2 );
186  printf( "Uniques =%8d. ", p->nUniques );
187  printf( "Singles =%8d. ", p->nSingles );
188  printf( "%9.2f sec", (float)(Time)/(float)(CLOCKS_PER_SEC) );
189  printf( "\n" );
190  fflush( stdout );
191 }
int nSingles
Definition: giaIso.c:73
int nEntries
Definition: giaIso.c:74
int nUniques
Definition: giaIso.c:72
void Gia_IsoPrintClasses ( Gia_IsoMan_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 163 of file giaIso.c.

164 {
165  int fVerbose = 0;
166  int i, k, iBegin, nSize;
167  printf( "The total of %d classes:\n", Vec_IntSize(p->vClasses)/2 );
168  Vec_IntForEachEntryDouble( p->vClasses, iBegin, nSize, i )
169  {
170  printf( "%5d : (%3d,%3d) ", i/2, iBegin, nSize );
171  if ( fVerbose )
172  {
173  printf( "{" );
174  for ( k = 0; k < nSize; k++ )
175  printf( " %3d,%08x", Gia_IsoGetItem(p, iBegin+k), Gia_IsoGetValue(p, iBegin+k) );
176  printf( " }" );
177  }
178  printf( "\n" );
179  }
180 }
static unsigned Gia_IsoGetItem(Gia_IsoMan_t *p, int i)
Definition: giaIso.c:94
static unsigned Gia_IsoGetValue(Gia_IsoMan_t *p, int i)
Definition: giaIso.c:93
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition: vecInt.h:66
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Vec_Int_t * vClasses
Definition: giaIso.c:82
void Gia_IsoRecognizeMuxes ( Gia_Man_t pGia)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 682 of file giaIso.c.

683 {
684  Gia_Obj_t * pObj, * pObjC, * pObj1, * pObj0;
685  int i;
686  Gia_ManForEachAnd( pGia, pObj, i )
687  {
688  if ( !Gia_ObjIsMuxType(pObj) )
689  continue;
690  pObjC = Gia_ObjRecognizeMux( pObj, &pObj1, &pObj0 );
691  if ( Gia_Regular(pObj0) == Gia_Regular(pObj1) )
692  {
693  // this is XOR
694  Gia_Regular(pObj)->Value += s_256Primes[233];
695  Gia_Regular(pObjC)->Value += s_256Primes[234];
696  Gia_Regular(pObj0)->Value += s_256Primes[234];
697  }
698  else
699  {
700  // this is MUX
701  Gia_Regular(pObj)->Value += s_256Primes[235];
702  Gia_Regular(pObjC)->Value += s_256Primes[236];
703  Gia_Regular(pObj0)->Value += s_256Primes[237];
704  Gia_Regular(pObj1)->Value += s_256Primes[237];
705  }
706  }
707 }
static Gia_Obj_t * Gia_Regular(Gia_Obj_t *p)
Definition: gia.h:377
Definition: gia.h:75
static int s_256Primes[ISO_MASK+1]
Definition: giaIso.c:27
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
Definition: giaUtil.c:885
Gia_Obj_t * Gia_ObjRecognizeMux(Gia_Obj_t *pNode, Gia_Obj_t **ppNodeT, Gia_Obj_t **ppNodeE)
Definition: giaUtil.c:959
unsigned Value
Definition: gia.h:87
void Gia_IsoReportTopmost ( Gia_IsoMan_t p)

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

Synopsis [Report topmost equiv nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 631 of file giaIso.c.

632 {
633  Gia_Obj_t * pObj;
634  int i, k, iBegin, nSize, Counter = 0;
635  // go through equivalence classes
637  Vec_IntForEachEntryDouble( p->vClasses, iBegin, nSize, i )
638  {
639 // printf( "%d(%d) ", nSize, p->pLevels[Gia_IsoGetItem(p, iBegin)] );
640  for ( k = 0; k < nSize; k++ )
641  {
642  pObj = Gia_ManObj( p->pGia, Gia_IsoGetItem(p, iBegin+k) );
643  if ( Gia_ObjIsAnd(pObj) )
644  {
647  }
648  else if ( Gia_ObjIsRo(p->pGia, pObj) )
650  }
651  }
652 // printf( "\n" );
653 
654  // report non-labeled nodes
655  Vec_IntForEachEntryDouble( p->vClasses, iBegin, nSize, i )
656  {
657  for ( k = 0; k < nSize; k++ )
658  {
659  pObj = Gia_ManObj( p->pGia, Gia_IsoGetItem(p, iBegin+k) );
660  if ( !Gia_ObjIsTravIdCurrent(p->pGia, pObj) )
661  {
662  printf( "%5d : ", ++Counter );
663  printf( "Obj %6d : Level = %4d. iBegin = %4d. Size = %4d.\n",
664  Gia_ObjId(p->pGia, pObj), p->pLevels[Gia_ObjId(p->pGia, pObj)], iBegin, nSize );
665  break;
666  }
667  }
668  }
669 }
static int Gia_ObjIsTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:533
Gia_Man_t * pGia
Definition: giaIso.c:70
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
static unsigned Gia_IsoGetItem(Gia_IsoMan_t *p, int i)
Definition: giaIso.c:94
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
int * pLevels
Definition: giaIso.c:76
static int Gia_ObjIsRo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:443
static Gia_Obj_t * Gia_ObjRoToRi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:446
static void Gia_ObjSetTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:531
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Counter
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition: vecInt.h:66
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
Vec_Int_t * vClasses
Definition: giaIso.c:82
static void Gia_IsoSetItem ( Gia_IsoMan_t p,
int  i,
unsigned  v 
)
inlinestatic

Definition at line 97 of file giaIso.c.

97 { ((unsigned *)(p->pStoreW + i))[1] = v; }
word * pStoreW
Definition: giaIso.c:78
static void Gia_IsoSetValue ( Gia_IsoMan_t p,
int  i,
unsigned  v 
)
inlinestatic

Definition at line 96 of file giaIso.c.

96 { ((unsigned *)(p->pStoreW + i))[0] = v; }
word * pStoreW
Definition: giaIso.c:78
void Gia_IsoSimulate ( Gia_IsoMan_t p,
int  Iter 
)

Definition at line 453 of file giaIso.c.

454 {
455  Gia_Obj_t * pObj, * pObjF;
456  int i, iObj;
457  // initialize constant, inputs, and flops in the first frame
459  Gia_ManForEachPi( p->pGia, pObj, i )
460  pObj->Value += s_256Primes[ISO_MASK-1];
461  if ( Iter == 0 )
462  Gia_ManForEachRo( p->pGia, pObj, i )
463  pObj->Value += s_256Primes[ISO_MASK-2];
464  // simulate nodes
465  Gia_ManForEachAnd( p->pGia, pObj, i )
466  {
467  pObj->Value += Gia_ObjFanin0(pObj)->Value + Gia_IsoUpdate(p, Iter, Gia_ObjFaninId0(pObj, i), Gia_ObjFaninC0(pObj));
468  pObj->Value += Gia_ObjFanin1(pObj)->Value + Gia_IsoUpdate(p, Iter, Gia_ObjFaninId1(pObj, i), Gia_ObjFaninC1(pObj));
469  }
470  // simulate COs
471  Gia_ManForEachCo( p->pGia, pObj, i )
472  {
473  iObj = Gia_ObjId(p->pGia, pObj);
474  pObj->Value += Gia_ObjFanin0(pObj)->Value + Gia_IsoUpdate(p, Iter, Gia_ObjFaninId0(pObj, iObj), Gia_ObjFaninC0(pObj));
475  }
476  // transfer flop values
477  Gia_ManForEachRiRo( p->pGia, pObjF, pObj, i )
478  pObj->Value += pObjF->Value;
479 }
#define ISO_MASK
Definition: giaIso.c:26
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
Gia_Man_t * pGia
Definition: giaIso.c:70
Definition: gia.h:75
#define Gia_ManForEachRiRo(p, pObjRi, pObjRo, i)
Definition: gia.h:1042
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static int s_256Primes[ISO_MASK+1]
Definition: giaIso.c:27
if(last==0)
Definition: sparse_int.h:34
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
static unsigned Gia_IsoUpdate(Gia_IsoMan_t *p, int Iter, int iObj, int fCompl)
Definition: giaIso.c:446
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
#define Gia_ManForEachRo(p, pObj, i)
Definition: gia.h:1038
unsigned Value
Definition: gia.h:87
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
void Gia_IsoSimulateBack ( Gia_IsoMan_t p,
int  Iter 
)

Definition at line 480 of file giaIso.c.

481 {
482  Gia_Obj_t * pObj, * pObjF;
483  int i, iObj;
484  // simulate COs
485  Gia_ManForEachCo( p->pGia, pObj, i )
486  {
487  iObj = Gia_ObjId(p->pGia, pObj);
488  Gia_ObjFanin0(pObj)->Value += pObj->Value + Gia_IsoUpdate(p, Iter, iObj, Gia_ObjFaninC0(pObj));
489  }
490  // simulate objects
491  Gia_ManForEachAndReverse( p->pGia, pObj, i )
492  {
493  Gia_ObjFanin0(pObj)->Value += pObj->Value + Gia_IsoUpdate(p, Iter, i, Gia_ObjFaninC0(pObj));
494  Gia_ObjFanin1(pObj)->Value += pObj->Value + Gia_IsoUpdate(p, Iter, i, Gia_ObjFaninC1(pObj));
495  }
496  // transfer flop values
497  Gia_ManForEachRiRo( p->pGia, pObjF, pObj, i )
498  pObjF->Value += pObj->Value;
499 }
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
Gia_Man_t * pGia
Definition: giaIso.c:70
Definition: gia.h:75
#define Gia_ManForEachRiRo(p, pObjRi, pObjRo, i)
Definition: gia.h:1042
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
#define Gia_ManForEachAndReverse(p, pObj, i)
Definition: gia.h:1010
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static unsigned Gia_IsoUpdate(Gia_IsoMan_t *p, int Iter, int iObj, int fCompl)
Definition: giaIso.c:446
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
unsigned Value
Definition: gia.h:87
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
int Gia_IsoSort ( Gia_IsoMan_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 299 of file giaIso.c.

300 {
301  Gia_Obj_t * pObj, * pObj0;
302  int i, k, fSameValue, iBegin, iBeginOld, nSize, nSizeNew;
303  int fRefined = 0;
304  abctime clk;
305 
306  // go through the equiv classes
307  p->nSingles = 0;
308  Vec_IntClear( p->vClasses2 );
309  Vec_IntForEachEntryDouble( p->vClasses, iBegin, nSize, i )
310  {
311  assert( nSize > 1 );
312  fSameValue = 1;
313  pObj0 = Gia_ManObj( p->pGia, Gia_IsoGetItem(p,iBegin) );
314  for ( k = 0; k < nSize; k++ )
315  {
316  pObj = Gia_ManObj( p->pGia, Gia_IsoGetItem(p,iBegin+k) );
317  Gia_IsoSetValue( p, iBegin+k, pObj->Value );
318  if ( pObj->Value != pObj0->Value )
319  fSameValue = 0;
320  }
321  if ( fSameValue )
322  {
323  Vec_IntPush( p->vClasses2, iBegin );
324  Vec_IntPush( p->vClasses2, nSize );
325  continue;
326  }
327  fRefined = 1;
328  // sort objects
329  clk = Abc_Clock();
330  Abc_QuickSort3( p->pStoreW + iBegin, nSize, 0 );
331  p->timeSort += Abc_Clock() - clk;
332  // divide into new classes
333  iBeginOld = iBegin;
334  pObj0 = Gia_ManObj( p->pGia, Gia_IsoGetItem(p,iBegin) );
335  for ( k = 1; k < nSize; k++ )
336  {
337  pObj = Gia_ManObj( p->pGia, Gia_IsoGetItem(p,iBegin+k) );
338  if ( pObj0->Value == pObj->Value )
339  continue;
340  nSizeNew = iBegin + k - iBeginOld;
341  if ( nSizeNew == 1 )
342  {
343  assert( p->pUniques[Gia_IsoGetItem(p, iBeginOld)] == 0 );
344  p->pUniques[Gia_IsoGetItem(p, iBeginOld)] = p->nUniques++;
345  p->nSingles++;
346  }
347  else
348  {
349  Vec_IntPush( p->vClasses2, iBeginOld );
350  Vec_IntPush( p->vClasses2, nSizeNew );
351  }
352  iBeginOld = iBegin + k;
353  pObj0 = pObj;
354  }
355  // add the last one
356  nSizeNew = iBegin + k - iBeginOld;
357  if ( nSizeNew == 1 )
358  {
359  assert( p->pUniques[Gia_IsoGetItem(p, iBeginOld)] == 0 );
360  p->pUniques[Gia_IsoGetItem(p, iBeginOld)] = p->nUniques++;
361  p->nSingles++;
362  }
363  else
364  {
365  Vec_IntPush( p->vClasses2, iBeginOld );
366  Vec_IntPush( p->vClasses2, nSizeNew );
367  }
368  }
369 
370  ABC_SWAP( Vec_Int_t *, p->vClasses, p->vClasses2 );
371  p->nEntries -= p->nSingles;
372  return fRefined;
373 }
int * pUniques
Definition: giaIso.c:77
Vec_Int_t * vClasses2
Definition: giaIso.c:83
int nSingles
Definition: giaIso.c:73
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Gia_Man_t * pGia
Definition: giaIso.c:70
static void Gia_IsoSetValue(Gia_IsoMan_t *p, int i, unsigned v)
Definition: giaIso.c:96
static abctime Abc_Clock()
Definition: abc_global.h:279
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
static unsigned Gia_IsoGetItem(Gia_IsoMan_t *p, int i)
Definition: giaIso.c:94
word * pStoreW
Definition: giaIso.c:78
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
void Abc_QuickSort3(word *pData, int nSize, int fDecrease)
Definition: utilSort.c:680
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition: vecInt.h:66
int nEntries
Definition: giaIso.c:74
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
Vec_Int_t * vClasses
Definition: giaIso.c:82
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
ABC_INT64_T abctime
Definition: abc_global.h:278
abctime timeSort
Definition: giaIso.c:88
int nUniques
Definition: giaIso.c:72
void Gia_IsoTest ( Gia_Man_t p,
Abc_Cex_t pCex,
int  fVerbose 
)

Definition at line 1280 of file giaIso.c.

1281 {
1282  Abc_Cex_t * pCexNew;
1283  Vec_Int_t * vPiPerm;
1284  Vec_Ptr_t * vPosEquivs, * vPisPerm;
1285  Vec_Int_t * vPerm0, * vPerm1;
1286  Gia_Man_t * pPerm, * pDouble, * pAig;
1287  assert( Gia_ManPoNum(p) == 1 );
1288  assert( Gia_ManRegNum(p) > 0 );
1289  // generate random permutation of PIs
1290  vPiPerm = Gia_IsoTestGenPerm( Gia_ManPiNum(p) );
1291  printf( "Considering random permutation of the primary inputs of the AIG:\n" );
1292  Vec_IntPrint( vPiPerm );
1293  // create AIG with two primary outputs (original and permuted)
1294  pPerm = Gia_ManDupPerm( p, vPiPerm );
1295  pDouble = Gia_ManDupAppendNew( p, pPerm );
1296 //Gia_AigerWrite( pDouble, "test.aig", 0, 0 );
1297 
1298  // analyze the two-output miter
1299  pAig = Gia_ManIsoReduce( pDouble, &vPosEquivs, &vPisPerm, 0, 0, 0, 0 );
1300  Vec_VecFree( (Vec_Vec_t *)vPosEquivs );
1301 
1302  // given CEX for output 0, derive CEX for output 1
1303  vPerm0 = (Vec_Int_t *)Vec_PtrEntry( vPisPerm, 0 );
1304  vPerm1 = (Vec_Int_t *)Vec_PtrEntry( vPisPerm, 1 );
1305  pCexNew = Abc_CexPermuteTwo( pCex, vPerm0, vPerm1 );
1306  Vec_VecFree( (Vec_Vec_t *)vPisPerm );
1307 
1308  // check that original CEX and the resulting CEX is valid
1309  if ( Gia_ManVerifyCex(p, pCex, 0) )
1310  printf( "CEX for the init AIG is valid.\n" );
1311  else
1312  printf( "CEX for the init AIG is not valid.\n" );
1313  if ( Gia_ManVerifyCex(pPerm, pCexNew, 0) )
1314  printf( "CEX for the perm AIG is valid.\n" );
1315  else
1316  printf( "CEX for the perm AIG is not valid.\n" );
1317  // delete
1318  Gia_ManStop( pAig );
1319  Gia_ManStop( pDouble );
1320  Gia_ManStop( pPerm );
1321  Vec_IntFree( vPiPerm );
1322  Abc_CexFree( pCexNew );
1323 }
Gia_Man_t * Gia_ManIsoReduce(Gia_Man_t *pInit, Vec_Ptr_t **pvPosEquivs, Vec_Ptr_t **pvPiPerms, int fEstimate, int fDualOut, int fVerbose, int fVeryVerbose)
Definition: giaIso.c:1075
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
int Gia_ManVerifyCex(Gia_Man_t *pAig, Abc_Cex_t *p, int fDualOut)
DECLARATIONS ///.
Definition: giaCex.c:44
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
Gia_Man_t * Gia_ManDupPerm(Gia_Man_t *p, Vec_Int_t *vPiPerm)
Definition: giaDup.c:632
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Vec_Int_t * Gia_IsoTestGenPerm(int nPis)
Definition: giaIso.c:1267
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
Gia_Man_t * Gia_ManDupAppendNew(Gia_Man_t *pOne, Gia_Man_t *pTwo)
Definition: giaDup.c:783
static int pPerm[13719]
Definition: rwrTemp.c:32
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
Definition: gia.h:95
Abc_Cex_t * Abc_CexPermuteTwo(Abc_Cex_t *p, Vec_Int_t *vPermOld, Vec_Int_t *vPermNew)
Definition: utilCex.c:515
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
Definition: utilCex.h:39
static void Vec_IntPrint(Vec_Int_t *vVec)
Definition: vecInt.h:1803
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
void Abc_CexFree(Abc_Cex_t *p)
Definition: utilCex.c:371
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
Vec_Int_t* Gia_IsoTestGenPerm ( int  nPis)

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

Synopsis [Test remapping of CEXes for isomorphic POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 1267 of file giaIso.c.

1268 {
1269  Vec_Int_t * vPerm;
1270  int i, * pArray;
1271  vPerm = Vec_IntStartNatural( nPis );
1272  pArray = Vec_IntArray( vPerm );
1273  for ( i = 0; i < nPis; i++ )
1274  {
1275  int iNew = rand() % nPis;
1276  ABC_SWAP( int, pArray[i], pArray[iNew] );
1277  }
1278  return vPerm;
1279 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Vec_Int_t * Vec_IntStartNatural(int nSize)
Definition: bblif.c:192
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
void Gia_IsoTestOld ( Gia_Man_t p,
int  fVerbose 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1241 of file giaIso.c.

1242 {
1243  Vec_Ptr_t * vEquivs;
1244  abctime clk = Abc_Clock();
1245  vEquivs = Gia_IsoDeriveEquivPos( p, 0, fVerbose );
1246  printf( "Reduced %d outputs to %d. ", Gia_ManPoNum(p), vEquivs ? Vec_PtrSize(vEquivs) : 1 );
1247  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1248  if ( fVerbose && vEquivs && Gia_ManPoNum(p) != Vec_PtrSize(vEquivs) )
1249  {
1250  printf( "Nontrivial classes:\n" );
1251 // Vec_VecPrintInt( (Vec_Vec_t *)vEquivs, 1 );
1252  }
1253  Vec_VecFreeP( (Vec_Vec_t **)&vEquivs );
1254 }
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 Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
static void Vec_VecFreeP(Vec_Vec_t **p)
Definition: vecVec.h:367
ABC_INT64_T abctime
Definition: abc_global.h:278
Vec_Ptr_t * Gia_IsoDeriveEquivPos(Gia_Man_t *pGia, int fForward, int fVerbose)
Definition: giaIso.c:720
static unsigned Gia_IsoUpdate ( Gia_IsoMan_t p,
int  Iter,
int  iObj,
int  fCompl 
)
inlinestatic

Definition at line 446 of file giaIso.c.

447 {
448  if ( Iter == 0 ) return Gia_IsoUpdateValue( p->pLevels[iObj], fCompl );
449  if ( p->pUniques[iObj] > 0 ) return Gia_IsoUpdateValue( p->pUniques[iObj], fCompl );
450 // if ( p->pUniques[iObj] > 0 ) return Gia_IsoUpdateValue( 11, fCompl );
451  return 0;
452 }
int * pUniques
Definition: giaIso.c:77
int * pLevels
Definition: giaIso.c:76
static unsigned Gia_IsoUpdateValue(int Value, int fCompl)
Definition: giaIso.c:442
static unsigned Gia_IsoUpdateValue ( int  Value,
int  fCompl 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 442 of file giaIso.c.

443 {
444  return (Value+1) * s_256Primes[Abc_Var2Lit(Value, fCompl) & ISO_MASK];
445 }
#define ISO_MASK
Definition: giaIso.c:26
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static int s_256Primes[ISO_MASK+1]
Definition: giaIso.c:27
void Gia_ManFindCaninicalOrder ( Gia_Man_t p,
Vec_Int_t vCis,
Vec_Int_t vAnds,
Vec_Int_t vCos,
Vec_Int_t **  pvPiPerm 
)

Definition at line 882 of file giaIso.c.

883 {
884  Vec_Ptr_t * vTemp;
885  Gia_Obj_t * pObj;
886  int i;
887 
888  vTemp = Vec_PtrAlloc( 1000 );
889  Vec_IntClear( vCis );
890  Vec_IntClear( vAnds );
891  Vec_IntClear( vCos );
892 
893  // assign unique IDs to PIs
894  Vec_PtrClear( vTemp );
895  Gia_ManForEachPi( p, pObj, i )
896  Vec_PtrPush( vTemp, pObj );
897  Vec_PtrSort( vTemp, (int (*)(void))Gia_ObjCompareByValue );
898  // create the result
899  Vec_PtrForEachEntry( Gia_Obj_t *, vTemp, pObj, i )
900  Vec_IntPush( vCis, Gia_ObjId(p, pObj) );
901  // remember PI permutation
902  if ( pvPiPerm )
903  {
904  *pvPiPerm = Vec_IntAlloc( Gia_ManPiNum(p) );
905  Vec_PtrForEachEntry( Gia_Obj_t *, vTemp, pObj, i )
906  Vec_IntPush( *pvPiPerm, Gia_ObjCioId(pObj) );
907  }
908 
909  // assign unique IDs to POs
910  if ( Gia_ManPoNum(p) == 1 )
911  Vec_IntPush( vCos, Gia_ObjId(p, Gia_ManPo(p, 0)) );
912  else
913  {
914  Vec_PtrClear( vTemp );
915  Gia_ManForEachPo( p, pObj, i )
916  {
917  pObj->Value = Abc_Var2Lit( Gia_ObjFanin0(pObj)->Value, Gia_ObjFaninC0(pObj) );
918  Vec_PtrPush( vTemp, pObj );
919  }
920  Vec_PtrSort( vTemp, (int (*)(void))Gia_ObjCompareByValue );
921  Vec_PtrForEachEntry( Gia_Obj_t *, vTemp, pObj, i )
922  Vec_IntPush( vCos, Gia_ObjId(p, pObj) );
923  }
924 
925  // assign unique IDs to ROs
926  Vec_PtrClear( vTemp );
927  Gia_ManForEachRo( p, pObj, i )
928  Vec_PtrPush( vTemp, pObj );
929  Vec_PtrSort( vTemp, (int (*)(void))Gia_ObjCompareByValue );
930  // create the result
931  Vec_PtrForEachEntry( Gia_Obj_t *, vTemp, pObj, i )
932  {
933  Vec_IntPush( vCis, Gia_ObjId(p, pObj) );
934  Vec_IntPush( vCos, Gia_ObjId(p, Gia_ObjRoToRi(p, pObj)) );
935  }
936  Vec_PtrFree( vTemp );
937 
938  // assign unique IDs to internal nodes
941  Gia_ManForEachObjVec( vCis, p, pObj, i )
942  Gia_ObjSetTravIdCurrent( p, pObj );
943  Gia_ManForEachObjVec( vCos, p, pObj, i )
944  Gia_ManFindCaninicalOrder_rec( p, Gia_ObjFanin0(pObj), vAnds );
945 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Gia_ManFindCaninicalOrder_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vAnds)
Definition: giaIso.c:855
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
static Gia_Obj_t * Gia_ManPo(Gia_Man_t *p, int v)
Definition: gia.h:406
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static void Vec_PtrSort(Vec_Ptr_t *p, int(*Vec_PtrSortCompare)()) ___unused
Definition: vecPtr.h:851
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
Definition: gia.h:75
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static Gia_Obj_t * Gia_ObjRoToRi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:446
static void Gia_ObjSetTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:531
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
int Gia_ObjCompareByValue(Gia_Obj_t **pp1, Gia_Obj_t **pp2)
Definition: giaIso.c:848
#define Gia_ManForEachRo(p, pObj, i)
Definition: gia.h:1038
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036
static int Gia_ObjCioId(Gia_Obj_t *pObj)
Definition: gia.h:411
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Gia_ManFindCaninicalOrder_rec ( Gia_Man_t p,
Gia_Obj_t pObj,
Vec_Int_t vAnds 
)

Definition at line 855 of file giaIso.c.

856 {
857  if ( Gia_ObjIsTravIdCurrent(p, pObj) )
858  return;
859  Gia_ObjSetTravIdCurrent(p, pObj);
860  assert( Gia_ObjIsAnd(pObj) );
861  if ( !Gia_ObjIsAnd(Gia_ObjFanin0(pObj)) || !Gia_ObjIsAnd(Gia_ObjFanin1(pObj)) )
862  {
863  Gia_ManFindCaninicalOrder_rec( p, Gia_ObjFanin0(pObj), vAnds );
864  Gia_ManFindCaninicalOrder_rec( p, Gia_ObjFanin1(pObj), vAnds );
865  }
866  else
867  {
868  assert( Gia_ObjFanin0(pObj)->Value != Gia_ObjFanin1(pObj)->Value );
869  if ( Gia_ObjFanin0(pObj)->Value < Gia_ObjFanin1(pObj)->Value )
870  {
871  Gia_ManFindCaninicalOrder_rec( p, Gia_ObjFanin0(pObj), vAnds );
872  Gia_ManFindCaninicalOrder_rec( p, Gia_ObjFanin1(pObj), vAnds );
873  }
874  else
875  {
876  Gia_ManFindCaninicalOrder_rec( p, Gia_ObjFanin1(pObj), vAnds );
877  Gia_ManFindCaninicalOrder_rec( p, Gia_ObjFanin0(pObj), vAnds );
878  }
879  }
880  Vec_IntPush( vAnds, Gia_ObjId(p, pObj) );
881 }
void Gia_ManFindCaninicalOrder_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vAnds)
Definition: giaIso.c:855
static int Gia_ObjIsTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:533
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static void Gia_ObjSetTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:531
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
Gia_Man_t* Gia_ManIsoCanonicize ( Gia_Man_t p,
int  fVerbose 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 958 of file giaIso.c.

959 {
960  Gia_Man_t * pRes = NULL;
961  Vec_Int_t * vCis, * vAnds, * vCos;
962  Vec_Ptr_t * vEquiv;
963  if ( Gia_ManCiNum(p) == 0 ) // const AIG
964  {
965  assert( Gia_ManPoNum(p) == 1 );
966  assert( Gia_ManObjNum(p) == 2 );
967  return Gia_ManDup(p);
968  }
969  // derive canonical values
970  vEquiv = Gia_IsoDeriveEquivPos( p, 0, fVerbose );
971  Vec_VecFreeP( (Vec_Vec_t **)&vEquiv );
972  // find canonical order of CIs/COs/nodes
973  // find canonical order
974  vCis = Vec_IntAlloc( Gia_ManCiNum(p) );
975  vAnds = Vec_IntAlloc( Gia_ManAndNum(p) );
976  vCos = Vec_IntAlloc( Gia_ManCoNum(p) );
977  Gia_ManFindCaninicalOrder( p, vCis, vAnds, vCos, NULL );
978  // derive the new AIG
979  pRes = Gia_ManDupFromVecs( p, vCis, vAnds, vCos, Gia_ManRegNum(p) );
980  // cleanup
981  Vec_IntFree( vCis );
982  Vec_IntFree( vAnds );
983  Vec_IntFree( vCos );
984  return pRes;
985 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
Definition: giaDup.c:552
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Gia_Man_t * Gia_ManDupFromVecs(Gia_Man_t *p, Vec_Int_t *vCis, Vec_Int_t *vAnds, Vec_Int_t *vCos, int nRegs)
Definition: giaDup.c:2853
void Gia_ManFindCaninicalOrder(Gia_Man_t *p, Vec_Int_t *vCis, Vec_Int_t *vAnds, Vec_Int_t *vCos, Vec_Int_t **pvPiPerm)
Definition: giaIso.c:882
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
Definition: gia.h:95
static void Vec_VecFreeP(Vec_Vec_t **p)
Definition: vecVec.h:367
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static int Gia_ManCoNum(Gia_Man_t *p)
Definition: gia.h:384
Vec_Ptr_t * Gia_IsoDeriveEquivPos(Gia_Man_t *pGia, int fForward, int fVerbose)
Definition: giaIso.c:720
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
Vec_Str_t* Gia_ManIsoFindString ( Gia_Man_t p,
int  iPo,
int  fVerbose,
Vec_Int_t **  pvPiPerm 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 998 of file giaIso.c.

999 {
1000  Gia_Man_t * pPart;
1001  Vec_Ptr_t * vEquiv;
1002  Vec_Int_t * vCis, * vAnds, * vCos;
1003  Vec_Str_t * vStr;
1004  // duplicate
1005  pPart = Gia_ManDupCones( p, &iPo, 1, 1 );
1006 //Gia_ManPrint( pPart );
1007  assert( Gia_ManPoNum(pPart) == 1 );
1008  if ( Gia_ManCiNum(pPart) == 0 ) // const AIG
1009  {
1010  assert( Gia_ManPoNum(pPart) == 1 );
1011  assert( Gia_ManObjNum(pPart) == 2 );
1012  vStr = Gia_AigerWriteIntoMemoryStr( pPart );
1013  Gia_ManStop( pPart );
1014  if ( pvPiPerm )
1015  *pvPiPerm = Vec_IntAlloc( 0 );
1016  return vStr;
1017  }
1018  // derive canonical values
1019  vEquiv = Gia_IsoDeriveEquivPos( pPart, 0, fVerbose );
1020  Vec_VecFreeP( (Vec_Vec_t **)&vEquiv );
1021  // find canonical order
1022  vCis = Vec_IntAlloc( Gia_ManCiNum(pPart) );
1023  vAnds = Vec_IntAlloc( Gia_ManAndNum(pPart) );
1024  vCos = Vec_IntAlloc( Gia_ManCoNum(pPart) );
1025  Gia_ManFindCaninicalOrder( pPart, vCis, vAnds, vCos, pvPiPerm );
1026 //printf( "Internal: " );
1027 //Vec_IntPrint( vCis );
1028  // derive the AIGER string
1029  vStr = Gia_AigerWriteIntoMemoryStrPart( pPart, vCis, vAnds, vCos, Gia_ManRegNum(pPart) );
1030  // cleanup
1031  Vec_IntFree( vCis );
1032  Vec_IntFree( vAnds );
1033  Vec_IntFree( vCos );
1034  Gia_ManStop( pPart );
1035  return vStr;
1036 }
Gia_Man_t * Gia_ManDupCones(Gia_Man_t *p, int *pPos, int nPos, int fTrimPis)
Definition: giaDup.c:2691
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Gia_ManFindCaninicalOrder(Gia_Man_t *p, Vec_Int_t *vCis, Vec_Int_t *vAnds, Vec_Int_t *vCos, Vec_Int_t **pvPiPerm)
Definition: giaIso.c:882
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Vec_Str_t * Gia_AigerWriteIntoMemoryStrPart(Gia_Man_t *p, Vec_Int_t *vCis, Vec_Int_t *vAnds, Vec_Int_t *vCos, int nRegs)
Definition: giaAiger.c:940
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
Definition: gia.h:95
static void Vec_VecFreeP(Vec_Vec_t **p)
Definition: vecVec.h:367
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Vec_Str_t * Gia_AigerWriteIntoMemoryStr(Gia_Man_t *p)
Definition: giaAiger.c:866
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static int Gia_ManCoNum(Gia_Man_t *p)
Definition: gia.h:384
Vec_Ptr_t * Gia_IsoDeriveEquivPos(Gia_Man_t *pGia, int fForward, int fVerbose)
Definition: giaIso.c:720
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
Gia_Man_t* Gia_ManIsoReduce ( Gia_Man_t pInit,
Vec_Ptr_t **  pvPosEquivs,
Vec_Ptr_t **  pvPiPerms,
int  fEstimate,
int  fDualOut,
int  fVerbose,
int  fVeryVerbose 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1075 of file giaIso.c.

1076 {
1077  Gia_Man_t * p, * pPart;
1078  Vec_Ptr_t * vEquivs, * vEquivs2, * vStrings;
1079  Vec_Int_t * vRemain, * vLevel, * vLevel2;
1080  Vec_Str_t * vStr, * vStr2;
1081  int i, k, s, sStart, iPo, Counter;
1082  int nClasses, nUsedPos;
1083  abctime clk = Abc_Clock();
1084  if ( pvPosEquivs )
1085  *pvPosEquivs = NULL;
1086  if ( pvPiPerms )
1087  *pvPiPerms = Vec_PtrStart( Gia_ManPoNum(pInit) );
1088 
1089  if ( fDualOut )
1090  {
1091  assert( (Gia_ManPoNum(pInit) & 1) == 0 );
1092  if ( Gia_ManPoNum(pInit) == 2 )
1093  return Gia_ManDup(pInit);
1094  p = Gia_ManTransformMiter( pInit );
1095  p = Gia_ManSeqStructSweep( pPart = p, 1, 1, 0 );
1096  Gia_ManStop( pPart );
1097  }
1098  else
1099  {
1100  if ( Gia_ManPoNum(pInit) == 1 )
1101  return Gia_ManDup(pInit);
1102  p = pInit;
1103  }
1104 
1105  // create preliminary equivalences
1106  vEquivs = Gia_IsoDeriveEquivPos( p, 1, fVeryVerbose );
1107  if ( vEquivs == NULL )
1108  {
1109  if ( fDualOut )
1110  Gia_ManStop( p );
1111  return NULL;
1112  }
1113  nClasses = Vec_IntCountNonTrivial( vEquivs, &nUsedPos );
1114  printf( "Reduced %d outputs to %d candidate classes (%d outputs are in %d non-trivial classes). ",
1115  Gia_ManPoNum(p), Vec_PtrSize(vEquivs), nUsedPos, nClasses );
1116  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1117  if ( fEstimate )
1118  {
1119  Vec_VecFree( (Vec_Vec_t *)vEquivs );
1120  return Gia_ManDup(pInit);
1121  }
1122 
1123  // perform refinement of equivalence classes
1124  Counter = 0;
1125  vEquivs2 = Vec_PtrAlloc( 100 );
1126  Vec_PtrForEachEntry( Vec_Int_t *, vEquivs, vLevel, i )
1127  {
1128  if ( Vec_IntSize(vLevel) < 2 )
1129  {
1130  Vec_PtrPush( vEquivs2, Vec_IntDup(vLevel) );
1131  for ( k = 0; k < Vec_IntSize(vLevel); k++ )
1132  if ( ++Counter % 100 == 0 )
1133  printf( "%6d finished...\r", Counter );
1134  continue;
1135  }
1136 
1137  if ( fVerbose )
1138  {
1139  iPo = Vec_IntEntry(vLevel, 0);
1140  printf( "%6d %6d %6d : ", i, Vec_IntSize(vLevel), iPo );
1141  pPart = Gia_ManDupCones( p, &iPo, 1, 1 );
1142  Gia_ManPrintStats(pPart, NULL);
1143  Gia_ManStop( pPart );
1144  }
1145 
1146  sStart = Vec_PtrSize( vEquivs2 );
1147  vStrings = Vec_PtrAlloc( 100 );
1148  Vec_IntForEachEntry( vLevel, iPo, k )
1149  {
1150  if ( ++Counter % 100 == 0 )
1151  printf( "%6d finished...\r", Counter );
1152  assert( pvPiPerms == NULL || Vec_PtrArray(*pvPiPerms)[iPo] == NULL );
1153  vStr = Gia_ManIsoFindString( p, iPo, 0, pvPiPerms ? (Vec_Int_t **)Vec_PtrArray(*pvPiPerms) + iPo : NULL );
1154 
1155 // printf( "Output %2d : ", iPo );
1156 // Vec_IntPrint( Vec_PtrArray(*pvPiPerms)[iPo] );
1157 
1158  // check if this string already exists
1159  Vec_PtrForEachEntry( Vec_Str_t *, vStrings, vStr2, s )
1160  if ( Vec_StrCompareVec(vStr, vStr2) == 0 )
1161  break;
1162  if ( s == Vec_PtrSize(vStrings) )
1163  {
1164  Vec_PtrPush( vStrings, vStr );
1165  Vec_PtrPush( vEquivs2, Vec_IntAlloc(8) );
1166  }
1167  else
1168  Vec_StrFree( vStr );
1169  // add this entry to the corresponding level
1170  vLevel2 = (Vec_Int_t *)Vec_PtrEntry( vEquivs2, sStart + s );
1171  Vec_IntPush( vLevel2, iPo );
1172  }
1173 // if ( Vec_PtrSize(vEquivs2) - sStart > 1 )
1174 // printf( "Refined class %d into %d classes.\n", i, Vec_PtrSize(vEquivs2) - sStart );
1175  Vec_VecFree( (Vec_Vec_t *)vStrings );
1176  }
1177  assert( Counter == Gia_ManPoNum(p) );
1178  Vec_VecSortByFirstInt( (Vec_Vec_t *)vEquivs2, 0 );
1179  Vec_VecFree( (Vec_Vec_t *)vEquivs );
1180  vEquivs = vEquivs2;
1181 
1182  // collect the first ones
1183  vRemain = Vec_IntAlloc( 100 );
1184  Vec_PtrForEachEntry( Vec_Int_t *, vEquivs, vLevel, i )
1185  Vec_IntPush( vRemain, Vec_IntEntry(vLevel, 0) );
1186 
1187  if ( fDualOut )
1188  {
1189  Vec_Int_t * vTemp = Vec_IntAlloc( Vec_IntSize(vRemain) );
1190  int i, Entry;
1191  Vec_IntForEachEntry( vRemain, Entry, i )
1192  {
1193 // printf( "%d ", Entry );
1194  Vec_IntPush( vTemp, 2*Entry );
1195  Vec_IntPush( vTemp, 2*Entry+1 );
1196  }
1197 // printf( "\n" );
1198  Vec_IntFree( vRemain );
1199  vRemain = vTemp;
1200  Gia_ManStop( p );
1201  p = pInit;
1202  }
1203 
1204 
1205  // derive the resulting AIG
1206  pPart = Gia_ManDupCones( p, Vec_IntArray(vRemain), Vec_IntSize(vRemain), 0 );
1207  Vec_IntFree( vRemain );
1208  // report the results
1209  nClasses = Vec_IntCountNonTrivial( vEquivs, &nUsedPos );
1210  if ( !fDualOut )
1211  printf( "Reduced %d outputs to %d equivalence classes (%d outputs are in %d non-trivial classes). ",
1212  Gia_ManPoNum(p), Vec_PtrSize(vEquivs), nUsedPos, nClasses );
1213  else
1214  printf( "Reduced %d dual outputs to %d dual outputs. ", Gia_ManPoNum(p)/2, Gia_ManPoNum(pPart)/2 );
1215  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1216  if ( fVerbose )
1217  {
1218  printf( "Nontrivial classes:\n" );
1219  Vec_VecPrintInt( (Vec_Vec_t *)vEquivs, 1 );
1220  }
1221  if ( pvPosEquivs )
1222  *pvPosEquivs = vEquivs;
1223  else
1224  Vec_VecFree( (Vec_Vec_t *)vEquivs );
1225 // Gia_ManStopP( &pPart );
1226  return pPart;
1227 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
Gia_Man_t * Gia_ManDupCones(Gia_Man_t *p, int *pPos, int nPos, int fTrimPis)
Definition: giaDup.c:2691
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
Definition: giaDup.c:552
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
Gia_Man_t * Gia_ManTransformMiter(Gia_Man_t *p)
Definition: giaDup.c:2324
static Vec_Int_t * Vec_IntDup(Vec_Int_t *pVec)
Definition: vecInt.h:214
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
Definition: giaMan.c:389
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static abctime Abc_Clock()
Definition: abc_global.h:279
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 void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int Vec_IntCountNonTrivial(Vec_Ptr_t *vEquivs, int *pnUsed)
Definition: giaIso.c:1049
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Vec_VecPrintInt(Vec_Vec_t *p, int fSkipSingles)
Definition: vecVec.h:616
if(last==0)
Definition: sparse_int.h:34
static void Vec_VecSortByFirstInt(Vec_Vec_t *p, int fReverse)
Definition: vecVec.h:595
Vec_Str_t * Gia_ManIsoFindString(Gia_Man_t *p, int iPo, int fVerbose, Vec_Int_t **pvPiPerm)
Definition: giaIso.c:998
Gia_Man_t * Gia_ManSeqStructSweep(Gia_Man_t *p, int fConst, int fEquiv, int fVerbose)
Definition: giaScl.c:258
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Counter
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Vec_StrCompareVec(Vec_Str_t *p1, Vec_Str_t *p2)
Definition: vecStr.h:793
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Definition: gia.h:95
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_INT64_T abctime
Definition: abc_global.h:278
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static void ** Vec_PtrArray(Vec_Ptr_t *p)
Definition: vecPtr.h:279
Vec_Ptr_t * Gia_IsoDeriveEquivPos(Gia_Man_t *pGia, int fForward, int fVerbose)
Definition: giaIso.c:720
int Gia_ObjCompareByValue ( Gia_Obj_t **  pp1,
Gia_Obj_t **  pp2 
)

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

Synopsis [Finds canonical ordering of CIs/COs/nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 848 of file giaIso.c.

849 {
850  Gia_Obj_t * pObj1 = *pp1;
851  Gia_Obj_t * pObj2 = *pp2;
852 // assert( pObj1->Value != pObj2->Value );
853  return (int)pObj1->Value - (int)pObj2->Value;
854 }
Definition: gia.h:75
unsigned Value
Definition: gia.h:87
int Vec_IntCountNonTrivial ( Vec_Ptr_t vEquivs,
int *  pnUsed 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1049 of file giaIso.c.

1050 {
1051  Vec_Int_t * vClass;
1052  int i, nClasses = 0;
1053  *pnUsed = 0;
1054  Vec_PtrForEachEntry( Vec_Int_t *, vEquivs, vClass, i )
1055  {
1056  if ( Vec_IntSize(vClass) < 2 )
1057  continue;
1058  nClasses++;
1059  (*pnUsed) += Vec_IntSize(vClass);
1060  }
1061  return nClasses;
1062 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55

Variable Documentation

int s_256Primes[ISO_MASK+1]
static

Definition at line 27 of file giaIso.c.