ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
dar.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Dar_RwrPar_t_
 
struct  Dar_RefPar_t_
 

Typedefs

typedef typedefABC_NAMESPACE_HEADER_START struct Dar_RwrPar_t_ Dar_RwrPar_t
 INCLUDES ///.
 
typedef struct Dar_RefPar_t_ Dar_RefPar_t
 

Functions

void Dar_LibStart ()
 MACRO DEFINITIONS ///.
 
void Dar_LibStop ()
 
void Dar_LibPrepare (int nSubgraphs)
 
int Dar_LibReturnClass (unsigned uTruth)
 
Aig_Man_tDar_ManBalance (Aig_Man_t *p, int fUpdateLevel)
 
Aig_Man_tDar_ManBalanceXor (Aig_Man_t *pAig, int fExor, int fUpdateLevel, int fVerbose)
 
void Dar_BalancePrintStats (Aig_Man_t *p)
 
void Dar_ManDefaultRwrParams (Dar_RwrPar_t *pPars)
 FUNCTION DEFINITIONS ///.
 
int Dar_ManRewrite (Aig_Man_t *pAig, Dar_RwrPar_t *pPars)
 
Aig_MmFixed_tDar_ManComputeCuts (Aig_Man_t *pAig, int nCutsMax, int fSkipTtMin, int fVerbose)
 
void Dar_ManDefaultRefParams (Dar_RefPar_t *pPars)
 FUNCTION DEFINITIONS ///.
 
int Dar_ManRefactor (Aig_Man_t *pAig, Dar_RefPar_t *pPars)
 
Aig_Man_tDar_ManRewriteDefault (Aig_Man_t *pAig)
 DECLARATIONS ///.
 
Aig_Man_tDar_ManRwsat (Aig_Man_t *pAig, int fBalance, int fVerbose)
 DECLARATIONS ///.
 
Aig_Man_tDar_ManCompress (Aig_Man_t *pAig, int fBalance, int fUpdateLevel, int fPower, int fVerbose)
 
Aig_Man_tDar_ManCompress2 (Aig_Man_t *pAig, int fBalance, int fUpdateLevel, int fFanout, int fPower, int fVerbose)
 
Aig_Man_tDar_ManChoice (Aig_Man_t *pAig, int fBalance, int fUpdateLevel, int fConstruct, int nConfMax, int nLevelMax, int fVerbose)
 

Typedef Documentation

◆ Dar_RefPar_t

typedef struct Dar_RefPar_t_ Dar_RefPar_t

Definition at line 43 of file dar.h.

◆ Dar_RwrPar_t

typedef typedefABC_NAMESPACE_HEADER_START struct Dar_RwrPar_t_ Dar_RwrPar_t

INCLUDES ///.

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

FileName [dar.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [DAG-aware AIG rewriting.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - April 28, 2007.]

Revision [

Id
dar.h,v 1.00 2007/04/28 00:00:00 alanmi Exp

] PARAMETERS /// BASIC TYPES ///

Definition at line 42 of file dar.h.

Function Documentation

◆ Dar_BalancePrintStats()

void Dar_BalancePrintStats ( Aig_Man_t * p)
extern

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

Synopsis [Inserts a new node in the order by levels.]

Description []

SideEffects []

SeeAlso []

Definition at line 716 of file darBalance.c.

717{
718 Vec_Ptr_t * vSuper;
719 Aig_Obj_t * pObj, * pTemp;
720 int i, k;
721 if ( Aig_ManExorNum(p) == 0 )
722 {
723 printf( "There is no EXOR gates.\n" );
724 return;
725 }
726 Aig_ManForEachExor( p, pObj, i )
727 {
728 Aig_ObjFanin0(pObj)->fMarkA = 1;
729 Aig_ObjFanin1(pObj)->fMarkA = 1;
730 assert( !Aig_ObjFaninC0(pObj) );
731 assert( !Aig_ObjFaninC1(pObj) );
732 }
733 vSuper = Vec_PtrAlloc( 1000 );
734 Aig_ManForEachExor( p, pObj, i )
735 {
736 if ( pObj->fMarkA && pObj->nRefs == 1 )
737 continue;
738 Vec_PtrClear( vSuper );
739 Dar_BalanceCone_rec( pObj, pObj, vSuper );
740 Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pTemp, k )
741 pTemp->fMarkB = 0;
742 if ( Vec_PtrSize(vSuper) < 3 )
743 continue;
744 printf( " %d(", Vec_PtrSize(vSuper) );
745 Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pTemp, k )
746 printf( " %d", pTemp->Level );
747 printf( " )" );
748 }
749 Vec_PtrFree( vSuper );
750 Aig_ManForEachObj( p, pObj, i )
751 pObj->fMarkA = 0;
752 printf( "\n" );
753}
#define Aig_ManForEachObj(p, pObj, i)
Definition aig.h:403
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
#define Aig_ManForEachExor(p, pObj, i)
Definition aig.h:418
void Dar_BalanceCone_rec(Aig_Obj_t *pRoot, Aig_Obj_t *pObj, Vec_Ptr_t *vSuper)
Definition darBalance.c:106
Cube * p
Definition exorList.c:222
unsigned int nRefs
Definition aig.h:81
unsigned int fMarkB
Definition aig.h:80
unsigned int fMarkA
Definition aig.h:79
unsigned Level
Definition aig.h:82
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_LibPrepare()

void Dar_LibPrepare ( int nSubgraphs)
extern

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

Synopsis [Starts the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 478 of file darLib.c.

479{
480 Dar_Lib_t * p = s_DarLib;
481 int i, k, nNodes0Total;
482 if ( p->nSubgraphs == nSubgraphs )
483 return;
484
485 // favor special classes:
486 // 1 : F = (!d*!c*!b*!a)
487 // 4 : F = (!d*!c*!(b*a))
488 // 12 : F = (!d*!(c*!(!b*!a)))
489 // 20 : F = (!d*!(c*b*a))
490
491 // set the subgraph counters
492 p->nSubgr0Total = 0;
493 for ( i = 0; i < 222; i++ )
494 {
495// if ( i == 1 || i == 4 || i == 12 || i == 20 ) // special classes
496 if ( i == 1 ) // special classes
497 p->nSubgr0[i] = p->nSubgr[i];
498 else
499 p->nSubgr0[i] = Abc_MinInt( p->nSubgr[i], nSubgraphs );
500 p->nSubgr0Total += p->nSubgr0[i];
501 for ( k = 0; k < p->nSubgr0[i]; k++ )
502 p->pSubgr0[i][k] = p->pSubgr[i][ p->pPrios[i][k] ];
503 }
504
505 // count the number of nodes
506 // clean node counters
507 for ( i = 0; i < 222; i++ )
508 p->nNodes0[i] = 0;
509 // create traversal IDs
510 for ( i = 0; i < p->iObj; i++ )
511 Dar_LibObj(p, i)->Num = 0xff;
512 // count nodes in each class
513 // count the total number of nodes and the largest class
514 p->nNodes0Total = 0;
515 p->nNodes0Max = 0;
516 for ( i = 0; i < 222; i++ )
517 {
518 for ( k = 0; k < p->nSubgr0[i]; k++ )
519 Dar_LibSetup0_rec( p, Dar_LibObj(p, p->pSubgr0[i][k]), i, 0 );
520 p->nNodes0Total += p->nNodes0[i];
521 p->nNodes0Max = Abc_MaxInt( p->nNodes0Max, p->nNodes0[i] );
522 }
523
524 // clean node counters
525 for ( i = 0; i < 222; i++ )
526 p->nNodes0[i] = 0;
527 // create traversal IDs
528 for ( i = 0; i < p->iObj; i++ )
529 Dar_LibObj(p, i)->Num = 0xff;
530 // add the nodes to storage
531 nNodes0Total = 0;
532 for ( i = 0; i < 222; i++ )
533 {
534 for ( k = 0; k < p->nSubgr0[i]; k++ )
535 Dar_LibSetup0_rec( p, Dar_LibObj(p, p->pSubgr0[i][k]), i, 1 );
536 nNodes0Total += p->nNodes0[i];
537 }
538 assert( nNodes0Total == p->nNodes0Total );
539 // prepare the number of the PI nodes
540 for ( i = 0; i < 4; i++ )
541 Dar_LibObj(p, i)->Num = i;
542
543 // realloc the datas
544 Dar_LibCreateData( p, p->nNodes0Max + 32 );
545 // allocated more because Dar_LibBuildBest() sometimes requires more entries
546}
typedefABC_NAMESPACE_IMPL_START struct Dar_Lib_t_ Dar_Lib_t
DECLARATIONS ///.
Definition darLib.c:32
void Dar_LibSetup0_rec(Dar_Lib_t *p, Dar_LibObj_t *pObj, int Class, int fCollect)
Definition darLib.c:454
void Dar_LibCreateData(Dar_Lib_t *p, int nDatas)
Definition darLib.c:432
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_LibReturnClass()

int Dar_LibReturnClass ( unsigned uTruth)
extern

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

Synopsis [Returns canonical truth tables.]

Description []

SideEffects []

SeeAlso []

Definition at line 194 of file darLib.c.

195{
196 return s_DarLib->pMap[uTruth & 0xffff];
197}
Here is the caller graph for this function:

◆ Dar_LibStart()

void Dar_LibStart ( )
extern

MACRO DEFINITIONS ///.

ITERATORS /// FUNCTION DECLARATIONS ///

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

Synopsis [Starts the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 593 of file darLib.c.

594{
595// abctime clk = Abc_Clock();
596 if ( s_DarLib != NULL )
597 return;
598 assert( s_DarLib == NULL );
599 s_DarLib = Dar_LibRead();
600// printf( "The 4-input library started with %d nodes and %d subgraphs. ", s_DarLib->nObjs - 4, s_DarLib->nSubgrTotal );
601// ABC_PRT( "Time", Abc_Clock() - clk );
602}
Dar_Lib_t * Dar_LibRead()
Definition darLib.c:559
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_LibStop()

void Dar_LibStop ( )
extern

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

Synopsis [Stops the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 615 of file darLib.c.

616{
617 assert( s_DarLib != NULL );
618 Dar_LibFree( s_DarLib );
619 s_DarLib = NULL;
620}
void Dar_LibFree(Dar_Lib_t *p)
Definition darLib.c:164
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_ManBalance()

Aig_Man_t * Dar_ManBalance ( Aig_Man_t * p,
int fUpdateLevel )
extern

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

Synopsis [Performs algebraic balancing of the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 554 of file darBalance.c.

555{
556 Aig_Man_t * pNew;
557 Aig_Obj_t * pObj, * pDriver, * pObjNew;
558 Vec_Vec_t * vStore;
559 int i;
561 // create the new manager
562 pNew = Aig_ManStart( Aig_ManObjNumMax(p) );
563 pNew->pName = Abc_UtilStrsav( p->pName );
564 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
565 pNew->nAsserts = p->nAsserts;
566 pNew->nConstrs = p->nConstrs;
567 pNew->nBarBufs = p->nBarBufs;
568 pNew->Time2Quit = p->Time2Quit;
569 if ( p->vFlopNums )
570 pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
571 // map the PI nodes
573 Aig_ManConst1(p)->pData = Aig_ManConst1(pNew);
574 vStore = Vec_VecAlloc( 50 );
575 if ( p->pManTime != NULL )
576 {
577 float arrTime;
578 Tim_ManIncrementTravId( (Tim_Man_t *)p->pManTime );
580 Aig_ManForEachObj( p, pObj, i )
581 {
582 if ( Aig_ObjIsNode(pObj) || Aig_ObjIsConst1(pObj) )
583 continue;
584 if ( Aig_ObjIsCi(pObj) )
585 {
586 // copy the PI
587 pObjNew = Aig_ObjCreateCi(pNew);
588 pObj->pData = pObjNew;
589 // set the arrival time of the new PI
590 arrTime = Tim_ManGetCiArrival( (Tim_Man_t *)p->pManTime, Aig_ObjCioId(pObj) );
591 pObjNew->Level = (int)arrTime;
592 }
593 else if ( Aig_ObjIsCo(pObj) )
594 {
595 // perform balancing
596 pDriver = Aig_ObjReal_rec( Aig_ObjChild0(pObj) );
597 pObjNew = Dar_Balance_rec( pNew, Aig_Regular(pDriver), vStore, 0, fUpdateLevel );
598 if ( pObjNew == NULL )
599 {
600 Vec_VecFree( vStore );
601 Aig_ManStop( pNew );
602 return NULL;
603 }
604 pObjNew = Aig_NotCond( pObjNew, Aig_IsComplement(pDriver) );
605 // save arrival time of the output
606 arrTime = (float)Aig_Regular(pObjNew)->Level;
607 Tim_ManSetCoArrival( (Tim_Man_t *)p->pManTime, Aig_ObjCioId(pObj), arrTime );
608 // create PO
609 pObjNew = Aig_ObjCreateCo( pNew, pObjNew );
610 }
611 else
612 assert( 0 );
613 }
615 pNew->pManTime = Tim_ManDup( (Tim_Man_t *)p->pManTime, 0 );
616 }
617 else
618 {
619 Aig_ManForEachCi( p, pObj, i )
620 {
621 pObjNew = Aig_ObjCreateCi(pNew);
622 pObjNew->Level = pObj->Level;
623 pObj->pData = pObjNew;
624 }
625 if ( p->nBarBufs == 0 )
626 {
627 Aig_ManForEachCo( p, pObj, i )
628 {
629 pDriver = Aig_ObjReal_rec( Aig_ObjChild0(pObj) );
630 pObjNew = Dar_Balance_rec( pNew, Aig_Regular(pDriver), vStore, 0, fUpdateLevel );
631 if ( pObjNew == NULL )
632 {
633 Vec_VecFree( vStore );
634 Aig_ManStop( pNew );
635 return NULL;
636 }
637 pObjNew = Aig_NotCond( pObjNew, Aig_IsComplement(pDriver) );
638 pObjNew = Aig_ObjCreateCo( pNew, pObjNew );
639 }
640 }
641 else
642 {
643 Vec_Ptr_t * vLits = Vec_PtrStart( Aig_ManCoNum(p) );
644 Aig_ManForEachCo( p, pObj, i )
645 {
646 int k = i < p->nBarBufs ? Aig_ManCoNum(p) - p->nBarBufs + i : i - p->nBarBufs;
647 pObj = Aig_ManCo( p, k );
648 pDriver = Aig_ObjReal_rec( Aig_ObjChild0(pObj) );
649 pObjNew = Dar_Balance_rec( pNew, Aig_Regular(pDriver), vStore, 0, fUpdateLevel );
650 if ( pObjNew == NULL )
651 {
652 Vec_VecFree( vStore );
653 Aig_ManStop( pNew );
654 return NULL;
655 }
656 pObjNew = Aig_NotCond( pObjNew, Aig_IsComplement(pDriver) );
657 Vec_PtrWriteEntry( vLits, k, pObjNew );
658 if ( i < p->nBarBufs )
659 Aig_ManCi(pNew, Aig_ManCiNum(p) - p->nBarBufs + i)->Level = Aig_Regular(pObjNew)->Level;
660 }
661 Aig_ManForEachCo( p, pObj, i )
662 Aig_ObjCreateCo( pNew, (Aig_Obj_t *)Vec_PtrEntry(vLits, i) );
663 Vec_PtrFree(vLits);
664 }
665 }
666 Vec_VecFree( vStore );
667 // remove dangling nodes
668 Aig_ManCleanup( pNew );
669 Aig_ManSetRegNum( pNew, Aig_ManRegNum(p) );
670 // check the resulting AIG
671 if ( !Aig_ManCheck(pNew) )
672 printf( "Dar_ManBalance(): The check has failed.\n" );
673 return pNew;
674}
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
Definition aigMan.c:438
void Aig_ManSetCioIds(Aig_Man_t *p)
Definition aigUtil.c:978
int Aig_ManVerifyTopoOrder(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigDfs.c:46
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition aig.h:393
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition aigObj.c:66
void Aig_ManCleanCioIds(Aig_Man_t *p)
Definition aigUtil.c:999
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition aigMan.c:47
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
int Aig_ManCleanup(Aig_Man_t *p)
Definition aigMan.c:265
#define Aig_ManForEachCo(p, pObj, i)
Definition aig.h:398
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigObj.c:45
Aig_Obj_t * Aig_ObjReal_rec(Aig_Obj_t *pObj)
Definition aigUtil.c:476
void Aig_ManCleanData(Aig_Man_t *p)
Definition aigUtil.c:205
ABC_DLL int Aig_ManCheck(Aig_Man_t *p)
FUNCTION DECLARATIONS ///.
Definition aigCheck.c:45
Aig_Obj_t * Dar_Balance_rec(Aig_Man_t *pNew, Aig_Obj_t *pObjOld, Vec_Vec_t *vStore, int Level, int fUpdateLevel)
Definition darBalance.c:502
void * pData
Definition aig.h:87
void Tim_ManSetCoArrival(Tim_Man_t *p, int iCo, float Delay)
Definition timTime.c:116
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition tim.h:92
void Tim_ManIncrementTravId(Tim_Man_t *p)
DECLARATIONS ///.
Definition timTrav.c:44
Tim_Man_t * Tim_ManDup(Tim_Man_t *p, int fUnitDelay)
Definition timMan.c:86
float Tim_ManGetCiArrival(Tim_Man_t *p, int iCi)
Definition timTime.c:174
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition vecVec.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_ManBalanceXor()

Aig_Man_t * Dar_ManBalanceXor ( Aig_Man_t * pAig,
int fExor,
int fUpdateLevel,
int fVerbose )
extern

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

Synopsis [Reproduces script "compress2".]

Description []

SideEffects []

SeeAlso []

Definition at line 687 of file darBalance.c.

688{
689 Aig_Man_t * pAigXor, * pRes;
690 if ( fExor )
691 {
692 pAigXor = Aig_ManDupExor( pAig );
693 if ( fVerbose )
694 Dar_BalancePrintStats( pAigXor );
695 pRes = Dar_ManBalance( pAigXor, fUpdateLevel );
696 Aig_ManStop( pAigXor );
697 }
698 else
699 {
700 pRes = Dar_ManBalance( pAig, fUpdateLevel );
701 }
702 return pRes;
703}
Aig_Man_t * Aig_ManDupExor(Aig_Man_t *p)
Definition aigDup.c:462
Aig_Man_t * Dar_ManBalance(Aig_Man_t *p, int fUpdateLevel)
Definition darBalance.c:554
void Dar_BalancePrintStats(Aig_Man_t *p)
Definition darBalance.c:716
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_ManChoice()

Aig_Man_t * Dar_ManChoice ( Aig_Man_t * pAig,
int fBalance,
int fUpdateLevel,
int fConstruct,
int nConfMax,
int nLevelMax,
int fVerbose )
extern

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

Synopsis [Reproduces script "compress2".]

Description []

SideEffects []

SeeAlso []

Definition at line 378 of file darScript.c.

379{
380 Aig_Man_t * pMan, * pTemp;
381 Vec_Ptr_t * vAigs;
382 int i;
383 abctime clk;
384
385clk = Abc_Clock();
386// vAigs = Dar_ManChoiceSynthesisExt();
387 vAigs = Dar_ManChoiceSynthesis( pAig, fBalance, fUpdateLevel, 0, fVerbose );
388
389 // swap the first and last network
390 // this should lead to the primary choice being "better" because of synthesis
391 // (it is also important when constructing choices)
392 if ( !fConstruct )
393 {
394 pMan = (Aig_Man_t *)Vec_PtrPop( vAigs );
395 Vec_PtrPush( vAigs, Vec_PtrEntry(vAigs,0) );
396 Vec_PtrWriteEntry( vAigs, 0, pMan );
397 }
398
399if ( fVerbose )
400{
401ABC_PRT( "Synthesis time", Abc_Clock() - clk );
402}
403clk = Abc_Clock();
404 if ( fConstruct )
405 pMan = Aig_ManChoiceConstructive( vAigs, fVerbose );
406 else
407 pMan = Aig_ManChoicePartitioned( vAigs, 300, nConfMax, nLevelMax, fVerbose );
408 Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pTemp, i )
409 Aig_ManStop( pTemp );
410 Vec_PtrFree( vAigs );
411if ( fVerbose )
412{
413ABC_PRT( "Choicing time ", Abc_Clock() - clk );
414}
415 return pMan;
416// return NULL;
417}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
Aig_Man_t * Aig_ManChoiceConstructive(Vec_Ptr_t *vAigs, int fVerbose)
Definition aigPart.c:1564
Aig_Man_t * Aig_ManChoicePartitioned(Vec_Ptr_t *vAigs, int nPartSize, int nConfMax, int nLevelMax, int fVerbose)
Definition aigPart.c:1247
Vec_Ptr_t * Dar_ManChoiceSynthesis(Aig_Man_t *pAig, int fBalance, int fUpdateLevel, int fPower, int fVerbose)
Definition darScript.c:345
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_ManCompress()

Aig_Man_t * Dar_ManCompress ( Aig_Man_t * pAig,
int fBalance,
int fUpdateLevel,
int fPower,
int fVerbose )
extern

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

Synopsis [Reproduces script "compress".]

Description []

SideEffects []

SeeAlso []

Definition at line 162 of file darScript.c.

164{
165 Aig_Man_t * pTemp;
166
167 Dar_RwrPar_t ParsRwr, * pParsRwr = &ParsRwr;
168 Dar_RefPar_t ParsRef, * pParsRef = &ParsRef;
169
170 Dar_ManDefaultRwrParams( pParsRwr );
171 Dar_ManDefaultRefParams( pParsRef );
172
173 pParsRwr->fUpdateLevel = fUpdateLevel;
174 pParsRef->fUpdateLevel = fUpdateLevel;
175
176 pParsRwr->fPower = fPower;
177
178 pParsRwr->fVerbose = 0;//fVerbose;
179 pParsRef->fVerbose = 0;//fVerbose;
180
181 pAig = Aig_ManDupDfs( pAig );
182 if ( fVerbose ) printf( "Starting: " ), Aig_ManPrintStats( pAig );
183/*
184 // balance
185 if ( fBalance )
186 {
187 pAig = Dar_ManBalance( pTemp = pAig, fUpdateLevel );
188 Aig_ManStop( pTemp );
189 if ( fVerbose ) printf( "Balance: " ), Aig_ManPrintStats( pAig );
190 }
191*/
192 // rewrite
193 Dar_ManRewrite( pAig, pParsRwr );
194 pAig = Aig_ManDupDfs( pTemp = pAig );
195 Aig_ManStop( pTemp );
196 if ( fVerbose ) printf( "Rewrite: " ), Aig_ManPrintStats( pAig );
197
198 // refactor
199 Dar_ManRefactor( pAig, pParsRef );
200 pAig = Aig_ManDupDfs( pTemp = pAig );
201 Aig_ManStop( pTemp );
202 if ( fVerbose ) printf( "Refactor: " ), Aig_ManPrintStats( pAig );
203
204 // balance
205 if ( fBalance )
206 {
207 pAig = Dar_ManBalance( pTemp = pAig, fUpdateLevel );
208 Aig_ManStop( pTemp );
209 if ( fVerbose ) printf( "Balance: " ), Aig_ManPrintStats( pAig );
210 }
211
212 pParsRwr->fUseZeros = 1;
213 pParsRef->fUseZeros = 1;
214
215 // rewrite
216 Dar_ManRewrite( pAig, pParsRwr );
217 pAig = Aig_ManDupDfs( pTemp = pAig );
218 Aig_ManStop( pTemp );
219 if ( fVerbose ) printf( "RewriteZ: " ), Aig_ManPrintStats( pAig );
220
221 return pAig;
222}
Aig_Man_t * Aig_ManDupDfs(Aig_Man_t *p)
Definition aigDup.c:563
void Aig_ManPrintStats(Aig_Man_t *p)
Definition aigMan.c:379
int Dar_ManRefactor(Aig_Man_t *pAig, Dar_RefPar_t *pPars)
Definition darRefact.c:496
typedefABC_NAMESPACE_HEADER_START struct Dar_RwrPar_t_ Dar_RwrPar_t
INCLUDES ///.
Definition dar.h:42
void Dar_ManDefaultRwrParams(Dar_RwrPar_t *pPars)
FUNCTION DEFINITIONS ///.
Definition darCore.c:51
Aig_Man_t * Dar_ManBalance(Aig_Man_t *p, int fUpdateLevel)
Definition darBalance.c:554
struct Dar_RefPar_t_ Dar_RefPar_t
Definition dar.h:43
int Dar_ManRewrite(Aig_Man_t *pAig, Dar_RwrPar_t *pPars)
Definition darCore.c:79
void Dar_ManDefaultRefParams(Dar_RefPar_t *pPars)
FUNCTION DEFINITIONS ///.
Definition darRefact.c:85
int fVerbose
Definition dar.h:67
int fUseZeros
Definition dar.h:66
int fUpdateLevel
Definition dar.h:65
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_ManCompress2()

Aig_Man_t * Dar_ManCompress2 ( Aig_Man_t * pAig,
int fBalance,
int fUpdateLevel,
int fFanout,
int fPower,
int fVerbose )
extern

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

Synopsis [Reproduces script "compress2".]

Description []

SideEffects []

SeeAlso []

Definition at line 235 of file darScript.c.

237{
238 Aig_Man_t * pTemp;
239
240 Dar_RwrPar_t ParsRwr, * pParsRwr = &ParsRwr;
241 Dar_RefPar_t ParsRef, * pParsRef = &ParsRef;
242
243 Dar_ManDefaultRwrParams( pParsRwr );
244 Dar_ManDefaultRefParams( pParsRef );
245
246 pParsRwr->fUpdateLevel = fUpdateLevel;
247 pParsRef->fUpdateLevel = fUpdateLevel;
248 pParsRwr->fFanout = fFanout;
249 pParsRwr->fPower = fPower;
250
251 pParsRwr->fVerbose = 0;//fVerbose;
252 pParsRef->fVerbose = 0;//fVerbose;
253
254 pAig = Aig_ManDupDfs( pAig );
255 if ( fVerbose ) printf( "Starting: " ), Aig_ManPrintStats( pAig );
256/*
257 // balance
258 if ( fBalance )
259 {
260 pAig = Dar_ManBalance( pTemp = pAig, fUpdateLevel );
261 Aig_ManStop( pTemp );
262 if ( fVerbose ) printf( "Balance: " ), Aig_ManPrintStats( pAig );
263 }
264*/
265 // rewrite
266// Dar_ManRewrite( pAig, pParsRwr );
267 pParsRwr->fUpdateLevel = 0; // disable level update
268 Dar_ManRewrite( pAig, pParsRwr );
269 pParsRwr->fUpdateLevel = fUpdateLevel; // reenable level update if needed
270
271 pAig = Aig_ManDupDfs( pTemp = pAig );
272 Aig_ManStop( pTemp );
273 if ( fVerbose ) printf( "Rewrite: " ), Aig_ManPrintStats( pAig );
274
275 // refactor
276 Dar_ManRefactor( pAig, pParsRef );
277 pAig = Aig_ManDupDfs( pTemp = pAig );
278 Aig_ManStop( pTemp );
279 if ( fVerbose ) printf( "Refactor: " ), Aig_ManPrintStats( pAig );
280
281 // balance
282// if ( fBalance )
283 {
284 pAig = Dar_ManBalance( pTemp = pAig, fUpdateLevel );
285 Aig_ManStop( pTemp );
286 if ( fVerbose ) printf( "Balance: " ), Aig_ManPrintStats( pAig );
287 }
288
289 // rewrite
290 Dar_ManRewrite( pAig, pParsRwr );
291 pAig = Aig_ManDupDfs( pTemp = pAig );
292 Aig_ManStop( pTemp );
293 if ( fVerbose ) printf( "Rewrite: " ), Aig_ManPrintStats( pAig );
294
295 pParsRwr->fUseZeros = 1;
296 pParsRef->fUseZeros = 1;
297
298 // rewrite
299 Dar_ManRewrite( pAig, pParsRwr );
300 pAig = Aig_ManDupDfs( pTemp = pAig );
301 Aig_ManStop( pTemp );
302 if ( fVerbose ) printf( "RewriteZ: " ), Aig_ManPrintStats( pAig );
303
304 // balance
305 if ( fBalance )
306 {
307 pAig = Dar_ManBalance( pTemp = pAig, fUpdateLevel );
308 Aig_ManStop( pTemp );
309 if ( fVerbose ) printf( "Balance: " ), Aig_ManPrintStats( pAig );
310 }
311
312 // refactor
313 Dar_ManRefactor( pAig, pParsRef );
314 pAig = Aig_ManDupDfs( pTemp = pAig );
315 Aig_ManStop( pTemp );
316 if ( fVerbose ) printf( "RefactorZ: " ), Aig_ManPrintStats( pAig );
317
318 // rewrite
319 Dar_ManRewrite( pAig, pParsRwr );
320 pAig = Aig_ManDupDfs( pTemp = pAig );
321 Aig_ManStop( pTemp );
322 if ( fVerbose ) printf( "RewriteZ: " ), Aig_ManPrintStats( pAig );
323
324 // balance
325 if ( fBalance )
326 {
327 pAig = Dar_ManBalance( pTemp = pAig, fUpdateLevel );
328 Aig_ManStop( pTemp );
329 if ( fVerbose ) printf( "Balance: " ), Aig_ManPrintStats( pAig );
330 }
331 return pAig;
332}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_ManComputeCuts()

Aig_MmFixed_t * Dar_ManComputeCuts ( Aig_Man_t * pAig,
int nCutsMax,
int fSkipTtMin,
int fVerbose )
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 291 of file darCore.c.

292{
293 Dar_Man_t * p;
294 Dar_RwrPar_t Pars, * pPars = &Pars;
295 Aig_Obj_t * pObj;
296 Aig_MmFixed_t * pMemCuts;
297 int i, nNodes;
298 abctime clk = Abc_Clock();
299 // remove dangling nodes
300 if ( (nNodes = Aig_ManCleanup( pAig )) )
301 {
302// printf( "Removing %d nodes.\n", nNodes );
303 }
304 // create default parameters
306 pPars->nCutsMax = nCutsMax;
307 // create rewriting manager
308 p = Dar_ManStart( pAig, pPars );
309 // set elementary cuts for the PIs
310// Dar_ManCutsStart( p );
311 Aig_MmFixedRestart( p->pMemCuts );
312 Dar_ObjPrepareCuts( p, Aig_ManConst1(p->pAig) );
313 Aig_ManForEachCi( pAig, pObj, i )
314 Dar_ObjPrepareCuts( p, pObj );
315 // compute cuts for each nodes in the topological order
316 Aig_ManForEachNode( pAig, pObj, i )
317 Dar_ObjComputeCuts( p, pObj, fSkipTtMin );
318 // print verbose stats
319 if ( fVerbose )
320 {
321// Aig_Obj_t * pObj;
322 int nCuts, nCutsK;//, i;
323 nCuts = Dar_ManCutCount( pAig, &nCutsK );
324 printf( "Nodes = %6d. Total cuts = %6d. 4-input cuts = %6d.\n",
325 Aig_ManObjNum(pAig), nCuts, nCutsK );
326 printf( "Cut size = %2d. Truth size = %2d. Total mem = %5.2f MB ",
327 (int)sizeof(Dar_Cut_t), (int)4, 1.0*Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20) );
328 ABC_PRT( "Runtime", Abc_Clock() - clk );
329/*
330 Aig_ManForEachNode( pAig, pObj, i )
331 if ( i % 300 == 0 )
332 Dar_ObjCutPrint( pAig, pObj );
333*/
334 }
335 // free the cuts
336 pMemCuts = p->pMemCuts;
337 p->pMemCuts = NULL;
338// Dar_ManCutsFree( p );
339 // stop the rewriting manager
340 Dar_ManStop( p );
341 return pMemCuts;
342}
int Aig_MmFixedReadMemUsage(Aig_MmFixed_t *p)
Definition aigMem.c:271
#define Aig_ManForEachNode(p, pObj, i)
Definition aig.h:413
void Aig_MmFixedRestart(Aig_MmFixed_t *p)
Definition aigMem.c:232
struct Aig_MmFixed_t_ Aig_MmFixed_t
Definition aig.h:52
void Dar_ManDefaultRwrParams(Dar_RwrPar_t *pPars)
FUNCTION DEFINITIONS ///.
Definition darCore.c:51
int Dar_ManCutCount(Aig_Man_t *pAig, int *pnCutsK)
Definition darCore.c:263
Dar_Cut_t * Dar_ObjComputeCuts(Dar_Man_t *p, Aig_Obj_t *pObj, int fSkipTtMin)
Definition darCut.c:738
Dar_Cut_t * Dar_ObjPrepareCuts(Dar_Man_t *p, Aig_Obj_t *pObj)
Definition darCut.c:668
typedefABC_NAMESPACE_HEADER_START struct Dar_Man_t_ Dar_Man_t
INCLUDES ///.
Definition darInt.h:51
void Dar_ManStop(Dar_Man_t *p)
Definition darMan.c:69
Dar_Man_t * Dar_ManStart(Aig_Man_t *pAig, Dar_RwrPar_t *pPars)
DECLARATIONS ///.
Definition darMan.c:44
struct Dar_Cut_t_ Dar_Cut_t
Definition darInt.h:52
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_ManDefaultRefParams()

void Dar_ManDefaultRefParams ( Dar_RefPar_t * pPars)
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Returns the structure with default assignment of parameters.]

Description []

SideEffects []

SeeAlso []

Definition at line 85 of file darRefact.c.

86{
87 memset( pPars, 0, sizeof(Dar_RefPar_t) );
88 pPars->nMffcMin = 2; // the min MFFC size for which refactoring is used
89 pPars->nLeafMax = 12; // the max number of leaves of a cut
90 pPars->nCutsMax = 5; // the max number of cuts to consider
91 pPars->fUpdateLevel = 0;
92 pPars->fUseZeros = 0;
93 pPars->fVerbose = 0;
94 pPars->fVeryVerbose = 0;
95}
int nLeafMax
Definition dar.h:62
int nCutsMax
Definition dar.h:63
int fVeryVerbose
Definition dar.h:68
int nMffcMin
Definition dar.h:61
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_ManDefaultRwrParams()

void Dar_ManDefaultRwrParams ( Dar_RwrPar_t * pPars)
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Returns the structure with default assignment of parameters.]

Description []

SideEffects []

SeeAlso []

Definition at line 51 of file darCore.c.

52{
53 memset( pPars, 0, sizeof(Dar_RwrPar_t) );
54 pPars->nCutsMax = 8; // 8
55 pPars->nSubgMax = 5; // 5 is a "magic number"
56 pPars->nMinSaved = 1;
57 pPars->fFanout = 1;
58 pPars->fUpdateLevel = 0;
59 pPars->fUseZeros = 0;
60 pPars->fPower = 0;
61 pPars->fRecycle = 1;
62 pPars->fVerbose = 0;
63 pPars->fVeryVerbose = 0;
64}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_ManRefactor()

int Dar_ManRefactor ( Aig_Man_t * pAig,
Dar_RefPar_t * pPars )
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 496 of file darRefact.c.

497{
498// Bar_Progress_t * pProgress;
499 Ref_Man_t * p;
500 Vec_Ptr_t * vCut, * vCut2;
501 Aig_Obj_t * pObj, * pObjNew;
502 int nNodesOld, nNodeBefore, nNodeAfter, nNodesSaved, nNodesSaved2;
503 int i, Required, nLevelMin;
504 abctime clkStart, clk;
505
506 // start the manager
507 p = Dar_ManRefStart( pAig, pPars );
508 // remove dangling nodes
509 Aig_ManCleanup( pAig );
510 // if updating levels is requested, start fanout and timing
511 Aig_ManFanoutStart( pAig );
512 if ( p->pPars->fUpdateLevel )
513 Aig_ManStartReverseLevels( pAig, 0 );
514
515 // resynthesize each node once
516 clkStart = Abc_Clock();
517 vCut = Vec_VecEntry( p->vCuts, 0 );
518 vCut2 = Vec_VecEntry( p->vCuts, 1 );
519 p->nNodesInit = Aig_ManNodeNum(pAig);
520 nNodesOld = Vec_PtrSize( pAig->vObjs );
521// pProgress = Bar_ProgressStart( stdout, nNodesOld );
522 Aig_ManForEachObj( pAig, pObj, i )
523 {
524// Bar_ProgressUpdate( pProgress, i, NULL );
525 if ( !Aig_ObjIsNode(pObj) )
526 continue;
527 if ( i > nNodesOld )
528 break;
529 if ( pAig->Time2Quit && !(i & 256) && Abc_Clock() > pAig->Time2Quit )
530 break;
531 Vec_VecClear( p->vCuts );
532
533//printf( "\nConsidering node %d.\n", pObj->Id );
534 // get the bounded MFFC size
535clk = Abc_Clock();
536 nLevelMin = Abc_MaxInt( 0, Aig_ObjLevel(pObj) - 10 );
537 nNodesSaved = Aig_NodeMffcSupp( pAig, pObj, nLevelMin, vCut );
538 if ( nNodesSaved < p->pPars->nMffcMin ) // too small to consider
539 {
540p->timeCuts += Abc_Clock() - clk;
541 continue;
542 }
543 p->nNodesTried++;
544 if ( Vec_PtrSize(vCut) > p->pPars->nLeafMax ) // get one reconv-driven cut
545 {
546 Aig_ManFindCut( pObj, vCut, p->vCutNodes, p->pPars->nLeafMax, 50 );
547 nNodesSaved = Aig_NodeMffcLabelCut( p->pAig, pObj, vCut );
548 }
549 else if ( Vec_PtrSize(vCut) < p->pPars->nLeafMax - 2 && p->pPars->fExtend )
550 {
551 if ( !Dar_ObjCutLevelAchieved(vCut, nLevelMin) )
552 {
553 if ( Aig_NodeMffcExtendCut( pAig, pObj, vCut, vCut2 ) )
554 {
555 nNodesSaved2 = Aig_NodeMffcLabelCut( p->pAig, pObj, vCut );
556 assert( nNodesSaved2 == nNodesSaved );
557 }
558 if ( Vec_PtrSize(vCut2) > p->pPars->nLeafMax )
559 Vec_PtrClear(vCut2);
560 if ( Vec_PtrSize(vCut2) > 0 )
561 {
562 p->nNodesExten++;
563// printf( "%d(%d) ", Vec_PtrSize(vCut), Vec_PtrSize(vCut2) );
564 }
565 }
566 else
567 p->nNodesBelow++;
568 }
569p->timeCuts += Abc_Clock() - clk;
570
571 // try the cuts
572clk = Abc_Clock();
573 Required = pAig->vLevelR? Aig_ObjRequiredLevel(pAig, pObj) : ABC_INFINITY;
574 Dar_ManRefactorTryCuts( p, pObj, nNodesSaved, Required );
575p->timeEval += Abc_Clock() - clk;
576
577 // check the best gain
578 if ( !(p->GainBest > 0 || (p->GainBest == 0 && p->pPars->fUseZeros)) )
579 {
580 if ( p->pGraphBest )
581 Kit_GraphFree( p->pGraphBest );
582 continue;
583 }
584//printf( "\n" );
585
586 // if we end up here, a rewriting step is accepted
587 nNodeBefore = Aig_ManNodeNum( pAig );
588 pObjNew = Dar_RefactBuildGraph( pAig, p->vLeavesBest, p->pGraphBest );
589 //assert( (int)Aig_Regular(pObjNew)->Level <= Required );
590 // replace the node
591 Aig_ObjReplace( pAig, pObj, pObjNew, p->pPars->fUpdateLevel );
592 // compare the gains
593 nNodeAfter = Aig_ManNodeNum( pAig );
594 assert( p->GainBest <= nNodeBefore - nNodeAfter );
595 Kit_GraphFree( p->pGraphBest );
596 p->nCutsUsed++;
597// break;
598 }
599p->timeTotal = Abc_Clock() - clkStart;
600p->timeOther = p->timeTotal - p->timeCuts - p->timeEval;
601
602// Bar_ProgressStop( pProgress );
603 // put the nodes into the DFS order and reassign their IDs
604// Aig_NtkReassignIds( p );
605 // fix the levels
606 Aig_ManFanoutStop( pAig );
607 if ( p->pPars->fUpdateLevel )
609/*
610 Aig_ManForEachObj( p->pAig, pObj, i )
611 if ( Aig_ObjIsNode(pObj) && Aig_ObjRefs(pObj) == 0 )
612 {
613 printf( "Unreferenced " );
614 Aig_ObjPrintVerbose( pObj, 0 );
615 printf( "\n" );
616 }
617*/
618 // remove dangling nodes (they should not be here!)
619 Aig_ManCleanup( pAig );
620
621 // stop the rewriting manager
622 Dar_ManRefStop( p );
623// Aig_ManCheckPhase( pAig );
624 if ( !Aig_ManCheck( pAig ) )
625 {
626 printf( "Dar_ManRefactor: The network check has failed.\n" );
627 return 0;
628 }
629 return 1;
630
631}
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
void Aig_ManFanoutStart(Aig_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition aigFanout.c:56
void Aig_ManFanoutStop(Aig_Man_t *p)
Definition aigFanout.c:89
int Aig_NodeMffcExtendCut(Aig_Man_t *p, Aig_Obj_t *pNode, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vResult)
Definition aigMffc.c:265
void Aig_ManStartReverseLevels(Aig_Man_t *p, int nMaxLevelIncrease)
Definition aigTiming.c:142
void Aig_ManFindCut(Aig_Obj_t *pRoot, Vec_Ptr_t *vFront, Vec_Ptr_t *vVisited, int nSizeLimit, int nFanoutLimit)
Definition aigWin.c:145
void Aig_ManStopReverseLevels(Aig_Man_t *p)
Definition aigTiming.c:175
void Aig_ObjReplace(Aig_Man_t *p, Aig_Obj_t *pObjOld, Aig_Obj_t *pObjNew, int fUpdateLevel)
Definition aigObj.c:467
int Aig_NodeMffcLabelCut(Aig_Man_t *p, Aig_Obj_t *pNode, Vec_Ptr_t *vLeaves)
Definition aigMffc.c:236
int Aig_ObjRequiredLevel(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition aigTiming.c:100
int Aig_NodeMffcSupp(Aig_Man_t *p, Aig_Obj_t *pNode, int LevelMin, Vec_Ptr_t *vSupp)
Definition aigMffc.c:179
Aig_Obj_t * Dar_RefactBuildGraph(Aig_Man_t *pAig, Vec_Ptr_t *vCut, Kit_Graph_t *pGraph)
Definition darRefact.c:313
void Dar_ManRefStop(Ref_Man_t *p)
Definition darRefact.c:166
typedefABC_NAMESPACE_IMPL_START struct Ref_Man_t_ Ref_Man_t
DECLARATIONS ///.
Definition darRefact.c:35
Ref_Man_t * Dar_ManRefStart(Aig_Man_t *pAig, Dar_RefPar_t *pPars)
Definition darRefact.c:108
int Dar_ObjCutLevelAchieved(Vec_Ptr_t *vCut, int nLevelMin)
Definition darRefact.c:475
int Dar_ManRefactorTryCuts(Ref_Man_t *p, Aig_Obj_t *pObj, int nNodesSaved, int Required)
Definition darRefact.c:359
void Kit_GraphFree(Kit_Graph_t *pGraph)
Definition kitGraph.c:132
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_ManRewrite()

int Dar_ManRewrite ( Aig_Man_t * pAig,
Dar_RwrPar_t * pPars )
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 79 of file darCore.c.

80{
81 extern Vec_Int_t * Saig_ManComputeSwitchProbs( Aig_Man_t * p, int nFrames, int nPref, int fProbOne );
82 Dar_Man_t * p;
83// Bar_Progress_t * pProgress;
84 Dar_Cut_t * pCut;
85 Aig_Obj_t * pObj, * pObjNew;
86 int i, k, nNodesOld, nNodeBefore, nNodeAfter, Required;
87 abctime clk = 0, clkStart;
88 int Counter = 0;
89 int nMffcSize;//, nMffcGains[MAX_VAL+1][MAX_VAL+1] = {{0}};
90 if ( pPars->fUseZeros )
91 pPars->nMinSaved = 0;
92 // prepare the library
93 Dar_LibPrepare( pPars->nSubgMax );
94 // create rewriting manager
95 p = Dar_ManStart( pAig, pPars );
96 if ( pPars->fPower )
97 pAig->vProbs = Saig_ManComputeSwitchProbs( pAig, 48, 16, 1 );
98 // remove dangling nodes
99 Aig_ManCleanup( pAig );
100 // if updating levels is requested, start fanout and timing
101 if ( p->pPars->fFanout )
102 Aig_ManFanoutStart( pAig );
103 if ( p->pPars->fUpdateLevel )
104 Aig_ManStartReverseLevels( pAig, 0 );
105 // set elementary cuts for the PIs
106// Dar_ManCutsStart( p );
107 // resynthesize each node once
108 clkStart = Abc_Clock();
109 p->nNodesInit = Aig_ManNodeNum(pAig);
110 nNodesOld = Vec_PtrSize( pAig->vObjs );
111
112// pProgress = Bar_ProgressStart( stdout, nNodesOld );
113 Aig_ManForEachObj( pAig, pObj, i )
114// pProgress = Bar_ProgressStart( stdout, 100 );
115// Aig_ManOrderStart( pAig );
116// Aig_ManForEachNodeInOrder( pAig, pObj )
117 {
118 if ( pAig->Time2Quit && !(i & 256) && Abc_Clock() > pAig->Time2Quit )
119 break;
120// Bar_ProgressUpdate( pProgress, 100*pAig->nAndPrev/pAig->nAndTotal, NULL );
121// Bar_ProgressUpdate( pProgress, i, NULL );
122 if ( !Aig_ObjIsNode(pObj) )
123 continue;
124 if ( i > nNodesOld )
125// if ( p->pPars->fUseZeros && i > nNodesOld )
126 break;
127 if ( pPars->fRecycle && ++Counter % 50000 == 0 && Aig_DagSize(pObj) < Vec_PtrSize(p->vCutNodes)/100 )
128 {
129// printf( "Counter = %7d. Node = %7d. Dag = %5d. Vec = %5d.\n",
130// Counter, i, Aig_DagSize(pObj), Vec_PtrSize(p->vCutNodes) );
131// fflush( stdout );
132 Dar_ManCutsRestart( p, pObj );
133 }
134
135 // consider freeing the cuts
136// if ( (i & 0xFFF) == 0 && Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20) > 100 )
137// Dar_ManCutsStart( p );
138
139 // compute cuts for the node
140 p->nNodesTried++;
141clk = Abc_Clock();
142 Dar_ObjSetCuts( pObj, NULL );
143 Dar_ObjComputeCuts_rec( p, pObj );
144p->timeCuts += Abc_Clock() - clk;
145
146 // check if there is a trivial cut
147 Dar_ObjForEachCut( pObj, pCut, k )
148 if ( pCut->nLeaves == 0 || (pCut->nLeaves == 1 && pCut->pLeaves[0] != pObj->Id && Aig_ManObj(p->pAig, pCut->pLeaves[0])) )
149 break;
150 if ( k < (int)pObj->nCuts )
151 {
152 assert( pCut->nLeaves < 2 );
153 if ( pCut->nLeaves == 0 ) // replace by constant
154 {
155 assert( pCut->uTruth == 0 || pCut->uTruth == 0xFFFF );
156 pObjNew = Aig_NotCond( Aig_ManConst1(p->pAig), pCut->uTruth==0 );
157 }
158 else
159 {
160 assert( pCut->uTruth == 0xAAAA || pCut->uTruth == 0x5555 );
161 pObjNew = Aig_NotCond( Aig_ManObj(p->pAig, pCut->pLeaves[0]), pCut->uTruth==0x5555 );
162 }
163 // remove the old cuts
164 Dar_ObjSetCuts( pObj, NULL );
165 // replace the node
166 Aig_ObjReplace( pAig, pObj, pObjNew, p->pPars->fUpdateLevel );
167 continue;
168 }
169
170 // evaluate the cuts
171 p->GainBest = -1;
172 nMffcSize = -1;
173 Required = pAig->vLevelR? Aig_ObjRequiredLevel(pAig, pObj) : ABC_INFINITY;
174 Dar_ObjForEachCut( pObj, pCut, k )
175 {
176 int nLeavesOld = pCut->nLeaves;
177 if ( pCut->nLeaves == 3 )
178 pCut->pLeaves[pCut->nLeaves++] = 0;
179 Dar_LibEval( p, pObj, pCut, Required, &nMffcSize );
180 pCut->nLeaves = nLeavesOld;
181 }
182 // check the best gain
183 //if ( !(p->GainBest > 0 || (p->GainBest == 0 && p->pPars->fUseZeros)) )
184 if ( p->GainBest < p->pPars->nMinSaved )
185 {
186// Aig_ObjOrderAdvance( pAig );
187 continue;
188 }
189// nMffcGains[p->GainBest < MAX_VAL ? p->GainBest : MAX_VAL][nMffcSize < MAX_VAL ? nMffcSize : MAX_VAL]++;
190 // remove the old cuts
191 Dar_ObjSetCuts( pObj, NULL );
192 // if we end up here, a rewriting step is accepted
193 nNodeBefore = Aig_ManNodeNum( pAig );
194 pObjNew = Dar_LibBuildBest( p ); // pObjNew can be complemented!
195 pObjNew = Aig_NotCond( pObjNew, Aig_ObjPhaseReal(pObjNew) ^ pObj->fPhase );
196 assert( (int)Aig_Regular(pObjNew)->Level <= Required );
197 // replace the node
198 Aig_ObjReplace( pAig, pObj, pObjNew, p->pPars->fUpdateLevel );
199 // compare the gains
200 nNodeAfter = Aig_ManNodeNum( pAig );
201 assert( p->GainBest <= nNodeBefore - nNodeAfter );
202 // count gains of this class
203 p->ClassGains[p->ClassBest] += nNodeBefore - nNodeAfter;
204 }
205// Aig_ManOrderStop( pAig );
206/*
207 printf( "Distribution of gain (row) by MFFC size (column) %s 0-costs:\n", p->pPars->fUseZeros? "with":"without" );
208 for ( k = 0; k <= MAX_VAL; k++ )
209 printf( "<%4d> ", k );
210 printf( "\n" );
211 for ( i = 0; i <= MAX_VAL; i++ )
212 {
213 for ( k = 0; k <= MAX_VAL; k++ )
214 printf( "%6d ", nMffcGains[i][k] );
215 printf( "\n" );
216 }
217*/
218
219p->timeTotal = Abc_Clock() - clkStart;
220p->timeOther = p->timeTotal - p->timeCuts - p->timeEval;
221
222// Bar_ProgressStop( pProgress );
224 // put the nodes into the DFS order and reassign their IDs
225// Aig_NtkReassignIds( p );
226 // fix the levels
227// Aig_ManVerifyLevel( pAig );
228 if ( p->pPars->fFanout )
229 Aig_ManFanoutStop( pAig );
230 if ( p->pPars->fUpdateLevel )
231 {
232// Aig_ManVerifyReverseLevel( pAig );
234 }
235 if ( pAig->vProbs )
236 {
237 Vec_IntFree( pAig->vProbs );
238 pAig->vProbs = NULL;
239 }
240 // stop the rewriting manager
241 Dar_ManStop( p );
242 Aig_ManCheckPhase( pAig );
243 // check
244 if ( !Aig_ManCheck( pAig ) )
245 {
246 printf( "Aig_ManRewrite: The network check has failed.\n" );
247 return 0;
248 }
249 return 1;
250}
int Aig_DagSize(Aig_Obj_t *pObj)
Definition aigDfs.c:726
void Aig_ManCheckPhase(Aig_Man_t *p)
Definition aigCheck.c:151
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
void Dar_ManCutsRestart(Dar_Man_t *p, Aig_Obj_t *pRoot)
FUNCTION DECLARATIONS ///.
Definition darCut.c:714
Dar_Cut_t * Dar_ObjComputeCuts_rec(Dar_Man_t *p, Aig_Obj_t *pObj)
Definition darCut.c:818
void Dar_ManCutsFree(Dar_Man_t *p)
Definition darCut.c:648
void Dar_LibEval(Dar_Man_t *p, Aig_Obj_t *pRoot, Dar_Cut_t *pCut, int Required, int *pnMffcSize)
Definition darLib.c:920
Aig_Obj_t * Dar_LibBuildBest(Dar_Man_t *p)
Definition darLib.c:1031
#define Dar_ObjForEachCut(pObj, pCut, i)
Definition darInt.h:121
void Dar_LibPrepare(int nSubgraphs)
Definition darLib.c:478
Vec_Int_t * Saig_ManComputeSwitchProbs(Aig_Man_t *pAig, int nFrames, int nPref, int fProbOne)
Definition giaSwitch.c:711
int Id
Definition aig.h:85
unsigned nCuts
Definition aig.h:83
unsigned int fPhase
Definition aig.h:78
unsigned nLeaves
Definition darInt.h:62
int pLeaves[4]
Definition darInt.h:63
unsigned uTruth
Definition darInt.h:58
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_ManRewriteDefault()

Aig_Man_t * Dar_ManRewriteDefault ( Aig_Man_t * pAig)
extern

DECLARATIONS ///.

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

FileName [darScript.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [DAG-aware AIG rewriting.]

Synopsis [Rewriting scripts.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - April 28, 2007.]

Revision [

Id
darScript.c,v 1.00 2007/04/28 00:00:00 alanmi Exp

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

Synopsis [Performs one iteration of AIG rewriting.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file darScript.c.

49{
50 Aig_Man_t * pTemp;
51 Dar_RwrPar_t Pars, * pPars = &Pars;
53 pAig = Aig_ManDupDfs( pAig );
54 Dar_ManRewrite( pAig, pPars );
55 pAig = Aig_ManDupDfs( pTemp = pAig );
56 Aig_ManStop( pTemp );
57 return pAig;
58}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_ManRwsat()

Aig_Man_t * Dar_ManRwsat ( Aig_Man_t * pAig,
int fBalance,
int fVerbose )
extern

DECLARATIONS ///.

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

Synopsis [Reproduces script "rwsat".]

Description []

SideEffects [This procedure does not tighten level during restructuring.]

SeeAlso []

Definition at line 71 of file darScript.c.

73{
74 Aig_Man_t * pTemp;
75 abctime Time = pAig->Time2Quit;
76
77 Dar_RwrPar_t ParsRwr, * pParsRwr = &ParsRwr;
78 Dar_RefPar_t ParsRef, * pParsRef = &ParsRef;
79
80 Dar_ManDefaultRwrParams( pParsRwr );
81 Dar_ManDefaultRefParams( pParsRef );
82
83 pParsRwr->fUpdateLevel = 0;
84 pParsRef->fUpdateLevel = 0;
85
86 pParsRwr->fVerbose = fVerbose;
87 pParsRef->fVerbose = fVerbose;
88//printf( "1" );
89 pAig = Aig_ManDupDfs( pAig );
90 if ( fVerbose ) printf( "Starting: " ), Aig_ManPrintStats( pAig );
91
92//printf( "2" );
93 // balance
94 if ( fBalance )
95 {
96 pAig->Time2Quit = Time;
97 pAig = Dar_ManBalance( pTemp = pAig, 0 );
98 Aig_ManStop( pTemp );
99 if ( fVerbose ) printf( "Balance: " ), Aig_ManPrintStats( pAig );
100 if ( Time && Abc_Clock() > Time )
101 { if ( pAig ) Aig_ManStop( pAig ); return NULL; }
102 }
103
104//Aig_ManDumpBlif( pAig, "inter.blif", NULL, NULL );
105//printf( "3" );
106 // rewrite
107 pAig->Time2Quit = Time;
108 Dar_ManRewrite( pAig, pParsRwr );
109 pAig = Aig_ManDupDfs( pTemp = pAig );
110 Aig_ManStop( pTemp );
111 if ( fVerbose ) printf( "Rewrite: " ), Aig_ManPrintStats( pAig );
112 if ( Time && Abc_Clock() > Time )
113 { if ( pAig ) Aig_ManStop( pAig ); return NULL; }
114
115//printf( "4" );
116 // refactor
117 pAig->Time2Quit = Time;
118 Dar_ManRefactor( pAig, pParsRef );
119 pAig = Aig_ManDupDfs( pTemp = pAig );
120 Aig_ManStop( pTemp );
121 if ( fVerbose ) printf( "Refactor: " ), Aig_ManPrintStats( pAig );
122 if ( Time && Abc_Clock() > Time )
123 { if ( pAig ) Aig_ManStop( pAig ); return NULL; }
124
125//printf( "5" );
126 // balance
127 if ( fBalance )
128 {
129 pAig->Time2Quit = Time;
130 pAig = Dar_ManBalance( pTemp = pAig, 0 );
131 Aig_ManStop( pTemp );
132 if ( fVerbose ) printf( "Balance: " ), Aig_ManPrintStats( pAig );
133 if ( Time && Abc_Clock() > Time )
134 { if ( pAig ) Aig_ManStop( pAig ); return NULL; }
135 }
136
137//printf( "6" );
138 // rewrite
139 pAig->Time2Quit = Time;
140 Dar_ManRewrite( pAig, pParsRwr );
141 pAig = Aig_ManDupDfs( pTemp = pAig );
142 Aig_ManStop( pTemp );
143 if ( fVerbose ) printf( "Rewrite: " ), Aig_ManPrintStats( pAig );
144 if ( Time && Abc_Clock() > Time )
145 { if ( pAig ) Aig_ManStop( pAig ); return NULL; }
146
147//printf( "7" );
148 return pAig;
149}