abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ivyCanon.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [ivyCanon.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [And-Inverter Graph package.]
8 
9  Synopsis [Finding canonical form of objects.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - May 11, 2006.]
16 
17  Revision [$Id: ivyCanon.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "ivy.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 static Ivy_Obj_t * Ivy_TableLookupPair_rec( Ivy_Man_t * p, Ivy_Obj_t * pObj0, Ivy_Obj_t * pObj1, int fCompl0, int fCompl1, Ivy_Type_t Type );
31 
32 ////////////////////////////////////////////////////////////////////////
33 /// FUNCTION DEFINITIONS ///
34 ////////////////////////////////////////////////////////////////////////
35 
36 /**Function*************************************************************
37 
38  Synopsis [Creates the canonical form of the node.]
39 
40  Description []
41 
42  SideEffects []
43 
44  SeeAlso []
45 
46 ***********************************************************************/
48 {
49  Ivy_Obj_t * pResult, * pLat0, * pLat1;
50  Ivy_Init_t Init, Init0, Init1;
51  int fCompl0, fCompl1;
52  Ivy_Type_t Type;
53  assert( Ivy_ObjIsNode(pGhost) );
54  assert( Ivy_ObjIsAnd(pGhost) || (!Ivy_ObjFaninC0(pGhost) && !Ivy_ObjFaninC1(pGhost)) );
55  assert( Ivy_ObjFaninId0(pGhost) != 0 && Ivy_ObjFaninId1(pGhost) != 0 );
56  // consider the case when the pair is canonical
57  if ( !Ivy_ObjIsLatch(Ivy_ObjFanin0(pGhost)) || !Ivy_ObjIsLatch(Ivy_ObjFanin1(pGhost)) )
58  {
59  if ( (pResult = Ivy_TableLookup( p, pGhost )) )
60  return pResult;
61  return Ivy_ObjCreate( p, pGhost );
62  }
63  /// remember the latches
64  pLat0 = Ivy_ObjFanin0(pGhost);
65  pLat1 = Ivy_ObjFanin1(pGhost);
66  // remember type and compls
67  Type = Ivy_ObjType(pGhost);
68  fCompl0 = Ivy_ObjFaninC0(pGhost);
69  fCompl1 = Ivy_ObjFaninC1(pGhost);
70  // call recursively
71  pResult = Ivy_Oper( p, Ivy_NotCond(Ivy_ObjFanin0(pLat0), fCompl0), Ivy_NotCond(Ivy_ObjFanin0(pLat1), fCompl1), Type );
72  // build latch on top of this
73  Init0 = Ivy_InitNotCond( Ivy_ObjInit(pLat0), fCompl0 );
74  Init1 = Ivy_InitNotCond( Ivy_ObjInit(pLat1), fCompl1 );
75  Init = (Type == IVY_AND)? Ivy_InitAnd(Init0, Init1) : Ivy_InitExor(Init0, Init1);
76  return Ivy_Latch( p, pResult, Init );
77 }
78 
79 /**Function*************************************************************
80 
81  Synopsis [Creates the canonical form of the node.]
82 
83  Description []
84 
85  SideEffects []
86 
87  SeeAlso []
88 
89 ***********************************************************************/
91 {
92  Ivy_Obj_t * pGhost, * pResult;
93  pGhost = Ivy_ObjCreateGhost( p, pObj0, pObj1, IVY_AND, IVY_INIT_NONE );
94  pResult = Ivy_CanonPair_rec( p, pGhost );
95  return pResult;
96 }
97 
98 /**Function*************************************************************
99 
100  Synopsis [Creates the canonical form of the node.]
101 
102  Description []
103 
104  SideEffects []
105 
106  SeeAlso []
107 
108 ***********************************************************************/
110 {
111  Ivy_Obj_t * pGhost, * pResult;
112  int fCompl = Ivy_IsComplement(pObj0) ^ Ivy_IsComplement(pObj1);
113  pObj0 = Ivy_Regular(pObj0);
114  pObj1 = Ivy_Regular(pObj1);
115  pGhost = Ivy_ObjCreateGhost( p, pObj0, pObj1, IVY_EXOR, IVY_INIT_NONE );
116  pResult = Ivy_CanonPair_rec( p, pGhost );
117  return Ivy_NotCond( pResult, fCompl );
118 }
119 
120 /**Function*************************************************************
121 
122  Synopsis [Creates the canonical form of the node.]
123 
124  Description []
125 
126  SideEffects []
127 
128  SeeAlso []
129 
130 ***********************************************************************/
132 {
133  Ivy_Obj_t * pGhost, * pResult;
134  int fCompl = Ivy_IsComplement(pObj);
135  pObj = Ivy_Regular(pObj);
136  pGhost = Ivy_ObjCreateGhost( p, pObj, NULL, IVY_LATCH, Ivy_InitNotCond(Init, fCompl) );
137  pResult = Ivy_TableLookup( p, pGhost );
138  if ( pResult == NULL )
139  pResult = Ivy_ObjCreate( p, pGhost );
140  return Ivy_NotCond( pResult, fCompl );
141 }
142 
143 ////////////////////////////////////////////////////////////////////////
144 /// END OF FILE ///
145 ////////////////////////////////////////////////////////////////////////
146 
147 
149 
Ivy_Obj_t * Ivy_Latch(Ivy_Man_t *p, Ivy_Obj_t *pObj, Ivy_Init_t Init)
Definition: ivyOper.c:287
static int Ivy_IsComplement(Ivy_Obj_t *p)
Definition: ivy.h:196
Definition: ivy.h:58
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Ivy_Obj_t * Ivy_CanonAnd(Ivy_Man_t *p, Ivy_Obj_t *pObj0, Ivy_Obj_t *pObj1)
Definition: ivyCanon.c:90
static int Ivy_ObjFaninId1(Ivy_Obj_t *pObj)
Definition: ivy.h:268
Definition: ivy.h:57
Ivy_Obj_t * Ivy_ObjCreate(Ivy_Man_t *p, Ivy_Obj_t *pGhost)
Definition: ivyObj.c:77
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
static Ivy_Init_t Ivy_InitNotCond(Ivy_Init_t Init, int fCompl)
Definition: ivy.h:327
static int Ivy_ObjIsLatch(Ivy_Obj_t *pObj)
Definition: ivy.h:241
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_ObjFaninId0(Ivy_Obj_t *pObj)
Definition: ivy.h:267
Ivy_Obj_t * Ivy_TableLookup(Ivy_Man_t *p, Ivy_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition: ivyTable.c:71
Ivy_Obj_t * Ivy_CanonLatch(Ivy_Man_t *p, Ivy_Obj_t *pObj, Ivy_Init_t Init)
Definition: ivyCanon.c:131
static int Ivy_ObjFaninC1(Ivy_Obj_t *pObj)
Definition: ivy.h:270
Ivy_Obj_t * Ivy_CanonExor(Ivy_Man_t *p, Ivy_Obj_t *pObj0, Ivy_Obj_t *pObj1)
Definition: ivyCanon.c:109
Ivy_Init_t
Definition: ivy.h:65
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
Definition: ivy.h:73
static Ivy_Obj_t * Ivy_Regular(Ivy_Obj_t *p)
Definition: ivy.h:193
static Ivy_Type_t Ivy_ObjType(Ivy_Obj_t *pObj)
Definition: ivy.h:231
static int Ivy_ObjIsNode(Ivy_Obj_t *pObj)
Definition: ivy.h:245
static Ivy_Init_t Ivy_InitAnd(Ivy_Init_t InitA, Ivy_Init_t InitB)
Definition: ivy.h:340
typedefABC_NAMESPACE_HEADER_START struct Ivy_Man_t_ Ivy_Man_t
INCLUDES ///.
Definition: ivy.h:46
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
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
Definition: ivy.h:59
static int Ivy_ObjIsAnd(Ivy_Obj_t *pObj)
Definition: ivy.h:242
static Ivy_Obj_t * Ivy_NotCond(Ivy_Obj_t *p, int c)
Definition: ivy.h:195
static Ivy_Init_t Ivy_InitExor(Ivy_Init_t InitA, Ivy_Init_t InitB)
Definition: ivy.h:351
#define assert(ex)
Definition: util_old.h:213
Ivy_Obj_t * Ivy_CanonPair_rec(Ivy_Man_t *p, Ivy_Obj_t *pGhost)
FUNCTION DEFINITIONS ///.
Definition: ivyCanon.c:47
Ivy_Type_t
Definition: ivy.h:52
static int Ivy_ObjFaninC0(Ivy_Obj_t *pObj)
Definition: ivy.h:269
static ABC_NAMESPACE_IMPL_START Ivy_Obj_t * Ivy_TableLookupPair_rec(Ivy_Man_t *p, Ivy_Obj_t *pObj0, Ivy_Obj_t *pObj1, int fCompl0, int fCompl1, Ivy_Type_t Type)
DECLARATIONS ///.
static Ivy_Init_t Ivy_ObjInit(Ivy_Obj_t *pObj)
Definition: ivy.h:232