src/map/if/ifUtil.c File Reference

#include "if.h"
Include dependency graph for ifUtil.c:

Go to the source code of this file.

Functions

void If_ManCleanNodeCopy (If_Man_t *p)
void If_ManCleanCutData (If_Man_t *p)
void If_ManCleanMarkV (If_Man_t *p)
float If_ManDelayMax (If_Man_t *p, int fSeq)
void If_ManComputeRequired (If_Man_t *p)
float If_ManScanMapping_rec (If_Man_t *p, If_Obj_t *pObj, If_Obj_t **ppStore)
float If_ManScanMapping (If_Man_t *p)
float If_ManScanMappingSeq_rec (If_Man_t *p, If_Obj_t *pObj, Vec_Ptr_t *vMapped)
float If_ManScanMappingSeq (If_Man_t *p)
void If_ManResetOriginalRefs (If_Man_t *p)
int If_ManCrossCut (If_Man_t *p)
int If_ManCountTrueArea (If_Man_t *p)

Function Documentation

void If_ManCleanCutData ( If_Man_t p  ) 

Function*************************************************************

Synopsis [Sets all the cut data to NULL.]

Description []

SideEffects []

SeeAlso []

Definition at line 61 of file ifUtil.c.

00062 {
00063     If_Obj_t * pObj;
00064     int i;
00065     If_ManForEachObj( p, pObj, i )
00066         If_CutSetData( If_ObjCutBest(pObj), NULL );
00067 }

void If_ManCleanMarkV ( If_Man_t p  ) 

Function*************************************************************

Synopsis [Sets all visited marks to 0.]

Description []

SideEffects []

SeeAlso []

Definition at line 80 of file ifUtil.c.

00081 {
00082     If_Obj_t * pObj;
00083     int i;
00084     If_ManForEachObj( p, pObj, i )
00085         pObj->fVisit = 0;
00086 }

void If_ManCleanNodeCopy ( If_Man_t p  ) 

CFile****************************************************************

FileName [ifUtil.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [FPGA mapping based on priority cuts.]

Synopsis [Various utilities.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - November 21, 2006.]

Revision [

Id
ifUtil.c,v 1.00 2006/11/21 00:00:00 alanmi Exp

] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Sets all the node copy to NULL.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file ifUtil.c.

00043 {
00044     If_Obj_t * pObj;
00045     int i;
00046     If_ManForEachObj( p, pObj, i )
00047         If_ObjSetCopy( pObj, NULL );
00048 }

void If_ManComputeRequired ( If_Man_t p  ) 

Function*************************************************************

Synopsis [Computes the required times of all nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 143 of file ifUtil.c.

00144 {
00145     If_Obj_t * pObj;
00146     int i, Counter;
00147 
00148     // compute area, clean required times, collect nodes used in the mapping
00149     p->nNets = 0;
00150     p->AreaGlo = If_ManScanMapping( p );
00151 
00152     // consider the case when the required times are given
00153     if ( p->pPars->pTimesReq )
00154     {
00155         assert( !p->pPars->fAreaOnly );
00156         // make sure that the required time hold
00157         Counter = 0;
00158         If_ManForEachCo( p, pObj, i )
00159         {
00160             if ( If_ObjArrTime(If_ObjFanin0(pObj)) > p->pPars->pTimesReq[i] + p->fEpsilon )
00161             {
00162                 Counter++;
00163 //                printf( "Required times are violated for output %d (arr = %d; req = %d).\n", 
00164 //                    i, (int)If_ObjArrTime(If_ObjFanin0(pObj)), (int)p->pPars->pTimesReq[i] );
00165             }
00166             If_ObjFanin0(pObj)->Required = p->pPars->pTimesReq[i];
00167         }
00168         if ( Counter )
00169             printf( "Required times are violated for %d outputs.\n", Counter );
00170     }
00171     else
00172     {
00173         // get the global required times
00174         p->RequiredGlo = If_ManDelayMax( p, 0 );
00175         // update the required times according to the target
00176         if ( p->pPars->DelayTarget != -1 )
00177         {
00178             if ( p->RequiredGlo > p->pPars->DelayTarget + p->fEpsilon )
00179             {
00180                 if ( p->fNextRound == 0 )
00181                 {
00182                     p->fNextRound = 1;
00183                     printf( "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->pPars->DelayTarget );
00184                 }
00185             }
00186             else if ( p->RequiredGlo < p->pPars->DelayTarget - p->fEpsilon )
00187             {
00188                 if ( p->fNextRound == 0 )
00189                 {
00190                     p->fNextRound = 1;
00191                     printf( "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
00192                 }
00193                 p->RequiredGlo = p->pPars->DelayTarget;
00194             }
00195         }
00196         // do not propagate required times if area minimization is requested
00197         if ( p->pPars->fAreaOnly ) 
00198             return;
00199         // set the required times for the POs
00200         if ( p->pPars->fLatchPaths )
00201         {
00202             If_ManForEachLatchInput( p, pObj, i )
00203                 If_ObjFanin0(pObj)->Required = p->RequiredGlo;
00204         }
00205         else 
00206         {
00207             If_ManForEachCo( p, pObj, i )
00208                 If_ObjFanin0(pObj)->Required = p->RequiredGlo;
00209         }
00210     }
00211     // go through the nodes in the reverse topological order
00212     Vec_PtrForEachEntry( p->vMapped, pObj, i )
00213         If_CutPropagateRequired( p, If_ObjCutBest(pObj), pObj->Required );
00214 }

int If_ManCountTrueArea ( If_Man_t p  ) 

Function*************************************************************

Synopsis [Computes cross-cut of the circuit.]

Description []

SideEffects []

SeeAlso []

Definition at line 441 of file ifUtil.c.

00442 {
00443     If_Obj_t * pObj;
00444     int i, Area = 0;
00445     Vec_PtrForEachEntry( p->vMapped, pObj, i )
00446         Area += 1 + (If_ObjCutBest(pObj)->nLeaves > (unsigned)p->pPars->nLutSize / 2);
00447     return Area;
00448 }

int If_ManCrossCut ( If_Man_t p  ) 

Function*************************************************************

Synopsis [Computes cross-cut of the circuit.]

Description []

SideEffects []

SeeAlso []

Definition at line 394 of file ifUtil.c.

00395 {
00396     If_Obj_t * pObj, * pFanin;
00397     int i, nCutSize = 0, nCutSizeMax = 0;
00398     If_ManForEachObj( p, pObj, i )
00399     {
00400         if ( !If_ObjIsAnd(pObj) )
00401             continue;
00402         // consider the node
00403         if ( nCutSizeMax < ++nCutSize )
00404             nCutSizeMax = nCutSize;
00405         if ( pObj->nVisits == 0 )
00406             nCutSize--;
00407         // consider the fanins
00408         pFanin = If_ObjFanin0(pObj);
00409         if ( !If_ObjIsCi(pFanin) && --pFanin->nVisits == 0 )
00410             nCutSize--;
00411         pFanin = If_ObjFanin1(pObj);
00412         if ( !If_ObjIsCi(pFanin) && --pFanin->nVisits == 0 )
00413             nCutSize--;
00414         // consider the choice class
00415         if ( pObj->fRepr )
00416             for ( pFanin = pObj; pFanin; pFanin = pFanin->pEquiv )
00417                 if ( !If_ObjIsCi(pFanin) && --pFanin->nVisits == 0 )
00418                     nCutSize--;
00419     }
00420     If_ManForEachObj( p, pObj, i )
00421     {
00422         assert( If_ObjIsCi(pObj) || pObj->fVisit == 0 );
00423         pObj->nVisits = pObj->nVisitsCopy;
00424     }
00425     assert( nCutSize == 0 );
00426 //    printf( "Max cross cut size = %6d.\n", nCutSizeMax );
00427     return nCutSizeMax;
00428 }

float If_ManDelayMax ( If_Man_t p,
int  fSeq 
)

Function*************************************************************

Synopsis [Returns the max delay of the POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 99 of file ifUtil.c.

00100 {
00101     If_Obj_t * pObj;
00102     float DelayBest;
00103     int i;
00104     if ( p->pPars->fLatchPaths && p->pPars->nLatches == 0 )
00105     {
00106         printf( "Delay optimization of latch path is not performed because there is no latches.\n" );
00107         p->pPars->fLatchPaths = 0;
00108     }
00109     DelayBest = -IF_FLOAT_LARGE;
00110     if ( fSeq )
00111     {
00112         assert( p->pPars->nLatches > 0 );
00113         If_ManForEachPo( p, pObj, i )
00114             if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) )
00115                  DelayBest = If_ObjArrTime(If_ObjFanin0(pObj));
00116     }
00117     else if ( p->pPars->fLatchPaths )
00118     {
00119         If_ManForEachLatchInput( p, pObj, i )
00120             if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) )
00121                  DelayBest = If_ObjArrTime(If_ObjFanin0(pObj));
00122     }
00123     else 
00124     {
00125         If_ManForEachCo( p, pObj, i )
00126             if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) )
00127                  DelayBest = If_ObjArrTime(If_ObjFanin0(pObj));
00128     }
00129     return DelayBest;
00130 }

void If_ManResetOriginalRefs ( If_Man_t p  ) 

Function*************************************************************

Synopsis [Computes area, references, and nodes used in the mapping.]

Description [Collects the nodes in reverse topological order in array p->vMapping.]

SideEffects []

SeeAlso []

Definition at line 365 of file ifUtil.c.

00366 {
00367     If_Obj_t * pObj;
00368     int i;
00369     If_ManForEachObj( p, pObj, i )
00370         pObj->nRefs = 0;
00371     If_ManForEachObj( p, pObj, i )
00372     {
00373         if ( If_ObjIsAnd(pObj) )
00374         {
00375             pObj->pFanin0->nRefs++;
00376             pObj->pFanin1->nRefs++;
00377         }
00378         else if ( If_ObjIsCo(pObj) )
00379             pObj->pFanin0->nRefs++;
00380     }
00381 }

float If_ManScanMapping ( If_Man_t p  ) 

Function*************************************************************

Synopsis [Computes area, references, and nodes used in the mapping.]

Description [Collects the nodes in reverse topological order in array p->vMapping.]

SideEffects []

SeeAlso []

Definition at line 260 of file ifUtil.c.

00261 {
00262     If_Obj_t * pObj, ** ppStore;
00263     float aArea;
00264     int i;
00265     assert( !p->pPars->fLiftLeaves );
00266     // clean all references
00267     If_ManForEachObj( p, pObj, i )
00268     {
00269         pObj->Required = IF_FLOAT_LARGE;
00270         pObj->nVisits  = pObj->nVisitsCopy;
00271         pObj->nRefs    = 0;
00272     }
00273     // allocate place to store the nodes
00274     ppStore = ALLOC( If_Obj_t *, p->nLevelMax + 1 );
00275     memset( ppStore, 0, sizeof(If_Obj_t *) * (p->nLevelMax + 1) );
00276     // collect nodes reachable from POs in the DFS order through the best cuts
00277     aArea = 0;
00278     If_ManForEachCo( p, pObj, i )
00279         aArea += If_ManScanMapping_rec( p, If_ObjFanin0(pObj), ppStore );
00280     // reconnect the nodes in reverse topological order
00281     Vec_PtrClear( p->vMapped );
00282     for ( i = p->nLevelMax; i >= 0; i-- )
00283         for ( pObj = ppStore[i]; pObj; pObj = pObj->pCopy )
00284             Vec_PtrPush( p->vMapped, pObj );
00285     free( ppStore );
00286     return aArea;
00287 }

float If_ManScanMapping_rec ( If_Man_t p,
If_Obj_t pObj,
If_Obj_t **  ppStore 
)

Function*************************************************************

Synopsis [Computes area, references, and nodes used in the mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 227 of file ifUtil.c.

00228 {
00229     If_Obj_t * pLeaf;
00230     If_Cut_t * pCutBest;
00231     float aArea;
00232     int i;
00233     if ( pObj->nRefs++ || If_ObjIsCi(pObj) || If_ObjIsConst1(pObj) )
00234         return 0.0;
00235     // store the node in the structure by level
00236     assert( If_ObjIsAnd(pObj) );
00237     pObj->pCopy = (char *)ppStore[pObj->Level]; 
00238     ppStore[pObj->Level] = pObj;
00239     // visit the transitive fanin of the selected cut
00240     pCutBest = If_ObjCutBest(pObj);
00241     p->nNets += pCutBest->nLeaves;
00242     aArea = If_CutLutArea( p, pCutBest );
00243     If_CutForEachLeaf( p, pCutBest, pLeaf, i )
00244         aArea += If_ManScanMapping_rec( p, pLeaf, ppStore );
00245     return aArea;
00246 }

float If_ManScanMappingSeq ( If_Man_t p  ) 

Function*************************************************************

Synopsis [Computes area, references, and nodes used in the mapping.]

Description [Collects the nodes in reverse topological order in array p->vMapping.]

SideEffects []

SeeAlso []

Definition at line 336 of file ifUtil.c.

00337 {
00338     If_Obj_t * pObj;
00339     float aArea;
00340     int i;
00341     assert( p->pPars->fLiftLeaves );
00342     // clean all references
00343     If_ManForEachObj( p, pObj, i )
00344         pObj->nRefs = 0;
00345     // collect nodes reachable from POs in the DFS order through the best cuts
00346     aArea = 0;
00347     Vec_PtrClear( p->vMapped );
00348     If_ManForEachPo( p, pObj, i )
00349         aArea += If_ManScanMappingSeq_rec( p, If_ObjFanin0(pObj), p->vMapped );
00350     return aArea;
00351 }

float If_ManScanMappingSeq_rec ( If_Man_t p,
If_Obj_t pObj,
Vec_Ptr_t vMapped 
)

Function*************************************************************

Synopsis [Computes area, references, and nodes used in the mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 300 of file ifUtil.c.

00301 {
00302     If_Obj_t * pLeaf;
00303     If_Cut_t * pCutBest;
00304     float aArea;
00305     int i, Shift;
00306     // treat latches transparently
00307     if ( If_ObjIsLatch(pObj) )
00308         return If_ManScanMappingSeq_rec( p, If_ObjFanin0(pObj), vMapped );
00309     // consider trivial cases
00310     if ( pObj->nRefs++ || If_ObjIsPi(pObj) || If_ObjIsConst1(pObj) )
00311         return 0.0;
00312     // store the node in the structure by level
00313     assert( If_ObjIsAnd(pObj) );
00314     // visit the transitive fanin of the selected cut
00315     pCutBest = If_ObjCutBest(pObj);
00316     aArea = If_ObjIsAnd(pObj)? If_CutLutArea(p, pCutBest) : (float)0.0;
00317     If_CutForEachLeafSeq( p, pCutBest, pLeaf, Shift, i )
00318         aArea += If_ManScanMappingSeq_rec( p, pLeaf, vMapped );
00319     // add the node
00320     Vec_PtrPush( vMapped, pObj );
00321     return aArea;
00322 }


Generated on Tue Jan 5 12:19:04 2010 for abc70930 by  doxygen 1.6.1