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 
23 ABC_NAMESPACE_IMPL_START
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 ***********************************************************************/
Saig_ManSupport_rec(Aig_Man_t * p,Aig_Obj_t * pObj,Vec_Ptr_t * vSupp)45 void Saig_ManSupport_rec( Aig_Man_t * p, Aig_Obj_t * pObj, Vec_Ptr_t * vSupp )
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 ***********************************************************************/
Saig_ManSupport(Aig_Man_t * p,Vec_Ptr_t * vNodes)77 Vec_Ptr_t * Saig_ManSupport( Aig_Man_t * p, Vec_Ptr_t * vNodes )
78 {
79     Vec_Ptr_t * vSupp;
80     Aig_Obj_t * pObj;
81     int i;
82     vSupp = Vec_PtrAlloc( 100 );
83     Aig_ManIncrementTravId( p );
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 ***********************************************************************/
Saig_ManPrintConeOne(Aig_Man_t * p,Aig_Obj_t * pObj)103 void Saig_ManPrintConeOne( Aig_Man_t * p, Aig_Obj_t * pObj )
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 ***********************************************************************/
Saig_ManPrintCones(Aig_Man_t * p)159 void Saig_ManPrintCones( Aig_Man_t * p )
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 
180 ABC_NAMESPACE_IMPL_END
181 
182