abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
nwkMap.c File Reference
#include "nwk.h"
#include "map/if/if.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Nwk_ManSetIfParsDefault (If_Par_t *pPars)
 DECLARATIONS ///. More...
 
If_Man_tNwk_ManToIf (Aig_Man_t *p, If_Par_t *pPars, Vec_Ptr_t *vAigToIf)
 
Hop_Obj_tNwk_NodeIfToHop2_rec (Hop_Man_t *pHopMan, If_Man_t *pIfMan, If_Obj_t *pIfObj, Vec_Ptr_t *vVisited)
 
Hop_Obj_tNwk_NodeIfToHop (Hop_Man_t *pHopMan, If_Man_t *pIfMan, If_Obj_t *pIfObj)
 
Nwk_Man_tNwk_ManFromIf (If_Man_t *pIfMan, Aig_Man_t *p, Vec_Ptr_t *vAigToIf)
 
Nwk_Man_tNwk_MappingIf (Aig_Man_t *p, Tim_Man_t *pManTime, If_Par_t *pPars)
 

Function Documentation

Nwk_Man_t* Nwk_ManFromIf ( If_Man_t pIfMan,
Aig_Man_t p,
Vec_Ptr_t vAigToIf 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 275 of file nwkMap.c.

276 {
277  Vec_Ptr_t * vIfToAig;
278  Nwk_Man_t * pNtk;
279  Nwk_Obj_t * pObjNew;
280  Aig_Obj_t * pObj, * pObjRepr;
281  If_Obj_t * pIfObj;
282  If_Cut_t * pCutBest;
283  int i, k, nLeaves, * ppLeaves;
284  assert( Aig_ManCiNum(p) == If_ManCiNum(pIfMan) );
285  assert( Aig_ManCoNum(p) == If_ManCoNum(pIfMan) );
286  assert( Aig_ManNodeNum(p) == If_ManAndNum(pIfMan) );
287  Aig_ManCleanData( p );
288  If_ManCleanCutData( pIfMan );
289  // create mapping of IF to AIG
290  vIfToAig = Vec_PtrStart( If_ManObjNum(pIfMan) );
291  Aig_ManForEachObj( p, pObj, i )
292  {
293  pIfObj = (If_Obj_t *)Vec_PtrEntry( vAigToIf, i );
294  Vec_PtrWriteEntry( vIfToAig, pIfObj->Id, pObj );
295  }
296  // construct the network
297  pNtk = Nwk_ManAlloc();
298  pNtk->pName = Abc_UtilStrsav( p->pName );
299  pNtk->pSpec = Abc_UtilStrsav( p->pSpec );
300 // pNtk->nLatches = Aig_ManRegNum(p);
301 // pNtk->nTruePis = Nwk_ManCiNum(pNtk) - pNtk->nLatches;
302 // pNtk->nTruePos = Nwk_ManCoNum(pNtk) - pNtk->nLatches;
303  Aig_ManForEachObj( p, pObj, i )
304  {
305  pIfObj = (If_Obj_t *)Vec_PtrEntry( vAigToIf, i );
306  if ( pIfObj->nRefs == 0 && !If_ObjIsTerm(pIfObj) )
307  continue;
308  if ( Aig_ObjIsNode(pObj) )
309  {
310  pCutBest = If_ObjCutBest( pIfObj );
311  nLeaves = If_CutLeaveNum( pCutBest );
312  ppLeaves = If_CutLeaves( pCutBest );
313  // create node
314  pObjNew = Nwk_ManCreateNode( pNtk, nLeaves, pIfObj->nRefs );
315  for ( k = 0; k < nLeaves; k++ )
316  {
317  pObjRepr = (Aig_Obj_t *)Vec_PtrEntry( vIfToAig, ppLeaves[k] );
318  Nwk_ObjAddFanin( pObjNew, (Nwk_Obj_t *)pObjRepr->pData );
319  }
320  // get the functionality
321  pObjNew->pFunc = Nwk_NodeIfToHop( pNtk->pManHop, pIfMan, pIfObj );
322  }
323  else if ( Aig_ObjIsCi(pObj) )
324  pObjNew = Nwk_ManCreateCi( pNtk, pIfObj->nRefs );
325  else if ( Aig_ObjIsCo(pObj) )
326  {
327  pObjNew = Nwk_ManCreateCo( pNtk );
328  pObjNew->fInvert = Aig_ObjFaninC0(pObj);
329  Nwk_ObjAddFanin( pObjNew, (Nwk_Obj_t *)Aig_ObjFanin0(pObj)->pData );
330 //printf( "%d ", pObjNew->Id );
331  }
332  else if ( Aig_ObjIsConst1(pObj) )
333  {
334  pObjNew = Nwk_ManCreateNode( pNtk, 0, pIfObj->nRefs );
335  pObjNew->pFunc = Hop_ManConst1( pNtk->pManHop );
336  }
337  else
338  assert( 0 );
339  pObj->pData = pObjNew;
340  }
341 //printf( "\n" );
342  Vec_PtrFree( vIfToAig );
343  pNtk->pManTime = Tim_ManDup( pIfMan->pManTim, 0 );
344  Nwk_ManMinimumBase( pNtk, 0 );
345  assert( Nwk_ManCheck( pNtk ) );
346  return pNtk;
347 }
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
int Id
Definition: if.h:316
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Definition: hop.h:132
static int If_ManAndNum(If_Man_t *p)
Definition: if.h:362
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * pSpec
Definition: nwk.h:65
Definition: if.h:303
Definition: if.h:275
void * pData
Definition: aig.h:87
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
char * pName
Definition: nwk.h:64
Hop_Obj_t * Nwk_NodeIfToHop(Hop_Man_t *pHopMan, If_Man_t *pIfMan, If_Obj_t *pIfObj)
Definition: nwkMap.c:235
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
int nRefs
Definition: if.h:318
Tim_Man_t * pManTim
Definition: if.h:263
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static int If_ManCiNum(If_Man_t *p)
Definition: if.h:360
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
ABC_DLL void Nwk_ManMinimumBase(Nwk_Man_t *pNtk, int fVerbose)
Definition: nwkUtil.c:563
ABC_DLL int Nwk_ManCheck(Nwk_Man_t *p)
DECLARATIONS ///.
Definition: nwkCheck.c:45
Hop_Man_t * pManHop
Definition: nwk.h:73
Definition: nwk.h:61
static int * If_CutLeaves(If_Cut_t *pCut)
Definition: if.h:391
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
ABC_DLL Nwk_Man_t * Nwk_ManAlloc()
DECLARATIONS ///.
Definition: nwkMan.c:45
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
ABC_DLL Nwk_Obj_t * Nwk_ManCreateCo(Nwk_Man_t *pMan)
Definition: nwkObj.c:92
Tim_Man_t * Tim_ManDup(Tim_Man_t *p, int fUnitDelay)
Definition: timMan.c:86
Definition: aig.h:69
Tim_Man_t * pManTime
Definition: nwk.h:74
static int If_ObjIsTerm(If_Obj_t *pObj)
Definition: if.h:375
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int If_ManObjNum(If_Man_t *p)
Definition: if.h:363
ABC_DLL Nwk_Obj_t * Nwk_ManCreateCi(Nwk_Man_t *pMan, int nFanouts)
Definition: nwkObj.c:70
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
void If_ManCleanCutData(If_Man_t *p)
Definition: ifUtil.c:64
ABC_DLL void Nwk_ObjAddFanin(Nwk_Obj_t *pObj, Nwk_Obj_t *pFanin)
Definition: nwkFanio.c:165
#define assert(ex)
Definition: util_old.h:213
static int If_ManCoNum(If_Man_t *p)
Definition: if.h:361
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
void Aig_ManCleanData(Aig_Man_t *p)
Definition: aigUtil.c:205
static int Aig_ObjIsCo(Aig_Obj_t *pObj)
Definition: aig.h:276
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
ABC_DLL Nwk_Obj_t * Nwk_ManCreateNode(Nwk_Man_t *pMan, int nFanins, int nFanouts)
Definition: nwkObj.c:134
ABC_NAMESPACE_IMPL_START void Nwk_ManSetIfParsDefault ( If_Par_t pPars)

DECLARATIONS ///.

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

FileName [nwkMap.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Logic network representation.]

Synopsis [Interface to technology mapping.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Load the network into FPGA manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file nwkMap.c.

47 {
48 // extern void * Abc_FrameReadLibLut();
49  // set defaults
50  memset( pPars, 0, sizeof(If_Par_t) );
51  // user-controlable paramters
52 // pPars->nLutSize = -1;
53  pPars->nLutSize = 6;
54  pPars->nCutsMax = 8;
55  pPars->nFlowIters = 1;
56  pPars->nAreaIters = 2;
57  pPars->DelayTarget = -1;
58  pPars->Epsilon = (float)0.005;
59  pPars->fPreprocess = 1;
60  pPars->fArea = 0;
61  pPars->fFancy = 0;
62  pPars->fExpRed = 1; ////
63  pPars->fLatchPaths = 0;
64  pPars->fEdge = 1;
65  pPars->fPower = 0;
66  pPars->fCutMin = 0;
67  pPars->fVerbose = 0;
68  // internal parameters
69  pPars->fTruth = 0;
70  pPars->nLatchesCi = 0;
71  pPars->nLatchesCo = 0;
72  pPars->fLiftLeaves = 0;
73 // pPars->pLutLib = Abc_FrameReadLibLut();
74  pPars->pLutLib = NULL;
75  pPars->pTimesArr = NULL;
76  pPars->pTimesArr = NULL;
77  pPars->pFuncCost = NULL;
78 /*
79  if ( pPars->nLutSize == -1 )
80  {
81  if ( pPars->pLutLib == NULL )
82  {
83  printf( "The LUT library is not given.\n" );
84  return;
85  }
86  // get LUT size from the library
87  pPars->nLutSize = pPars->pLutLib->LutMax;
88  }
89 */
90 }
char * memset()
int nLutSize
Definition: if.h:103
Definition: if.h:100
int fVerbose
Definition: if.h:140
int(* pFuncCost)(If_Man_t *, If_Cut_t *)
Definition: if.h:163
int nLatchesCi
Definition: if.h:152
int fExpRed
Definition: if.h:116
int nFlowIters
Definition: if.h:105
int fEdge
Definition: if.h:118
int fPreprocess
Definition: if.h:113
int fTruth
Definition: if.h:146
int fLatchPaths
Definition: if.h:117
float * pTimesArr
Definition: if.h:161
float Epsilon
Definition: if.h:110
int fFancy
Definition: if.h:115
float DelayTarget
Definition: if.h:109
int nLatchesCo
Definition: if.h:153
int nAreaIters
Definition: if.h:106
int fPower
Definition: if.h:119
int fCutMin
Definition: if.h:120
int nCutsMax
Definition: if.h:104
int fArea
Definition: if.h:114
int fLiftLeaves
Definition: if.h:156
If_LibLut_t * pLutLib
Definition: if.h:160
If_Man_t* Nwk_ManToIf ( Aig_Man_t p,
If_Par_t pPars,
Vec_Ptr_t vAigToIf 
)

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

Synopsis [Load the network into FPGA manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 103 of file nwkMap.c.

104 {
105  extern Vec_Int_t * Saig_ManComputeSwitchProbs( Aig_Man_t * p, int nFrames, int nPref, int fProbOne );
106  Vec_Int_t * vSwitching = NULL, * vSwitching2 = NULL;
107  float * pSwitching = NULL, * pSwitching2 = NULL;
108  If_Man_t * pIfMan;
109  If_Obj_t * pIfObj;
110  Aig_Obj_t * pNode, * pFanin, * pPrev;
111  int i;
112  abctime clk = Abc_Clock();
113  // set the number of registers (switch activity will be combinational)
114  Aig_ManSetRegNum( p, 0 );
115  if ( pPars->fPower )
116  {
117  vSwitching = Saig_ManComputeSwitchProbs( p, 48, 16, 0 );
118  if ( pPars->fVerbose )
119  {
120  ABC_PRT( "Computing switching activity", Abc_Clock() - clk );
121  }
122  pSwitching = (float *)vSwitching->pArray;
123  vSwitching2 = Vec_IntStart( Aig_ManObjNumMax(p) );
124  pSwitching2 = (float *)vSwitching2->pArray;
125  }
126  // start the mapping manager and set its parameters
127  pIfMan = If_ManStart( pPars );
128  pIfMan->vSwitching = vSwitching2;
129  // load the AIG into the mapper
130  Aig_ManForEachObj( p, pNode, i )
131  {
132  if ( Aig_ObjIsAnd(pNode) )
133  {
134  pIfObj = If_ManCreateAnd( pIfMan,
135  If_NotCond( (If_Obj_t *)Aig_ObjFanin0(pNode)->pData, Aig_ObjFaninC0(pNode) ),
136  If_NotCond( (If_Obj_t *)Aig_ObjFanin1(pNode)->pData, Aig_ObjFaninC1(pNode) ) );
137 // printf( "no%d=%d\n ", If_ObjId(pIfObj), If_ObjLevel(pIfObj) );
138  }
139  else if ( Aig_ObjIsCi(pNode) )
140  {
141  pIfObj = If_ManCreateCi( pIfMan );
142  If_ObjSetLevel( pIfObj, Aig_ObjLevel(pNode) );
143 // printf( "pi%d=%d\n ", If_ObjId(pIfObj), If_ObjLevel(pIfObj) );
144  if ( pIfMan->nLevelMax < (int)pIfObj->Level )
145  pIfMan->nLevelMax = (int)pIfObj->Level;
146  }
147  else if ( Aig_ObjIsCo(pNode) )
148  {
149  pIfObj = If_ManCreateCo( pIfMan, If_NotCond( (If_Obj_t *)Aig_ObjFanin0(pNode)->pData, Aig_ObjFaninC0(pNode) ) );
150 // printf( "po%d=%d\n ", If_ObjId(pIfObj), If_ObjLevel(pIfObj) );
151  }
152  else if ( Aig_ObjIsConst1(pNode) )
153  pIfObj = If_ManConst1( pIfMan );
154  else // add the node to the mapper
155  assert( 0 );
156  // save the result
157  assert( Vec_PtrEntry(vAigToIf, i) == NULL );
158  Vec_PtrWriteEntry( vAigToIf, i, pIfObj );
159  pNode->pData = pIfObj;
160  if ( vSwitching2 )
161  pSwitching2[pIfObj->Id] = pSwitching[pNode->Id];
162  // set up the choice node
163  if ( Aig_ObjIsChoice( p, pNode ) )
164  {
165  for ( pPrev = pNode, pFanin = Aig_ObjEquiv(p, pNode); pFanin; pPrev = pFanin, pFanin = Aig_ObjEquiv(p, pFanin) )
166  If_ObjSetChoice( (If_Obj_t *)pPrev->pData, (If_Obj_t *)pFanin->pData );
167  If_ManCreateChoice( pIfMan, (If_Obj_t *)pNode->pData );
168  }
169 // assert( If_ObjLevel(pIfObj) == Aig_ObjLevel(pNode) );
170  }
171  if ( vSwitching )
172  Vec_IntFree( vSwitching );
173  return pIfMan;
174 }
static If_Obj_t * If_NotCond(If_Obj_t *p, int c)
Definition: if.h:357
int Id
Definition: if.h:316
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
If_Man_t * If_ManStart(If_Par_t *pPars)
FUNCTION DEFINITIONS ///.
Definition: ifMan.c:50
Definition: if.h:303
void * pData
Definition: aig.h:87
int fVerbose
Definition: if.h:140
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
int nLevelMax
Definition: if.h:194
static abctime Abc_Clock()
Definition: abc_global.h:279
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
Vec_Int_t * vSwitching
Definition: if.h:208
static void If_ObjSetLevel(If_Obj_t *pObj, int Level)
Definition: if.h:386
If_Obj_t * If_ManCreateCo(If_Man_t *p, If_Obj_t *pDriver)
Definition: ifMan.c:338
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
Vec_Int_t * Saig_ManComputeSwitchProbs(Aig_Man_t *pAig, int nFrames, int nPref, int fProbOne)
Definition: giaSwitch.c:684
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
Definition: aigMan.c:438
Definition: if.h:180
static If_Obj_t * If_ManConst1(If_Man_t *p)
Definition: if.h:365
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
static Aig_Obj_t * Aig_ObjEquiv(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:328
Definition: aig.h:69
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
unsigned Level
Definition: if.h:315
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static void If_ObjSetChoice(If_Obj_t *pObj, If_Obj_t *pEqu)
Definition: if.h:388
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
void If_ManCreateChoice(If_Man_t *p, If_Obj_t *pRepr)
Definition: ifMan.c:442
#define ABC_PRT(a, t)
Definition: abc_global.h:220
int fPower
Definition: if.h:119
If_Obj_t * If_ManCreateCi(If_Man_t *p)
Definition: ifMan.c:316
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
static int Aig_ObjLevel(Aig_Obj_t *pObj)
Definition: aig.h:323
If_Obj_t * If_ManCreateAnd(If_Man_t *p, If_Obj_t *pFan0, If_Obj_t *pFan1)
Definition: ifMan.c:366
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
ABC_INT64_T abctime
Definition: abc_global.h:278
int Id
Definition: aig.h:85
static int Aig_ObjIsCo(Aig_Obj_t *pObj)
Definition: aig.h:276
static int Aig_ObjIsChoice(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:283
static int Aig_ObjIsAnd(Aig_Obj_t *pObj)
Definition: aig.h:278
Nwk_Man_t* Nwk_MappingIf ( Aig_Man_t p,
Tim_Man_t pManTime,
If_Par_t pPars 
)

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

Synopsis [Interface with the FPGA mapping package.]

Description []

SideEffects []

SeeAlso []

Definition at line 360 of file nwkMap.c.

361 {
362  Nwk_Man_t * pNtk;
363  If_Man_t * pIfMan;
364  Vec_Ptr_t * vAigToIf;
365  // set the arrival times
366  pPars->pTimesArr = ABC_ALLOC( float, Aig_ManCiNum(p) );
367  memset( pPars->pTimesArr, 0, sizeof(float) * Aig_ManCiNum(p) );
368  // translate into the mapper
369  vAigToIf = Vec_PtrStart( Aig_ManObjNumMax(p) );
370  pIfMan = Nwk_ManToIf( p, pPars, vAigToIf );
371  if ( pIfMan == NULL )
372  return NULL;
373  pIfMan->pManTim = Tim_ManDup( pManTime, 0 );
374  pIfMan->pPars->fCutMin = 0; // is not compatible with deriving result
375  if ( !If_ManPerformMapping( pIfMan ) )
376  {
377  If_ManStop( pIfMan );
378  return NULL;
379  }
380  // transform the result of mapping into the new network
381  pNtk = Nwk_ManFromIf( pIfMan, p, vAigToIf );
382  if ( pPars->fBidec && pPars->nLutSize <= 8 )
383  Nwk_ManBidecResyn( pNtk, 0 );
384  If_ManStop( pIfMan );
385  Vec_PtrFree( vAigToIf );
386  return pNtk;
387 }
char * memset()
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int nLutSize
Definition: if.h:103
static Llb_Mgr_t * p
Definition: llb3Image.c:950
If_Man_t * Nwk_ManToIf(Aig_Man_t *p, If_Par_t *pPars, Vec_Ptr_t *vAigToIf)
Definition: nwkMap.c:103
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Tim_Man_t * pManTim
Definition: if.h:263
Definition: nwk.h:61
Definition: if.h:180
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
float * pTimesArr
Definition: if.h:161
Tim_Man_t * Tim_ManDup(Tim_Man_t *p, int fUnitDelay)
Definition: timMan.c:86
int fBidec
Definition: if.h:125
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
If_Par_t * pPars
Definition: if.h:184
int If_ManPerformMapping(If_Man_t *p)
Definition: ifCore.c:80
ABC_DLL void Nwk_ManBidecResyn(Nwk_Man_t *p, int fVerbose)
Definition: nwkBidec.c:129
int fCutMin
Definition: if.h:120
Nwk_Man_t * Nwk_ManFromIf(If_Man_t *pIfMan, Aig_Man_t *p, Vec_Ptr_t *vAigToIf)
Definition: nwkMap.c:275
void If_ManStop(If_Man_t *p)
Definition: ifMan.c:205
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Hop_Obj_t* Nwk_NodeIfToHop ( Hop_Man_t pHopMan,
If_Man_t pIfMan,
If_Obj_t pIfObj 
)

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

Synopsis [Derives the local AIG for the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 235 of file nwkMap.c.

236 {
237  If_Cut_t * pCut;
238  Hop_Obj_t * gFunc;
239  If_Obj_t * pLeaf;
240  int i;
241  // get the best cut
242  pCut = If_ObjCutBest(pIfObj);
243  assert( pCut->nLeaves > 1 );
244  // set the leaf variables
245  If_CutForEachLeaf( pIfMan, pCut, pLeaf, i )
246  If_CutSetData( If_ObjCutBest(pLeaf), Hop_IthVar(pHopMan, i) );
247  // recursively compute the function while collecting visited cuts
248  Vec_PtrClear( pIfMan->vTemp );
249  gFunc = Nwk_NodeIfToHop2_rec( pHopMan, pIfMan, pIfObj, pIfMan->vTemp );
250  if ( gFunc == (void *)1 )
251  {
252  printf( "Nwk_NodeIfToHop(): Computing local AIG has failed.\n" );
253  return NULL;
254  }
255 // printf( "%d ", Vec_PtrSize(p->vTemp) );
256  // clean the cuts
257  If_CutForEachLeaf( pIfMan, pCut, pLeaf, i )
258  If_CutSetData( If_ObjCutBest(pLeaf), NULL );
259  Vec_PtrForEachEntry( If_Cut_t *, pIfMan->vTemp, pCut, i )
260  If_CutSetData( pCut, NULL );
261  return gFunc;
262 }
unsigned nLeaves
Definition: if.h:289
Hop_Obj_t * Nwk_NodeIfToHop2_rec(Hop_Man_t *pHopMan, If_Man_t *pIfMan, If_Obj_t *pIfObj, Vec_Ptr_t *vVisited)
Definition: nwkMap.c:188
Definition: if.h:303
Definition: if.h:275
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static void If_CutSetData(If_Cut_t *pCut, void *pData)
Definition: if.h:412
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
Definition: hop.h:65
if(last==0)
Definition: sparse_int.h:34
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: hopOper.c:63
Hop_Obj_t* Nwk_NodeIfToHop2_rec ( Hop_Man_t pHopMan,
If_Man_t pIfMan,
If_Obj_t pIfObj,
Vec_Ptr_t vVisited 
)

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

Synopsis [Recursively derives the local AIG for the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 188 of file nwkMap.c.

189 {
190  If_Cut_t * pCut;
191  If_Obj_t * pTemp;
192  Hop_Obj_t * gFunc, * gFunc0, * gFunc1;
193  // get the best cut
194  pCut = If_ObjCutBest(pIfObj);
195  // if the cut is visited, return the result
196  if ( If_CutData(pCut) )
197  return (Hop_Obj_t *)If_CutData(pCut);
198  // mark the node as visited
199  Vec_PtrPush( vVisited, pCut );
200  // insert the worst case
201  If_CutSetData( pCut, (void *)1 );
202  // skip in case of primary input
203  if ( If_ObjIsCi(pIfObj) )
204  return (Hop_Obj_t *)If_CutData(pCut);
205  // compute the functions of the children
206  for ( pTemp = pIfObj; pTemp; pTemp = pTemp->pEquiv )
207  {
208  gFunc0 = Nwk_NodeIfToHop2_rec( pHopMan, pIfMan, pTemp->pFanin0, vVisited );
209  if ( gFunc0 == (void *)1 )
210  continue;
211  gFunc1 = Nwk_NodeIfToHop2_rec( pHopMan, pIfMan, pTemp->pFanin1, vVisited );
212  if ( gFunc1 == (void *)1 )
213  continue;
214  // both branches are solved
215  gFunc = Hop_And( pHopMan, Hop_NotCond(gFunc0, pTemp->fCompl0), Hop_NotCond(gFunc1, pTemp->fCompl1) );
216  if ( pTemp->fPhase != pIfObj->fPhase )
217  gFunc = Hop_Not(gFunc);
218  If_CutSetData( pCut, gFunc );
219  break;
220  }
221  return (Hop_Obj_t *)If_CutData(pCut);
222 }
If_Obj_t * pFanin0
Definition: if.h:321
Hop_Obj_t * Nwk_NodeIfToHop2_rec(Hop_Man_t *pHopMan, If_Man_t *pIfMan, If_Obj_t *pIfObj, Vec_Ptr_t *vVisited)
Definition: nwkMap.c:188
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:104
Definition: if.h:303
Definition: if.h:275
static void If_CutSetData(If_Cut_t *pCut, void *pData)
Definition: if.h:412
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int If_ObjIsCi(If_Obj_t *pObj)
Definition: if.h:373
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
static Hop_Obj_t * Hop_Not(Hop_Obj_t *p)
Definition: hop.h:127
Definition: hop.h:65
If_Obj_t * pFanin1
Definition: if.h:322
If_Obj_t * pEquiv
Definition: if.h:323
static void * If_CutData(If_Cut_t *pCut)
Definition: if.h:411
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Definition: hop.h:128
unsigned fCompl1
Definition: if.h:307
unsigned fCompl0
Definition: if.h:306
unsigned fPhase
Definition: if.h:308