abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
int2Refine.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [int2Refine.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Interpolation engine.]
8 
9  Synopsis [Various utilities.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - Dec 1, 2013.]
16 
17  Revision [$Id: int2Refine.c,v 1.00 2013/12/01 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "int2Int.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis []
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
45 void Int2_ManJustify_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSelect )
46 {
47  if ( pObj->fMark1 )
48  return;
49  pObj->fMark1 = 1;
50  if ( Gia_ObjIsPi(p, pObj) )
51  return;
52  if ( Gia_ObjIsCo(pObj) )
53  {
54  Vec_IntPush( vSelect, Gia_ObjCioId(pObj) );
55  return;
56  }
57  assert( Gia_ObjIsAnd(pObj) );
58  if ( pObj->Value == 1 )
59  {
60  if ( Gia_ObjFanin0(pObj)->Value < ABC_INFINITY )
61  Int2_ManJustify_rec( p, Gia_ObjFanin0(pObj), vSelect );
62  if ( Gia_ObjFanin1(pObj)->Value < ABC_INFINITY )
63  Int2_ManJustify_rec( p, Gia_ObjFanin1(pObj), vSelect );
64  return;
65  }
66  if ( (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) == 0 && (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj)) == 0 )
67  {
68  if ( Gia_ObjFanin0(pObj)->fMark0 <= Gia_ObjFanin1(pObj)->fMark0 ) // choice
69  {
70  if ( Gia_ObjFanin0(pObj)->Value < ABC_INFINITY )
71  Int2_ManJustify_rec( p, Gia_ObjFanin0(pObj), vSelect );
72  }
73  else
74  {
75  if ( Gia_ObjFanin1(pObj)->Value < ABC_INFINITY )
76  Int2_ManJustify_rec( p, Gia_ObjFanin1(pObj), vSelect );
77  }
78  }
79  else if ( (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) == 0 )
80  {
81  if ( Gia_ObjFanin0(pObj)->Value < ABC_INFINITY )
82  Int2_ManJustify_rec( p, Gia_ObjFanin0(pObj), vSelect );
83  }
84  else if ( (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj)) == 0 )
85  {
86  if ( Gia_ObjFanin1(pObj)->Value < ABC_INFINITY )
87  Int2_ManJustify_rec( p, Gia_ObjFanin1(pObj), vSelect );
88  }
89  else assert( 0 );
90  }
91 
92 /**Function*************************************************************
93 
94  Synopsis [Computes the reduced set of flop variables.]
95 
96  Description [Given is a single-output seq AIG manager and an assignment
97  of its CIs. Returned is a subset of flops that justifies the output.]
98 
99  SideEffects []
100 
101  SeeAlso []
102 
103 ***********************************************************************/
105 {
106  Vec_Int_t * vSubset;
107  Gia_Obj_t * pObj;
108  int i;
109  // set values and prios
110  assert( Gia_ManRegNum(p) > 0 );
111  assert( Vec_IntSize(vAssign) == Vec_IntSize(vPrio) );
112  Gia_ManConst0(p)->fMark0 = 0;
113  Gia_ManConst0(p)->fMark1 = 0;
115  Gia_ManForEachCi( p, pObj, i )
116  {
117  pObj->fMark0 = Vec_IntEntry(vAssign, i);
118  pObj->fMark1 = 0;
119  pObj->Value = Vec_IntEntry(vPrio, i);
120  }
121  Gia_ManForEachAnd( p, pObj, i )
122  {
123  pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) & (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj));
124  pObj->fMark1 = 0;
125  if ( pObj->fMark0 == 1 )
126  pObj->Value = Abc_MaxInt( Gia_ObjFanin0(pObj)->Value, Gia_ObjFanin1(pObj)->Value );
127  else if ( (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) == 0 && (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj)) == 0 )
128  pObj->Value = Abc_MinInt( Gia_ObjFanin0(pObj)->Value, Gia_ObjFanin1(pObj)->Value ); // choice
129  else if ( (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) == 0 )
130  pObj->Value = Gia_ObjFanin0(pObj)->Value;
131  else
132  pObj->Value = Gia_ObjFanin1(pObj)->Value;
133  }
134  pObj = Gia_ManPo( p, 0 );
135  pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj));
136  pObj->fMark1 = 0;
137  pObj->Value = Gia_ObjFanin0(pObj)->Value;
138  assert( pObj->fMark0 == 1 );
139  assert( pObj->Value < ABC_INFINITY );
140  // select subset
141  vSubset = Vec_IntAlloc( 100 );
142  Int2_ManJustify_rec( p, Gia_ObjFanin0(pObj), vSubset );
143  return vSubset;
144 }
145 
146 
147 
148 ////////////////////////////////////////////////////////////////////////
149 /// END OF FILE ///
150 ////////////////////////////////////////////////////////////////////////
151 
152 
154 
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 Gia_Obj_t * Gia_ManPo(Gia_Man_t *p, int v)
Definition: gia.h:406
Vec_Int_t * Int2_ManRefineCube(Gia_Man_t *p, Vec_Int_t *vAssign, Vec_Int_t *vPrio)
Definition: int2Refine.c:104
unsigned fMark1
Definition: gia.h:84
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
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
ABC_NAMESPACE_IMPL_START void Int2_ManJustify_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSelect)
DECLARATIONS ///.
Definition: int2Refine.c:45
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
#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_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
unsigned fMark0
Definition: gia.h:79
Definition: gia.h:95
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
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 ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static int Gia_ObjCioId(Gia_Obj_t *pObj)
Definition: gia.h:411
static int Gia_ObjIsPi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:441
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387