abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
covBuild.c File Reference
#include "cov.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Abc_Obj_t
Abc_NtkCovDeriveCube (Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, Min_Cube_t *pCube, Vec_Int_t *vSupp, int fCompl)
 DECLARATIONS ///. More...
 
Abc_Obj_tAbc_NtkCovDeriveNode_rec (Cov_Man_t *p, Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int Level)
 
Abc_Ntk_tAbc_NtkCovDerive (Cov_Man_t *p, Abc_Ntk_t *pNtk)
 FUNCTION DEFINITIONS ///. More...
 
Abc_Obj_tAbc_NtkCovDeriveInv (Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCompl)
 
Abc_Obj_tAbc_NtkCovDeriveCubeInv (Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, Min_Cube_t *pCube, Vec_Int_t *vSupp)
 
Abc_Obj_tAbc_NtkCovDeriveNodeInv_rec (Cov_Man_t *p, Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCompl)
 
Abc_Ntk_tAbc_NtkCovDeriveClean (Cov_Man_t *p, Abc_Ntk_t *pNtk)
 
Abc_Obj_tAbc_NtkCovDerive_rec (Cov_Man_t *p, Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj)
 
Abc_Ntk_tAbc_NtkCovDeriveRegular (Cov_Man_t *p, Abc_Ntk_t *pNtk)
 

Function Documentation

Abc_Ntk_t* Abc_NtkCovDerive ( Cov_Man_t p,
Abc_Ntk_t pNtk 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Derives the decomposed network.]

Description []

SideEffects []

SeeAlso []

Definition at line 183 of file covBuild.c.

184 {
185  Abc_Ntk_t * pNtkNew;
186  Abc_Obj_t * pObj;
187  int i;
188  assert( Abc_NtkIsStrash(pNtk) );
189  // perform strashing
190  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
191  // reconstruct the network
192  Abc_NtkForEachCo( pNtk, pObj, i )
193  {
194  Abc_NtkCovDeriveNode_rec( p, pNtkNew, Abc_ObjFanin0(pObj), 0 );
195 // printf( "*** CO %s : %d -> %d \n", Abc_ObjName(pObj), pObj->pCopy->Id, Abc_ObjFanin0(pObj)->pCopy->Id );
196  }
197  // add the COs
198  Abc_NtkFinalize( pNtk, pNtkNew );
199  Abc_NtkLogicMakeSimpleCos( pNtkNew, 1 );
200  // make sure everything is okay
201  if ( !Abc_NtkCheck( pNtkNew ) )
202  {
203  printf( "Abc_NtkCovDerive: The network check has failed.\n" );
204  Abc_NtkDelete( pNtkNew );
205  return NULL;
206  }
207  return pNtkNew;
208 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
ABC_DLL void Abc_NtkFinalize(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Definition: abcNtk.c:302
Abc_Obj_t * Abc_NtkCovDeriveNode_rec(Cov_Man_t *p, Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int Level)
Definition: covBuild.c:103
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition: abcUtil.c:1047
#define assert(ex)
Definition: util_old.h:213
Abc_Obj_t* Abc_NtkCovDerive_rec ( Cov_Man_t p,
Abc_Ntk_t pNtkNew,
Abc_Obj_t pObj 
)

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

Synopsis [Derives the decomposed network.]

Description []

SideEffects []

SeeAlso []

Definition at line 396 of file covBuild.c.

397 {
398  int fVerbose = 0;
399  Min_Cube_t * pCover, * pCovers[3];
400  Abc_Obj_t * pNodeNew, * pFanin;
401  Vec_Int_t * vSupp;
402  Vec_Str_t * vCover;
403  int i, Entry, nCubes, Type;
404  // skip if already computed
405  if ( pObj->pCopy )
406  return pObj->pCopy;
407  assert( Abc_ObjIsNode(pObj) );
408  // get the support and the cover
409  vSupp = Abc_ObjGetSupp( pObj );
410  assert( vSupp );
411  // choose the cover to implement
412  pCovers[0] = Abc_ObjGetCover( pObj, 0 );
413  pCovers[1] = Abc_ObjGetCover( pObj, 1 );
414  pCovers[2] = Abc_ObjGetCover2( pObj );
415  // use positive polarity
416  if ( pCovers[0]
417  && (!pCovers[1] || Min_CoverCountCubes(pCovers[0]) <= Min_CoverCountCubes(pCovers[1]))
418  && (!pCovers[2] || Min_CoverCountCubes(pCovers[0]) <= Min_CoverCountCubes(pCovers[2])) )
419  {
420  pCover = pCovers[0];
421  Type = '1';
422  }
423  else
424  // use negative polarity
425  if ( pCovers[1]
426  && (!pCovers[0] || Min_CoverCountCubes(pCovers[1]) <= Min_CoverCountCubes(pCovers[0]))
427  && (!pCovers[2] || Min_CoverCountCubes(pCovers[1]) <= Min_CoverCountCubes(pCovers[2])) )
428  {
429  pCover = pCovers[1];
430  Type = '0';
431  }
432  else
433  // use XOR polarity
434  if ( pCovers[2]
435  && (!pCovers[0] || Min_CoverCountCubes(pCovers[2]) < Min_CoverCountCubes(pCovers[0]))
436  && (!pCovers[1] || Min_CoverCountCubes(pCovers[2]) < Min_CoverCountCubes(pCovers[1])) )
437  {
438  pCover = pCovers[2];
439  Type = 'x';
440  }
441  else
442  assert( 0 );
443  // print the support of this node
444  if ( fVerbose )
445  {
446  printf( "{ " );
447  Vec_IntForEachEntry( vSupp, Entry, i )
448  printf( "%d ", Entry );
449  printf( "} cubes = %d\n", Min_CoverCountCubes( pCover ) );
450  }
451  // process the fanins
452  Vec_IntForEachEntry( vSupp, Entry, i )
453  {
454  pFanin = Abc_NtkObj(pObj->pNtk, Entry);
455  Abc_NtkCovDerive_rec( p, pNtkNew, pFanin );
456  }
457  // for each cube, construct the node
458  nCubes = Min_CoverCountCubes( pCover );
459  if ( nCubes == 0 )
460  pNodeNew = Abc_NtkCreateNodeConst0(pNtkNew);
461  else if ( nCubes == 1 )
462  pNodeNew = Abc_NtkCovDeriveCube( pNtkNew, pObj, pCover, vSupp, Type == '0' );
463  else
464  {
465  // create the node
466  pNodeNew = Abc_NtkCreateNode( pNtkNew );
467  Vec_IntForEachEntry( vSupp, Entry, i )
468  {
469  pFanin = Abc_NtkObj(pObj->pNtk, Entry);
470  Abc_ObjAddFanin( pNodeNew, pFanin->pCopy );
471  }
472  // derive the function
473  vCover = Vec_StrAlloc( 100 );
474  Min_CoverCreate( vCover, pCover, (char)Type );
475  pNodeNew->pData = Abc_SopRegister((Mem_Flex_t *)pNtkNew->pManFunc, Vec_StrArray(vCover) );
476  Vec_StrFree( vCover );
477  }
478 
479 /*
480  printf( "Created node %d(%d) at level %d: ", pNodeNew->Id, pObj->Id, Level );
481  Vec_IntForEachEntry( vSupp, Entry, i )
482  {
483  pFanin = Abc_NtkObj(pObj->pNtk, Entry);
484  printf( "%d(%d) ", pFanin->pCopy->Id, pFanin->Id );
485  }
486  printf( "\n" );
487  Min_CoverWrite( stdout, pCover );
488 */
489  return pObj->pCopy = pNodeNew;
490 }
static Vec_Int_t * Abc_ObjGetSupp(Abc_Obj_t *pObj)
Definition: cov.h:74
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
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
void Min_CoverCreate(Vec_Str_t *vCover, Min_Cube_t *pCover, char Type)
Definition: covMinUtil.c:85
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
static Min_Cube_t * Abc_ObjGetCover2(Abc_Obj_t *pObj)
Definition: cov.h:77
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
void * pManFunc
Definition: abc.h:191
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, char *pName)
DECLARATIONS ///.
Definition: abcSop.c:56
Abc_Obj_t * pCopy
Definition: abc.h:148
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
static int Min_CoverCountCubes(Min_Cube_t *pCover)
Definition: covInt.h:274
ABC_NAMESPACE_IMPL_START Abc_Obj_t * Abc_NtkCovDeriveCube(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, Min_Cube_t *pCube, Vec_Int_t *vSupp, int fCompl)
DECLARATIONS ///.
Definition: covBuild.c:45
Abc_Ntk_t * pNtk
Definition: abc.h:130
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition: abcObj.c:604
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static Min_Cube_t * Abc_ObjGetCover(Abc_Obj_t *pObj, int Pol)
Definition: cov.h:80
Abc_Obj_t * Abc_NtkCovDerive_rec(Cov_Man_t *p, Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj)
Definition: covBuild.c:396
Abc_Ntk_t* Abc_NtkCovDeriveClean ( Cov_Man_t p,
Abc_Ntk_t pNtk 
)

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

Synopsis [Derives the decomposed network.]

Description [The resulting network contains only pure AND/OR/EXOR gates and inverters. This procedure is usedful to generate Verilog.]

SideEffects []

SeeAlso []

Definition at line 357 of file covBuild.c.

358 {
359  Abc_Ntk_t * pNtkNew;
360  Abc_Obj_t * pObj, * pNodeNew;
361  int i;
362  assert( Abc_NtkIsStrash(pNtk) );
363  // perform strashing
364  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
365  // reconstruct the network
366  Abc_NtkForEachCo( pNtk, pObj, i )
367  {
368  pNodeNew = Abc_NtkCovDeriveNodeInv_rec( p, pNtkNew, Abc_ObjFanin0(pObj), Abc_ObjFaninC0(pObj) );
369  Abc_ObjAddFanin( pObj->pCopy, pNodeNew );
370  }
371  // add the COs
372  Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
373  // make sure everything is okay
374  if ( !Abc_NtkCheck( pNtkNew ) )
375  {
376  printf( "Abc_NtkCovDeriveInv: The network check has failed.\n" );
377  Abc_NtkDelete( pNtkNew );
378  return NULL;
379  }
380  return pNtkNew;
381 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
Abc_Obj_t * Abc_NtkCovDeriveNodeInv_rec(Cov_Man_t *p, Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCompl)
Definition: covBuild.c:300
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
Abc_Obj_t * pCopy
Definition: abc.h:148
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition: abcUtil.c:1047
#define assert(ex)
Definition: util_old.h:213
ABC_NAMESPACE_IMPL_START Abc_Obj_t* Abc_NtkCovDeriveCube ( Abc_Ntk_t pNtkNew,
Abc_Obj_t pObj,
Min_Cube_t pCube,
Vec_Int_t vSupp,
int  fCompl 
)

DECLARATIONS ///.

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

FileName [covBuild.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Mapping into network of SOPs/ESOPs.]

Synopsis [Network construction procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Derives the decomposed network.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file covBuild.c.

46 {
47  Vec_Int_t * vLits;
48  Abc_Obj_t * pNodeNew, * pFanin;
49  int i, iFanin, Lit;
50  // create empty cube
51  if ( pCube->nLits == 0 )
52  {
53  if ( fCompl )
54  return Abc_NtkCreateNodeConst0(pNtkNew);
55  return Abc_NtkCreateNodeConst1(pNtkNew);
56  }
57  // get the literals of this cube
58  vLits = Vec_IntAlloc( 10 );
59  Min_CubeGetLits( pCube, vLits );
60  assert( pCube->nLits == (unsigned)vLits->nSize );
61  // create special case when there is only one literal
62  if ( pCube->nLits == 1 )
63  {
64  iFanin = Vec_IntEntry(vLits,0);
65  pFanin = Abc_NtkObj( pObj->pNtk, Vec_IntEntry(vSupp, iFanin) );
66  Lit = Min_CubeGetVar(pCube, iFanin);
67  assert( Lit == 1 || Lit == 2 );
68  Vec_IntFree( vLits );
69  if ( (Lit == 1) ^ fCompl )// negative
70  return Abc_NtkCreateNodeInv( pNtkNew, pFanin->pCopy );
71  return pFanin->pCopy;
72  }
73  assert( pCube->nLits > 1 );
74  // create the AND cube
75  pNodeNew = Abc_NtkCreateNode( pNtkNew );
76  for ( i = 0; i < vLits->nSize; i++ )
77  {
78  iFanin = Vec_IntEntry(vLits,i);
79  pFanin = Abc_NtkObj( pObj->pNtk, Vec_IntEntry(vSupp, iFanin) );
80  Lit = Min_CubeGetVar(pCube, iFanin);
81  assert( Lit == 1 || Lit == 2 );
82  Vec_IntWriteEntry( vLits, i, Lit==1 );
83  Abc_ObjAddFanin( pNodeNew, pFanin->pCopy );
84  }
85  pNodeNew->pData = Abc_SopCreateAnd( (Mem_Flex_t *)pNtkNew->pManFunc, vLits->nSize, vLits->pArray );
86  if ( fCompl )
87  Abc_SopComplement( (char *)pNodeNew->pData );
88  Vec_IntFree( vLits );
89  return pNodeNew;
90 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
ABC_DLL char * Abc_SopCreateAnd(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition: abcSop.c:162
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition: abcObj.c:633
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
void * pManFunc
Definition: abc.h:191
Abc_Obj_t * pCopy
Definition: abc.h:148
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:662
static int Min_CubeGetVar(Min_Cube_t *p, int Var)
Definition: covInt.h:86
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned nLits
Definition: covInt.h:59
static void Min_CubeGetLits(Min_Cube_t *pCube, Vec_Int_t *vLits)
Definition: covInt.h:249
Abc_Ntk_t * pNtk
Definition: abc.h:130
ABC_DLL void Abc_SopComplement(char *pSop)
Definition: abcSop.c:600
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition: abcObj.c:604
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Abc_Obj_t* Abc_NtkCovDeriveCubeInv ( Abc_Ntk_t pNtkNew,
Abc_Obj_t pObj,
Min_Cube_t pCube,
Vec_Int_t vSupp 
)

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

Synopsis [Derives the decomposed network.]

Description []

SideEffects []

SeeAlso []

Definition at line 245 of file covBuild.c.

246 {
247  Vec_Int_t * vLits;
248  Abc_Obj_t * pNodeNew, * pFanin;
249  int i, iFanin, Lit;
250  // create empty cube
251  if ( pCube->nLits == 0 )
252  return Abc_NtkCreateNodeConst1(pNtkNew);
253  // get the literals of this cube
254  vLits = Vec_IntAlloc( 10 );
255  Min_CubeGetLits( pCube, vLits );
256  assert( pCube->nLits == (unsigned)vLits->nSize );
257  // create special case when there is only one literal
258  if ( pCube->nLits == 1 )
259  {
260  iFanin = Vec_IntEntry(vLits,0);
261  pFanin = Abc_NtkObj( pObj->pNtk, Vec_IntEntry(vSupp, iFanin) );
262  Lit = Min_CubeGetVar(pCube, iFanin);
263  assert( Lit == 1 || Lit == 2 );
264  Vec_IntFree( vLits );
265 // if ( Lit == 1 )// negative
266 // return Abc_NtkCreateNodeInv( pNtkNew, pFanin->pCopy );
267 // return pFanin->pCopy;
268  return Abc_NtkCovDeriveInv( pNtkNew, pFanin, Lit==1 );
269  }
270  assert( pCube->nLits > 1 );
271  // create the AND cube
272  pNodeNew = Abc_NtkCreateNode( pNtkNew );
273  for ( i = 0; i < vLits->nSize; i++ )
274  {
275  iFanin = Vec_IntEntry(vLits,i);
276  pFanin = Abc_NtkObj( pObj->pNtk, Vec_IntEntry(vSupp, iFanin) );
277  Lit = Min_CubeGetVar(pCube, iFanin);
278  assert( Lit == 1 || Lit == 2 );
279  Vec_IntWriteEntry( vLits, i, Lit==1 );
280 // Abc_ObjAddFanin( pNodeNew, pFanin->pCopy );
281  Abc_ObjAddFanin( pNodeNew, Abc_NtkCovDeriveInv( pNtkNew, pFanin, Lit==1 ) );
282  }
283 // pNodeNew->pData = Abc_SopCreateAnd( (Mem_Flex_t *)pNtkNew->pManFunc, vLits->nSize, vLits->pArray );
284  pNodeNew->pData = Abc_SopCreateAnd( (Mem_Flex_t *)pNtkNew->pManFunc, vLits->nSize, NULL );
285  Vec_IntFree( vLits );
286  return pNodeNew;
287 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
ABC_DLL char * Abc_SopCreateAnd(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition: abcSop.c:162
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition: abcObj.c:633
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
Abc_Obj_t * Abc_NtkCovDeriveInv(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCompl)
Definition: covBuild.c:224
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
void * pManFunc
Definition: abc.h:191
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Min_CubeGetVar(Min_Cube_t *p, int Var)
Definition: covInt.h:86
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned nLits
Definition: covInt.h:59
static void Min_CubeGetLits(Min_Cube_t *pCube, Vec_Int_t *vLits)
Definition: covInt.h:249
Abc_Ntk_t * pNtk
Definition: abc.h:130
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Abc_Obj_t* Abc_NtkCovDeriveInv ( Abc_Ntk_t pNtkNew,
Abc_Obj_t pObj,
int  fCompl 
)

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

Synopsis [Derives the decomposed network.]

Description []

SideEffects []

SeeAlso []

Definition at line 224 of file covBuild.c.

225 {
226  assert( pObj->pCopy );
227  if ( !fCompl )
228  return pObj->pCopy;
229  if ( pObj->pCopy->pCopy == NULL )
230  pObj->pCopy->pCopy = Abc_NtkCreateNodeInv( pNtkNew, pObj->pCopy );
231  return pObj->pCopy->pCopy;
232  }
Abc_Obj_t * pCopy
Definition: abc.h:148
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:662
#define assert(ex)
Definition: util_old.h:213
Abc_Obj_t* Abc_NtkCovDeriveNode_rec ( Cov_Man_t p,
Abc_Ntk_t pNtkNew,
Abc_Obj_t pObj,
int  Level 
)

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

Synopsis [Derives the decomposed network.]

Description []

SideEffects []

SeeAlso []

Definition at line 103 of file covBuild.c.

104 {
105  Min_Cube_t * pCover, * pCube;
106  Abc_Obj_t * pFaninNew, * pNodeNew, * pFanin;
107  Vec_Int_t * vSupp;
108  int Entry, nCubes, i;
109 
110  if ( Abc_ObjIsCi(pObj) )
111  return pObj->pCopy;
112  assert( Abc_ObjIsNode(pObj) );
113  // skip if already computed
114  if ( pObj->pCopy )
115  return pObj->pCopy;
116 
117  // get the support and the cover
118  vSupp = Abc_ObjGetSupp( pObj );
119  pCover = Abc_ObjGetCover2( pObj );
120  assert( vSupp );
121 /*
122  if ( pCover && pCover->nVars - Min_CoverSuppVarNum(p->pManMin, pCover) > 0 )
123  {
124  printf( "%d\n ", pCover->nVars - Min_CoverSuppVarNum(p->pManMin, pCover) );
125  Min_CoverWrite( stdout, pCover );
126  }
127 */
128 /*
129  // print the support of this node
130  printf( "{ " );
131  Vec_IntForEachEntry( vSupp, Entry, i )
132  printf( "%d ", Entry );
133  printf( "} cubes = %d\n", Min_CoverCountCubes( pCover ) );
134 */
135  // process the fanins
136  Vec_IntForEachEntry( vSupp, Entry, i )
137  {
138  pFanin = Abc_NtkObj(pObj->pNtk, Entry);
139  Abc_NtkCovDeriveNode_rec( p, pNtkNew, pFanin, Level+1 );
140  }
141 
142  // for each cube, construct the node
143  nCubes = Min_CoverCountCubes( pCover );
144  if ( nCubes == 0 )
145  pNodeNew = Abc_NtkCreateNodeConst0(pNtkNew);
146  else if ( nCubes == 1 )
147  pNodeNew = Abc_NtkCovDeriveCube( pNtkNew, pObj, pCover, vSupp, 0 );
148  else
149  {
150  pNodeNew = Abc_NtkCreateNode( pNtkNew );
151  Min_CoverForEachCube( pCover, pCube )
152  {
153  pFaninNew = Abc_NtkCovDeriveCube( pNtkNew, pObj, pCube, vSupp, 0 );
154  Abc_ObjAddFanin( pNodeNew, pFaninNew );
155  }
156  pNodeNew->pData = Abc_SopCreateXorSpecial( (Mem_Flex_t *)pNtkNew->pManFunc, nCubes );
157  }
158 /*
159  printf( "Created node %d(%d) at level %d: ", pNodeNew->Id, pObj->Id, Level );
160  Vec_IntForEachEntry( vSupp, Entry, i )
161  {
162  pFanin = Abc_NtkObj(pObj->pNtk, Entry);
163  printf( "%d(%d) ", pFanin->pCopy->Id, pFanin->Id );
164  }
165  printf( "\n" );
166  Min_CoverWrite( stdout, pCover );
167 */
168  pObj->pCopy = pNodeNew;
169  return pNodeNew;
170 }
static Vec_Int_t * Abc_ObjGetSupp(Abc_Obj_t *pObj)
Definition: cov.h:74
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
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
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
static Min_Cube_t * Abc_ObjGetCover2(Abc_Obj_t *pObj)
Definition: cov.h:77
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
void * pManFunc
Definition: abc.h:191
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
Abc_Obj_t * pCopy
Definition: abc.h:148
static int Min_CoverCountCubes(Min_Cube_t *pCover)
Definition: covInt.h:274
ABC_NAMESPACE_IMPL_START Abc_Obj_t * Abc_NtkCovDeriveCube(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, Min_Cube_t *pCube, Vec_Int_t *vSupp, int fCompl)
DECLARATIONS ///.
Definition: covBuild.c:45
Abc_Obj_t * Abc_NtkCovDeriveNode_rec(Cov_Man_t *p, Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int Level)
Definition: covBuild.c:103
Abc_Ntk_t * pNtk
Definition: abc.h:130
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition: abcObj.c:604
#define Min_CoverForEachCube(pCover, pCube)
Definition: covInt.h:65
ABC_DLL char * Abc_SopCreateXorSpecial(Mem_Flex_t *pMan, int nVars)
Definition: abcSop.c:291
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
Abc_Obj_t* Abc_NtkCovDeriveNodeInv_rec ( Cov_Man_t p,
Abc_Ntk_t pNtkNew,
Abc_Obj_t pObj,
int  fCompl 
)

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

Synopsis [Derives the decomposed network.]

Description []

SideEffects []

SeeAlso []

Definition at line 300 of file covBuild.c.

301 {
302  Min_Cube_t * pCover, * pCube;
303  Abc_Obj_t * pFaninNew, * pNodeNew, * pFanin;
304  Vec_Int_t * vSupp;
305  int Entry, nCubes, i;
306 
307  // skip if already computed
308  if ( pObj->pCopy )
309  return Abc_NtkCovDeriveInv( pNtkNew, pObj, fCompl );
310  assert( Abc_ObjIsNode(pObj) );
311 
312  // get the support and the cover
313  vSupp = Abc_ObjGetSupp( pObj );
314  pCover = Abc_ObjGetCover2( pObj );
315  assert( vSupp );
316 
317  // process the fanins
318  Vec_IntForEachEntry( vSupp, Entry, i )
319  {
320  pFanin = Abc_NtkObj(pObj->pNtk, Entry);
321  Abc_NtkCovDeriveNodeInv_rec( p, pNtkNew, pFanin, 0 );
322  }
323 
324  // for each cube, construct the node
325  nCubes = Min_CoverCountCubes( pCover );
326  if ( nCubes == 0 )
327  pNodeNew = Abc_NtkCreateNodeConst0(pNtkNew);
328  else if ( nCubes == 1 )
329  pNodeNew = Abc_NtkCovDeriveCubeInv( pNtkNew, pObj, pCover, vSupp );
330  else
331  {
332  pNodeNew = Abc_NtkCreateNode( pNtkNew );
333  Min_CoverForEachCube( pCover, pCube )
334  {
335  pFaninNew = Abc_NtkCovDeriveCubeInv( pNtkNew, pObj, pCube, vSupp );
336  Abc_ObjAddFanin( pNodeNew, pFaninNew );
337  }
338  pNodeNew->pData = Abc_SopCreateXorSpecial( (Mem_Flex_t *)pNtkNew->pManFunc, nCubes );
339  }
340 
341  pObj->pCopy = pNodeNew;
342  return Abc_NtkCovDeriveInv( pNtkNew, pObj, fCompl );
343 }
Abc_Obj_t * Abc_NtkCovDeriveNodeInv_rec(Cov_Man_t *p, Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCompl)
Definition: covBuild.c:300
static Vec_Int_t * Abc_ObjGetSupp(Abc_Obj_t *pObj)
Definition: cov.h:74
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
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
static Min_Cube_t * Abc_ObjGetCover2(Abc_Obj_t *pObj)
Definition: cov.h:77
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
Abc_Obj_t * Abc_NtkCovDeriveInv(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCompl)
Definition: covBuild.c:224
void * pManFunc
Definition: abc.h:191
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
Abc_Obj_t * pCopy
Definition: abc.h:148
static int Min_CoverCountCubes(Min_Cube_t *pCover)
Definition: covInt.h:274
Abc_Obj_t * Abc_NtkCovDeriveCubeInv(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, Min_Cube_t *pCube, Vec_Int_t *vSupp)
Definition: covBuild.c:245
Abc_Ntk_t * pNtk
Definition: abc.h:130
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition: abcObj.c:604
#define Min_CoverForEachCube(pCover, pCube)
Definition: covInt.h:65
ABC_DLL char * Abc_SopCreateXorSpecial(Mem_Flex_t *pMan, int nVars)
Definition: abcSop.c:291
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
Abc_Ntk_t* Abc_NtkCovDeriveRegular ( Cov_Man_t p,
Abc_Ntk_t pNtk 
)

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

Synopsis [Derives the decomposed network.]

Description []

SideEffects []

SeeAlso []

Definition at line 503 of file covBuild.c.

504 {
505  Abc_Ntk_t * pNtkNew;
506  Abc_Obj_t * pObj, * pNodeNew;
507  int i;
508  assert( Abc_NtkIsStrash(pNtk) );
509  // perform strashing
510  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
511  // reconstruct the network
512  if ( Abc_ObjFanoutNum(Abc_AigConst1(pNtk)) > 0 )
513  Abc_AigConst1(pNtk)->pCopy = Abc_NtkCreateNodeConst1(pNtkNew);
514  Abc_NtkForEachCo( pNtk, pObj, i )
515  {
516  pNodeNew = Abc_NtkCovDerive_rec( p, pNtkNew, Abc_ObjFanin0(pObj) );
517  if ( Abc_ObjFaninC0(pObj) )
518  {
519  if ( pNodeNew->pData && Abc_ObjFanoutNum(Abc_ObjFanin0(pObj)) == 1 )
520  Abc_SopComplement( (char *)pNodeNew->pData );
521  else
522  pNodeNew = Abc_NtkCreateNodeInv( pNtkNew, pNodeNew );
523  }
524  Abc_ObjAddFanin( pObj->pCopy, pNodeNew );
525  }
526  // add the COs
527  Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
528  // make sure everything is okay
529  if ( !Abc_NtkCheck( pNtkNew ) )
530  {
531  printf( "Abc_NtkCovDerive: The network check has failed.\n" );
532  Abc_NtkDelete( pNtkNew );
533  return NULL;
534  }
535  return pNtkNew;
536 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition: abcObj.c:633
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
Abc_Obj_t * pCopy
Definition: abc.h:148
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:662
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition: abcUtil.c:1047
ABC_DLL void Abc_SopComplement(char *pSop)
Definition: abcSop.c:600
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
Abc_Obj_t * Abc_NtkCovDerive_rec(Cov_Man_t *p, Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj)
Definition: covBuild.c:396