abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
lpk.h File Reference

Go to the source code of this file.

Data Structures

struct  Lpk_Par_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Lpk_Par_t_ 
Lpk_Par_t
 INCLUDES ///. More...
 

Functions

int Lpk_Resynthesize (Abc_Ntk_t *pNtk, Lpk_Par_t *pPars)
 MACRO DEFINITIONS ///. More...
 

Typedef Documentation

typedef typedefABC_NAMESPACE_HEADER_START struct Lpk_Par_t_ Lpk_Par_t

INCLUDES ///.

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

FileName [lpk.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Fast Boolean matching for LUT structures.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]PARAMETERS ///BASIC TYPES ///

Definition at line 42 of file lpk.h.

Function Documentation

int Lpk_Resynthesize ( Abc_Ntk_t pNtk,
Lpk_Par_t pPars 
)

MACRO DEFINITIONS ///.

ITERATORS ///FUNCTION DECLARATIONS ///

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

Synopsis [Performs resynthesis for one network.]

Description []

SideEffects []

SeeAlso []

Definition at line 505 of file lpkCore.c.

506 {
507  ProgressBar * pProgress = NULL; // Suppress "might be used uninitialized"
508  Lpk_Man_t * p;
509  Abc_Obj_t * pObj;
510  double Delta;
511 // int * pnFanouts, nObjMax;
512  int i, Iter, nNodes, nNodesPrev;
513  abctime clk = Abc_Clock();
514  assert( Abc_NtkIsLogic(pNtk) );
515 
516  // sweep dangling nodes as a preprocessing step
517  Abc_NtkSweep( pNtk, 0 );
518 
519  // get the number of inputs
520  if ( Abc_FrameReadLibLut() )
521  pPars->nLutSize = ((If_LibLut_t *)Abc_FrameReadLibLut())->LutMax;
522  else
523  pPars->nLutSize = Abc_NtkGetFaninMax( pNtk );
524  if ( pPars->nLutSize > 6 )
525  pPars->nLutSize = 6;
526  if ( pPars->nLutSize < 3 )
527  pPars->nLutSize = 3;
528  // adjust the number of crossbars based on LUT size
529  if ( pPars->nVarsShared > pPars->nLutSize - 2 )
530  pPars->nVarsShared = pPars->nLutSize - 2;
531  // get the max number of LUTs tried
532  pPars->nVarsMax = pPars->nLutsMax * (pPars->nLutSize - 1) + 1; // V = N * (K-1) + 1
533  while ( pPars->nVarsMax > 16 )
534  {
535  pPars->nLutsMax--;
536  pPars->nVarsMax = pPars->nLutsMax * (pPars->nLutSize - 1) + 1;
537 
538  }
539  if ( pPars->fVerbose )
540  {
541  printf( "Resynthesis for %d %d-LUTs with %d non-MFFC LUTs, %d crossbars, and %d-input cuts.\n",
542  pPars->nLutsMax, pPars->nLutSize, pPars->nLutsOver, pPars->nVarsShared, pPars->nVarsMax );
543  }
544 
545 
546  // convert into the AIG
547  if ( !Abc_NtkToAig(pNtk) )
548  {
549  fprintf( stdout, "Converting to BDD has failed.\n" );
550  return 0;
551  }
552  assert( Abc_NtkHasAig(pNtk) );
553 
554  // set the number of levels
555  Abc_NtkLevel( pNtk );
556  Abc_NtkStartReverseLevels( pNtk, pPars->nGrowthLevel );
557 
558  // start the manager
559  p = Lpk_ManStart( pPars );
560  p->pNtk = pNtk;
561  p->nNodesTotal = Abc_NtkNodeNum(pNtk);
562  p->vLevels = Vec_VecStart( pNtk->LevelMax );
563  if ( p->pPars->fSatur )
564  p->vVisited = Vec_VecStart( 0 );
565  if ( pPars->fVerbose )
566  {
568  p->nTotalNodes = Abc_NtkNodeNum(pNtk);
569  }
570 /*
571  // save the number of fanouts of all objects
572  nObjMax = Abc_NtkObjNumMax( pNtk );
573  pnFanouts = ABC_ALLOC( int, nObjMax );
574  memset( pnFanouts, 0, sizeof(int) * nObjMax );
575  Abc_NtkForEachObj( pNtk, pObj, i )
576  pnFanouts[pObj->Id] = Abc_ObjFanoutNum(pObj);
577 */
578 
579  // iterate over the network
580  nNodesPrev = p->nNodesTotal;
581  for ( Iter = 1; ; Iter++ )
582  {
583  // expand storage for changed nodes
584  if ( p->pPars->fSatur )
585  Vec_VecExpand( p->vVisited, Abc_NtkObjNumMax(pNtk) + 1 );
586 
587  // consider all nodes
588  nNodes = Abc_NtkObjNumMax(pNtk);
589  if ( !pPars->fVeryVerbose )
590  pProgress = Extra_ProgressBarStart( stdout, nNodes );
591  Abc_NtkForEachNode( pNtk, pObj, i )
592  {
593  // skip all except the final node
594  if ( pPars->fFirst )
595  {
596  if ( !Abc_ObjIsCo(Abc_ObjFanout0(pObj)) )
597  continue;
598  }
599  if ( i >= nNodes )
600  break;
601  if ( !pPars->fVeryVerbose )
602  Extra_ProgressBarUpdate( pProgress, i, NULL );
603  // skip the nodes that did not change
604  if ( p->pPars->fSatur && !Lpk_NodeHasChanged(p, pObj->Id) )
605  continue;
606  // resynthesize
607  p->pObj = pObj;
608  if ( p->pPars->fOldAlgo )
610  else
612  }
613  if ( !pPars->fVeryVerbose )
614  Extra_ProgressBarStop( pProgress );
615 
616  // check the increase
617  Delta = 100.00 * (nNodesPrev - Abc_NtkNodeNum(pNtk)) / p->nNodesTotal;
618  if ( Delta < 0.05 )
619  break;
620  nNodesPrev = Abc_NtkNodeNum(pNtk);
621  if ( !p->pPars->fSatur )
622  break;
623 
624  if ( pPars->fFirst )
625  break;
626  }
627  Abc_NtkStopReverseLevels( pNtk );
628 /*
629  // report the fanout changes
630  Abc_NtkForEachObj( pNtk, pObj, i )
631  {
632  if ( i >= nObjMax )
633  continue;
634  if ( Abc_ObjFanoutNum(pObj) - pnFanouts[pObj->Id] == 0 )
635  continue;
636  printf( "%d ", Abc_ObjFanoutNum(pObj) - pnFanouts[pObj->Id] );
637  }
638  printf( "\n" );
639 */
640 
641  if ( pPars->fVerbose )
642  {
643 // Cloud_PrintInfo( p->pDsdMan->dd );
645  p->nTotalNodes2 = Abc_NtkNodeNum(pNtk);
646  printf( "Node gain = %5d. (%.2f %%) ",
647  p->nTotalNodes-p->nTotalNodes2, 100.0*(p->nTotalNodes-p->nTotalNodes2)/p->nTotalNodes );
648  printf( "Edge gain = %5d. (%.2f %%) ",
649  p->nTotalNets-p->nTotalNets2, 100.0*(p->nTotalNets-p->nTotalNets2)/p->nTotalNets );
650  printf( "Muxes = %4d. Dsds = %4d.", p->nMuxes, p->nDsds );
651  printf( "\n" );
652  printf( "Nodes = %5d (%3d) Cuts = %5d (%4d) Changes = %5d Iter = %2d Benefit = %d.\n",
653  p->nNodesTotal, p->nNodesOver, p->nCutsTotal, p->nCutsUseful, p->nChanges, Iter, p->nBenefited );
654 
655  printf( "Non-DSD:" );
656  for ( i = 3; i <= pPars->nVarsMax; i++ )
657  if ( p->nBlocks[i] )
658  printf( " %d=%d", i, p->nBlocks[i] );
659  printf( "\n" );
660 
661  p->timeTotal = Abc_Clock() - clk;
662  p->timeEval = p->timeEval - p->timeMap;
663  p->timeOther = p->timeTotal - p->timeCuts - p->timeTruth - p->timeEval - p->timeMap;
664  ABC_PRTP( "Cuts ", p->timeCuts, p->timeTotal );
665  ABC_PRTP( "Truth ", p->timeTruth, p->timeTotal );
666  ABC_PRTP( "CSupps", p->timeSupps, p->timeTotal );
667  ABC_PRTP( "Eval ", p->timeEval, p->timeTotal );
668  ABC_PRTP( " MuxAn", p->timeEvalMuxAn, p->timeEval );
669  ABC_PRTP( " MuxSp", p->timeEvalMuxSp, p->timeEval );
670  ABC_PRTP( " DsdAn", p->timeEvalDsdAn, p->timeEval );
671  ABC_PRTP( " DsdSp", p->timeEvalDsdSp, p->timeEval );
673  ABC_PRTP( "Map ", p->timeMap, p->timeTotal );
674  ABC_PRTP( "Other ", p->timeOther, p->timeTotal );
675  ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
676  }
677 
678  Lpk_ManStop( p );
679  // check the resulting network
680  if ( !Abc_NtkCheck( pNtk ) )
681  {
682  printf( "Lpk_Resynthesize: The network check has failed.\n" );
683  return 0;
684  }
685  return 1;
686 }
int nNodesTotal
Definition: lpkInt.h:108
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
Lpk_Par_t * pPars
Definition: lpkInt.h:72
int nTotalNets2
Definition: lpkInt.h:118
Vec_Vec_t * vVisited
Definition: lpkInt.h:84
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Lpk_NodeHasChanged(Lpk_Man_t *p, int iNode)
Definition: lpkCore.c:96
int LevelMax
Definition: abc.h:195
abctime timeMap
Definition: lpkInt.h:130
int nChanges
Definition: lpkInt.h:113
int Lpk_ResynthesizeNode(Lpk_Man_t *p)
Definition: lpkCore.c:239
abctime timeEvalMuxSp
Definition: lpkInt.h:135
ABC_DLL int Abc_NtkGetFaninMax(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:453
int nBenefited
Definition: lpkInt.h:114
int nCutsUseful
Definition: lpkInt.h:111
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
Lpk_Man_t * Lpk_ManStart(Lpk_Par_t *pPars)
DECLARATIONS ///.
Definition: lpkMan.c:45
static abctime Abc_Clock()
Definition: abc_global.h:279
ABC_DLL int Abc_NtkGetTotalFanins(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:487
Abc_Obj_t * pObj
Definition: lpkInt.h:75
ABC_DLL void Abc_NtkStopReverseLevels(Abc_Ntk_t *pNtk)
Definition: abcTiming.c:1190
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
int nNodesOver
Definition: lpkInt.h:109
#define ABC_PRTP(a, t, T)
Definition: abc_global.h:223
Abc_Ntk_t * pNtk
Definition: lpkInt.h:74
abctime timeEvalMuxAn
Definition: lpkInt.h:134
int nDsds
Definition: lpkInt.h:116
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
DECLARATIONS ///.
abctime timeEvalDsdSp
Definition: lpkInt.h:137
int Lpk_ResynthesizeNodeNew(Lpk_Man_t *p)
Definition: lpkCore.c:368
if(last==0)
Definition: sparse_int.h:34
Vec_Vec_t * vLevels
Definition: lpkInt.h:88
abctime timeEval
Definition: lpkInt.h:129
int nTotalNodes
Definition: lpkInt.h:119
static Vec_Vec_t * Vec_VecStart(int nSize)
Definition: vecVec.h:168
ABC_DLL void Abc_NtkStartReverseLevels(Abc_Ntk_t *pNtk, int nMaxLevelIncrease)
Definition: abcTiming.c:1162
void Extra_ProgressBarStop(ProgressBar *p)
int nCutsTotal
Definition: lpkInt.h:110
abctime timeSupps
Definition: lpkInt.h:126
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
abctime timeTruth
Definition: lpkInt.h:125
abctime timeTotal
Definition: lpkInt.h:132
ABC_DLL int Abc_NtkSweep(Abc_Ntk_t *pNtk, int fVerbose)
Definition: abcSweep.c:574
static void Vec_VecExpand(Vec_Vec_t *p, int Level)
Definition: vecVec.h:190
int Id
Definition: abc.h:132
void Lpk_ManStop(Lpk_Man_t *p)
Definition: lpkMan.c:94
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
abctime timeOther
Definition: lpkInt.h:131
ABC_DLL int Abc_NtkToAig(Abc_Ntk_t *pNtk)
Definition: abcFunc.c:1192
abctime timeEvalDsdAn
Definition: lpkInt.h:136
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
static int Abc_NtkHasAig(Abc_Ntk_t *pNtk)
Definition: abc.h:255
int nBlocks[17]
Definition: lpkInt.h:122
int nTotalNets
Definition: lpkInt.h:117
int nTotalNodes2
Definition: lpkInt.h:120
int nMuxes
Definition: lpkInt.h:115
ABC_INT64_T abctime
Definition: abc_global.h:278
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1265
ABC_DLL void * Abc_FrameReadLibLut()
Definition: mainFrame.c:54
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
abctime timeCuts
Definition: lpkInt.h:124