abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcRenode.c File Reference
#include "base/abc/abc.h"
#include "bdd/reo/reo.h"
#include "map/if/if.h"
#include "bool/kit/kit.h"
#include "misc/extra/extraBdd.h"

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int Abc_NtkRenodeEvalAig (If_Man_t *p, If_Cut_t *pCut)
 DECLARATIONS ///. More...
 
static int Abc_NtkRenodeEvalBdd (If_Man_t *p, If_Cut_t *pCut)
 
static int Abc_NtkRenodeEvalSop (If_Man_t *p, If_Cut_t *pCut)
 
static int Abc_NtkRenodeEvalCnf (If_Man_t *p, If_Cut_t *pCut)
 
static int Abc_NtkRenodeEvalMv (If_Man_t *p, If_Cut_t *pCut)
 
Abc_Ntk_tAbc_NtkRenode (Abc_Ntk_t *pNtk, int nFaninMax, int nCubeMax, int nFlowIters, int nAreaIters, int fArea, int fUseBdds, int fUseSops, int fUseCnfs, int fUseMv, int fVerbose)
 FUNCTION DEFINITIONS ///. More...
 

Variables

static reo_mans_pReo = NULL
 
static DdManagers_pDd = NULL
 
static Vec_Int_ts_vMemory = NULL
 
static Vec_Int_ts_vMemory2 = NULL
 
static int nDsdCounter = 0
 

Function Documentation

Abc_Ntk_t* Abc_NtkRenode ( Abc_Ntk_t pNtk,
int  nFaninMax,
int  nCubeMax,
int  nFlowIters,
int  nAreaIters,
int  fArea,
int  fUseBdds,
int  fUseSops,
int  fUseCnfs,
int  fUseMv,
int  fVerbose 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Performs renoding as technology mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 62 of file abcRenode.c.

63 {
64  extern Abc_Ntk_t * Abc_NtkIf( Abc_Ntk_t * pNtk, If_Par_t * pPars );
65  If_Par_t Pars, * pPars = &Pars;
66  Abc_Ntk_t * pNtkNew;
67 
68  if ( Abc_NtkGetChoiceNum( pNtk ) )
69  printf( "Performing renoding with choices.\n" );
70 
71  nDsdCounter = 0;
72 
73  // set defaults
74  memset( pPars, 0, sizeof(If_Par_t) );
75  // user-controlable paramters
76  pPars->nLutSize = nFaninMax;
77  pPars->nCutsMax = nCubeMax;
78  pPars->nFlowIters = nFlowIters;
79  pPars->nAreaIters = nAreaIters;
80  pPars->DelayTarget = -1;
81  pPars->Epsilon = (float)0.005;
82  pPars->fPreprocess = 1;
83  pPars->fArea = fArea;
84  pPars->fFancy = 0;
85  pPars->fExpRed = 0; //
86  pPars->fLatchPaths = 0;
87  pPars->fVerbose = fVerbose;
88  // internal parameters
89  pPars->fTruth = 1;
90  pPars->fUsePerm = 1;
91  pPars->nLatchesCi = 0;
92  pPars->nLatchesCo = 0;
93  pPars->pLutLib = NULL; // Abc_FrameReadLibLut();
94  pPars->pTimesArr = NULL;
95  pPars->pTimesArr = NULL;
96  pPars->fUseBdds = fUseBdds;
97  pPars->fUseSops = fUseSops;
98  pPars->fUseCnfs = fUseCnfs;
99  pPars->fUseMv = fUseMv;
100  if ( fUseBdds )
102  else if ( fUseSops )
104  else if ( fUseCnfs )
105  {
106  pPars->fArea = 1;
108  }
109  else if ( fUseMv )
111  else
113 
114  // start the manager
115  if ( fUseBdds )
116  {
117  assert( s_pReo == NULL );
118  s_pDd = Cudd_Init( nFaninMax, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
119  s_pReo = Extra_ReorderInit( nFaninMax, 100 );
120  pPars->pReoMan = s_pReo;
121  }
122  else
123  {
124  assert( s_vMemory == NULL );
125  s_vMemory = Vec_IntAlloc( 1 << 16 );
126  s_vMemory2 = Vec_IntAlloc( 1 << 16 );
127  }
128 
129  // perform mapping/renoding
130  pNtkNew = Abc_NtkIf( pNtk, pPars );
131 
132  // start the manager
133  if ( fUseBdds )
134  {
137  s_pReo = NULL;
138  s_pDd = NULL;
139  }
140  else
141  {
144  s_vMemory = NULL;
145  s_vMemory2 = NULL;
146  }
147 
148 // printf( "Decomposed %d functions.\n", nDsdCounter );
149 
150  return pNtkNew;
151 }
char * memset()
static DdManager * s_pDd
Definition: abcRenode.c:41
int fUseMv
Definition: if.h:151
#define CUDD_UNIQUE_SLOTS
Definition: cudd.h:97
int nLutSize
Definition: if.h:103
static Vec_Int_t * s_vMemory
Definition: abcRenode.c:42
int fUseCnfs
Definition: if.h:150
Definition: if.h:100
int fVerbose
Definition: if.h:140
static int Abc_NtkRenodeEvalCnf(If_Man_t *p, If_Cut_t *pCut)
Definition: abcRenode.c:248
Abc_Ntk_t * Abc_NtkIf(Abc_Ntk_t *pNtk, If_Par_t *pPars)
Definition: abcIf.c:106
#define CUDD_CACHE_SLOTS
Definition: cudd.h:98
int(* pFuncCost)(If_Man_t *, If_Cut_t *)
Definition: if.h:163
void Extra_StopManager(DdManager *dd)
Definition: extraBddMisc.c:223
ABC_DLL int Abc_NtkGetChoiceNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:430
int nLatchesCi
Definition: if.h:152
int fExpRed
Definition: if.h:116
int nFlowIters
Definition: if.h:105
void * pReoMan
Definition: if.h:166
int fUsePerm
Definition: if.h:147
int fPreprocess
Definition: if.h:113
static int nDsdCounter
Definition: abcRenode.c:45
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int fTruth
Definition: if.h:146
int fLatchPaths
Definition: if.h:117
static int Abc_NtkRenodeEvalMv(If_Man_t *p, If_Cut_t *pCut)
Definition: abcRenode.c:283
DdManager * Cudd_Init(unsigned int numVars, unsigned int numVarsZ, unsigned int numSlots, unsigned int cacheSize, unsigned long maxMemory)
Definition: cuddInit.c:125
float * pTimesArr
Definition: if.h:161
static ABC_NAMESPACE_IMPL_START int Abc_NtkRenodeEvalAig(If_Man_t *p, If_Cut_t *pCut)
DECLARATIONS ///.
Definition: abcRenode.c:164
float Epsilon
Definition: if.h:110
int fFancy
Definition: if.h:115
static reo_man * s_pReo
Definition: abcRenode.c:40
float DelayTarget
Definition: if.h:109
static int Abc_NtkRenodeEvalBdd(If_Man_t *p, If_Cut_t *pCut)
Definition: abcRenode.c:194
int fUseBdds
Definition: if.h:148
int nLatchesCo
Definition: if.h:153
int nAreaIters
Definition: if.h:106
static int Abc_NtkRenodeEvalSop(If_Man_t *p, If_Cut_t *pCut)
Definition: abcRenode.c:224
int fUseSops
Definition: if.h:149
#define assert(ex)
Definition: util_old.h:213
int nCutsMax
Definition: if.h:104
reo_man * Extra_ReorderInit(int nDdVarsMax, int nNodesMax)
FUNCTION DECLARATIONS ///.
Definition: reoApi.c:50
void Extra_ReorderQuit(reo_man *p)
Definition: reoApi.c:79
int fArea
Definition: if.h:114
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static Vec_Int_t * s_vMemory2
Definition: abcRenode.c:43
If_LibLut_t * pLutLib
Definition: if.h:160
int Abc_NtkRenodeEvalAig ( If_Man_t p,
If_Cut_t pCut 
)
static

DECLARATIONS ///.

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

FileName [abcRenode.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
abcRenode.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

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

Synopsis [Computes the cost based on the factored form.]

Description []

SideEffects []

SeeAlso []

Definition at line 164 of file abcRenode.c.

165 {
166  char * pPerm = If_CutPerm( pCut );
167  Kit_Graph_t * pGraph;
168  int i, nNodes;
169  pGraph = Kit_TruthToGraph( If_CutTruth(p, pCut), If_CutLeaveNum(pCut), s_vMemory );
170  if ( pGraph == NULL )
171  {
172  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
173  pPerm[i] = 100;
174  return IF_COST_MAX;
175  }
176  nNodes = Kit_GraphNodeNum( pGraph );
177  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
178  pPerm[i] = Kit_GraphLeafDepth_rec( pGraph, Kit_GraphNodeLast(pGraph), Kit_GraphNode(pGraph, i) );
179  Kit_GraphFree( pGraph );
180  return nNodes;
181 }
static Kit_Node_t * Kit_GraphNodeLast(Kit_Graph_t *pGraph)
Definition: kit.h:212
static Vec_Int_t * s_vMemory
Definition: abcRenode.c:42
static Kit_Node_t * Kit_GraphNode(Kit_Graph_t *pGraph, int i)
Definition: kit.h:211
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
static char * If_CutPerm(If_Cut_t *pCut)
Definition: if.h:397
int Kit_GraphLeafDepth_rec(Kit_Graph_t *pGraph, Kit_Node_t *pNode, Kit_Node_t *pLeaf)
Definition: kitGraph.c:383
void Kit_GraphFree(Kit_Graph_t *pGraph)
Definition: kitGraph.c:131
static unsigned * If_CutTruth(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:422
static int pPerm[13719]
Definition: rwrTemp.c:32
#define IF_COST_MAX
Definition: if.h:58
static int Kit_GraphNodeNum(Kit_Graph_t *pGraph)
Definition: kit.h:210
Kit_Graph_t * Kit_TruthToGraph(unsigned *pTruth, int nVars, Vec_Int_t *vMemory)
Definition: kitGraph.c:355
int Abc_NtkRenodeEvalBdd ( If_Man_t p,
If_Cut_t pCut 
)
static

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

Synopsis [Computes the cost based on the BDD size after reordering.]

Description []

SideEffects []

SeeAlso []

Definition at line 194 of file abcRenode.c.

195 {
196  char * pPerm = If_CutPerm( pCut );
197  int pOrder[IF_MAX_LUTSIZE];
198  DdNode * bFunc, * bFuncNew;
199  int i, k, nNodes;
200  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
201  pPerm[i] = pOrder[i] = -100;
202  bFunc = Kit_TruthToBdd( s_pDd, If_CutTruth(p, pCut), If_CutLeaveNum(pCut), 0 ); Cudd_Ref( bFunc );
203  bFuncNew = Extra_Reorder( s_pReo, s_pDd, bFunc, pOrder ); Cudd_Ref( bFuncNew );
204  for ( i = k = 0; i < If_CutLeaveNum(pCut); i++ )
205  if ( pOrder[i] >= 0 )
206  pPerm[pOrder[i]] = ++k; // double-check this!
207  nNodes = -1 + Cudd_DagSize( bFuncNew );
208  Cudd_RecursiveDeref( s_pDd, bFuncNew );
209  Cudd_RecursiveDeref( s_pDd, bFunc );
210  return nNodes;
211 }
static DdManager * s_pDd
Definition: abcRenode.c:41
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
DdNode * Extra_Reorder(reo_man *p, DdManager *dd, DdNode *Func, int *pOrder)
Definition: reoApi.c:262
static char * If_CutPerm(If_Cut_t *pCut)
Definition: if.h:397
DdNode * Kit_TruthToBdd(DdManager *dd, unsigned *pTruth, int nVars, int fMSBonTop)
Definition: kitBdd.c:182
#define IF_MAX_LUTSIZE
INCLUDES ///.
Definition: if.h:52
static unsigned * If_CutTruth(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:422
static int pPerm[13719]
Definition: rwrTemp.c:32
static reo_man * s_pReo
Definition: abcRenode.c:40
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
int Cudd_DagSize(DdNode *node)
Definition: cuddUtil.c:442
int Abc_NtkRenodeEvalCnf ( If_Man_t p,
If_Cut_t pCut 
)
static

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

Synopsis [Computes the cost based on two ISOPs.]

Description []

SideEffects []

SeeAlso []

Definition at line 248 of file abcRenode.c.

249 {
250  char * pPerm = If_CutPerm( pCut );
251  int i, RetValue, nClauses;
252  // set internal mapper parameters
253  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
254  pPerm[i] = 1;
255  // compute ISOP for the positive phase
256  RetValue = Kit_TruthIsop( If_CutTruth(p, pCut), If_CutLeaveNum(pCut), s_vMemory, 0 );
257  if ( RetValue == -1 )
258  return IF_COST_MAX;
259  assert( RetValue == 0 || RetValue == 1 );
260  nClauses = Vec_IntSize( s_vMemory );
261  // compute ISOP for the negative phase
262  Kit_TruthNot( If_CutTruth(p, pCut), If_CutTruth(p, pCut), If_CutLeaveNum(pCut) );
263  RetValue = Kit_TruthIsop( If_CutTruth(p, pCut), If_CutLeaveNum(pCut), s_vMemory, 0 );
264  Kit_TruthNot( If_CutTruth(p, pCut), If_CutTruth(p, pCut), If_CutLeaveNum(pCut) );
265  if ( RetValue == -1 )
266  return IF_COST_MAX;
267  assert( RetValue == 0 || RetValue == 1 );
268  nClauses += Vec_IntSize( s_vMemory );
269  return nClauses;
270 }
static Vec_Int_t * s_vMemory
Definition: abcRenode.c:42
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
static char * If_CutPerm(If_Cut_t *pCut)
Definition: if.h:397
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
Definition: kitIsop.c:55
static unsigned * If_CutTruth(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:422
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
static int pPerm[13719]
Definition: rwrTemp.c:32
#define IF_COST_MAX
Definition: if.h:58
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
int Abc_NtkRenodeEvalMv ( If_Man_t p,
If_Cut_t pCut 
)
static

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

Synopsis [Computes the cost of MV-SOP of the cut function.]

Description []

SideEffects []

SeeAlso []

Definition at line 283 of file abcRenode.c.

284 {
285  char * pPerm = If_CutPerm( pCut );
286  int i, RetValue;
287  // set internal mapper parameters
288  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
289  pPerm[i] = 1;
290  // compute ISOP for the positive phase
291  RetValue = Kit_TruthIsop( If_CutTruth(p, pCut), If_CutLeaveNum(pCut), s_vMemory, 0 );
292  if ( RetValue == -1 )
293  return IF_COST_MAX;
294  assert( RetValue == 0 || RetValue == 1 );
295  // compute ISOP for the negative phase
296  Kit_TruthNot( If_CutTruth(p, pCut), If_CutTruth(p, pCut), If_CutLeaveNum(pCut) );
297  RetValue = Kit_TruthIsop( If_CutTruth(p, pCut), If_CutLeaveNum(pCut), s_vMemory2, 0 );
298  Kit_TruthNot( If_CutTruth(p, pCut), If_CutTruth(p, pCut), If_CutLeaveNum(pCut) );
299  if ( RetValue == -1 )
300  return IF_COST_MAX;
301  assert( RetValue == 0 || RetValue == 1 );
302  // return the cost of the cut
304  if ( RetValue >= IF_COST_MAX )
305  return IF_COST_MAX;
306  return RetValue;
307 }
static Vec_Int_t * s_vMemory
Definition: abcRenode.c:42
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
static char * If_CutPerm(If_Cut_t *pCut)
Definition: if.h:397
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
Definition: kitIsop.c:55
static unsigned * If_CutTruth(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:422
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
static int pPerm[13719]
Definition: rwrTemp.c:32
#define IF_COST_MAX
Definition: if.h:58
#define assert(ex)
Definition: util_old.h:213
ABC_DLL int Abc_NodeEvalMvCost(int nVars, Vec_Int_t *vSop0, Vec_Int_t *vSop1)
Definition: abcBlifMv.c:1135
static Vec_Int_t * s_vMemory2
Definition: abcRenode.c:43
int Abc_NtkRenodeEvalSop ( If_Man_t p,
If_Cut_t pCut 
)
static

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

Synopsis [Computes the cost based on ISOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 224 of file abcRenode.c.

225 {
226  char * pPerm = If_CutPerm( pCut );
227  int i, RetValue;
228  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
229  pPerm[i] = 1;
230  RetValue = Kit_TruthIsop( If_CutTruth(p, pCut), If_CutLeaveNum(pCut), s_vMemory, 1 );
231  if ( RetValue == -1 )
232  return IF_COST_MAX;
233  assert( RetValue == 0 || RetValue == 1 );
234  return Vec_IntSize( s_vMemory );
235 }
static Vec_Int_t * s_vMemory
Definition: abcRenode.c:42
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
static char * If_CutPerm(If_Cut_t *pCut)
Definition: if.h:397
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
Definition: kitIsop.c:55
static unsigned * If_CutTruth(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:422
static int pPerm[13719]
Definition: rwrTemp.c:32
#define IF_COST_MAX
Definition: if.h:58
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213

Variable Documentation

int nDsdCounter = 0
static

Definition at line 45 of file abcRenode.c.

DdManager* s_pDd = NULL
static

Definition at line 41 of file abcRenode.c.

reo_man* s_pReo = NULL
static

Definition at line 40 of file abcRenode.c.

Vec_Int_t* s_vMemory = NULL
static

Definition at line 42 of file abcRenode.c.

Vec_Int_t* s_vMemory2 = NULL
static

Definition at line 43 of file abcRenode.c.