abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
wlcNtk.c File Reference
#include "wlc.h"
#include "misc/vec/vecWec.h"

Go to the source code of this file.

Functions

Wlc_Ntk_tWlc_NtkAlloc (char *pName, int nObjsAlloc)
 FUNCTION DEFINITIONS ///. More...
 
void Wlc_ObjSetCi (Wlc_Ntk_t *p, Wlc_Obj_t *pObj)
 
void Wlc_ObjSetCo (Wlc_Ntk_t *p, Wlc_Obj_t *pObj, int fFlopInput)
 
int Wlc_ObjAlloc (Wlc_Ntk_t *p, int Type, int Signed, int End, int Beg)
 
int Wlc_ObjCreate (Wlc_Ntk_t *p, int Type, int Signed, int End, int Beg, Vec_Int_t *vFanins)
 
char * Wlc_ObjName (Wlc_Ntk_t *p, int iObj)
 
void Wlc_ObjUpdateType (Wlc_Ntk_t *p, Wlc_Obj_t *pObj, int Type)
 
void Wlc_ObjAddFanins (Wlc_Ntk_t *p, Wlc_Obj_t *pObj, Vec_Int_t *vFanins)
 
void Wlc_NtkFree (Wlc_Ntk_t *p)
 
int Wlc_NtkMemUsage (Wlc_Ntk_t *p)
 
static void Vec_WrdSelectSortCost2 (word *pArray, int nSize, word *pCosts)
 
static word Wlc_NtkPrintDistribMakeSign (int s, int s0, int s1)
 
static void Wlc_NtkPrintDistribFromSign (word sss, int *s, int *s0, int *s1)
 
static void Wlc_NtkPrintDistribAddOne (Vec_Ptr_t *vTypes, Vec_Ptr_t *vOccurs, int Type, word Sign)
 
void Wlc_NtkPrintDistribSortOne (Vec_Ptr_t *vTypes, Vec_Ptr_t *vOccurs, int Type)
 
void Wlc_NtkPrintDistrib (Wlc_Ntk_t *p, int fVerbose)
 
void Wlc_NtkPrintNodes (Wlc_Ntk_t *p, int Type)
 
void Wlc_NtkPrintStats (Wlc_Ntk_t *p, int fDistrib, int fVerbose)
 
void Wlc_ObjCollectCopyFanins (Wlc_Ntk_t *p, int iObj, Vec_Int_t *vFanins)
 
int Wlc_ObjDup (Wlc_Ntk_t *pNew, Wlc_Ntk_t *p, int iObj, Vec_Int_t *vFanins)
 
void Wlc_NtkDupDfs_rec (Wlc_Ntk_t *pNew, Wlc_Ntk_t *p, int iObj, Vec_Int_t *vFanins)
 
Wlc_Ntk_tWlc_NtkDupDfs (Wlc_Ntk_t *p)
 
void Wlc_NtkTransferNames (Wlc_Ntk_t *pNew, Wlc_Ntk_t *p)
 

Variables

static
ABC_NAMESPACE_IMPL_START char * 
Wlc_Names [WLC_OBJ_NUMBER+1]
 DECLARATIONS ///. More...
 

Function Documentation

static void Vec_WrdSelectSortCost2 ( word pArray,
int  nSize,
word pCosts 
)
inlinestatic

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

Synopsis [Prints distribution of operator types.]

Description []

SideEffects []

SeeAlso []

Definition at line 241 of file wlcNtk.c.

242 {
243  int i, j, best_i;
244  for ( i = 0; i < nSize-1; i++ )
245  {
246  best_i = i;
247  for ( j = i+1; j < nSize; j++ )
248  if ( pCosts[j] < pCosts[best_i] )
249  best_i = j;
250  ABC_SWAP( word, pArray[i], pArray[best_i] );
251  ABC_SWAP( word, pCosts[i], pCosts[best_i] );
252  }
253 }
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
Wlc_Ntk_t* Wlc_NtkAlloc ( char *  pName,
int  nObjsAlloc 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Working with models.]

Description []

SideEffects []

SeeAlso []

Definition at line 94 of file wlcNtk.c.

95 {
96  Wlc_Ntk_t * p;
97  p = ABC_CALLOC( Wlc_Ntk_t, 1 );
98  p->pName = Extra_FileNameGeneric( pName );
99  Vec_IntGrow( &p->vPis, 111 );
100  Vec_IntGrow( &p->vPos, 111 );
101  Vec_IntGrow( &p->vCis, 111 );
102  Vec_IntGrow( &p->vCos, 111 );
103  Vec_IntGrow( &p->vFfs, 111 );
104  p->pMemFanin = Mem_FlexStart();
105  p->nObjsAlloc = nObjsAlloc;
106  p->pObjs = ABC_CALLOC( Wlc_Obj_t, p->nObjsAlloc );
107  p->iObj = 1;
108  return p;
109 }
Mem_Flex_t * pMemFanin
Definition: wlc.h:129
Vec_Int_t vCis
Definition: wlc.h:120
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Wlc_Obj_t * pObjs
Definition: wlc.h:126
int iObj
Definition: wlc.h:127
Vec_Int_t vPis
Definition: wlc.h:118
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
Mem_Flex_t * Mem_FlexStart()
Definition: mem.c:311
char * pName
Definition: wlc.h:117
char * Extra_FileNameGeneric(char *FileName)
int nObjsAlloc
Definition: wlc.h:128
Vec_Int_t vPos
Definition: wlc.h:119
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Vec_Int_t vCos
Definition: wlc.h:121
Vec_Int_t vFfs
Definition: wlc.h:122
Wlc_Ntk_t* Wlc_NtkDupDfs ( Wlc_Ntk_t p)

Definition at line 457 of file wlcNtk.c.

458 {
459  Wlc_Ntk_t * pNew;
460  Wlc_Obj_t * pObj;
461  Vec_Int_t * vFanins;
462  int i;
463  Wlc_NtkCleanCopy( p );
464  vFanins = Vec_IntAlloc( 100 );
465  pNew = Wlc_NtkAlloc( p->pName, p->nObjsAlloc );
466  Wlc_NtkForEachCi( p, pObj, i )
467  Wlc_ObjDup( pNew, p, Wlc_ObjId(p, pObj), vFanins );
468  Wlc_NtkForEachCo( p, pObj, i )
469  Wlc_NtkDupDfs_rec( pNew, p, Wlc_ObjId(p, pObj), vFanins );
470  Wlc_NtkForEachCo( p, pObj, i )
471  Wlc_ObjSetCo( pNew, Wlc_ObjCopyObj(pNew, p, pObj), pObj->fIsFi );
472  Vec_IntFree( vFanins );
473  return pNew;
474 }
#define Wlc_NtkForEachCo(p, pCo, i)
Definition: wlc.h:216
static int Wlc_ObjId(Wlc_Ntk_t *p, Wlc_Obj_t *pObj)
Definition: wlc.h:161
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int Wlc_ObjDup(Wlc_Ntk_t *pNew, Wlc_Ntk_t *p, int iObj, Vec_Int_t *vFanins)
Definition: wlcNtk.c:436
static void Wlc_NtkCleanCopy(Wlc_Ntk_t *p)
Definition: wlc.h:185
void Wlc_NtkDupDfs_rec(Wlc_Ntk_t *pNew, Wlc_Ntk_t *p, int iObj, Vec_Int_t *vFanins)
Definition: wlcNtk.c:446
#define Wlc_NtkForEachCi(p, pCi, i)
Definition: wlc.h:214
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
char * pName
Definition: wlc.h:117
static Wlc_Obj_t * Wlc_ObjCopyObj(Wlc_Ntk_t *pNew, Wlc_Ntk_t *p, Wlc_Obj_t *pObj)
Definition: wlc.h:189
int nObjsAlloc
Definition: wlc.h:128
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Wlc_Ntk_t * Wlc_NtkAlloc(char *pName, int nObjsAlloc)
FUNCTION DEFINITIONS ///.
Definition: wlcNtk.c:94
void Wlc_ObjSetCo(Wlc_Ntk_t *p, Wlc_Obj_t *pObj, int fFlopInput)
Definition: wlcNtk.c:130
void Wlc_NtkDupDfs_rec ( Wlc_Ntk_t pNew,
Wlc_Ntk_t p,
int  iObj,
Vec_Int_t vFanins 
)

Definition at line 446 of file wlcNtk.c.

447 {
448  Wlc_Obj_t * pObj;
449  int i, iFanin;
450  if ( Wlc_ObjCopy(p, iObj) )
451  return;
452  pObj = Wlc_NtkObj( p, iObj );
453  Wlc_ObjForEachFanin( pObj, iFanin, i )
454  Wlc_NtkDupDfs_rec( pNew, p, iFanin, vFanins );
455  Wlc_ObjDup( pNew, p, iObj, vFanins );
456 }
#define Wlc_ObjForEachFanin(pObj, iFanin, i)
Definition: wlc.h:221
int Wlc_ObjDup(Wlc_Ntk_t *pNew, Wlc_Ntk_t *p, int iObj, Vec_Int_t *vFanins)
Definition: wlcNtk.c:436
static Wlc_Obj_t * Wlc_NtkObj(Wlc_Ntk_t *p, int Id)
Definition: wlc.h:149
void Wlc_NtkDupDfs_rec(Wlc_Ntk_t *pNew, Wlc_Ntk_t *p, int iObj, Vec_Int_t *vFanins)
Definition: wlcNtk.c:446
static int Wlc_ObjCopy(Wlc_Ntk_t *p, int iObj)
Definition: wlc.h:188
void Wlc_NtkFree ( Wlc_Ntk_t p)

Definition at line 195 of file wlcNtk.c.

196 {
197  if ( p->pManName )
198  Abc_NamStop( p->pManName );
199  if ( p->pMemFanin )
200  Mem_FlexStop( p->pMemFanin, 0 );
201  if ( p->pMemTable )
202  Mem_FlexStop( p->pMemTable, 0 );
203  Vec_PtrFreeP( &p->vTables );
204  ABC_FREE( p->vPis.pArray );
205  ABC_FREE( p->vPos.pArray );
206  ABC_FREE( p->vCis.pArray );
207  ABC_FREE( p->vCos.pArray );
208  ABC_FREE( p->vFfs.pArray );
209  ABC_FREE( p->vTravIds.pArray );
210  ABC_FREE( p->vNameIds.pArray );
211  ABC_FREE( p->vCopies.pArray );
212  ABC_FREE( p->pObjs );
213  ABC_FREE( p->pName );
214  ABC_FREE( p );
215 }
Mem_Flex_t * pMemFanin
Definition: wlc.h:129
Mem_Flex_t * pMemTable
Definition: wlc.h:130
void Abc_NamStop(Abc_Nam_t *p)
Definition: utilNam.c:110
Vec_Int_t vCis
Definition: wlc.h:120
Vec_Ptr_t * vTables
Definition: wlc.h:131
Wlc_Obj_t * pObjs
Definition: wlc.h:126
Vec_Int_t vPis
Definition: wlc.h:118
char * pName
Definition: wlc.h:117
Vec_Int_t vCopies
Definition: wlc.h:138
void Mem_FlexStop(Mem_Flex_t *p, int fVerbose)
Definition: mem.c:343
Vec_Int_t vTravIds
Definition: wlc.h:137
Vec_Int_t vPos
Definition: wlc.h:119
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_PtrFreeP(Vec_Ptr_t **p)
Definition: vecPtr.h:240
Vec_Int_t vNameIds
Definition: wlc.h:134
Vec_Int_t vCos
Definition: wlc.h:121
Vec_Int_t vFfs
Definition: wlc.h:122
Abc_Nam_t * pManName
Definition: wlc.h:133
int Wlc_NtkMemUsage ( Wlc_Ntk_t p)

Definition at line 216 of file wlcNtk.c.

217 {
218  int Mem = sizeof(Wlc_Ntk_t);
219  Mem += 4 * p->vPis.nCap;
220  Mem += 4 * p->vPos.nCap;
221  Mem += 4 * p->vCis.nCap;
222  Mem += 4 * p->vCos.nCap;
223  Mem += 4 * p->vFfs.nCap;
224  Mem += sizeof(Wlc_Obj_t) * p->nObjsAlloc;
225  Mem += Abc_NamMemUsed(p->pManName);
226  Mem += Mem_FlexReadMemUsage(p->pMemFanin);
227  return Mem;
228 }
Mem_Flex_t * pMemFanin
Definition: wlc.h:129
Vec_Int_t vCis
Definition: wlc.h:120
Vec_Int_t vPis
Definition: wlc.h:118
int Abc_NamMemUsed(Abc_Nam_t *p)
Definition: utilNam.c:202
struct Wlc_Ntk_t_ Wlc_Ntk_t
Definition: wlc.h:114
int nObjsAlloc
Definition: wlc.h:128
Vec_Int_t vPos
Definition: wlc.h:119
struct Wlc_Obj_t_ Wlc_Obj_t
BASIC TYPES ///.
Definition: wlc.h:99
int Mem_FlexReadMemUsage(Mem_Flex_t *p)
Definition: mem.c:445
Vec_Int_t vCos
Definition: wlc.h:121
Vec_Int_t vFfs
Definition: wlc.h:122
Abc_Nam_t * pManName
Definition: wlc.h:133
void Wlc_NtkPrintDistrib ( Wlc_Ntk_t p,
int  fVerbose 
)

Definition at line 284 of file wlcNtk.c.

285 {
286  Wlc_Obj_t * pObj;
287  Vec_Ptr_t * vTypes, * vOccurs;
288  word Sign;
289  int i, k, s, s0, s1;
290  // allocate statistics arrays
291  vTypes = Vec_PtrStart( WLC_OBJ_NUMBER );
292  vOccurs = Vec_PtrStart( WLC_OBJ_NUMBER );
293  for ( i = 0; i < WLC_OBJ_NUMBER; i++ )
294  Vec_PtrWriteEntry( vTypes, i, Vec_WrdAlloc(16) );
295  for ( i = 0; i < WLC_OBJ_NUMBER; i++ )
296  Vec_PtrWriteEntry( vOccurs, i, Vec_WrdAlloc(16) );
297  // add nodes
298  Wlc_NtkForEachObj( p, pObj, i )
299  {
300 // char * pName = Wlc_ObjName(p, i);
301  if ( Wlc_ObjSign(pObj) > 0x1FFFFF )
302  printf( "Object %6d has range %d, which is reduced to %d in the statistics.\n",
303  i, Wlc_ObjRange(pObj), Wlc_ObjRange(pObj) & 0xFFFFF );
304  if ( pObj->Beg )
305  printf( "Object %6d has non-standard range %d=[%d:%d]\n", i, Wlc_ObjRange(pObj), pObj->End, pObj->Beg );
306  // 0-input types
307  if ( Wlc_ObjIsCi(pObj) || pObj->Type == WLC_OBJ_CONST || pObj->Type == WLC_OBJ_BIT_CONCAT )
308  Sign = Wlc_NtkPrintDistribMakeSign( Wlc_ObjSign(pObj), 0, 0 );
309  // 1-input types
310  else if ( pObj->Type == WLC_OBJ_BUF || pObj->Type == WLC_OBJ_BIT_SELECT || pObj->Type == WLC_OBJ_TABLE ||
311  pObj->Type == WLC_OBJ_BIT_ZEROPAD || pObj->Type == WLC_OBJ_BIT_SIGNEXT ||
312  pObj->Type == WLC_OBJ_BIT_NOT || pObj->Type == WLC_OBJ_LOGIC_NOT || pObj->Type == WLC_OBJ_ARI_MINUS )
314  // 2-input types (including MUX)
315  else if ( Wlc_ObjFaninNum(pObj) == 1 )
317  else
318  {
319  assert( Wlc_ObjFaninNum(pObj) >= 2 );
321  }
322  // add to storage
323  Wlc_NtkPrintDistribAddOne( vTypes, vOccurs, pObj->Type, Sign );
324  }
325  // print by occurrence
326  printf( "ID : name occurrence (occurrence)<output_range>=<input_range>.<input_range> ...\n" );
327  for ( i = 0; i < WLC_OBJ_NUMBER; i++ )
328  {
329  Vec_Wrd_t * vType = (Vec_Wrd_t *)Vec_PtrEntry( vTypes, i );
330  Vec_Wrd_t * vOccur = (Vec_Wrd_t *)Vec_PtrEntry( vOccurs, i );
331  if ( p->nObjs[i] == 0 )
332  continue;
333  printf( "%2d : %-8s %6d ", i, Wlc_Names[i], p->nObjs[i] );
334  // sort by occurence
335  Wlc_NtkPrintDistribSortOne( vTypes, vOccurs, i );
336  Vec_WrdForEachEntry( vType, Sign, k )
337  {
338  Wlc_NtkPrintDistribFromSign( Sign, &s, &s0, &s1 );
339  if ( ((k % 8) == 7 && s1) || ((k % 10) == 9 && !s1) )
340  printf( "\n " );
341  printf( "(%d)", (int)Vec_WrdEntry( vOccur, k ) );
342  printf( "%s%d", Abc_LitIsCompl(s)?"-":"", Abc_Lit2Var(s) );
343  if ( s0 )
344  printf( "=%s%d", Abc_LitIsCompl(s0)?"-":"", Abc_Lit2Var(s0) );
345  if ( s1 )
346  printf( ".%s%d", Abc_LitIsCompl(s1)?"-":"", Abc_Lit2Var(s1) );
347  printf( " " );
348  }
349  printf( "\n" );
350  }
351  Vec_VecFree( (Vec_Vec_t *)vTypes );
352  Vec_VecFree( (Vec_Vec_t *)vOccurs );
353 }
static void Wlc_NtkPrintDistribAddOne(Vec_Ptr_t *vTypes, Vec_Ptr_t *vOccurs, int Type, word Sign)
Definition: wlcNtk.c:262
static ABC_NAMESPACE_IMPL_START char * Wlc_Names[WLC_OBJ_NUMBER+1]
DECLARATIONS ///.
Definition: wlcNtk.c:32
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
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static word Wlc_NtkPrintDistribMakeSign(int s, int s0, int s1)
Definition: wlcNtk.c:254
int nObjs[WLC_OBJ_NUMBER]
Definition: wlc.h:123
static Wlc_Obj_t * Wlc_ObjFanin0(Wlc_Ntk_t *p, Wlc_Obj_t *pObj)
Definition: wlc.h:171
static int Wlc_ObjSign(Wlc_Obj_t *p)
Definition: wlc.h:180
static int Wlc_ObjRange(Wlc_Obj_t *p)
Definition: wlc.h:175
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
#define Vec_WrdForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecWrd.h:54
void Wlc_NtkPrintDistribSortOne(Vec_Ptr_t *vTypes, Vec_Ptr_t *vOccurs, int Type)
Definition: wlcNtk.c:276
unsigned Beg
Definition: wlc.h:109
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Wlc_ObjFaninNum(Wlc_Obj_t *p)
Definition: wlc.h:163
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
unsigned Type
Definition: wlc.h:102
static int Wlc_ObjIsCi(Wlc_Obj_t *p)
Definition: wlc.h:158
static char s1[largest_string]
Definition: set.c:514
#define Wlc_NtkForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition: wlc.h:206
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static Vec_Wrd_t * Vec_WrdAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecWrd.h:80
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
unsigned End
Definition: wlc.h:108
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static Wlc_Obj_t * Wlc_ObjFanin1(Wlc_Ntk_t *p, Wlc_Obj_t *pObj)
Definition: wlc.h:172
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42
static void Wlc_NtkPrintDistribFromSign(word sss, int *s, int *s0, int *s1)
Definition: wlcNtk.c:258
static void Wlc_NtkPrintDistribAddOne ( Vec_Ptr_t vTypes,
Vec_Ptr_t vOccurs,
int  Type,
word  Sign 
)
inlinestatic

Definition at line 262 of file wlcNtk.c.

263 {
264  Vec_Wrd_t * vType = (Vec_Wrd_t *)Vec_PtrEntry( vTypes, Type );
265  Vec_Wrd_t * vOccur = (Vec_Wrd_t *)Vec_PtrEntry( vOccurs, Type );
266  word Entry; int i;
267  Vec_WrdForEachEntry( vType, Entry, i )
268  if ( Entry == Sign )
269  {
270  Vec_WrdAddToEntry( vOccur, i, 1 );
271  return;
272  }
273  Vec_WrdPush( vType, Sign );
274  Vec_WrdPush( vOccur, 1 );
275 }
static void Vec_WrdPush(Vec_Wrd_t *p, word Entry)
Definition: vecWrd.h:618
#define Vec_WrdForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecWrd.h:54
static word Vec_WrdAddToEntry(Vec_Wrd_t *p, int i, word Addition)
Definition: vecWrd.h:435
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
if(last==0)
Definition: sparse_int.h:34
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42
static void Wlc_NtkPrintDistribFromSign ( word  sss,
int *  s,
int *  s0,
int *  s1 
)
inlinestatic

Definition at line 258 of file wlcNtk.c.

259 {
260  *s1 = (int)(sss >> 42); *s0 = (int)(sss >> 21) & 0x1FFFFF; *s = (int)sss & 0x1FFFFF;
261 }
static char s1[largest_string]
Definition: set.c:514
static word Wlc_NtkPrintDistribMakeSign ( int  s,
int  s0,
int  s1 
)
inlinestatic

Definition at line 254 of file wlcNtk.c.

255 {
256  return ((word)s1 << 42) | ((word)s0 << 21) | (word)s;
257 }
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static char s1[largest_string]
Definition: set.c:514
void Wlc_NtkPrintDistribSortOne ( Vec_Ptr_t vTypes,
Vec_Ptr_t vOccurs,
int  Type 
)

Definition at line 276 of file wlcNtk.c.

277 {
278  Vec_Wrd_t * vType = (Vec_Wrd_t *)Vec_PtrEntry( vTypes, Type );
279  Vec_Wrd_t * vOccur = (Vec_Wrd_t *)Vec_PtrEntry( vOccurs, Type );
280  Vec_WrdSelectSortCost2( Vec_WrdArray(vType), Vec_WrdSize(vType), Vec_WrdArray(vOccur) );
281  Vec_WrdReverseOrder( vType );
282  Vec_WrdReverseOrder( vOccur );
283 }
static void Vec_WrdSelectSortCost2(word *pArray, int nSize, word *pCosts)
Definition: wlcNtk.c:241
static void Vec_WrdReverseOrder(Vec_Wrd_t *p)
Definition: vecWrd.h:897
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static word * Vec_WrdArray(Vec_Wrd_t *p)
Definition: vecWrd.h:316
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42
void Wlc_NtkPrintNodes ( Wlc_Ntk_t p,
int  Type 
)

Definition at line 354 of file wlcNtk.c.

355 {
356  Wlc_Obj_t * pObj;
357  int i, Counter = 0;
358  printf( "Operation %s\n", Wlc_Names[Type] );
359  Wlc_NtkForEachObj( p, pObj, i )
360  {
361  if ( (int)pObj->Type != Type )
362  continue;
363  printf( "%8d :", Counter++ );
364  printf( "%8d : ", i );
365  printf( "%3d%s = ", Wlc_ObjRange(pObj), Wlc_ObjIsSigned(pObj) ? "s" : " " );
366  printf( "%3d%s %s ", Wlc_ObjRange(Wlc_ObjFanin0(p, pObj)), Wlc_ObjIsSigned(Wlc_ObjFanin0(p, pObj)) ? "s" : " ", Wlc_Names[Type] );
367  printf( "%3d%s ", Wlc_ObjRange(Wlc_ObjFanin1(p, pObj)), Wlc_ObjIsSigned(Wlc_ObjFanin1(p, pObj)) ? "s" : " " );
368  printf( " : " );
369  printf( "%-12s = ", Wlc_ObjName(p, i) );
370  printf( "%-12s %s ", Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)), Wlc_Names[Type] );
371  printf( "%-12s ", Wlc_ObjName(p, Wlc_ObjFaninId1(pObj)) );
372  printf( "\n" );
373  }
374 }
static ABC_NAMESPACE_IMPL_START char * Wlc_Names[WLC_OBJ_NUMBER+1]
DECLARATIONS ///.
Definition: wlcNtk.c:32
static int Wlc_ObjFaninId1(Wlc_Obj_t *p)
Definition: wlc.h:168
static int Wlc_ObjIsSigned(Wlc_Obj_t *p)
Definition: wlc.h:178
static Wlc_Obj_t * Wlc_ObjFanin0(Wlc_Ntk_t *p, Wlc_Obj_t *pObj)
Definition: wlc.h:171
static int Wlc_ObjRange(Wlc_Obj_t *p)
Definition: wlc.h:175
static int Wlc_ObjFaninId0(Wlc_Obj_t *p)
Definition: wlc.h:167
unsigned Type
Definition: wlc.h:102
static int Counter
#define Wlc_NtkForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition: wlc.h:206
char * Wlc_ObjName(Wlc_Ntk_t *p, int iObj)
Definition: wlcNtk.c:167
static Wlc_Obj_t * Wlc_ObjFanin1(Wlc_Ntk_t *p, Wlc_Obj_t *pObj)
Definition: wlc.h:172
void Wlc_NtkPrintStats ( Wlc_Ntk_t p,
int  fDistrib,
int  fVerbose 
)

Definition at line 375 of file wlcNtk.c.

376 {
377  int i;
378  printf( "%-20s : ", p->pName );
379  printf( "PI = %4d ", Wlc_NtkPiNum(p) );
380  printf( "PO = %4d ", Wlc_NtkPoNum(p) );
381  printf( "FF = %4d ", Wlc_NtkFfNum(p) );
382  printf( "Obj = %6d ", Wlc_NtkObjNum(p) );
383  printf( "Mem = %.3f MB", 1.0*Wlc_NtkMemUsage(p)/(1<<20) );
384  printf( "\n" );
385  if ( fDistrib )
386  {
387  Wlc_NtkPrintDistrib( p, fVerbose );
388  return;
389  }
390  if ( !fVerbose )
391  return;
392  printf( "Node type statistics:\n" );
393  for ( i = 1; i < WLC_OBJ_NUMBER; i++ )
394  {
395  if ( !p->nObjs[i] )
396  continue;
397  if ( p->nAnds[0] && p->nAnds[i] )
398  printf( "%2d : %-8s %6d %7.2f %%\n", i, Wlc_Names[i], p->nObjs[i], 100.0*p->nAnds[i]/p->nAnds[0] );
399  else
400  printf( "%2d : %-8s %6d\n", i, Wlc_Names[i], p->nObjs[i] );
401  }
402 }
static ABC_NAMESPACE_IMPL_START char * Wlc_Names[WLC_OBJ_NUMBER+1]
DECLARATIONS ///.
Definition: wlcNtk.c:32
static int Wlc_NtkObjNum(Wlc_Ntk_t *p)
Definition: wlc.h:141
int nObjs[WLC_OBJ_NUMBER]
Definition: wlc.h:123
static int Wlc_NtkFfNum(Wlc_Ntk_t *p)
Definition: wlc.h:147
static int Wlc_NtkPoNum(Wlc_Ntk_t *p)
Definition: wlc.h:144
int Wlc_NtkMemUsage(Wlc_Ntk_t *p)
Definition: wlcNtk.c:216
char * pName
Definition: wlc.h:117
int nAnds[WLC_OBJ_NUMBER]
Definition: wlc.h:124
void Wlc_NtkPrintDistrib(Wlc_Ntk_t *p, int fVerbose)
Definition: wlcNtk.c:284
static int Wlc_NtkPiNum(Wlc_Ntk_t *p)
Definition: wlc.h:143
void Wlc_NtkTransferNames ( Wlc_Ntk_t pNew,
Wlc_Ntk_t p 
)

Definition at line 475 of file wlcNtk.c.

476 {
477  int i;
478  assert( !Wlc_NtkHasCopy(pNew) && Wlc_NtkHasCopy(p) );
479  assert( !Wlc_NtkHasNameId(pNew) && Wlc_NtkHasNameId(p) );
480  assert( pNew->pManName == NULL && p->pManName != NULL );
481  Wlc_NtkCleanNameId( pNew );
482  for ( i = 0; i < p->nObjsAlloc; i++ )
483  if ( Wlc_ObjCopy(p, i) && i < Vec_IntSize(&p->vNameIds) && Wlc_ObjNameId(p, i) )
484  Wlc_ObjSetNameId( pNew, Wlc_ObjCopy(p, i), Wlc_ObjNameId(p, i) );
485  pNew->pManName = p->pManName;
486  p->pManName = NULL;
487  Vec_IntErase( &p->vNameIds );
488  // transfer table
489  pNew->pMemTable = p->pMemTable; p->pMemTable = NULL;
490  pNew->vTables = p->vTables; p->vTables = NULL;
491 }
Mem_Flex_t * pMemTable
Definition: wlc.h:130
Vec_Ptr_t * vTables
Definition: wlc.h:131
static void Vec_IntErase(Vec_Int_t *p)
Definition: vecInt.h:266
static void Wlc_NtkCleanNameId(Wlc_Ntk_t *p)
Definition: wlc.h:191
static int Wlc_NtkHasNameId(Wlc_Ntk_t *p)
Definition: wlc.h:192
static int Wlc_ObjNameId(Wlc_Ntk_t *p, int iObj)
Definition: wlc.h:194
static void Wlc_ObjSetNameId(Wlc_Ntk_t *p, int iObj, int i)
Definition: wlc.h:193
int nObjsAlloc
Definition: wlc.h:128
static int Wlc_ObjCopy(Wlc_Ntk_t *p, int iObj)
Definition: wlc.h:188
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Vec_Int_t vNameIds
Definition: wlc.h:134
#define assert(ex)
Definition: util_old.h:213
static int Wlc_NtkHasCopy(Wlc_Ntk_t *p)
Definition: wlc.h:186
Abc_Nam_t * pManName
Definition: wlc.h:133
void Wlc_ObjAddFanins ( Wlc_Ntk_t p,
Wlc_Obj_t pObj,
Vec_Int_t vFanins 
)

Definition at line 182 of file wlcNtk.c.

183 {
184  assert( pObj->nFanins == 0 );
185  pObj->nFanins = Vec_IntSize(vFanins);
186  if ( Wlc_ObjHasArray(pObj) )
187  pObj->pFanins[0] = (int *)Mem_FlexEntryFetch( p->pMemFanin, Vec_IntSize(vFanins) * sizeof(int) );
188  memcpy( Wlc_ObjFanins(pObj), Vec_IntArray(vFanins), sizeof(int) * Vec_IntSize(vFanins) );
189  // special treatment of CONST, SELECT and TABLE
190  if ( pObj->Type == WLC_OBJ_CONST )
191  pObj->nFanins = 0;
192  else if ( pObj->Type == WLC_OBJ_BIT_SELECT || pObj->Type == WLC_OBJ_TABLE )
193  pObj->nFanins = 1;
194 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
Mem_Flex_t * pMemFanin
Definition: wlc.h:129
unsigned nFanins
Definition: wlc.h:107
char * memcpy()
char * Mem_FlexEntryFetch(Mem_Flex_t *p, int nBytes)
Definition: mem.c:372
static int Wlc_ObjHasArray(Wlc_Obj_t *p)
Definition: wlc.h:164
unsigned Type
Definition: wlc.h:102
int * pFanins[1]
Definition: wlc.h:111
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int * Wlc_ObjFanins(Wlc_Obj_t *p)
Definition: wlc.h:165
#define assert(ex)
Definition: util_old.h:213
int Wlc_ObjAlloc ( Wlc_Ntk_t p,
int  Type,
int  Signed,
int  End,
int  Beg 
)

Definition at line 141 of file wlcNtk.c.

142 {
143  Wlc_Obj_t * pObj;
144  assert( Type != WLC_OBJ_PO && Type != WLC_OBJ_FI );
145  if ( p->iObj == p->nObjsAlloc )
146  {
147  p->pObjs = ABC_REALLOC( Wlc_Obj_t, p->pObjs, 2 * p->nObjsAlloc );
148  memset( p->pObjs + p->nObjsAlloc, 0, sizeof(Wlc_Obj_t) * p->nObjsAlloc );
149  p->nObjsAlloc *= 2;
150  }
151  pObj = Wlc_NtkObj( p, p->iObj );
152  pObj->Type = Type;
153  pObj->Signed = Signed;
154  pObj->End = End;
155  pObj->Beg = Beg;
156  if ( Wlc_ObjIsCi(pObj) )
157  Wlc_ObjSetCi( p, pObj );
158  p->nObjs[Type]++;
159  return p->iObj++;
160 }
char * memset()
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
static Wlc_Obj_t * Wlc_NtkObj(Wlc_Ntk_t *p, int Id)
Definition: wlc.h:149
Wlc_Obj_t * pObjs
Definition: wlc.h:126
int nObjs[WLC_OBJ_NUMBER]
Definition: wlc.h:123
int iObj
Definition: wlc.h:127
Definition: wlc.h:48
unsigned Beg
Definition: wlc.h:109
unsigned Type
Definition: wlc.h:102
static int Wlc_ObjIsCi(Wlc_Obj_t *p)
Definition: wlc.h:158
unsigned Signed
Definition: wlc.h:103
int nObjsAlloc
Definition: wlc.h:128
unsigned End
Definition: wlc.h:108
void Wlc_ObjSetCi(Wlc_Ntk_t *p, Wlc_Obj_t *pObj)
Definition: wlcNtk.c:110
Definition: wlc.h:46
#define assert(ex)
Definition: util_old.h:213
void Wlc_ObjCollectCopyFanins ( Wlc_Ntk_t p,
int  iObj,
Vec_Int_t vFanins 
)

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

Synopsis [Duplicates the network in a topological order.]

Description []

SideEffects []

SeeAlso []

Definition at line 415 of file wlcNtk.c.

416 {
417  int i, iFanin;
418  Wlc_Obj_t * pObj = Wlc_NtkObj( p, iObj );
419  Vec_IntClear( vFanins );
420  Wlc_ObjForEachFanin( pObj, iFanin, i )
421  Vec_IntPush( vFanins, Wlc_ObjCopy(p, iFanin) );
422  // special treatment of CONST and SELECT
423  if ( pObj->Type == WLC_OBJ_CONST )
424  {
425  int * pInts = Wlc_ObjConstValue( pObj );
426  int nInts = Abc_BitWordNum( Wlc_ObjRange(pObj) );
427  for ( i = 0; i < nInts; i++ )
428  Vec_IntPush( vFanins, pInts[i] );
429  }
430  else if ( pObj->Type == WLC_OBJ_BIT_SELECT || pObj->Type == WLC_OBJ_TABLE )
431  {
432  assert( Vec_IntSize(vFanins) == 1 );
433  Vec_IntPush( vFanins, pObj->Fanins[1] );
434  }
435 }
#define Wlc_ObjForEachFanin(pObj, iFanin, i)
Definition: wlc.h:221
static Wlc_Obj_t * Wlc_NtkObj(Wlc_Ntk_t *p, int Id)
Definition: wlc.h:149
static int Wlc_ObjRange(Wlc_Obj_t *p)
Definition: wlc.h:175
unsigned Type
Definition: wlc.h:102
if(last==0)
Definition: sparse_int.h:34
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int * Wlc_ObjConstValue(Wlc_Obj_t *p)
Definition: wlc.h:181
static int Wlc_ObjCopy(Wlc_Ntk_t *p, int iObj)
Definition: wlc.h:188
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_BitWordNum(int nBits)
Definition: abc_global.h:255
int Fanins[2]
Definition: wlc.h:110
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
int Wlc_ObjCreate ( Wlc_Ntk_t p,
int  Type,
int  Signed,
int  End,
int  Beg,
Vec_Int_t vFanins 
)

Definition at line 161 of file wlcNtk.c.

162 {
163  int iFaninNew = Wlc_ObjAlloc( p, Type, Signed, End, Beg );
164  Wlc_ObjAddFanins( p, Wlc_NtkObj(p, iFaninNew), vFanins );
165  return iFaninNew;
166 }
void Wlc_ObjAddFanins(Wlc_Ntk_t *p, Wlc_Obj_t *pObj, Vec_Int_t *vFanins)
Definition: wlcNtk.c:182
static Wlc_Obj_t * Wlc_NtkObj(Wlc_Ntk_t *p, int Id)
Definition: wlc.h:149
int Wlc_ObjAlloc(Wlc_Ntk_t *p, int Type, int Signed, int End, int Beg)
Definition: wlcNtk.c:141
int Wlc_ObjDup ( Wlc_Ntk_t pNew,
Wlc_Ntk_t p,
int  iObj,
Vec_Int_t vFanins 
)

Definition at line 436 of file wlcNtk.c.

437 {
438  Wlc_Obj_t * pObj = Wlc_NtkObj( p, iObj );
439  int iFaninNew = Wlc_ObjAlloc( pNew, pObj->Type, Wlc_ObjIsSigned(pObj), pObj->End, pObj->Beg );
440  Wlc_Obj_t * pObjNew = Wlc_NtkObj(pNew, iFaninNew);
441  Wlc_ObjCollectCopyFanins( p, iObj, vFanins );
442  Wlc_ObjAddFanins( pNew, pObjNew, vFanins );
443  Wlc_ObjSetCopy( p, iObj, iFaninNew );
444  return iFaninNew;
445 }
void Wlc_ObjCollectCopyFanins(Wlc_Ntk_t *p, int iObj, Vec_Int_t *vFanins)
Definition: wlcNtk.c:415
static int Wlc_ObjIsSigned(Wlc_Obj_t *p)
Definition: wlc.h:178
void Wlc_ObjAddFanins(Wlc_Ntk_t *p, Wlc_Obj_t *pObj, Vec_Int_t *vFanins)
Definition: wlcNtk.c:182
static Wlc_Obj_t * Wlc_NtkObj(Wlc_Ntk_t *p, int Id)
Definition: wlc.h:149
int Wlc_ObjAlloc(Wlc_Ntk_t *p, int Type, int Signed, int End, int Beg)
Definition: wlcNtk.c:141
unsigned Beg
Definition: wlc.h:109
static void Wlc_ObjSetCopy(Wlc_Ntk_t *p, int iObj, int i)
Definition: wlc.h:187
unsigned Type
Definition: wlc.h:102
unsigned End
Definition: wlc.h:108
char* Wlc_ObjName ( Wlc_Ntk_t p,
int  iObj 
)

Definition at line 167 of file wlcNtk.c.

168 {
169  static char Buffer[100];
170  if ( Wlc_NtkHasNameId(p) && Wlc_ObjNameId(p, iObj) )
171  return Abc_NamStr( p->pManName, Wlc_ObjNameId(p, iObj) );
172  sprintf( Buffer, "n%d", iObj );
173  return Buffer;
174 }
static int Wlc_NtkHasNameId(Wlc_Ntk_t *p)
Definition: wlc.h:192
static int Wlc_ObjNameId(Wlc_Ntk_t *p, int iObj)
Definition: wlc.h:194
char * sprintf()
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
Definition: utilNam.c:479
Abc_Nam_t * pManName
Definition: wlc.h:133
void Wlc_ObjSetCi ( Wlc_Ntk_t p,
Wlc_Obj_t pObj 
)

Definition at line 110 of file wlcNtk.c.

111 {
112  assert( Wlc_ObjIsCi(pObj) );
113  assert( Wlc_ObjFaninNum(pObj) == 0 );
114  if ( Wlc_NtkPiNum(p) == Wlc_NtkCiNum(p) || pObj->Type != WLC_OBJ_PI )
115  {
116  pObj->Fanins[1] = Vec_IntSize(&p->vCis);
117  Vec_IntPush( &p->vCis, Wlc_ObjId(p, pObj) );
118  }
119  else // insert in the array of CI at the end of PIs
120  {
121  Wlc_Obj_t * pTemp; int i;
122  Vec_IntInsert( &p->vCis, Wlc_NtkPiNum(p), Wlc_ObjId(p, pObj) );
123  // other CI IDs are invalidated... naive fix!
124  Wlc_NtkForEachCi( p, pTemp, i )
125  pTemp->Fanins[1] = i;
126  }
127  if ( pObj->Type == WLC_OBJ_PI )
128  Vec_IntPush( &p->vPis, Wlc_ObjId(p, pObj) );
129 }
static int Wlc_ObjId(Wlc_Ntk_t *p, Wlc_Obj_t *pObj)
Definition: wlc.h:161
Vec_Int_t vCis
Definition: wlc.h:120
static void Vec_IntInsert(Vec_Int_t *p, int iHere, int Entry)
Definition: vecInt.h:975
static int Wlc_NtkCiNum(Wlc_Ntk_t *p)
Definition: wlc.h:145
#define Wlc_NtkForEachCi(p, pCi, i)
Definition: wlc.h:214
static int Wlc_ObjFaninNum(Wlc_Obj_t *p)
Definition: wlc.h:163
unsigned Type
Definition: wlc.h:102
if(last==0)
Definition: sparse_int.h:34
static int Wlc_ObjIsCi(Wlc_Obj_t *p)
Definition: wlc.h:158
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
Definition: wlc.h:45
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Wlc_NtkPiNum(Wlc_Ntk_t *p)
Definition: wlc.h:143
int Fanins[2]
Definition: wlc.h:110
#define assert(ex)
Definition: util_old.h:213
void Wlc_ObjSetCo ( Wlc_Ntk_t p,
Wlc_Obj_t pObj,
int  fFlopInput 
)

Definition at line 130 of file wlcNtk.c.

131 {
132 // pObj->Fanins[1] = Vec_IntSize(&p->vCos);
133  Vec_IntPush( &p->vCos, Wlc_ObjId(p, pObj) );
134  if ( !fFlopInput )
135  Vec_IntPush( &p->vPos, Wlc_ObjId(p, pObj) );
136  if ( fFlopInput )
137  pObj->fIsFi = 1;
138  else
139  pObj->fIsPo = 1;
140 }
static int Wlc_ObjId(Wlc_Ntk_t *p, Wlc_Obj_t *pObj)
Definition: wlc.h:161
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
unsigned fIsPo
Definition: wlc.h:105
Vec_Int_t vPos
Definition: wlc.h:119
Vec_Int_t vCos
Definition: wlc.h:121
unsigned fIsFi
Definition: wlc.h:106
void Wlc_ObjUpdateType ( Wlc_Ntk_t p,
Wlc_Obj_t pObj,
int  Type 
)

Definition at line 175 of file wlcNtk.c.

176 {
177  assert( pObj->Type == WLC_OBJ_NONE );
178  p->nObjs[pObj->Type]--;
179  pObj->Type = Type;
180  p->nObjs[pObj->Type]++;
181 }
int nObjs[WLC_OBJ_NUMBER]
Definition: wlc.h:123
unsigned Type
Definition: wlc.h:102
#define assert(ex)
Definition: util_old.h:213

Variable Documentation

ABC_NAMESPACE_IMPL_START char* Wlc_Names[WLC_OBJ_NUMBER+1]
static

DECLARATIONS ///.

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

FileName [wlcNtk.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Verilog parser.]

Synopsis [Network data-structure.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - August 22, 2014.]

Revision [

Id:
wlcNtk.c,v 1.00 2014/09/12 00:00:00 alanmi Exp

]

Definition at line 32 of file wlcNtk.c.