abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaIso3.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [giaIso3.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Scalable AIG package.]
8 
9  Synopsis []
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: giaIso3.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "gia.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 static unsigned Iso_Nodes[6] = { 0x04892ed6, 0xc2523d7d, 0xdc36cd2e, 0xf2db64f8, 0xde3126bb, 0xdebbdff0 }; // ab, a!b, !a!b, pi, po, const0
31 static unsigned Iso_Fanio[2] = { 0x855ee0cf, 0x946e1b5f }; // fanin, fanout
32 static unsigned Iso_Compl[2] = { 0x8ba63e50, 0x14d87f02 }; // non-compl, compl
33 
34 ////////////////////////////////////////////////////////////////////////
35 /// FUNCTION DEFINITIONS ///
36 ////////////////////////////////////////////////////////////////////////
37 
38 /**Function*************************************************************
39 
40  Synopsis []
41 
42  Description []
43 
44  SideEffects []
45 
46  SeeAlso []
47 
48 ***********************************************************************/
49 static inline unsigned Gia_Iso3Node( Gia_Obj_t * pObj )
50 {
51  if ( Gia_ObjIsAnd(pObj) )
52  return Iso_Nodes[Gia_ObjFaninC0(pObj) + Gia_ObjFaninC1(pObj)];
53  if ( Gia_ObjIsCi(pObj) )
54  return Iso_Nodes[3];
55  if ( Gia_ObjIsCo(pObj) )
56  return Iso_Nodes[4];
57  return Iso_Nodes[5];
58 }
60 {
61  Gia_Obj_t * pObj;
62  int i;
63  Gia_ManForEachObj( p, pObj, i )
64  pObj->Value = Gia_Iso3Node( pObj );
65 }
66 
67 /**Function*************************************************************
68 
69  Synopsis []
70 
71  Description []
72 
73  SideEffects []
74 
75  SeeAlso []
76 
77 ***********************************************************************/
78 static inline void Gia_Iso3ComputeEdge( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanin, int fCompl, Vec_Int_t * vSign )
79 {
80  pObj->Value += Vec_IntEntry(vSign, Gia_ObjId(p, pFanin)) + Iso_Compl[fCompl] + Iso_Fanio[0];
81  pFanin->Value += Vec_IntEntry(vSign, Gia_ObjId(p, pObj)) + Iso_Compl[fCompl] + Iso_Fanio[1];
82 }
84 {
85  Gia_Obj_t * pObj;
86  int i;
87  Gia_ManForEachObj( p, pObj, i )
88  {
89  if ( Gia_ObjIsAnd(pObj) || Gia_ObjIsCo(pObj) )
90  Gia_Iso3ComputeEdge( p, pObj, Gia_ObjFanin0(pObj), Gia_ObjFaninC0(pObj), vSign );
91  if ( Gia_ObjIsAnd(pObj) )
92  Gia_Iso3ComputeEdge( p, pObj, Gia_ObjFanin1(pObj), Gia_ObjFaninC1(pObj), vSign );
93  }
94 }
95 
96 /**Function*************************************************************
97 
98  Synopsis []
99 
100  Description []
101 
102  SideEffects []
103 
104  SeeAlso []
105 
106 ***********************************************************************/
107 static inline Vec_Int_t * Gia_Iso3Save( Gia_Man_t * p )
108 {
109  Vec_Int_t * vSign;
110  Gia_Obj_t * pObj;
111  int i;
112  vSign = Vec_IntAlloc( Gia_ManObjNum(p) );
113  Gia_ManForEachObj( p, pObj, i )
114  Vec_IntPush( vSign, pObj->Value );
115  return vSign;
116 }
117 int Gia_Iso3Unique( Vec_Int_t * vSign )
118 {
119  int nUnique;
120  Vec_Int_t * vCopy = Vec_IntDup( vSign );
121  Vec_IntUniqify( vCopy );
122  nUnique = Vec_IntSize(vCopy);
123  Vec_IntFree( vCopy );
124  return nUnique;
125 }
126 
127 /**Function*************************************************************
128 
129  Synopsis []
130 
131  Description []
132 
133  SideEffects []
134 
135  SeeAlso []
136 
137 ***********************************************************************/
139 {
140  int nIterMax = 500;
141  int i, Prev = -1, This;
142  abctime clk = Abc_Clock();
143  Vec_Int_t * vSign = NULL;
144  Gia_Iso3Init( p );
145  for ( i = 0; i < nIterMax; i++ )
146  {
147  vSign = Gia_Iso3Save( p );
148 // This = Gia_Iso3Unique( vSign );
149  This = Vec_IntUniqueCount( vSign, 1, NULL );
150  printf( "Iter %3d : %6d out of %6d ", i, This, Vec_IntSize(vSign) );
151  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
152  if ( This == Prev )
153  break;
154  Prev = This;
155  Gia_Iso3Compute( p, vSign );
156  Vec_IntFreeP( &vSign );
157  }
158  Vec_IntFreeP( &vSign );
159 }
160 
161 ////////////////////////////////////////////////////////////////////////
162 /// END OF FILE ///
163 ////////////////////////////////////////////////////////////////////////
164 
165 
167 
static Vec_Int_t * Vec_IntDup(Vec_Int_t *pVec)
Definition: vecInt.h:214
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
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 abctime Abc_Clock()
Definition: abc_global.h:279
static Vec_Int_t * Gia_Iso3Save(Gia_Man_t *p)
Definition: giaIso3.c:107
Definition: gia.h:75
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
static unsigned Gia_Iso3Node(Gia_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition: giaIso3.c:49
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
void Gia_Iso3Compute(Gia_Man_t *p, Vec_Int_t *vSign)
Definition: giaIso3.c:83
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
static int Vec_IntUniqify(Vec_Int_t *p)
Definition: vecInt.h:1314
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 void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
static unsigned Iso_Fanio[2]
Definition: giaIso3.c:31
void Gia_Iso3Test(Gia_Man_t *p)
Definition: giaIso3.c:138
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static unsigned Iso_Compl[2]
Definition: giaIso3.c:32
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int Gia_Iso3Unique(Vec_Int_t *vSign)
Definition: giaIso3.c:117
Definition: gia.h:95
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition: gia.h:984
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
static int Vec_IntUniqueCount(Vec_Int_t *vData, int nIntSize, Vec_Int_t **pvMap)
Definition: vecInt.h:1437
unsigned Value
Definition: gia.h:87
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
ABC_INT64_T abctime
Definition: abc_global.h:278
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Gia_Iso3Init(Gia_Man_t *p)
Definition: giaIso3.c:59
static ABC_NAMESPACE_IMPL_START unsigned Iso_Nodes[6]
DECLARATIONS ///.
Definition: giaIso3.c:30
static void Gia_Iso3ComputeEdge(Gia_Man_t *p, Gia_Obj_t *pObj, Gia_Obj_t *pFanin, int fCompl, Vec_Int_t *vSign)
Definition: giaIso3.c:78