abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
llb2Driver.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [llb2Driver.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [BDD based reachability.]
8 
9  Synopsis [Procedures working with flop drivers.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: llb2Driver.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "llbInt.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 // driver issue:arises when creating
31 // - driver ref-counter array
32 // - Ns2Glo maps
33 // - final partition
34 // - change-phase cube
35 
36 // LI variable is used when
37 // - driver drives more than one LI
38 // - driver is a PI
39 // - driver is a constant
40 
41 ////////////////////////////////////////////////////////////////////////
42 /// FUNCTION DEFINITIONS ///
43 ////////////////////////////////////////////////////////////////////////
44 
45 /**Function*************************************************************
46 
47  Synopsis [Returns the array of times each flop driver is referenced.]
48 
49  Description []
50 
51  SideEffects []
52 
53  SeeAlso []
54 
55 ***********************************************************************/
57 {
58  Vec_Int_t * vCounts;
59  Aig_Obj_t * pObj;
60  int i;
61  vCounts = Vec_IntStart( Aig_ManObjNumMax(p) );
62  Saig_ManForEachLi( p, pObj, i )
63  Vec_IntAddToEntry( vCounts, Aig_ObjFaninId0(pObj), 1 );
64  return vCounts;
65 }
66 
67 /**Function*************************************************************
68 
69  Synopsis [Returns array of NS variables.]
70 
71  Description []
72 
73  SideEffects []
74 
75  SeeAlso []
76 
77 ***********************************************************************/
79 {
80  Vec_Int_t * vVars;
81  Aig_Obj_t * pObj, * pDri;
82  int i;
83  vVars = Vec_IntAlloc( Aig_ManRegNum(pAig) );
84  Saig_ManForEachLi( pAig, pObj, i )
85  {
86  pDri = Aig_ObjFanin0(pObj);
87  if ( Vec_IntEntry( vDriRefs, Aig_ObjId(pDri) ) != 1 || Saig_ObjIsPi(pAig, pDri) || Aig_ObjIsConst1(pDri) )
88  Vec_IntPush( vVars, Aig_ObjId(pObj) );
89  else
90  Vec_IntPush( vVars, Aig_ObjId(pDri) );
91  }
92  return vVars;
93 }
94 
95 /**Function*************************************************************
96 
97  Synopsis [Returns array of CS variables.]
98 
99  Description []
100 
101  SideEffects []
102 
103  SeeAlso []
104 
105 ***********************************************************************/
107 {
108  Vec_Int_t * vVars;
109  Aig_Obj_t * pObj;
110  int i;
111  vVars = Vec_IntAlloc( Aig_ManRegNum(pAig) );
112  Saig_ManForEachLo( pAig, pObj, i )
113  Vec_IntPush( vVars, Aig_ObjId(pObj) );
114  return vVars;
115 }
116 
117 /**Function*************************************************************
118 
119  Synopsis [Create cube for phase swapping.]
120 
121  Description []
122 
123  SideEffects []
124 
125  SeeAlso []
126 
127 ***********************************************************************/
129 {
130  DdNode * bCube, * bVar, * bTemp;
131  Aig_Obj_t * pObj;
132  int i;
133  abctime TimeStop;
134  TimeStop = dd->TimeStop; dd->TimeStop = 0;
135  bCube = Cudd_ReadOne( dd ); Cudd_Ref( bCube );
136  Saig_ManForEachLi( pAig, pObj, i )
137  {
138  assert( Vec_IntEntry( vDriRefs, Aig_ObjFaninId0(pObj) ) >= 1 );
139  if ( Vec_IntEntry( vDriRefs, Aig_ObjFaninId0(pObj) ) != 1 )
140  continue;
141  if ( !Aig_ObjFaninC0(pObj) )
142  continue;
143  bVar = Cudd_bddIthVar( dd, Aig_ObjFaninId0(pObj) );
144  bCube = Cudd_bddAnd( dd, bTemp = bCube, bVar ); Cudd_Ref( bCube );
145  Cudd_RecursiveDeref( dd, bTemp );
146  }
147  Cudd_Deref( bCube );
148  dd->TimeStop = TimeStop;
149  return bCube;
150 }
151 
152 /**Function*************************************************************
153 
154  Synopsis [Compute the last partition.]
155 
156  Description []
157 
158  SideEffects []
159 
160  SeeAlso []
161 
162 ***********************************************************************/
164 {
165 // int fVerbose = 1;
166  DdManager * dd;
167  DdNode * bVar1, * bVar2, * bProd, * bRes, * bTemp;
168  Aig_Obj_t * pObj;
169  int i;
172  dd->TimeStop = TimeTarget;
173  bRes = Cudd_ReadOne(dd); Cudd_Ref( bRes );
174 
175  // mark the duplicated flop inputs
176  Aig_ManForEachObjVec( vVarsNs, p, pObj, i )
177  {
178  if ( !Saig_ObjIsLi(p, pObj) )
179  continue;
180  bVar1 = Cudd_bddIthVar( dd, Aig_ObjId(pObj) );
181  bVar2 = Cudd_bddIthVar( dd, Aig_ObjFaninId0(pObj) );
182  if ( Aig_ObjIsConst1(Aig_ObjFanin0(pObj)) )
183  bVar2 = Cudd_ReadOne(dd);
184  bVar2 = Cudd_NotCond( bVar2, Aig_ObjFaninC0(pObj) );
185  bProd = Cudd_bddXnor( dd, bVar1, bVar2 ); Cudd_Ref( bProd );
186 // bRes = Cudd_bddAnd( dd, bTemp = bRes, bProd ); Cudd_Ref( bRes );
187 // bRes = Extra_bddAndTime( dd, bTemp = bRes, bProd, TimeTarget );
188  bRes = Cudd_bddAnd( dd, bTemp = bRes, bProd );
189  if ( bRes == NULL )
190  {
191  Cudd_RecursiveDeref( dd, bTemp );
192  Cudd_RecursiveDeref( dd, bProd );
193  return NULL;
194  }
195  Cudd_Ref( bRes );
196  Cudd_RecursiveDeref( dd, bTemp );
197  Cudd_RecursiveDeref( dd, bProd );
198  }
199 
200 /*
201  Saig_ManForEachLi( p, pObj, i )
202  printf( "%d ", Aig_ObjId(pObj) );
203  printf( "\n" );
204  Saig_ManForEachLi( p, pObj, i )
205  printf( "%c%d ", Aig_ObjFaninC0(pObj)? '-':'+', Aig_ObjFaninId0(pObj) );
206  printf( "\n" );
207 */
208  Cudd_AutodynDisable( dd );
209 // Cudd_RecursiveDeref( dd, bRes );
210 // Extra_StopManager( dd );
211  dd->bFunc = bRes;
212  dd->TimeStop = 0;
213  return dd;
214 }
215 
216 ////////////////////////////////////////////////////////////////////////
217 /// END OF FILE ///
218 ////////////////////////////////////////////////////////////////////////
219 
220 
222 
#define CUDD_UNIQUE_SLOTS
Definition: cudd.h:97
static int Aig_ObjFaninId0(Aig_Obj_t *pObj)
Definition: aig.h:304
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
abctime TimeStop
Definition: cuddInt.h:489
Definition: cudd.h:278
#define Aig_ManForEachObjVec(vIds, p, pObj, i)
Definition: aig.h:408
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
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
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
DdManager * Llb_DriverLastPartition(Aig_Man_t *p, Vec_Int_t *vVarsNs, abctime TimeTarget)
Definition: llb2Driver.c:163
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
#define CUDD_CACHE_SLOTS
Definition: cudd.h:98
DdNode * bFunc
Definition: cuddInt.h:487
ABC_NAMESPACE_IMPL_START Vec_Int_t * Llb_DriverCountRefs(Aig_Man_t *p)
DECLARATIONS ///.
Definition: llb2Driver.c:56
static int Saig_ObjIsLi(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: saig.h:85
Vec_Int_t * Llb_DriverCollectNs(Aig_Man_t *pAig, Vec_Int_t *vDriRefs)
Definition: llb2Driver.c:78
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
Vec_Int_t * Llb_DriverCollectCs(Aig_Man_t *pAig)
Definition: llb2Driver.c:106
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
#define Saig_ManForEachLi(p, pObj, i)
Definition: saig.h:98
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
DdManager * Cudd_Init(unsigned int numVars, unsigned int numVarsZ, unsigned int numSlots, unsigned int cacheSize, unsigned long maxMemory)
Definition: cuddInit.c:125
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
Definition: aig.h:69
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Saig_ManForEachLo(p, pObj, i)
Definition: saig.h:96
DdNode * Cudd_bddXnor(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:507
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
void Cudd_AutodynDisable(DdManager *unique)
Definition: cuddAPI.c:708
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
DdNode * Cudd_ReadOne(DdManager *dd)
Definition: cuddAPI.c:987
DdNode * Llb_DriverPhaseCube(Aig_Man_t *pAig, Vec_Int_t *vDriRefs, DdManager *dd)
Definition: llb2Driver.c:128
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:416
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static int Aig_ObjId(Aig_Obj_t *pObj)
Definition: aig.h:286
#define assert(ex)
Definition: util_old.h:213
void Cudd_AutodynEnable(DdManager *unique, Cudd_ReorderingType method)
Definition: cuddAPI.c:669
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
ABC_INT64_T abctime
Definition: abc_global.h:278
static int Saig_ObjIsPi(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: saig.h:82