abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
saigCone.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [saigCone.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Sequential AIG package.]
8 
9  Synopsis [Cone of influence computation.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: saigCone.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "saig.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis [Counts the support size of the node.]
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
46 {
47  if ( Aig_ObjIsTravIdCurrent(p, pObj) )
48  return;
49  Aig_ObjSetTravIdCurrent(p, pObj);
50  if ( Aig_ObjIsConst1(pObj) )
51  return;
52  if ( Aig_ObjIsCi(pObj) )
53  {
54  if ( Saig_ObjIsLo(p,pObj) )
55  {
56  pObj = Saig_ManLi( p, Aig_ObjCioId(pObj)-Saig_ManPiNum(p) );
57  Vec_PtrPush( vSupp, pObj );
58  }
59  return;
60  }
61  assert( Aig_ObjIsNode(pObj) );
62  Saig_ManSupport_rec( p, Aig_ObjFanin0(pObj), vSupp );
63  Saig_ManSupport_rec( p, Aig_ObjFanin1(pObj), vSupp );
64 }
65 
66 /**Function*************************************************************
67 
68  Synopsis [Counts the support size of the node.]
69 
70  Description []
71 
72  SideEffects []
73 
74  SeeAlso []
75 
76 ***********************************************************************/
78 {
79  Vec_Ptr_t * vSupp;
80  Aig_Obj_t * pObj;
81  int i;
82  vSupp = Vec_PtrAlloc( 100 );
84  Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
85  {
86  assert( Aig_ObjIsCo(pObj) );
87  Saig_ManSupport_rec( p, Aig_ObjFanin0(pObj), vSupp );
88  }
89  return vSupp;
90 }
91 
92 /**Function*************************************************************
93 
94  Synopsis [Prints information about cones of influence of the POs.]
95 
96  Description []
97 
98  SideEffects []
99 
100  SeeAlso []
101 
102 ***********************************************************************/
104 {
105  Vec_Ptr_t * vPrev, * vCur, * vTotal;
106  int s, i, nCurNew, nCurPrev, nCurOld;
107  assert( Saig_ObjIsPo(p, pObj) );
108  // start the array
109  vPrev = Vec_PtrAlloc( 100 );
110  Vec_PtrPush( vPrev, pObj );
111  // get the current support
112  vCur = Saig_ManSupport( p, vPrev );
113  Vec_PtrClear( vPrev );
114  printf( " PO %3d ", Aig_ObjCioId(pObj) );
115  // continue computing supports as long as there are now nodes
116  vTotal = Vec_PtrAlloc( 100 );
117  for ( s = 0; ; s++ )
118  {
119  // classify current into those new, prev, and older
120  nCurNew = nCurPrev = nCurOld = 0;
121  Vec_PtrForEachEntry( Aig_Obj_t *, vCur, pObj, i )
122  {
123  if ( Vec_PtrFind(vTotal, pObj) == -1 )
124  {
125  Vec_PtrPush( vTotal, pObj );
126  nCurNew++;
127  }
128  else if ( Vec_PtrFind(vPrev, pObj) >= 0 )
129  nCurPrev++;
130  else
131  nCurOld++;
132  }
133  assert( nCurNew + nCurPrev + nCurOld == Vec_PtrSize(vCur) );
134  // print the result
135  printf( "%d:%d %d=%d+%d+%d ", s, Vec_PtrSize(vTotal), Vec_PtrSize(vCur), nCurNew, nCurPrev, nCurOld );
136  if ( nCurNew == 0 )
137  break;
138  // compute one more step
139  Vec_PtrFree( vPrev );
140  vCur = Saig_ManSupport( p, vPrev = vCur );
141  }
142  printf( "\n" );
143  Vec_PtrFree( vPrev );
144  Vec_PtrFree( vCur );
145  Vec_PtrFree( vTotal );
146 }
147 
148 /**Function*************************************************************
149 
150  Synopsis [Prints information about cones of influence of the POs.]
151 
152  Description []
153 
154  SideEffects []
155 
156  SeeAlso []
157 
158 ***********************************************************************/
160 {
161  Aig_Obj_t * pObj;
162  int i;
163  printf( "The format of this print-out: For each PO, x:a b=c+d+e, where \n" );
164  printf( "- x is the time-frame counting back from the PO\n" );
165  printf( "- a is the total number of registers in the COI of the PO so far\n" );
166  printf( "- b is the number of registers in the COI of the PO in this time-frame\n" );
167  printf( "- c is the number of registers in b that are new (appear for the first time)\n" );
168  printf( "- d is the number of registers in b in common with the previous time-frame\n" );
169  printf( "- e is the number of registers in b in common with other time-frames\n" );
170  Aig_ManSetCioIds( p );
171  Saig_ManForEachPo( p, pObj, i )
172  Saig_ManPrintConeOne( p, pObj );
173 }
174 
175 ////////////////////////////////////////////////////////////////////////
176 /// END OF FILE ///
177 ////////////////////////////////////////////////////////////////////////
178 
179 
181 
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Saig_ManPrintConeOne(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: saigCone.c:103
static int Saig_ObjIsLo(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: saig.h:84
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
ABC_NAMESPACE_IMPL_START void Saig_ManSupport_rec(Aig_Man_t *p, Aig_Obj_t *pObj, Vec_Ptr_t *vSupp)
DECLARATIONS ///.
Definition: saigCone.c:45
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Aig_ObjIsTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:295
void Saig_ManPrintCones(Aig_Man_t *p)
FUNCTION DECLARATIONS ///.
Definition: saigCone.c:159
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:293
static int Vec_PtrFind(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:694
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigUtil.c:44
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static int Saig_ObjIsPo(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: saig.h:83
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
static Aig_Obj_t * Saig_ManLi(Aig_Man_t *p, int i)
Definition: saig.h:80
Definition: aig.h:69
void Aig_ManSetCioIds(Aig_Man_t *p)
Definition: aigUtil.c:965
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static int Saig_ManPiNum(Aig_Man_t *p)
MACRO DEFINITIONS ///.
Definition: saig.h:73
#define Saig_ManForEachPo(p, pObj, i)
Definition: saig.h:93
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
Vec_Ptr_t * Saig_ManSupport(Aig_Man_t *p, Vec_Ptr_t *vNodes)
Definition: saigCone.c:77
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
static int Aig_ObjIsCo(Aig_Obj_t *pObj)
Definition: aig.h:276
static int Aig_ObjCioId(Aig_Obj_t *pObj)
Definition: aig.h:285
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223