ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
sbdPath.c
Go to the documentation of this file.
1
20
21#include "sbdInt.h"
22#include "misc/tim/tim.h"
23
25
26
30
34
47{
48 Gia_Obj_t * pObj;
49 int k, iFan, Value = 0;
50 if ( Gia_ObjIsTravIdCurrentId(p, iObj) )
51 return Vec_BitEntry(vPath, iObj);
52 Gia_ObjSetTravIdCurrentId(p, iObj);
53 pObj = Gia_ManObj( p, iObj );
54 if ( Gia_ObjIsCi(pObj) )
55 return Vec_BitEntry(vPath, iObj);
56 assert( Gia_ObjIsAnd(pObj) );
57 Gia_LutForEachFanin( p, iObj, iFan, k )
58 Value |= Sbc_ManAddInternalToPath_rec( p, iFan, vPath );
59 if ( Value )
60 Vec_BitWriteEntry( vPath, iObj, 1 );
61 return Value;
62}
64{
65 int k, iFan, iObj;
66 Gia_ManForEachLut( p, iObj )
67 {
68 if ( !Vec_BitEntry(vPath, iObj) )
69 continue;
71 Gia_LutForEachFanin( p, iObj, iFan, k )
72 Gia_ObjSetTravIdCurrentId(p, iFan);
73 Sbc_ManAddInternalToPath_rec( p, iObj, vPath );
74 }
75}
76
88void Sbc_ManCriticalPath_rec( Gia_Man_t * p, int * pLevels, int iObj, int LevelFan, Vec_Bit_t * vPath, int Slack )
89{
90 Gia_Obj_t * pObj; int k, iFan;
91 if ( Gia_ObjIsTravIdCurrentId(p, iObj) )
92 return;
93 Gia_ObjSetTravIdCurrentId(p, iObj);
94 pObj = Gia_ManObj( p, iObj );
95 Vec_BitWriteEntry( vPath, iObj, 1 );
96 if ( Gia_ObjIsCi(pObj) )
97 {
98 Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
99 int iBox = pManTime ? Tim_ManBoxForCi( pManTime, Gia_ObjCioId(pObj) ) : -1;
100 if ( iBox >= 0 )
101 {
102 int curCo = Tim_ManBoxInputFirst( pManTime, iBox );
103 int nBoxInputs = Tim_ManBoxInputNum( pManTime, iBox );
104 for ( k = 0; k < nBoxInputs; k++ )
105 {
106 Gia_Obj_t * pCo = Gia_ManCo( p, curCo + k );
107 int iDriver = Gia_ObjFaninId0p( p, pCo );
108 if ( (pLevels[iDriver]+Slack >= LevelFan-1) && iDriver )
109 Sbc_ManCriticalPath_rec( p, pLevels, iDriver, pLevels[iDriver], vPath, Abc_MaxInt(0, pLevels[iDriver]+Slack-(LevelFan-1)) );
110 }
111 }
112 return;
113 }
114 assert( Gia_ObjIsAnd(pObj) );
115 Gia_LutForEachFanin( p, iObj, iFan, k )
116 if ( pLevels[iFan]+Slack >= LevelFan-1 )
117 Sbc_ManCriticalPath_rec( p, pLevels, iFan, pLevels[iFan], vPath, Abc_MaxInt(0, pLevels[iFan]+Slack-(LevelFan-1)) );
118}
120{
121 int * pLevels = NULL, k, iDriver, Slack = 1;
122 int nLevels = p->pManTime ? Gia_ManLutLevelWithBoxes(p) : Gia_ManLutLevel(p, &pLevels);
123 Vec_Bit_t * vPath = Vec_BitStart( Gia_ManObjNum(p) );
124 if ( p->pManTime )
125 pLevels = Vec_IntArray( p->vLevels );
127 Gia_ManForEachCoDriverId( p, iDriver, k )
128 if ( (pLevels[iDriver] == nLevels) && iDriver )
129 Sbc_ManCriticalPath_rec( p, pLevels, iDriver, pLevels[iDriver], vPath, Slack );
130 if ( !p->pManTime )
131 ABC_FREE( pLevels );
132 Sbc_ManAddInternalToPath( p, vPath );
133 return vPath;
134}
135
136
149{
150 Vec_Bit_t * vPath = Vec_BitStart( Gia_ManObjNum(p) );
151 int i, k, iFan, nLevels, * pLevels;
152 int nLuts = 0, nNodes = 0, nEdges = 0, nEdgesAll = 0;
153 if ( !Gia_ManHasMapping(p) )
154 {
155 printf( "No mapping is available.\n" );
156 return;
157 }
158 assert( Gia_ManHasMapping(p) );
159 // set critical CO drivers
160 nLevels = Gia_ManLutLevel( p, &pLevels );
161 Gia_ManForEachCoDriverId( p, iFan, i )
162 if ( pLevels[iFan] == nLevels )
163 Vec_BitWriteEntry( vPath, iFan, 1 );
164 // set critical internal nodes
166 {
167 nLuts++;
168 if ( !Vec_BitEntry(vPath, i) )
169 continue;
170 nNodes++;
171 Gia_LutForEachFanin( p, i, iFan, k )
172 {
173 if ( pLevels[iFan] +1 < pLevels[i] )
174 continue;
175 assert( pLevels[iFan] + 1 == pLevels[i] );
176 Vec_BitWriteEntry( vPath, iFan, 1 );
177 nEdges++;
178 //printf( "%d -> %d\n", i, iFan );
179 }
180 }
181 Gia_ManForEachLut( p, i )
182 Gia_LutForEachFanin( p, i, iFan, k )
183 nEdgesAll += (Vec_BitEntry(vPath, i) && Vec_BitEntry(vPath, iFan));
184
185 ABC_FREE( pLevels );
186 Vec_BitFree( vPath );
187 printf( "AIG = %d. LUT = %d. Lev = %d. Path nodes = %d. Path edges = %d. (%d.)\n",
188 Gia_ManAndNum(p), nLuts, nLevels, nNodes, nEdges, nEdgesAll );
189}
190
194
195
197
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Cube * p
Definition exorList.c:222
#define Gia_ManForEachLutReverse(p, i)
Definition gia.h:1159
int Gia_ManLutLevel(Gia_Man_t *p, int **ppLevels)
Definition giaIf.c:165
#define Gia_ManForEachCoDriverId(p, DriverId, i)
Definition gia.h:1246
#define Gia_ManForEachLut(p, i)
Definition gia.h:1157
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition gia.h:1161
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
int Gia_ManLutLevelWithBoxes(Gia_Man_t *p)
Definition giaTim.c:581
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition giaUtil.c:190
void Sbc_ManAddInternalToPath(Gia_Man_t *p, Vec_Bit_t *vPath)
Definition sbdPath.c:63
ABC_NAMESPACE_IMPL_START int Sbc_ManAddInternalToPath_rec(Gia_Man_t *p, int iObj, Vec_Bit_t *vPath)
DECLARATIONS ///.
Definition sbdPath.c:46
void Sbc_ManCriticalPath_rec(Gia_Man_t *p, int *pLevels, int iObj, int LevelFan, Vec_Bit_t *vPath, int Slack)
Definition sbdPath.c:88
void Sbc_ManDelayTrace(Gia_Man_t *p)
Definition sbdPath.c:148
Vec_Bit_t * Sbc_ManCriticalPath(Gia_Man_t *p)
Definition sbdPath.c:119
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition tim.h:92
int Tim_ManBoxForCi(Tim_Man_t *p, int iCo)
Definition timBox.c:87
int Tim_ManBoxInputFirst(Tim_Man_t *p, int iBox)
Definition timBox.c:123
int Tim_ManBoxInputNum(Tim_Man_t *p, int iBox)
Definition timBox.c:187
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
Definition vecBit.h:42