ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ifUtil.c File Reference
#include "if.h"
Include dependency graph for ifUtil.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void If_ManCleanNodeCopy (If_Man_t *p)
 DECLARATIONS ///.
 
void If_ManCleanCutData (If_Man_t *p)
 
void If_ManCleanMarkV (If_Man_t *p)
 
void If_ManResetOriginalRefs (If_Man_t *p)
 
int If_ManCrossCut (If_Man_t *p)
 
Vec_Ptr_tIf_ManReverseOrder (If_Man_t *p)
 
float If_ManMarkMapping_rec (If_Man_t *p, If_Obj_t *pObj)
 
void If_ManMarkMapping (If_Man_t *p)
 
Vec_Ptr_tIf_ManCollectMappingDirect (If_Man_t *p)
 
Vec_Int_tIf_ManCollectMappingInt (If_Man_t *p)
 
int If_ManCountSpecialPos (If_Man_t *p)
 
void If_CutTraverse (If_Man_t *p, If_Obj_t *pRoot, If_Cut_t *pCut, Vec_Ptr_t *vNodes)
 
void If_CutTraverseTest (If_Man_t *p, If_Obj_t *pRoot, If_Cut_t *pCut)
 
void If_ObjPrint (If_Obj_t *pObj)
 

Function Documentation

◆ If_CutTraverse()

void If_CutTraverse ( If_Man_t * p,
If_Obj_t * pRoot,
If_Cut_t * pCut,
Vec_Ptr_t * vNodes )

Definition at line 565 of file ifUtil.c.

566{
567 If_Obj_t * pLeaf;
568 int i;
569 // collect the internal nodes of the cut
570 Vec_PtrClear( vNodes );
571 If_CutForEachLeaf( p, pCut, pLeaf, i )
572 {
573 Vec_PtrPush( vNodes, pLeaf );
574 assert( pLeaf->fMark == 0 );
575 pLeaf->fMark = 1;
576 }
577 // collect other nodes
578 If_CutTraverse_rec( pRoot, vNodes );
579 // clean the mark
580 Vec_PtrForEachEntry( If_Obj_t *, vNodes, pLeaf, i )
581 pLeaf->fMark = 0;
582}
Cube * p
Definition exorList.c:222
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition if.h:503
struct If_Obj_t_ If_Obj_t
Definition if.h:79
unsigned fMark
Definition if.h:338
#define assert(ex)
Definition util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the caller graph for this function:

◆ If_CutTraverseTest()

void If_CutTraverseTest ( If_Man_t * p,
If_Obj_t * pRoot,
If_Cut_t * pCut )

Definition at line 583 of file ifUtil.c.

584{
585 Vec_Ptr_t * vNodes;
586 vNodes = Vec_PtrAlloc( 1000 );
587 If_CutTraverse( p, pRoot, pCut, vNodes );
588//if ( Vec_PtrSize(vNodes) > 30 )
589//printf( "%d ", Vec_PtrSize(vNodes) );
590 Vec_PtrFree( vNodes );
591}
void If_CutTraverse(If_Man_t *p, If_Obj_t *pRoot, If_Cut_t *pCut, Vec_Ptr_t *vNodes)
Definition ifUtil.c:565
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:

◆ If_ManCleanCutData()

void If_ManCleanCutData ( If_Man_t * p)

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

Synopsis [Sets all the cut data to NULL.]

Description []

SideEffects []

SeeAlso []

Definition at line 64 of file ifUtil.c.

65{
66 If_Obj_t * pObj;
67 int i;
68 If_ManForEachObj( p, pObj, i )
69 If_CutSetData( If_ObjCutBest(pObj), NULL );
70}
#define If_ManForEachObj(p, pObj, i)
Definition if.h:491
Here is the caller graph for this function:

◆ If_ManCleanMarkV()

void If_ManCleanMarkV ( If_Man_t * p)

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

Synopsis [Sets all visited marks to 0.]

Description []

SideEffects []

SeeAlso []

Definition at line 83 of file ifUtil.c.

84{
85 If_Obj_t * pObj;
86 int i;
87 If_ManForEachObj( p, pObj, i )
88 pObj->fVisit = 0;
89}
unsigned fVisit
Definition if.h:339

◆ If_ManCleanNodeCopy()

ABC_NAMESPACE_IMPL_START void If_ManCleanNodeCopy ( If_Man_t * p)

DECLARATIONS ///.

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

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

Synopsis [Sets all the node copy to NULL.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file ifUtil.c.

46{
47 If_Obj_t * pObj;
48 int i;
49 If_ManForEachObj( p, pObj, i )
50 If_ObjSetCopy( pObj, NULL );
51}
Here is the caller graph for this function:

◆ If_ManCollectMappingDirect()

Vec_Ptr_t * If_ManCollectMappingDirect ( If_Man_t * p)

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

Synopsis [Collects nodes used in the mapping in the topological order.]

Description []

SideEffects []

SeeAlso []

Definition at line 462 of file ifUtil.c.

463{
464 Vec_Ptr_t * vOrder;
465 If_Obj_t * pObj;
466 int i;
468 vOrder = Vec_PtrAlloc( If_ManObjNum(p) );
469 If_ManForEachObj( p, pObj, i )
470 if ( If_ObjIsAnd(pObj) && pObj->nRefs )
471 Vec_PtrPush( vOrder, pObj );
472 return vOrder;
473}
void If_ManMarkMapping(If_Man_t *p)
Definition ifUtil.c:434
int nRefs
Definition if.h:346
Here is the call graph for this function:

◆ If_ManCollectMappingInt()

Vec_Int_t * If_ManCollectMappingInt ( If_Man_t * p)

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

Synopsis [Collects nodes used in the mapping in the topological order.]

Description [Represents mapping as an array of integers.]

SideEffects []

SeeAlso []

Definition at line 486 of file ifUtil.c.

487{
488 Vec_Int_t * vOrder;
489 If_Cut_t * pCutBest;
490 If_Obj_t * pObj;
491 int i, k, nLeaves, * ppLeaves;
493 vOrder = Vec_IntAlloc( If_ManObjNum(p) );
494 If_ManForEachObj( p, pObj, i )
495 if ( If_ObjIsAnd(pObj) && pObj->nRefs )
496 {
497 pCutBest = If_ObjCutBest( pObj );
498 nLeaves = If_CutLeaveNum( pCutBest );
499 ppLeaves = If_CutLeaves( pCutBest );
500 // save the number of leaves, the leaves, and finally, the root
501 Vec_IntPush( vOrder, nLeaves );
502 for ( k = 0; k < nLeaves; k++ )
503 Vec_IntPush( vOrder, ppLeaves[k] );
504 Vec_IntPush( vOrder, pObj->Id );
505 }
506 return vOrder;
507}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
struct If_Cut_t_ If_Cut_t
Definition if.h:80
int Id
Definition if.h:344
Here is the call graph for this function:

◆ If_ManCountSpecialPos()

int If_ManCountSpecialPos ( If_Man_t * p)

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

Synopsis [Returns the number of POs pointing to the same internal nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 520 of file ifUtil.c.

521{
522 If_Obj_t * pObj;
523 int i, Counter = 0;
524 // clean all marks
525 If_ManForEachPo( p, pObj, i )
526 If_ObjFanin0(pObj)->fMark = 0;
527 // label nodes
528 If_ManForEachPo( p, pObj, i )
529 if ( !If_ObjFaninC0(pObj) )
530 If_ObjFanin0(pObj)->fMark = 1;
531 // label nodes
532 If_ManForEachPo( p, pObj, i )
533 if ( If_ObjFaninC0(pObj) )
534 Counter += If_ObjFanin0(pObj)->fMark;
535 // clean all marks
536 If_ManForEachPo( p, pObj, i )
537 If_ObjFanin0(pObj)->fMark = 0;
538 return Counter;
539}
#define If_ManForEachPo(p, pObj, i)
Definition if.h:483

◆ If_ManCrossCut()

int If_ManCrossCut ( If_Man_t * p)

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

Synopsis [Computes cross-cut of the circuit.]

Description []

SideEffects []

SeeAlso []

Definition at line 316 of file ifUtil.c.

317{
318 If_Obj_t * pObj, * pFanin;
319 int i, nCutSize = 0, nCutSizeMax = 0;
320 If_ManForEachObj( p, pObj, i )
321 {
322 if ( !If_ObjIsAnd(pObj) )
323 continue;
324 // consider the node
325 if ( nCutSizeMax < ++nCutSize )
326 nCutSizeMax = nCutSize;
327 if ( pObj->nVisits == 0 )
328 nCutSize--;
329 // consider the fanins
330 pFanin = If_ObjFanin0(pObj);
331 if ( !If_ObjIsCi(pFanin) && --pFanin->nVisits == 0 )
332 nCutSize--;
333 pFanin = If_ObjFanin1(pObj);
334 if ( !If_ObjIsCi(pFanin) && --pFanin->nVisits == 0 )
335 nCutSize--;
336 // consider the choice class
337 if ( pObj->fRepr )
338 for ( pFanin = pObj; pFanin; pFanin = pFanin->pEquiv )
339 if ( !If_ObjIsCi(pFanin) && --pFanin->nVisits == 0 )
340 nCutSize--;
341 }
342 If_ManForEachObj( p, pObj, i )
343 {
344 assert( If_ObjIsCi(pObj) || pObj->fVisit == 0 );
345 pObj->nVisits = pObj->nVisitsCopy;
346 }
347 assert( nCutSize == 0 );
348// Abc_Print( 1, "Max cross cut size = %6d.\n", nCutSizeMax );
349 return nCutSizeMax;
350}
int nVisits
Definition if.h:347
unsigned fRepr
Definition if.h:337
int nVisitsCopy
Definition if.h:348
If_Obj_t * pEquiv
Definition if.h:351
Here is the caller graph for this function:

◆ If_ManMarkMapping()

void If_ManMarkMapping ( If_Man_t * p)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 434 of file ifUtil.c.

435{
436 If_Obj_t * pObj;
437 int i;
438 If_ManForEachObj( p, pObj, i )
439 {
440 pObj->Required = IF_FLOAT_LARGE;
441 pObj->nVisits = pObj->nVisitsCopy;
442 pObj->nRefs = 0;
443 }
444 p->nNets = 0;
445 p->dPower = 0.0;
446 p->AreaGlo = 0.0;
447 If_ManForEachCo( p, pObj, i )
448 p->AreaGlo += If_ManMarkMapping_rec( p, If_ObjFanin0(pObj) );
449}
float If_ManMarkMapping_rec(If_Man_t *p, If_Obj_t *pObj)
Definition ifUtil.c:400
#define If_ManForEachCo(p, pObj, i)
Definition if.h:477
#define IF_FLOAT_LARGE
Definition if.h:469
float Required
Definition if.h:353
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_ManMarkMapping_rec()

float If_ManMarkMapping_rec ( If_Man_t * p,
If_Obj_t * pObj )

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 400 of file ifUtil.c.

401{
402 If_Obj_t * pLeaf;
403 If_Cut_t * pCutBest;
404 float * pSwitching = p->vSwitching? (float*)p->vSwitching->pArray : NULL;
405 float aArea;
406 int i;
407 if ( pObj->nRefs++ || If_ObjIsCi(pObj) || If_ObjIsConst1(pObj) )
408 return 0.0;
409 // store the node in the structure by level
410 assert( If_ObjIsAnd(pObj) );
411 // visit the transitive fanin of the selected cut
412 pCutBest = If_ObjCutBest(pObj);
413 p->nNets += pCutBest->nLeaves;
414 aArea = If_CutLutArea( p, pCutBest );
415 If_CutForEachLeaf( p, pCutBest, pLeaf, i )
416 {
417 p->dPower += pSwitching? pSwitching[pLeaf->Id] : 0.0;
418 aArea += If_ManMarkMapping_rec( p, pLeaf );
419 }
420 return aArea;
421}
unsigned nLeaves
Definition if.h:316
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_ManResetOriginalRefs()

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 287 of file ifUtil.c.

288{
289 If_Obj_t * pObj;
290 int i;
291 If_ManForEachObj( p, pObj, i )
292 pObj->nRefs = 0;
293 If_ManForEachObj( p, pObj, i )
294 {
295 if ( If_ObjIsAnd(pObj) )
296 {
297 pObj->pFanin0->nRefs++;
298 pObj->pFanin1->nRefs++;
299 }
300 else if ( If_ObjIsCo(pObj) )
301 pObj->pFanin0->nRefs++;
302 }
303}
If_Obj_t * pFanin1
Definition if.h:350
If_Obj_t * pFanin0
Definition if.h:349
Here is the caller graph for this function:

◆ If_ManReverseOrder()

Vec_Ptr_t * If_ManReverseOrder ( If_Man_t * p)

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

Synopsis [Computes the reverse topological order of nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 363 of file ifUtil.c.

364{
365 Vec_Ptr_t * vOrder;
366 If_Obj_t * pObj, ** ppStore;
367 int i;
368 // allocate place to store the nodes
369 ppStore = ABC_ALLOC( If_Obj_t *, p->nLevelMax + 1 );
370 memset( ppStore, 0, sizeof(If_Obj_t *) * (p->nLevelMax + 1) );
371 // add the nodes
372 If_ManForEachObj( p, pObj, i )
373 {
374 assert( pObj->Level >= 0 && pObj->Level <= (unsigned)p->nLevelMax );
375 pObj->pCopy = (char *)ppStore[pObj->Level];
376 ppStore[pObj->Level] = pObj;
377 }
378 vOrder = Vec_PtrAlloc( If_ManObjNum(p) );
379 for ( i = p->nLevelMax; i >= 0; i-- )
380 for ( pObj = ppStore[i]; pObj; pObj = (If_Obj_t *)pObj->pCopy )
381 Vec_PtrPush( vOrder, pObj );
382 ABC_FREE( ppStore );
383 // print the order
384// Vec_PtrForEachEntry( If_Obj_t *, vOrder, pObj, i )
385// Abc_Print( 1, "Obj %2d Type %d Level = %d\n", pObj->Id, pObj->Type, pObj->Level );
386 return vOrder;
387}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
unsigned Level
Definition if.h:343
void * pCopy
Definition if.h:356
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_ObjPrint()

void If_ObjPrint ( If_Obj_t * pObj)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 604 of file ifUtil.c.

605{
606 if ( pObj == NULL )
607 {
608 printf( "Object is NULL." );
609 return;
610 }
611 printf( "Obj %4d : ", If_ObjId(pObj) );
612 if ( If_ObjIsConst1(pObj) )
613 printf( "constant 1" );
614 else if ( If_ObjIsCi(pObj) )
615 printf( "PI" );
616 else if ( If_ObjIsCo(pObj) )
617 printf( "PO( %4d%s )", If_ObjId(If_ObjFanin0(pObj)), (If_ObjFaninC0(pObj)? "\'" : " ") );
618 else
619 printf( "AND( %4d%s, %4d%s )",
620 If_ObjId(If_ObjFanin0(pObj)), (If_ObjFaninC0(pObj)? "\'" : " "),
621 If_ObjId(If_ObjFanin1(pObj)), (If_ObjFaninC1(pObj)? "\'" : " ") );
622 printf( " (refs = %3d)", pObj->nVisitsCopy );
623 printf( "\n" );
624}