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

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int Ivy_ObjIsExorType (Ivy_Obj_t *p0, Ivy_Obj_t *p1, Ivy_Obj_t **ppFan0, Ivy_Obj_t **ppFan1)
 DECLARATIONS ///. More...
 
Ivy_Obj_tIvy_Oper (Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1, Ivy_Type_t Type)
 FUNCTION DEFINITIONS ///. More...
 
Ivy_Obj_tIvy_And (Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
 
Ivy_Obj_tIvy_Exor (Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
 
Ivy_Obj_tIvy_Or (Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
 
Ivy_Obj_tIvy_Mux (Ivy_Man_t *p, Ivy_Obj_t *pC, Ivy_Obj_t *p1, Ivy_Obj_t *p0)
 
Ivy_Obj_tIvy_Maj (Ivy_Man_t *p, Ivy_Obj_t *pA, Ivy_Obj_t *pB, Ivy_Obj_t *pC)
 
Ivy_Obj_tIvy_Multi_rec (Ivy_Man_t *p, Ivy_Obj_t **ppObjs, int nObjs, Ivy_Type_t Type)
 
Ivy_Obj_tIvy_Multi (Ivy_Man_t *p, Ivy_Obj_t **pArgs, int nArgs, Ivy_Type_t Type)
 
Ivy_Obj_tIvy_Miter (Ivy_Man_t *p, Vec_Ptr_t *vPairs)
 
Ivy_Obj_tIvy_Latch (Ivy_Man_t *p, Ivy_Obj_t *pObj, Ivy_Init_t Init)
 

Function Documentation

Ivy_Obj_t* Ivy_And ( Ivy_Man_t p,
Ivy_Obj_t p0,
Ivy_Obj_t p1 
)

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

Synopsis [Performs canonicization step.]

Description [The argument nodes can be complemented.]

SideEffects []

SeeAlso []

Definition at line 84 of file ivyOper.c.

85 {
86 // Ivy_Obj_t * pFan0, * pFan1;
87  // check trivial cases
88  if ( p0 == p1 )
89  return p0;
90  if ( p0 == Ivy_Not(p1) )
91  return Ivy_Not(p->pConst1);
92  if ( Ivy_Regular(p0) == p->pConst1 )
93  return p0 == p->pConst1 ? p1 : Ivy_Not(p->pConst1);
94  if ( Ivy_Regular(p1) == p->pConst1 )
95  return p1 == p->pConst1 ? p0 : Ivy_Not(p->pConst1);
96  // check if it can be an EXOR gate
97 // if ( Ivy_ObjIsExorType( p0, p1, &pFan0, &pFan1 ) )
98 // return Ivy_CanonExor( pFan0, pFan1 );
99  return Ivy_CanonAnd( p, p0, p1 );
100 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Ivy_Obj_t * Ivy_Regular(Ivy_Obj_t *p)
Definition: ivy.h:193
Ivy_Obj_t * Ivy_CanonAnd(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition: ivyCanon.c:90
static Ivy_Obj_t * Ivy_Not(Ivy_Obj_t *p)
Definition: ivy.h:194
Ivy_Obj_t* Ivy_Exor ( Ivy_Man_t p,
Ivy_Obj_t p0,
Ivy_Obj_t p1 
)

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

Synopsis [Performs canonicization step.]

Description [The argument nodes can be complemented.]

SideEffects []

SeeAlso []

Definition at line 113 of file ivyOper.c.

114 {
115 /*
116  // check trivial cases
117  if ( p0 == p1 )
118  return Ivy_Not(p->pConst1);
119  if ( p0 == Ivy_Not(p1) )
120  return p->pConst1;
121  if ( Ivy_Regular(p0) == p->pConst1 )
122  return Ivy_NotCond( p1, p0 == p->pConst1 );
123  if ( Ivy_Regular(p1) == p->pConst1 )
124  return Ivy_NotCond( p0, p1 == p->pConst1 );
125  // check the table
126  return Ivy_CanonExor( p, p0, p1 );
127 */
128  return Ivy_Or( p, Ivy_And(p, p0, Ivy_Not(p1)), Ivy_And(p, Ivy_Not(p0), p1) );
129 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Ivy_Obj_t * Ivy_Or(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition: ivyOper.c:142
static Ivy_Obj_t * Ivy_Not(Ivy_Obj_t *p)
Definition: ivy.h:194
Ivy_Obj_t * Ivy_And(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition: ivyOper.c:84
Ivy_Obj_t* Ivy_Latch ( Ivy_Man_t p,
Ivy_Obj_t pObj,
Ivy_Init_t  Init 
)

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

Synopsis [Performs canonicization step.]

Description []

SideEffects []

SeeAlso []

Definition at line 287 of file ivyOper.c.

288 {
289  return Ivy_CanonLatch( p, pObj, Init );
290 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Ivy_Obj_t * Ivy_CanonLatch(Ivy_Man_t *p, Ivy_Obj_t *pObj, Ivy_Init_t Init)
Definition: ivyCanon.c:131
Ivy_Obj_t* Ivy_Maj ( Ivy_Man_t p,
Ivy_Obj_t pA,
Ivy_Obj_t pB,
Ivy_Obj_t pC 
)

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

Synopsis [Implements ITE operation.]

Description []

SideEffects []

SeeAlso []

Definition at line 209 of file ivyOper.c.

210 {
211  return Ivy_Or( p, Ivy_Or(p, Ivy_And(p, pA, pB), Ivy_And(p, pA, pC)), Ivy_And(p, pB, pC) );
212 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Ivy_Obj_t * Ivy_Or(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition: ivyOper.c:142
Ivy_Obj_t * Ivy_And(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition: ivyOper.c:84
Ivy_Obj_t* Ivy_Miter ( Ivy_Man_t p,
Vec_Ptr_t vPairs 
)

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

Synopsis [Implements the miter.]

Description []

SideEffects []

SeeAlso []

Definition at line 264 of file ivyOper.c.

265 {
266  int i;
267  assert( vPairs->nSize > 0 );
268  assert( vPairs->nSize % 2 == 0 );
269  // go through the cubes of the node's SOP
270  for ( i = 0; i < vPairs->nSize; i += 2 )
271  vPairs->pArray[i/2] = Ivy_Not( Ivy_Exor( p, (Ivy_Obj_t *)vPairs->pArray[i], (Ivy_Obj_t *)vPairs->pArray[i+1] ) );
272  vPairs->nSize = vPairs->nSize/2;
273  return Ivy_Not( Ivy_Multi_rec( p, (Ivy_Obj_t **)vPairs->pArray, vPairs->nSize, IVY_AND ) );
274 }
Definition: ivy.h:58
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: ivy.h:73
Ivy_Obj_t * Ivy_Exor(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition: ivyOper.c:113
static Ivy_Obj_t * Ivy_Not(Ivy_Obj_t *p)
Definition: ivy.h:194
#define assert(ex)
Definition: util_old.h:213
Ivy_Obj_t * Ivy_Multi_rec(Ivy_Man_t *p, Ivy_Obj_t **ppObjs, int nObjs, Ivy_Type_t Type)
Definition: ivyOper.c:225
Ivy_Obj_t* Ivy_Multi ( Ivy_Man_t p,
Ivy_Obj_t **  pArgs,
int  nArgs,
Ivy_Type_t  Type 
)

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

Synopsis [Old code.]

Description []

SideEffects []

SeeAlso []

Definition at line 246 of file ivyOper.c.

247 {
248  assert( Type == IVY_AND || Type == IVY_EXOR );
249  assert( nArgs > 0 );
250  return Ivy_Multi_rec( p, pArgs, nArgs, Type );
251 }
Definition: ivy.h:58
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: ivy.h:59
#define assert(ex)
Definition: util_old.h:213
Ivy_Obj_t * Ivy_Multi_rec(Ivy_Man_t *p, Ivy_Obj_t **ppObjs, int nObjs, Ivy_Type_t Type)
Definition: ivyOper.c:225
Ivy_Obj_t* Ivy_Multi_rec ( Ivy_Man_t p,
Ivy_Obj_t **  ppObjs,
int  nObjs,
Ivy_Type_t  Type 
)

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

Synopsis [Constructs the well-balanced tree of gates.]

Description [Disregards levels and possible logic sharing.]

SideEffects []

SeeAlso []

Definition at line 225 of file ivyOper.c.

226 {
227  Ivy_Obj_t * pObj1, * pObj2;
228  if ( nObjs == 1 )
229  return ppObjs[0];
230  pObj1 = Ivy_Multi_rec( p, ppObjs, nObjs/2, Type );
231  pObj2 = Ivy_Multi_rec( p, ppObjs + nObjs/2, nObjs - nObjs/2, Type );
232  return Ivy_Oper( p, pObj1, pObj2, Type );
233 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: ivy.h:73
Ivy_Obj_t * Ivy_Multi_rec(Ivy_Man_t *p, Ivy_Obj_t **ppObjs, int nObjs, Ivy_Type_t Type)
Definition: ivyOper.c:225
Ivy_Obj_t * Ivy_Oper(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1, Ivy_Type_t Type)
FUNCTION DEFINITIONS ///.
Definition: ivyOper.c:63
Ivy_Obj_t* Ivy_Mux ( Ivy_Man_t p,
Ivy_Obj_t pC,
Ivy_Obj_t p1,
Ivy_Obj_t p0 
)

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

Synopsis [Implements ITE operation.]

Description []

SideEffects []

SeeAlso []

Definition at line 158 of file ivyOper.c.

159 {
160  Ivy_Obj_t * pTempA1, * pTempA2, * pTempB1, * pTempB2, * pTemp;
161  int Count0, Count1;
162  // consider trivial cases
163  if ( p0 == Ivy_Not(p1) )
164  return Ivy_Exor( p, pC, p0 );
165  // other cases can be added
166  // implement the first MUX (F = C * x1 + C' * x0)
167  pTempA1 = Ivy_TableLookup( p, Ivy_ObjCreateGhost(p, pC, p1, IVY_AND, IVY_INIT_NONE) );
169  if ( pTempA1 && pTempA2 )
170  {
171  pTemp = Ivy_TableLookup( p, Ivy_ObjCreateGhost(p, Ivy_Not(pTempA1), Ivy_Not(pTempA2), IVY_AND, IVY_INIT_NONE) );
172  if ( pTemp ) return Ivy_Not(pTemp);
173  }
174  Count0 = (pTempA1 != NULL) + (pTempA2 != NULL);
175  // implement the second MUX (F' = C * x1' + C' * x0')
178  if ( pTempB1 && pTempB2 )
179  {
180  pTemp = Ivy_TableLookup( p, Ivy_ObjCreateGhost(p, Ivy_Not(pTempB1), Ivy_Not(pTempB2), IVY_AND, IVY_INIT_NONE) );
181  if ( pTemp ) return pTemp;
182  }
183  Count1 = (pTempB1 != NULL) + (pTempB2 != NULL);
184  // compare and decide which one to implement
185  if ( Count0 >= Count1 )
186  {
187  pTempA1 = pTempA1? pTempA1 : Ivy_And(p, pC, p1);
188  pTempA2 = pTempA2? pTempA2 : Ivy_And(p, Ivy_Not(pC), p0);
189  return Ivy_Or( p, pTempA1, pTempA2 );
190  }
191  pTempB1 = pTempB1? pTempB1 : Ivy_And(p, pC, Ivy_Not(p1));
192  pTempB2 = pTempB2? pTempB2 : Ivy_And(p, Ivy_Not(pC), Ivy_Not(p0));
193  return Ivy_Not( Ivy_Or( p, pTempB1, pTempB2 ) );
194 
195 // return Ivy_Or( Ivy_And(pC, p1), Ivy_And(Ivy_Not(pC), p0) );
196 }
Definition: ivy.h:58
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Ivy_Obj_t * Ivy_TableLookup(Ivy_Man_t *p, Ivy_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition: ivyTable.c:71
Ivy_Obj_t * Ivy_Or(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition: ivyOper.c:142
Definition: ivy.h:73
Ivy_Obj_t * Ivy_Exor(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition: ivyOper.c:113
static Ivy_Obj_t * Ivy_ObjCreateGhost(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1, Ivy_Type_t Type, Ivy_Init_t Init)
Definition: ivy.h:308
static Ivy_Obj_t * Ivy_Not(Ivy_Obj_t *p)
Definition: ivy.h:194
Ivy_Obj_t * Ivy_And(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition: ivyOper.c:84
static ABC_NAMESPACE_IMPL_START int Ivy_ObjIsExorType ( Ivy_Obj_t p0,
Ivy_Obj_t p1,
Ivy_Obj_t **  ppFan0,
Ivy_Obj_t **  ppFan1 
)
inlinestatic

DECLARATIONS ///.

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

FileName [ivyOper.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [And-Inverter Graph package.]

Synopsis [AIG operations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - May 11, 2006.]

Revision [

Id:
ivyOper.c,v 1.00 2006/05/11 00:00:00 alanmi Exp

]

Definition at line 31 of file ivyOper.c.

32 {
33  if ( !Ivy_IsComplement(p0) || !Ivy_IsComplement(p1) )
34  return 0;
35  p0 = Ivy_Regular(p0);
36  p1 = Ivy_Regular(p1);
37  if ( !Ivy_ObjIsAnd(p0) || !Ivy_ObjIsAnd(p1) )
38  return 0;
39  if ( Ivy_ObjFanin0(p0) != Ivy_ObjFanin0(p1) || Ivy_ObjFanin1(p0) != Ivy_ObjFanin1(p1) )
40  return 0;
41  if ( Ivy_ObjFaninC0(p0) == Ivy_ObjFaninC0(p1) || Ivy_ObjFaninC1(p0) == Ivy_ObjFaninC1(p1) )
42  return 0;
43  *ppFan0 = Ivy_ObjChild0(p0);
44  *ppFan1 = Ivy_ObjChild1(p0);
45  return 1;
46 }
static int Ivy_IsComplement(Ivy_Obj_t *p)
Definition: ivy.h:196
static Ivy_Obj_t * Ivy_ObjFanin1(Ivy_Obj_t *pObj)
Definition: ivy.h:272
static Ivy_Obj_t * Ivy_ObjFanin0(Ivy_Obj_t *pObj)
Definition: ivy.h:271
static int Ivy_ObjFaninC1(Ivy_Obj_t *pObj)
Definition: ivy.h:270
static Ivy_Obj_t * Ivy_Regular(Ivy_Obj_t *p)
Definition: ivy.h:193
static Ivy_Obj_t * Ivy_ObjChild0(Ivy_Obj_t *pObj)
Definition: ivy.h:273
static int Ivy_ObjIsAnd(Ivy_Obj_t *pObj)
Definition: ivy.h:242
static Ivy_Obj_t * Ivy_ObjChild1(Ivy_Obj_t *pObj)
Definition: ivy.h:274
static int Ivy_ObjFaninC0(Ivy_Obj_t *pObj)
Definition: ivy.h:269
Ivy_Obj_t* Ivy_Oper ( Ivy_Man_t p,
Ivy_Obj_t p0,
Ivy_Obj_t p1,
Ivy_Type_t  Type 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Perform one operation.]

Description [The argument nodes can be complemented.]

SideEffects []

SeeAlso []

Definition at line 63 of file ivyOper.c.

64 {
65  if ( Type == IVY_AND )
66  return Ivy_And( p, p0, p1 );
67  if ( Type == IVY_EXOR )
68  return Ivy_Exor( p, p0, p1 );
69  assert( 0 );
70  return NULL;
71 }
Definition: ivy.h:58
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Ivy_Obj_t * Ivy_Exor(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition: ivyOper.c:113
Definition: ivy.h:59
#define assert(ex)
Definition: util_old.h:213
Ivy_Obj_t * Ivy_And(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition: ivyOper.c:84
Ivy_Obj_t* Ivy_Or ( Ivy_Man_t p,
Ivy_Obj_t p0,
Ivy_Obj_t p1 
)

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

Synopsis [Implements Boolean OR.]

Description []

SideEffects []

SeeAlso []

Definition at line 142 of file ivyOper.c.

143 {
144  return Ivy_Not( Ivy_And( p, Ivy_Not(p0), Ivy_Not(p1) ) );
145 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Ivy_Obj_t * Ivy_Not(Ivy_Obj_t *p)
Definition: ivy.h:194
Ivy_Obj_t * Ivy_And(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition: ivyOper.c:84