abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcUtil.c File Reference
#include "abc.h"
#include "base/main/main.h"
#include "map/mio/mio.h"
#include "bool/dec/dec.h"
#include "misc/extra/extraBdd.h"
#include "opt/fxu/fxu.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void * Abc_NtkAttrFree (Abc_Ntk_t *pNtk, int Attr, int fFreeMan)
 DECLARATIONS ///. More...
 
void Abc_NtkOrderCisCos (Abc_Ntk_t *pNtk)
 
int Abc_NtkGetCubeNum (Abc_Ntk_t *pNtk)
 
int Abc_NtkGetCubePairNum (Abc_Ntk_t *pNtk)
 
int Abc_NtkGetLitNum (Abc_Ntk_t *pNtk)
 
int Abc_NtkGetLitFactNum (Abc_Ntk_t *pNtk)
 
int Abc_NtkGetMultiRefNum (Abc_Ntk_t *pNtk)
 
int Abc_NtkGetBddNodeNum (Abc_Ntk_t *pNtk)
 
int Abc_NtkGetAigNodeNum (Abc_Ntk_t *pNtk)
 
int Abc_NtkGetClauseNum (Abc_Ntk_t *pNtk)
 
double Abc_NtkGetMappedArea (Abc_Ntk_t *pNtk)
 
int Abc_NtkGetExorNum (Abc_Ntk_t *pNtk)
 
int Abc_NtkGetMuxNum (Abc_Ntk_t *pNtk)
 
int Abc_NtkGetBufNum (Abc_Ntk_t *pNtk)
 
int Abc_NtkGetChoiceNum (Abc_Ntk_t *pNtk)
 
int Abc_NtkGetFaninMax (Abc_Ntk_t *pNtk)
 
int Abc_NtkGetFanoutMax (Abc_Ntk_t *pNtk)
 
int Abc_NtkGetTotalFanins (Abc_Ntk_t *pNtk)
 
void Abc_NtkCleanCopy (Abc_Ntk_t *pNtk)
 
void Abc_NtkCleanCopy_rec (Abc_Ntk_t *pNtk)
 
void Abc_NtkCleanData (Abc_Ntk_t *pNtk)
 
void Abc_NtkFillTemp (Abc_Ntk_t *pNtk)
 
int Abc_NtkCountCopy (Abc_Ntk_t *pNtk)
 
Vec_Ptr_tAbc_NtkSaveCopy (Abc_Ntk_t *pNtk)
 
void Abc_NtkLoadCopy (Abc_Ntk_t *pNtk, Vec_Ptr_t *vCopies)
 
void Abc_NtkCleanNext (Abc_Ntk_t *pNtk)
 
void Abc_NtkCleanNext_rec (Abc_Ntk_t *pNtk)
 
void Abc_NtkCleanMarkA (Abc_Ntk_t *pNtk)
 
void Abc_NtkCleanMarkB (Abc_Ntk_t *pNtk)
 
void Abc_NtkCleanMarkC (Abc_Ntk_t *pNtk)
 
void Abc_NtkCleanMarkAB (Abc_Ntk_t *pNtk)
 
void Abc_NtkCleanMarkABC (Abc_Ntk_t *pNtk)
 
int Abc_NodeFindFanin (Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
 
Abc_Obj_tAbc_NodeFindCoFanout (Abc_Obj_t *pNode)
 
Abc_Obj_tAbc_NodeFindNonCoFanout (Abc_Obj_t *pNode)
 
Abc_Obj_tAbc_NodeHasUniqueCoFanout (Abc_Obj_t *pNode)
 
void Abc_NtkFixCoDriverProblem (Abc_Obj_t *pDriver, Abc_Obj_t *pNodeCo, int fDuplicate)
 
int Abc_NtkLogicHasSimpleCos (Abc_Ntk_t *pNtk)
 
int Abc_NtkLogicMakeSimpleCos2 (Abc_Ntk_t *pNtk, int fDuplicate)
 
void Abc_NtkLogicMakeSimpleCosTest (Abc_Ntk_t *pNtk, int fDuplicate)
 
int Abc_NtkLogicMakeSimpleCos (Abc_Ntk_t *pNtk, int fDuplicate)
 
void Abc_VecObjPushUniqueOrderByLevel (Vec_Ptr_t *p, Abc_Obj_t *pNode)
 
int Abc_NodeIsExorType (Abc_Obj_t *pNode)
 
int Abc_NodeIsMuxType (Abc_Obj_t *pNode)
 
int Abc_NtkCountMuxes (Abc_Ntk_t *pNtk)
 
int Abc_NodeIsMuxControlType (Abc_Obj_t *pNode)
 
Abc_Obj_tAbc_NodeRecognizeMux (Abc_Obj_t *pNode, Abc_Obj_t **ppNodeT, Abc_Obj_t **ppNodeE)
 
int Abc_NtkPrepareTwoNtks (FILE *pErr, Abc_Ntk_t *pNtk, char **argv, int argc, Abc_Ntk_t **ppNtk1, Abc_Ntk_t **ppNtk2, int *pfDelete1, int *pfDelete2)
 
void Abc_NodeCollectFanins (Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
 
void Abc_NodeCollectFanouts (Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tAbc_NtkCollectLatches (Abc_Ntk_t *pNtk)
 
int Abc_NodeCompareLevelsIncrease (Abc_Obj_t **pp1, Abc_Obj_t **pp2)
 
int Abc_NodeCompareLevelsDecrease (Abc_Obj_t **pp1, Abc_Obj_t **pp2)
 
Vec_Int_tAbc_NtkFanoutCounts (Abc_Ntk_t *pNtk)
 
Vec_Ptr_tAbc_NtkCollectObjects (Abc_Ntk_t *pNtk)
 
Vec_Int_tAbc_NtkGetCiIds (Abc_Ntk_t *pNtk)
 
void Abc_NtkReassignIds (Abc_Ntk_t *pNtk)
 
void Abc_NtkDetectMatching (Abc_Ntk_t *pNtk)
 
int Abc_ObjPointerCompare (void **pp1, void **pp2)
 
void Abc_NtkTransferCopy (Abc_Ntk_t *pNtk)
 
static int Abc_ObjCrossCutInc (Abc_Obj_t *pObj)
 
int Abc_NtkCrossCut_rec (Abc_Obj_t *pObj, int *pnCutSize, int *pnCutSizeMax)
 
int Abc_NtkCrossCut (Abc_Ntk_t *pNtk)
 
void Abc_NtkPrint256 ()
 
int Abc_NtkCompareConesCompare (int *pNum1, int *pNum2)
 
void Abc_NtkCompareCones (Abc_Ntk_t *pNtk)
 
void Abc_NtkCompareSupports (Abc_Ntk_t *pNtk)
 
void Abc_NtkInvertConstraints (Abc_Ntk_t *pNtk)
 
void Abc_NtkPrintCiLevels (Abc_Ntk_t *pNtk)
 
int Abc_NtkAddBuffsEval (Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
 
int Abc_NtkAddBuffsEval2 (Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
 
Abc_Obj_tAbc_NtkAddBuffsOne (Vec_Ptr_t *vBuffs, Abc_Obj_t *pFanin, int Level, int nLevelMax)
 
Abc_Ntk_tAbc_NtkAddBuffsInt (Abc_Ntk_t *pNtkInit, int fReverse, int nImprove, int fVerbose)
 
Abc_Ntk_tAbc_NtkAddBuffs (Abc_Ntk_t *pNtkInit, int fDirect, int fReverse, int nImprove, int fVerbose)
 
float Abc_NtkComputeDelay (Abc_Ntk_t *pNtk)
 
void Abc_NodeSopToCubes (Abc_Obj_t *pNodeOld, Abc_Ntk_t *pNtkNew)
 
Abc_Ntk_tAbc_NtkSopToCubes (Abc_Ntk_t *pNtk)
 
static int Abc_NtkTopoHasBeg (Abc_Obj_t *p)
 
static int Abc_NtkTopoHasEnd (Abc_Obj_t *p)
 
static void Abc_NtkTopoSetBeg (Abc_Obj_t *p)
 
static void Abc_NtkTopoSetEnd (Abc_Obj_t *p)
 
void Abc_NtkReverseTopoOrder_rec (Abc_Obj_t *pObj, int fThisIsPivot)
 
void Abc_NtkReverseTopoOrder (Abc_Ntk_t *p)
 
void Abc_NtkReverse_rec (Abc_Obj_t *pObj, Vec_Int_t *vVisited)
 
void Abc_NtkReverseTopoOrderTest (Abc_Ntk_t *p)
 
Abc_Ntk_tAbc_NtkFromPla (char **pPlas, int nInputs, int nOutputs)
 
void Abc_NtkFromPlaTest ()
 
Abc_Ntk_tAbc_NtkSplitSop (Abc_Ntk_t *pNtk, int nCubesMax, int fVerbose)
 
int Abc_NtkIsTopo (Abc_Ntk_t *pNtk)
 
void Abc_NtkTransferPhases (Abc_Ntk_t *pNtkNew, Abc_Ntk_t *pNtk)
 

Variables

static int * pSupps
 

Function Documentation

void Abc_NodeCollectFanins ( Abc_Obj_t pNode,
Vec_Ptr_t vNodes 
)

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

Synopsis [Returns 1 if it is an AIG with choice nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 1587 of file abcUtil.c.

1588 {
1589  Abc_Obj_t * pFanin;
1590  int i;
1591  Vec_PtrClear(vNodes);
1592  Abc_ObjForEachFanin( pNode, pFanin, i )
1593  Vec_PtrPush( vNodes, pFanin );
1594 }
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
void Abc_NodeCollectFanouts ( Abc_Obj_t pNode,
Vec_Ptr_t vNodes 
)

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

Synopsis [Returns 1 if it is an AIG with choice nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 1607 of file abcUtil.c.

1608 {
1609  Abc_Obj_t * pFanout;
1610  int i;
1611  Vec_PtrClear(vNodes);
1612  Abc_ObjForEachFanout( pNode, pFanout, i )
1613  Vec_PtrPush( vNodes, pFanout );
1614 }
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
int Abc_NodeCompareLevelsDecrease ( Abc_Obj_t **  pp1,
Abc_Obj_t **  pp2 
)

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

Synopsis [Procedure used for sorting the nodes in decreasing order of levels.]

Description []

SideEffects []

SeeAlso []

Definition at line 1675 of file abcUtil.c.

1676 {
1677  int Diff = Abc_ObjRegular(*pp1)->Level - Abc_ObjRegular(*pp2)->Level;
1678  if ( Diff > 0 )
1679  return -1;
1680  if ( Diff < 0 )
1681  return 1;
1682  Diff = Abc_ObjRegular(*pp1)->Id - Abc_ObjRegular(*pp2)->Id;
1683  if ( Diff > 0 )
1684  return -1;
1685  if ( Diff < 0 )
1686  return 1;
1687  return 0;
1688 }
unsigned Level
Definition: abc.h:142
if(last==0)
Definition: sparse_int.h:34
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
int Id
Definition: abc.h:132
int Abc_NodeCompareLevelsIncrease ( Abc_Obj_t **  pp1,
Abc_Obj_t **  pp2 
)

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

Synopsis [Procedure used for sorting the nodes in increasing order of levels.]

Description []

SideEffects []

SeeAlso []

Definition at line 1649 of file abcUtil.c.

1650 {
1651  int Diff = Abc_ObjRegular(*pp1)->Level - Abc_ObjRegular(*pp2)->Level;
1652  if ( Diff < 0 )
1653  return -1;
1654  if ( Diff > 0 )
1655  return 1;
1656  Diff = Abc_ObjRegular(*pp1)->Id - Abc_ObjRegular(*pp2)->Id;
1657  if ( Diff < 0 )
1658  return -1;
1659  if ( Diff > 0 )
1660  return 1;
1661  return 0;
1662 }
unsigned Level
Definition: abc.h:142
if(last==0)
Definition: sparse_int.h:34
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
int Id
Definition: abc.h:132
Abc_Obj_t* Abc_NodeFindCoFanout ( Abc_Obj_t pNode)

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

Synopsis [Checks if the internal node has CO fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 779 of file abcUtil.c.

780 {
781  Abc_Obj_t * pFanout;
782  int i;
783  Abc_ObjForEachFanout( pNode, pFanout, i )
784  if ( Abc_ObjIsCo(pFanout) )
785  return pFanout;
786  return NULL;
787 }
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
if(last==0)
Definition: sparse_int.h:34
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
int Abc_NodeFindFanin ( Abc_Obj_t pNode,
Abc_Obj_t pFanin 
)

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

Synopsis [Returns the index of the given fanin.]

Description []

SideEffects []

SeeAlso []

Definition at line 758 of file abcUtil.c.

759 {
760  Abc_Obj_t * pThis;
761  int i;
762  Abc_ObjForEachFanin( pNode, pThis, i )
763  if ( pThis == pFanin )
764  return i;
765  return -1;
766 }
if(last==0)
Definition: sparse_int.h:34
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
Abc_Obj_t* Abc_NodeFindNonCoFanout ( Abc_Obj_t pNode)

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

Synopsis [Checks if the internal node has CO fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 800 of file abcUtil.c.

801 {
802  Abc_Obj_t * pFanout;
803  int i;
804  Abc_ObjForEachFanout( pNode, pFanout, i )
805  if ( !Abc_ObjIsCo(pFanout) )
806  return pFanout;
807  return NULL;
808 }
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
if(last==0)
Definition: sparse_int.h:34
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
Abc_Obj_t* Abc_NodeHasUniqueCoFanout ( Abc_Obj_t pNode)

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

Synopsis [Checks if the internal node has CO drivers with the same name.]

Description [Checks if the internal node can borrow its name from CO fanouts. This is possible if all COs with non-complemented fanin edge pointing to this node have the same name.]

SideEffects []

SeeAlso []

Definition at line 823 of file abcUtil.c.

824 {
825  Abc_Obj_t * pFanout, * pFanoutCo;
826  int i;
827  pFanoutCo = NULL;
828  Abc_ObjForEachFanout( pNode, pFanout, i )
829  {
830  if ( !Abc_ObjIsCo(pFanout) )
831  continue;
832  if ( Abc_ObjFaninC0(pFanout) )
833  continue;
834  if ( pFanoutCo == NULL )
835  {
836  assert( Abc_ObjFaninNum(pFanout) == 1 );
837  assert( Abc_ObjFanin0(pFanout) == pNode );
838  pFanoutCo = pFanout;
839  continue;
840  }
841  if ( strcmp( Abc_ObjName(pFanoutCo), Abc_ObjName(pFanout) ) ) // they have diff names
842  return NULL;
843  }
844  return pFanoutCo;
845 }
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
int strcmp()
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
#define assert(ex)
Definition: util_old.h:213
int Abc_NodeIsExorType ( Abc_Obj_t pNode)

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

Synopsis [Returns 1 if the node is the root of EXOR/NEXOR.]

Description []

SideEffects []

SeeAlso []

Definition at line 1259 of file abcUtil.c.

1260 {
1261  Abc_Obj_t * pNode0, * pNode1;
1262  // check that the node is regular
1263  assert( !Abc_ObjIsComplement(pNode) );
1264  // if the node is not AND, this is not EXOR
1265  if ( !Abc_AigNodeIsAnd(pNode) )
1266  return 0;
1267  // if the children are not complemented, this is not EXOR
1268  if ( !Abc_ObjFaninC0(pNode) || !Abc_ObjFaninC1(pNode) )
1269  return 0;
1270  // get children
1271  pNode0 = Abc_ObjFanin0(pNode);
1272  pNode1 = Abc_ObjFanin1(pNode);
1273  // if the children are not ANDs, this is not EXOR
1274  if ( Abc_ObjFaninNum(pNode0) != 2 || Abc_ObjFaninNum(pNode1) != 2 )
1275  return 0;
1276  // this is AIG, which means the fanins should be ordered
1277  assert( Abc_ObjFaninId0(pNode0) != Abc_ObjFaninId1(pNode1) ||
1278  Abc_ObjFaninId0(pNode1) != Abc_ObjFaninId1(pNode0) );
1279  // if grand children are not the same, this is not EXOR
1280  if ( Abc_ObjFaninId0(pNode0) != Abc_ObjFaninId0(pNode1) ||
1281  Abc_ObjFaninId1(pNode0) != Abc_ObjFaninId1(pNode1) )
1282  return 0;
1283  // finally, if the complemented edges are matched, this is not EXOR
1284  if ( Abc_ObjFaninC0(pNode0) == Abc_ObjFaninC0(pNode1) ||
1285  Abc_ObjFaninC1(pNode0) == Abc_ObjFaninC1(pNode1) )
1286  return 0;
1287  return 1;
1288 }
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_ObjFaninId0(Abc_Obj_t *pObj)
Definition: abc.h:367
static int Abc_AigNodeIsAnd(Abc_Obj_t *pNode)
Definition: abc.h:397
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjFaninId1(Abc_Obj_t *pObj)
Definition: abc.h:368
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
int Abc_NodeIsMuxControlType ( Abc_Obj_t pNode)

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

Synopsis [Returns 1 if the node is the control type of the MUX.]

Description []

SideEffects []

SeeAlso []

Definition at line 1357 of file abcUtil.c.

1358 {
1359  Abc_Obj_t * pNode0, * pNode1;
1360  // check that the node is regular
1361  assert( !Abc_ObjIsComplement(pNode) );
1362  // skip the node that do not have two fanouts
1363  if ( Abc_ObjFanoutNum(pNode) != 2 )
1364  return 0;
1365  // get the fanouts
1366  pNode0 = Abc_ObjFanout( pNode, 0 );
1367  pNode1 = Abc_ObjFanout( pNode, 1 );
1368  // if they have more than one fanout, we are not interested
1369  if ( Abc_ObjFanoutNum(pNode0) != 1 || Abc_ObjFanoutNum(pNode1) != 1 )
1370  return 0;
1371  // if the fanouts have the same fanout, this is MUX or EXOR (or a redundant gate (CA)(CB))
1372  return Abc_ObjFanout0(pNode0) == Abc_ObjFanout0(pNode1);
1373 }
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
#define assert(ex)
Definition: util_old.h:213
static Abc_Obj_t * Abc_ObjFanout(Abc_Obj_t *pObj, int i)
Definition: abc.h:370
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
int Abc_NodeIsMuxType ( Abc_Obj_t pNode)

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

Synopsis [Returns 1 if the node is the root of MUX or EXOR/NEXOR.]

Description []

SideEffects []

SeeAlso []

Definition at line 1301 of file abcUtil.c.

1302 {
1303  Abc_Obj_t * pNode0, * pNode1;
1304  // check that the node is regular
1305  assert( !Abc_ObjIsComplement(pNode) );
1306  // if the node is not AND, this is not MUX
1307  if ( !Abc_AigNodeIsAnd(pNode) )
1308  return 0;
1309  // if the children are not complemented, this is not MUX
1310  if ( !Abc_ObjFaninC0(pNode) || !Abc_ObjFaninC1(pNode) )
1311  return 0;
1312  // get children
1313  pNode0 = Abc_ObjFanin0(pNode);
1314  pNode1 = Abc_ObjFanin1(pNode);
1315  // if the children are not ANDs, this is not MUX
1316  if ( !Abc_AigNodeIsAnd(pNode0) || !Abc_AigNodeIsAnd(pNode1) )
1317  return 0;
1318  // otherwise the node is MUX iff it has a pair of equal grandchildren with opposite polarity
1319  return (Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC0(pNode1))) ||
1320  (Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC1(pNode1))) ||
1321  (Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC0(pNode1))) ||
1322  (Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC1(pNode1)));
1323 }
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_ObjFaninId0(Abc_Obj_t *pObj)
Definition: abc.h:367
static int Abc_AigNodeIsAnd(Abc_Obj_t *pNode)
Definition: abc.h:397
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjFaninId1(Abc_Obj_t *pObj)
Definition: abc.h:368
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
Abc_Obj_t* Abc_NodeRecognizeMux ( Abc_Obj_t pNode,
Abc_Obj_t **  ppNodeT,
Abc_Obj_t **  ppNodeE 
)

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

Synopsis [Recognizes what nodes are control and data inputs of a MUX.]

Description [If the node is a MUX, returns the control variable C. Assigns nodes T and E to be the then and else variables of the MUX. Node C is never complemented. Nodes T and E can be complemented. This function also recognizes EXOR/NEXOR gates as MUXes.]

SideEffects []

SeeAlso []

Definition at line 1389 of file abcUtil.c.

1390 {
1391  Abc_Obj_t * pNode0, * pNode1;
1392  assert( !Abc_ObjIsComplement(pNode) );
1393  assert( Abc_NodeIsMuxType(pNode) );
1394  // get children
1395  pNode0 = Abc_ObjFanin0(pNode);
1396  pNode1 = Abc_ObjFanin1(pNode);
1397  // find the control variable
1398 // if ( pNode1->p1 == Fraig_Not(pNode2->p1) )
1399  if ( Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC0(pNode1)) )
1400  {
1401 // if ( Fraig_IsComplement(pNode1->p1) )
1402  if ( Abc_ObjFaninC0(pNode0) )
1403  { // pNode2->p1 is positive phase of C
1404  *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode1));//pNode2->p2);
1405  *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode0));//pNode1->p2);
1406  return Abc_ObjChild0(pNode1);//pNode2->p1;
1407  }
1408  else
1409  { // pNode1->p1 is positive phase of C
1410  *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode0));//pNode1->p2);
1411  *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode1));//pNode2->p2);
1412  return Abc_ObjChild0(pNode0);//pNode1->p1;
1413  }
1414  }
1415 // else if ( pNode1->p1 == Fraig_Not(pNode2->p2) )
1416  else if ( Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC1(pNode1)) )
1417  {
1418 // if ( Fraig_IsComplement(pNode1->p1) )
1419  if ( Abc_ObjFaninC0(pNode0) )
1420  { // pNode2->p2 is positive phase of C
1421  *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode1));//pNode2->p1);
1422  *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode0));//pNode1->p2);
1423  return Abc_ObjChild1(pNode1);//pNode2->p2;
1424  }
1425  else
1426  { // pNode1->p1 is positive phase of C
1427  *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode0));//pNode1->p2);
1428  *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode1));//pNode2->p1);
1429  return Abc_ObjChild0(pNode0);//pNode1->p1;
1430  }
1431  }
1432 // else if ( pNode1->p2 == Fraig_Not(pNode2->p1) )
1433  else if ( Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC0(pNode1)) )
1434  {
1435 // if ( Fraig_IsComplement(pNode1->p2) )
1436  if ( Abc_ObjFaninC1(pNode0) )
1437  { // pNode2->p1 is positive phase of C
1438  *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode1));//pNode2->p2);
1439  *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode0));//pNode1->p1);
1440  return Abc_ObjChild0(pNode1);//pNode2->p1;
1441  }
1442  else
1443  { // pNode1->p2 is positive phase of C
1444  *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode0));//pNode1->p1);
1445  *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode1));//pNode2->p2);
1446  return Abc_ObjChild1(pNode0);//pNode1->p2;
1447  }
1448  }
1449 // else if ( pNode1->p2 == Fraig_Not(pNode2->p2) )
1450  else if ( Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC1(pNode1)) )
1451  {
1452 // if ( Fraig_IsComplement(pNode1->p2) )
1453  if ( Abc_ObjFaninC1(pNode0) )
1454  { // pNode2->p2 is positive phase of C
1455  *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode1));//pNode2->p1);
1456  *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode0));//pNode1->p1);
1457  return Abc_ObjChild1(pNode1);//pNode2->p2;
1458  }
1459  else
1460  { // pNode1->p2 is positive phase of C
1461  *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode0));//pNode1->p1);
1462  *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode1));//pNode2->p1);
1463  return Abc_ObjChild1(pNode0);//pNode1->p2;
1464  }
1465  }
1466  assert( 0 ); // this is not MUX
1467  return NULL;
1468 }
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
int Abc_NodeIsMuxType(Abc_Obj_t *pNode)
Definition: abcUtil.c:1301
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_ObjFaninId0(Abc_Obj_t *pObj)
Definition: abc.h:367
static Abc_Obj_t * Abc_ObjChild0(Abc_Obj_t *pObj)
Definition: abc.h:383
#define assert(ex)
Definition: util_old.h:213
static Abc_Obj_t * Abc_ObjNot(Abc_Obj_t *p)
Definition: abc.h:324
static int Abc_ObjFaninId1(Abc_Obj_t *pObj)
Definition: abc.h:368
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
static Abc_Obj_t * Abc_ObjChild1(Abc_Obj_t *pObj)
Definition: abc.h:384
void Abc_NodeSopToCubes ( Abc_Obj_t pNodeOld,
Abc_Ntk_t pNtkNew 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 2492 of file abcUtil.c.

2493 {
2494  Abc_Obj_t * pNodeOr, * pNodeNew, * pFanin;
2495  char * pCube, * pSop = (char *)pNodeOld->pData;
2496  int v, Value, nVars = Abc_ObjFaninNum(pNodeOld), nFanins;
2497  // create the root node
2498  if ( Abc_SopGetCubeNum(pSop) < 2 )
2499  {
2500  pNodeNew = Abc_NtkDupObj( pNtkNew, pNodeOld, 0 );
2501  Abc_ObjForEachFanin( pNodeOld, pFanin, v )
2502  Abc_ObjAddFanin( pNodeNew, pFanin->pCopy );
2503  assert( pNodeOld->pCopy == pNodeNew );
2504  return;
2505  }
2506  // add the OR gate
2507  pNodeOr = Abc_NtkCreateNode( pNtkNew );
2508  pNodeOr->pData = Abc_SopCreateOr( (Mem_Flex_t *)pNtkNew->pManFunc, Abc_SopGetCubeNum(pSop), NULL );
2509  // check the logic function of the node
2510  Abc_SopForEachCube( pSop, nVars, pCube )
2511  {
2512  nFanins = 0;
2513  Abc_CubeForEachVar( pCube, Value, v )
2514  if ( Value == '0' || Value == '1' )
2515  nFanins++;
2516  assert( nFanins > 0 );
2517  // create node
2518  pNodeNew = Abc_NtkCreateNode( pNtkNew );
2519  pNodeNew->pData = Abc_SopCreateAnd( (Mem_Flex_t *)pNtkNew->pManFunc, nFanins, NULL );
2520  nFanins = 0;
2521  Abc_CubeForEachVar( pCube, Value, v )
2522  {
2523  if ( Value != '0' && Value != '1' )
2524  continue;
2525  Abc_ObjAddFanin( pNodeNew, Abc_ObjFanin(pNodeOld, v)->pCopy );
2526  if ( Value == '0' )
2527  Abc_SopComplementVar( (char *)pNodeNew->pData, nFanins );
2528  nFanins++;
2529  }
2530  Abc_ObjAddFanin( pNodeOr, pNodeNew );
2531  }
2532  // check the complement
2533  if ( Abc_SopIsComplement(pSop) )
2534  Abc_SopComplement( (char *)pNodeOr->pData );
2535  // mark the old node with the new one
2536  assert( pNodeOld->pCopy == NULL );
2537  pNodeOld->pCopy = pNodeOr;
2538 }
#define Abc_SopForEachCube(pSop, nFanins, pCube)
Definition: abc.h:531
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
Definition: abcSop.c:489
ABC_DLL char * Abc_SopCreateAnd(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition: abcSop.c:162
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition: abcObj.c:337
#define Abc_CubeForEachVar(pCube, Value, i)
Definition: abc.h:529
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL void Abc_SopComplementVar(char *pSop, int iVar)
Definition: abcSop.c:630
Abc_Obj_t * pCopy
Definition: abc.h:148
if(last==0)
Definition: sparse_int.h:34
ABC_DLL void Abc_SopComplement(char *pSop)
Definition: abcSop.c:600
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
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 Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
Definition: abc.h:372
ABC_DLL int Abc_SopIsComplement(char *pSop)
Definition: abcSop.c:655
ABC_DLL char * Abc_SopCreateOr(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition: abcSop.c:206
Abc_Ntk_t* Abc_NtkAddBuffs ( Abc_Ntk_t pNtkInit,
int  fDirect,
int  fReverse,
int  nImprove,
int  fVerbose 
)

Definition at line 2416 of file abcUtil.c.

2417 {
2418  Abc_Ntk_t * pNtkD, * pNtkR;
2419  if ( fDirect )
2420  return Abc_NtkAddBuffsInt( pNtkInit, 0, nImprove, fVerbose );
2421  if ( fReverse )
2422  return Abc_NtkAddBuffsInt( pNtkInit, 1, nImprove, fVerbose );
2423  pNtkD = Abc_NtkAddBuffsInt( pNtkInit, 0, nImprove, fVerbose );
2424  pNtkR = Abc_NtkAddBuffsInt( pNtkInit, 1, nImprove, fVerbose );
2425  if ( Abc_NtkNodeNum(pNtkD) < Abc_NtkNodeNum(pNtkR) )
2426  {
2427  Abc_NtkDelete( pNtkR );
2428  return pNtkD;
2429  }
2430  else
2431  {
2432  Abc_NtkDelete( pNtkD );
2433  return pNtkR;
2434  }
2435 }
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
Abc_Ntk_t * Abc_NtkAddBuffsInt(Abc_Ntk_t *pNtkInit, int fReverse, int nImprove, int fVerbose)
Definition: abcUtil.c:2306
int Abc_NtkAddBuffsEval ( Abc_Obj_t pNode,
Abc_Obj_t pFanin 
)

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

Synopsis [Returns 1 if all other fanouts of pFanin are below pNode.]

Description []

SideEffects []

SeeAlso []

Definition at line 2249 of file abcUtil.c.

2250 {
2251  Abc_Obj_t * pFanout;
2252  int i;
2253  Abc_ObjForEachFanout( pFanin, pFanout, i )
2254  if ( pFanout != pNode && pFanout->Level >= pNode->Level )
2255  return 0;
2256  return 1;
2257 }
if(last==0)
Definition: sparse_int.h:34
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
int Abc_NtkAddBuffsEval2 ( Abc_Obj_t pNode,
Abc_Obj_t pFanin 
)

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

Synopsis [Returns 1 if there exist a fanout of pFanin higher than pNode.]

Description []

SideEffects []

SeeAlso []

Definition at line 2269 of file abcUtil.c.

2270 {
2271  Abc_Obj_t * pFanout;
2272  int i;
2273  Abc_ObjForEachFanout( pFanin, pFanout, i )
2274  if ( pFanout != pNode && pFanout->Level > pNode->Level )
2275  return 1;
2276  return 0;
2277 }
if(last==0)
Definition: sparse_int.h:34
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
Abc_Ntk_t* Abc_NtkAddBuffsInt ( Abc_Ntk_t pNtkInit,
int  fReverse,
int  nImprove,
int  fVerbose 
)

Definition at line 2306 of file abcUtil.c.

2307 {
2308  Vec_Ptr_t * vBuffs;
2309  Abc_Ntk_t * pNtk = Abc_NtkDup( pNtkInit );
2310  Abc_Obj_t * pObj, * pFanin, * pBuffer;
2311  int i, k, Iter, nLevelMax = Abc_NtkLevel( pNtk );
2312  Abc_NtkForEachCo( pNtk, pObj, i )
2313  pObj->Level = nLevelMax + 1;
2314  if ( fReverse )
2315  {
2316  Vec_Ptr_t * vNodes = Abc_NtkDfs( pNtk, 1 );
2317  assert( nLevelMax < (1<<18) );
2318  Vec_PtrForEachEntryReverse( Abc_Obj_t *, vNodes, pObj, i )
2319  {
2320  pObj->Level = (1<<18);
2321  Abc_ObjForEachFanout( pObj, pFanin, k )
2322  pObj->Level = Abc_MinInt( pFanin->Level - 1, pObj->Level );
2323  assert( pObj->Level > 0 );
2324  }
2325  Abc_NtkForEachCi( pNtk, pObj, i )
2326  pObj->Level = 0;
2327 
2328  // move the nodes down one step at a time
2329  for ( Iter = 0; Iter < nImprove; Iter++ )
2330  {
2331  int Counter = 0, TotalGain = 0;
2332  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
2333  {
2334  int CountGain = -1;
2335  assert( pObj->Level > 0 );
2336  Abc_ObjForEachFanin( pObj, pFanin, k )
2337  {
2338  assert( pFanin->Level < pObj->Level );
2339  if ( pFanin->Level + 1 == pObj->Level )
2340  break;
2341  }
2342  if ( k < Abc_ObjFaninNum(pObj) ) // cannot move
2343  continue;
2344  Abc_ObjForEachFanin( pObj, pFanin, k )
2345  CountGain += Abc_NtkAddBuffsEval( pObj, pFanin );
2346  if ( CountGain >= 0 ) // can move
2347  {
2348  pObj->Level--;
2349  Counter++;
2350  TotalGain += CountGain;
2351  }
2352  }
2353  if ( fVerbose )
2354  printf( "Shifted %5d nodes down with total gain %5d.\n", Counter, TotalGain );
2355  if ( Counter == 0 )
2356  break;
2357  }
2358  Vec_PtrFree( vNodes );
2359  }
2360  else
2361  {
2362  // move the nodes up one step at a time
2363  Vec_Ptr_t * vNodes = Abc_NtkDfs( pNtk, 1 );
2364  for ( Iter = 0; Iter < nImprove; Iter++ )
2365  {
2366  int Counter = 0, TotalGain = 0;
2367  Vec_PtrForEachEntryReverse( Abc_Obj_t *, vNodes, pObj, i )
2368  {
2369  int CountGain = 1;
2370  assert( pObj->Level <= (unsigned)nLevelMax );
2371  Abc_ObjForEachFanout( pObj, pFanin, k )
2372  {
2373  assert( pFanin->Level > pObj->Level );
2374  if ( pFanin->Level == pObj->Level + 1 )
2375  break;
2376  }
2377  if ( k < Abc_ObjFanoutNum(pObj) ) // cannot move
2378  continue;
2379  Abc_ObjForEachFanin( pObj, pFanin, k )
2380  CountGain -= !Abc_NtkAddBuffsEval2( pObj, pFanin );
2381  if ( CountGain >= 0 ) // can move
2382  {
2383  pObj->Level++;
2384  Counter++;
2385  TotalGain += CountGain;
2386  }
2387  }
2388  if ( fVerbose )
2389  printf( "Shifted %5d nodes up with total gain %5d.\n", Counter, TotalGain );
2390  if ( Counter == 0 )
2391  break;
2392  }
2393  Vec_PtrFree( vNodes );
2394  }
2395  vBuffs = Vec_PtrStart( Abc_NtkObjNumMax(pNtk) * (nLevelMax + 1) );
2396  Abc_NtkForEachObj( pNtk, pObj, i )
2397  {
2398  if ( i == Vec_PtrSize(vBuffs) / (nLevelMax + 1) )
2399  break;
2400  if ( !Abc_ObjIsNode(pObj) && !Abc_ObjIsCo(pObj) )
2401  continue;
2402  Abc_ObjForEachFanin( pObj, pFanin, k )
2403  {
2404  assert( Abc_ObjLevel(pObj) - 1 >= Abc_ObjLevel(pFanin) );
2405  if ( Abc_ObjLevel(pObj) - 1 == Abc_ObjLevel(pFanin) )
2406  continue;
2407  pBuffer = Abc_NtkAddBuffsOne( vBuffs, pFanin, Abc_ObjLevel(pObj) - 1, nLevelMax );
2408  Abc_ObjPatchFanin( pObj, pFanin, pBuffer );
2409  }
2410  }
2411  Vec_PtrFree( vBuffs );
2412  Abc_NtkForEachCo( pNtk, pObj, i )
2413  pObj->Level = 0;
2414  return pNtk;
2415 }
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
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
#define Vec_PtrForEachEntryReverse(Type, vVec, pEntry, i)
Definition: vecPtr.h:63
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:419
Abc_Obj_t * Abc_NtkAddBuffsOne(Vec_Ptr_t *vBuffs, Abc_Obj_t *pFanin, int Level, int nLevelMax)
Definition: abcUtil.c:2290
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
int Abc_NtkAddBuffsEval(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
Definition: abcUtil.c:2249
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
for(p=first;p->value< newval;p=p->next)
unsigned Level
Definition: abc.h:142
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Definition: abcFanio.c:172
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
int Abc_NtkAddBuffsEval2(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
Definition: abcUtil.c:2269
static int Abc_ObjLevel(Abc_Obj_t *pObj)
Definition: abc.h:330
if(last==0)
Definition: sparse_int.h:34
static int Counter
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1265
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Abc_Obj_t* Abc_NtkAddBuffsOne ( Vec_Ptr_t vBuffs,
Abc_Obj_t pFanin,
int  Level,
int  nLevelMax 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 2290 of file abcUtil.c.

2291 {
2292  Abc_Obj_t * pBuffer;
2293  assert( Level - 1 >= Abc_ObjLevel(pFanin) );
2294  pBuffer = (Abc_Obj_t *)Vec_PtrEntry( vBuffs, Abc_ObjId(pFanin) * nLevelMax + Level );
2295  if ( pBuffer == NULL )
2296  {
2297  if ( Level - 1 == Abc_ObjLevel(pFanin) )
2298  pBuffer = pFanin;
2299  else
2300  pBuffer = Abc_NtkAddBuffsOne( vBuffs, pFanin, Level - 1, nLevelMax );
2301  pBuffer = Abc_NtkCreateNodeBuf( Abc_ObjNtk(pFanin), pBuffer );
2302  Vec_PtrWriteEntry( vBuffs, Abc_ObjId(pFanin) * nLevelMax + Level, pBuffer );
2303  }
2304  return pBuffer;
2305 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
Abc_Obj_t * Abc_NtkAddBuffsOne(Vec_Ptr_t *vBuffs, Abc_Obj_t *pFanin, int Level, int nLevelMax)
Definition: abcUtil.c:2290
static int Abc_ObjLevel(Abc_Obj_t *pObj)
Definition: abc.h:330
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:692
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
#define assert(ex)
Definition: util_old.h:213
static Abc_Ntk_t * Abc_ObjNtk(Abc_Obj_t *pObj)
Definition: abc.h:334
ABC_NAMESPACE_IMPL_START void* Abc_NtkAttrFree ( Abc_Ntk_t pNtk,
int  Attr,
int  fFreeMan 
)

DECLARATIONS ///.

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

FileName [abcUtil.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Various utilities.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Frees one attribute manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 50 of file abcUtil.c.

51 {
52  void * pUserMan;
53  Vec_Att_t * pAttrMan;
54  pAttrMan = (Vec_Att_t *)Vec_PtrEntry( pNtk->vAttrs, Attr );
55  Vec_PtrWriteEntry( pNtk->vAttrs, Attr, NULL );
56  pUserMan = Vec_AttFree( pAttrMan, fFreeMan );
57  return pUserMan;
58 }
Vec_Ptr_t * vAttrs
Definition: abc.h:214
static void * Vec_AttFree(Vec_Att_t *p, int fFreeMan)
Definition: vecAtt.h:126
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
void Abc_NtkCleanCopy ( Abc_Ntk_t pNtk)

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

Synopsis [Cleans the copy field of all objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 507 of file abcUtil.c.

508 {
509  Abc_Obj_t * pObj;
510  int i;
511  Abc_NtkForEachObj( pNtk, pObj, i )
512  pObj->pCopy = NULL;
513 }
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkCleanCopy_rec ( Abc_Ntk_t pNtk)

Definition at line 514 of file abcUtil.c.

515 {
516  Abc_Obj_t * pObj;
517  int i;
518  Abc_NtkCleanCopy( pNtk );
519  Abc_NtkForEachBox( pNtk, pObj, i )
521 }
void Abc_NtkCleanCopy_rec(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:514
static Abc_Ntk_t * Abc_ObjModel(Abc_Obj_t *pObj)
Definition: abc.h:335
#define Abc_NtkForEachBox(pNtk, pObj, i)
Definition: abc.h:495
void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
void Abc_NtkCleanData ( Abc_Ntk_t pNtk)

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

Synopsis [Cleans the copy field of all objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 534 of file abcUtil.c.

535 {
536  Abc_Obj_t * pObj;
537  int i;
538  Abc_NtkForEachObj( pNtk, pObj, i )
539  pObj->pData = NULL;
540 }
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkCleanMarkA ( Abc_Ntk_t pNtk)

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

Synopsis [Cleans the copy field of all objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 663 of file abcUtil.c.

664 {
665  Abc_Obj_t * pObj;
666  int i;
667  Abc_NtkForEachObj( pNtk, pObj, i )
668  pObj->fMarkA = 0;
669 }
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkCleanMarkAB ( Abc_Ntk_t pNtk)

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

Synopsis [Cleans the copy field of all objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 720 of file abcUtil.c.

721 {
722  Abc_Obj_t * pObj;
723  int i;
724  Abc_NtkForEachObj( pNtk, pObj, i )
725  pObj->fMarkA = pObj->fMarkB = 0;
726 }
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkCleanMarkABC ( Abc_Ntk_t pNtk)

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

Synopsis [Cleans the copy field of all objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 739 of file abcUtil.c.

740 {
741  Abc_Obj_t * pObj;
742  int i;
743  Abc_NtkForEachObj( pNtk, pObj, i )
744  pObj->fMarkA = pObj->fMarkB = pObj->fMarkC = 0;
745 }
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkCleanMarkB ( Abc_Ntk_t pNtk)

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

Synopsis [Cleans the copy field of all objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 682 of file abcUtil.c.

683 {
684  Abc_Obj_t * pObj;
685  int i;
686  Abc_NtkForEachObj( pNtk, pObj, i )
687  pObj->fMarkB = 0;
688 }
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkCleanMarkC ( Abc_Ntk_t pNtk)

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

Synopsis [Cleans the copy field of all objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 701 of file abcUtil.c.

702 {
703  Abc_Obj_t * pObj;
704  int i;
705  Abc_NtkForEachObj( pNtk, pObj, i )
706  pObj->fMarkC = 0;
707 }
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkCleanNext ( Abc_Ntk_t pNtk)

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

Synopsis [Cleans the copy field of all objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 636 of file abcUtil.c.

637 {
638  Abc_Obj_t * pObj;
639  int i;
640  Abc_NtkForEachObj( pNtk, pObj, i )
641  pObj->pNext = NULL;
642 }
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkCleanNext_rec ( Abc_Ntk_t pNtk)

Definition at line 643 of file abcUtil.c.

644 {
645  Abc_Obj_t * pObj;
646  int i;
647  Abc_NtkCleanNext( pNtk );
648  Abc_NtkForEachBox( pNtk, pObj, i )
650 }
void Abc_NtkCleanNext(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:636
static Abc_Ntk_t * Abc_ObjModel(Abc_Obj_t *pObj)
Definition: abc.h:335
#define Abc_NtkForEachBox(pNtk, pObj, i)
Definition: abc.h:495
void Abc_NtkCleanNext_rec(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:643
Vec_Ptr_t* Abc_NtkCollectLatches ( Abc_Ntk_t pNtk)

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

Synopsis [Collects all latches in the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 1627 of file abcUtil.c.

1628 {
1629  Vec_Ptr_t * vLatches;
1630  Abc_Obj_t * pObj;
1631  int i;
1632  vLatches = Vec_PtrAlloc( 10 );
1633  Abc_NtkForEachObj( pNtk, pObj, i )
1634  Vec_PtrPush( vLatches, pObj );
1635  return vLatches;
1636 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
Vec_Ptr_t* Abc_NtkCollectObjects ( Abc_Ntk_t pNtk)

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

Synopsis [Collects all objects into one array.]

Description []

SideEffects []

SeeAlso []

Definition at line 1725 of file abcUtil.c.

1726 {
1727  Vec_Ptr_t * vNodes;
1728  Abc_Obj_t * pNode;
1729  int i;
1730  vNodes = Vec_PtrAlloc( 100 );
1731  Abc_NtkForEachObj( pNtk, pNode, i )
1732  Vec_PtrPush( vNodes, pNode );
1733  return vNodes;
1734 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkCompareCones ( Abc_Ntk_t pNtk)

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

Synopsis [Analyze choice node support.]

Description []

SideEffects []

SeeAlso []

Definition at line 2086 of file abcUtil.c.

2087 {
2088  Vec_Ptr_t * vSupp, * vNodes, * vReverse;
2089  Abc_Obj_t * pObj, * pTemp;
2090  int Iter, i, k, Counter, CounterCos, CounterCosNew;
2091  int * pPerms;
2092 
2093  // sort COs by support size
2094  pPerms = ABC_ALLOC( int, Abc_NtkCoNum(pNtk) );
2095  pSupps = ABC_ALLOC( int, Abc_NtkCoNum(pNtk) );
2096  Abc_NtkForEachCo( pNtk, pObj, i )
2097  {
2098  pPerms[i] = i;
2099  vSupp = Abc_NtkNodeSupport( pNtk, &pObj, 1 );
2100  pSupps[i] = Vec_PtrSize(vSupp);
2101  Vec_PtrFree( vSupp );
2102  }
2103  qsort( (void *)pPerms, Abc_NtkCoNum(pNtk), sizeof(int), (int (*)(const void *, const void *)) Abc_NtkCompareConesCompare );
2104 
2105  // consider COs in this order
2106  Iter = 0;
2107  Abc_NtkForEachCo( pNtk, pObj, i )
2108  {
2109  pObj = Abc_NtkCo( pNtk, pPerms[i] );
2110  if ( pObj->fMarkA )
2111  continue;
2112  Iter++;
2113 
2114  vSupp = Abc_NtkNodeSupport( pNtk, &pObj, 1 );
2115  vNodes = Abc_NtkDfsNodes( pNtk, &pObj, 1 );
2116  vReverse = Abc_NtkDfsReverseNodesContained( pNtk, (Abc_Obj_t **)Vec_PtrArray(vSupp), Vec_PtrSize(vSupp) );
2117  // count the number of nodes in the reverse cone
2118  Counter = 0;
2119  for ( k = 1; k < Vec_PtrSize(vReverse) - 1; k++ )
2120  for ( pTemp = (Abc_Obj_t *)Vec_PtrEntry(vReverse, k); pTemp; pTemp = (Abc_Obj_t *)pTemp->pCopy )
2121  Counter++;
2122  CounterCos = CounterCosNew = 0;
2123  for ( pTemp = (Abc_Obj_t *)Vec_PtrEntryLast(vReverse); pTemp; pTemp = (Abc_Obj_t *)pTemp->pCopy )
2124  {
2125  assert( Abc_ObjIsCo(pTemp) );
2126  CounterCos++;
2127  if ( pTemp->fMarkA == 0 )
2128  CounterCosNew++;
2129  pTemp->fMarkA = 1;
2130  }
2131  // print statistics
2132  printf( "%4d CO %5d : Supp = %5d. Lev = %3d. Cone = %5d. Rev = %5d. COs = %3d (%3d).\n",
2133  Iter, pPerms[i], Vec_PtrSize(vSupp), Abc_ObjLevel(Abc_ObjFanin0(pObj)), Vec_PtrSize(vNodes), Counter, CounterCos, CounterCosNew );
2134 
2135  if ( Vec_PtrSize(vSupp) < 10 )
2136  {
2137  // free arrays
2138  Vec_PtrFree( vSupp );
2139  Vec_PtrFree( vNodes );
2140  Vec_PtrFree( vReverse );
2141  break;
2142  }
2143 
2144  // free arrays
2145  Vec_PtrFree( vSupp );
2146  Vec_PtrFree( vNodes );
2147  Vec_PtrFree( vReverse );
2148 
2149  }
2150  Abc_NtkForEachCo( pNtk, pObj, i )
2151  pObj->fMarkA = 0;
2152 
2153  ABC_FREE( pPerms );
2154  ABC_FREE( pSupps );
2155 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
unsigned fMarkA
Definition: abc.h:134
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
static Abc_Obj_t * Abc_NtkCo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:318
Abc_Obj_t * pCopy
Definition: abc.h:148
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
Definition: vecPtr.h:413
static int Abc_ObjLevel(Abc_Obj_t *pObj)
Definition: abc.h:330
ABC_DLL Vec_Ptr_t * Abc_NtkNodeSupport(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition: abcDfs.c:859
static int Counter
ABC_DLL Vec_Ptr_t * Abc_NtkDfsReverseNodesContained(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition: abcDfs.c:298
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define ABC_FREE(obj)
Definition: abc_global.h:232
static int * pSupps
Definition: abcUtil.c:2053
#define assert(ex)
Definition: util_old.h:213
int Abc_NtkCompareConesCompare(int *pNum1, int *pNum2)
Definition: abcUtil.c:2066
ABC_DLL Vec_Ptr_t * Abc_NtkDfsNodes(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition: abcDfs.c:120
static void ** Vec_PtrArray(Vec_Ptr_t *p)
Definition: vecPtr.h:279
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Abc_NtkCompareConesCompare ( int *  pNum1,
int *  pNum2 
)

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

Synopsis [Compares the supergates by their level.]

Description []

SideEffects []

SeeAlso []

Definition at line 2066 of file abcUtil.c.

2067 {
2068  if ( pSupps[*pNum1] > pSupps[*pNum2] )
2069  return -1;
2070  if ( pSupps[*pNum1] < pSupps[*pNum2] )
2071  return 1;
2072  return 0;
2073 }
static int * pSupps
Definition: abcUtil.c:2053
void Abc_NtkCompareSupports ( Abc_Ntk_t pNtk)

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

Synopsis [Analyze choice node support.]

Description []

SideEffects []

SeeAlso []

Definition at line 2168 of file abcUtil.c.

2169 {
2170  Vec_Ptr_t * vSupp;
2171  Abc_Obj_t * pObj, * pTemp;
2172  int i, nNodesOld;
2173  assert( Abc_NtkIsStrash(pNtk) );
2174  Abc_AigForEachAnd( pNtk, pObj, i )
2175  {
2176  if ( !Abc_AigNodeIsChoice(pObj) )
2177  continue;
2178 
2179  vSupp = Abc_NtkNodeSupport( pNtk, &pObj, 1 );
2180  nNodesOld = Vec_PtrSize(vSupp);
2181  Vec_PtrFree( vSupp );
2182 
2183  for ( pTemp = (Abc_Obj_t *)pObj->pData; pTemp; pTemp = (Abc_Obj_t *)pTemp->pData )
2184  {
2185  vSupp = Abc_NtkNodeSupport( pNtk, &pTemp, 1 );
2186  if ( nNodesOld != Vec_PtrSize(vSupp) )
2187  printf( "Choice orig = %3d Choice new = %3d\n", nNodesOld, Vec_PtrSize(vSupp) );
2188  Vec_PtrFree( vSupp );
2189  }
2190  }
2191 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition: abc.h:485
ABC_DLL Vec_Ptr_t * Abc_NtkNodeSupport(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition: abcDfs.c:859
static int Abc_AigNodeIsChoice(Abc_Obj_t *pNode)
Definition: abc.h:398
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
float Abc_NtkComputeDelay ( Abc_Ntk_t pNtk)

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

Synopsis [Computes max delay using log(n) delay model.]

Description []

SideEffects []

SeeAlso []

Definition at line 2448 of file abcUtil.c.

2449 {
2450  static double GateDelays[20] = { 1.00, 1.00, 2.00, 2.58, 3.00, 3.32, 3.58, 3.81, 4.00, 4.17, 4.32, 4.46, 4.58, 4.70, 4.81, 4.91, 5.00, 5.09, 5.17, 5.25 };
2451  Vec_Ptr_t * vNodes;
2452  Abc_Obj_t * pObj, * pFanin;
2453  float DelayMax, Delays[15] = {0};
2454  int nFaninMax, i, k;
2455  // calculate relative gate delays
2456  nFaninMax = Abc_NtkGetFaninMax( pNtk );
2457  assert( nFaninMax > 1 && nFaninMax < 15 );
2458  for ( i = 0; i <= nFaninMax; i++ )
2459  Delays[i] = GateDelays[i]/GateDelays[nFaninMax];
2460  // set max CI delay
2461  Abc_NtkForEachCi( pNtk, pObj, i )
2462  pObj->dTemp = 0.0;
2463  // compute delays for each node
2464  vNodes = Abc_NtkDfs( pNtk, 1 );
2465  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
2466  {
2467  pObj->dTemp = 0.0;
2468  Abc_ObjForEachFanin( pObj, pFanin, k )
2469  pObj->dTemp = Abc_MaxFloat( pObj->dTemp, pFanin->dTemp );
2470  pObj->dTemp += Delays[Abc_ObjFaninNum(pObj)];
2471  }
2472  Vec_PtrFree( vNodes );
2473  DelayMax = 0.0;
2474  // find max CO delay
2475  Abc_NtkForEachCo( pNtk, pObj, i )
2476  DelayMax = Abc_MaxFloat( DelayMax, Abc_ObjFanin0(pObj)->dTemp );
2477  return DelayMax;
2478 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int Abc_NtkGetFaninMax(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:453
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Abc_NtkCountCopy ( Abc_Ntk_t pNtk)

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

Synopsis [Counts the number of nodes having non-trivial copies.]

Description []

SideEffects []

SeeAlso []

Definition at line 572 of file abcUtil.c.

573 {
574  Abc_Obj_t * pObj;
575  int i, Counter = 0;
576  Abc_NtkForEachObj( pNtk, pObj, i )
577  {
578  if ( Abc_ObjIsNode(pObj) )
579  Counter += (pObj->pCopy != NULL);
580  }
581  return Counter;
582 }
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
Abc_Obj_t * pCopy
Definition: abc.h:148
static int Counter
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
int Abc_NtkCountMuxes ( Abc_Ntk_t pNtk)

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

Synopsis [Returns 1 if the node is the root of MUX or EXOR/NEXOR.]

Description []

SideEffects []

SeeAlso []

Definition at line 1336 of file abcUtil.c.

1337 {
1338  Abc_Obj_t * pNode;
1339  int i;
1340  int Counter = 0;
1341  Abc_NtkForEachNode( pNtk, pNode, i )
1342  Counter += Abc_NodeIsMuxType( pNode );
1343  return Counter;
1344 }
int Abc_NodeIsMuxType(Abc_Obj_t *pNode)
Definition: abcUtil.c:1301
static int Counter
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
int Abc_NtkCrossCut ( Abc_Ntk_t pNtk)

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

Synopsis [Computes cross-cut of the circuit.]

Description []

SideEffects []

SeeAlso []

Definition at line 2009 of file abcUtil.c.

2010 {
2011  Abc_Obj_t * pObj;
2012  int nCutSize = 0, nCutSizeMax = 0;
2013  int i;
2014  Abc_NtkCleanCopy( pNtk );
2015  Abc_NtkIncrementTravId( pNtk );
2016  Abc_NtkForEachCo( pNtk, pObj, i )
2017  {
2018  Abc_NtkCrossCut_rec( pObj, &nCutSize, &nCutSizeMax );
2019  nCutSize--;
2020  }
2021  assert( nCutSize == 0 );
2022  printf( "Max cross cut size = %6d. Ratio = %6.2f %%\n", nCutSizeMax, 100.0 * nCutSizeMax/Abc_NtkObjNum(pNtk) );
2023  return nCutSizeMax;
2024 }
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
int Abc_NtkCrossCut_rec(Abc_Obj_t *pObj, int *pnCutSize, int *pnCutSizeMax)
Definition: abcUtil.c:1962
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
#define assert(ex)
Definition: util_old.h:213
static int Abc_NtkObjNum(Abc_Ntk_t *pNtk)
Definition: abc.h:283
int Abc_NtkCrossCut_rec ( Abc_Obj_t pObj,
int *  pnCutSize,
int *  pnCutSizeMax 
)

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

Synopsis [Computes cross-cut of the circuit.]

Description [Returns 1 if it is the last visit to the node.]

SideEffects []

SeeAlso []

Definition at line 1962 of file abcUtil.c.

1963 {
1964  Abc_Obj_t * pFanin;
1965  int i, nDecrem = 0;
1966  int fReverse = 0;
1967  if ( Abc_ObjIsCi(pObj) )
1968  return 0;
1969  // if visited, increment visit counter
1970  if ( Abc_NodeIsTravIdCurrent( pObj ) )
1971  return Abc_ObjCrossCutInc( pObj );
1972  Abc_NodeSetTravIdCurrent( pObj );
1973  // visit the fanins
1974  if ( !Abc_ObjIsCi(pObj) )
1975  {
1976  if ( fReverse )
1977  {
1978  Abc_ObjForEachFanin( pObj, pFanin, i )
1979  {
1980  pFanin = Abc_ObjFanin( pObj, Abc_ObjFaninNum(pObj) - 1 - i );
1981  nDecrem += Abc_NtkCrossCut_rec( pFanin, pnCutSize, pnCutSizeMax );
1982  }
1983  }
1984  else
1985  {
1986  Abc_ObjForEachFanin( pObj, pFanin, i )
1987  nDecrem += Abc_NtkCrossCut_rec( pFanin, pnCutSize, pnCutSizeMax );
1988  }
1989  }
1990  // count the node
1991  (*pnCutSize)++;
1992  if ( *pnCutSizeMax < *pnCutSize )
1993  *pnCutSizeMax = *pnCutSize;
1994  (*pnCutSize) -= nDecrem;
1995  return Abc_ObjCrossCutInc( pObj );
1996 }
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
if(last==0)
Definition: sparse_int.h:34
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
int Abc_NtkCrossCut_rec(Abc_Obj_t *pObj, int *pnCutSize, int *pnCutSizeMax)
Definition: abcUtil.c:1962
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static int Abc_ObjCrossCutInc(Abc_Obj_t *pObj)
Definition: abcUtil.c:1943
static Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
Definition: abc.h:372
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
void Abc_NtkDetectMatching ( Abc_Ntk_t pNtk)

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

Synopsis [Detect cases when non-trivial FF matching is possible.]

Description []

SideEffects []

SeeAlso []

Definition at line 1853 of file abcUtil.c.

1854 {
1855 /*
1856  Abc_Obj_t * pLatch, * pFanin;
1857  int i, nTFFs, nJKFFs;
1858  nTFFs = nJKFFs = 0;
1859  Abc_NtkForEachLatch( pNtk, pLatch, i )
1860  {
1861  pFanin = Abc_ObjFanin0(pLatch);
1862  if ( Abc_ObjFaninNum(pFanin) != 2 )
1863  continue;
1864  if ( Abc_NodeIsExorType(pLatch) )
1865  {
1866  if ( Abc_ObjFanin0(Abc_ObjFanin0(pFanin)) == pLatch ||
1867  Abc_ObjFanin1(Abc_ObjFanin0(pFanin)) == pLatch )
1868  nTFFs++;
1869  }
1870  if ( Abc_ObjFaninNum( Abc_ObjFanin0(pFanin) ) != 2 ||
1871  Abc_ObjFaninNum( Abc_ObjFanin1(pFanin) ) != 2 )
1872  continue;
1873 
1874  if ( (Abc_ObjFanin0(Abc_ObjFanin0(pFanin)) == pLatch ||
1875  Abc_ObjFanin1(Abc_ObjFanin0(pFanin)) == pLatch) &&
1876  (Abc_ObjFanin0(Abc_ObjFanin1(pFanin)) == pLatch ||
1877  Abc_ObjFanin1(Abc_ObjFanin1(pFanin)) == pLatch) )
1878  {
1879  nJKFFs++;
1880  }
1881  }
1882  printf( "D = %6d. T = %6d. JK = %6d. (%6.2f %%)\n",
1883  Abc_NtkLatchNum(pNtk), nTFFs, nJKFFs, 100.0 * nJKFFs / Abc_NtkLatchNum(pNtk) );
1884 */
1885 }
Vec_Int_t* Abc_NtkFanoutCounts ( Abc_Ntk_t pNtk)

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

Synopsis [Creates the array of fanout counters.]

Description []

SideEffects []

SeeAlso []

Definition at line 1701 of file abcUtil.c.

1702 {
1703  Vec_Int_t * vFanNums;
1704  Abc_Obj_t * pObj;
1705  int i;
1706  vFanNums = Vec_IntAlloc( 0 );
1707  Vec_IntFill( vFanNums, Abc_NtkObjNumMax(pNtk), -1 );
1708  Abc_NtkForEachObj( pNtk, pObj, i )
1709  if ( Abc_ObjIsCi(pObj) || Abc_ObjIsNode(pObj) )
1710  Vec_IntWriteEntry( vFanNums, i, Abc_ObjFanoutNum(pObj) );
1711  return vFanNums;
1712 }
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
if(last==0)
Definition: sparse_int.h:34
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkFillTemp ( Abc_Ntk_t pNtk)

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

Synopsis [Cleans the copy field of all objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 553 of file abcUtil.c.

554 {
555  Abc_Obj_t * pObj;
556  int i;
557  Abc_NtkForEachObj( pNtk, pObj, i )
558  pObj->iTemp = -1;
559 }
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkFixCoDriverProblem ( Abc_Obj_t pDriver,
Abc_Obj_t pNodeCo,
int  fDuplicate 
)

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

Synopsis [Fixes the CO driver problem.]

Description []

SideEffects []

SeeAlso []

Definition at line 858 of file abcUtil.c.

859 {
860  Abc_Ntk_t * pNtk = pDriver->pNtk;
861  Abc_Obj_t * pDriverNew, * pFanin;
862  int k;
863  if ( fDuplicate && !Abc_ObjIsCi(pDriver) )
864  {
865  pDriverNew = Abc_NtkDupObj( pNtk, pDriver, 0 );
866  Abc_ObjForEachFanin( pDriver, pFanin, k )
867  Abc_ObjAddFanin( pDriverNew, pFanin );
868  if ( Abc_ObjFaninC0(pNodeCo) )
869  {
870  // change polarity of the duplicated driver
871  Abc_NodeComplement( pDriverNew );
872  Abc_ObjXorFaninC( pNodeCo, 0 );
873  }
874  }
875  else
876  {
877  // add inverters and buffers when necessary
878  if ( Abc_ObjFaninC0(pNodeCo) )
879  {
880  pDriverNew = Abc_NtkCreateNodeInv( pNtk, pDriver );
881  Abc_ObjXorFaninC( pNodeCo, 0 );
882  }
883  else
884  pDriverNew = Abc_NtkCreateNodeBuf( pNtk, pDriver );
885  }
886  // update the fanin of the PO node
887  Abc_ObjPatchFanin( pNodeCo, pDriver, pDriverNew );
888  assert( Abc_ObjFanoutNum(pDriverNew) == 1 );
889  // remove the old driver if it dangles
890  // (this happens when the duplicated driver had only one complemented fanout)
891  if ( Abc_ObjFanoutNum(pDriver) == 0 )
892  Abc_NtkDeleteObj( pDriver );
893 }
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition: abcObj.c:337
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Definition: abcFanio.c:172
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
Definition: abcObj.c:167
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:662
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:692
if(last==0)
Definition: sparse_int.h:34
Abc_Ntk_t * pNtk
Definition: abc.h:130
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static void Abc_ObjXorFaninC(Abc_Obj_t *pObj, int i)
Definition: abc.h:381
#define assert(ex)
Definition: util_old.h:213
ABC_DLL void Abc_NodeComplement(Abc_Obj_t *pNode)
Definition: abcObj.c:980
Abc_Ntk_t* Abc_NtkFromPla ( char **  pPlas,
int  nInputs,
int  nOutputs 
)

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

Synopsis [Converts multi-output PLA into an AIG with logic sharing.]

Description [The first argument is an array of char*-strings representing individual output of a multi-output PLA. The number of inputs (nInputs) and the number of outputs (nOutputs) are the second and third arguments. This procedure returns the AIG manager with the given number of inputs and outputs representing the PLA as a logic network with sharing.

For example, if the original PLA is 1000 10 0110 01 0011 01 the individual PLA for each the two outputs should be 1000 1 and 0110 1 0011 1

Reprsentation in terms of two char*-strings will be: char * pPlas[2] = { "1000 1\n", "0110 1\n0011 1\n" }; The call to the procedure may look as follows: Abc_Ntk_t * pNtkAig = Abc_NtkFromPla( pPlas, 4, 2 );]

SideEffects []

SeeAlso []

Definition at line 2708 of file abcUtil.c.

2709 {
2710  Fxu_Data_t Params, * p = &Params;
2711  Abc_Ntk_t * pNtkSop, * pNtkAig;
2712  Abc_Obj_t * pNode, * pFanin;
2713  int i, k;
2714  // allocate logic network with SOP local functions
2715  pNtkSop = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_SOP, 1 );
2716  pNtkSop->pName = Extra_FileNameGeneric("pla");
2717  // create primary inputs/outputs
2718  for ( i = 0; i < nInputs; i++ )
2719  Abc_NtkCreatePi( pNtkSop );
2720  for ( i = 0; i < nOutputs; i++ )
2721  Abc_NtkCreatePo( pNtkSop );
2722  Abc_NtkAddDummyPiNames( pNtkSop );
2723  Abc_NtkAddDummyPoNames( pNtkSop );
2724  // create internal nodes
2725  for ( i = 0; i < nOutputs; i++ )
2726  {
2727  pNode = Abc_NtkCreateNode( pNtkSop );
2728  Abc_NtkForEachPi( pNtkSop, pFanin, k )
2729  Abc_ObjAddFanin( pNode, pFanin );
2730  pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkSop->pManFunc, pPlas[i] );
2731  Abc_ObjAddFanin( Abc_NtkPo(pNtkSop, i), pNode );
2732  // check that the number of inputs is the same
2733  assert( Abc_SopGetVarNum((char*)pNode->pData) == nInputs );
2734  }
2735  if ( !Abc_NtkCheck( pNtkSop ) )
2736  fprintf( stdout, "Abc_NtkFromPla(): Network check has failed.\n" );
2737  // perform fast_extract
2739  Abc_NtkFastExtract( pNtkSop, p );
2740  Abc_NtkFxuFreeInfo( p );
2741  // convert to an AIG
2742  pNtkAig = Abc_NtkStrash( pNtkSop, 0, 1, 0 );
2743  Abc_NtkDelete( pNtkSop );
2744  return pNtkAig;
2745 }
Abc_Ntk_t * Abc_NtkFromPla(char **pPlas, int nInputs, int nOutputs)
Definition: abcUtil.c:2708
static Llb_Mgr_t * p
Definition: llb3Image.c:950
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Definition: abcStrash.c:265
void Abc_NtkFxuFreeInfo(Fxu_Data_t *p)
Definition: abcFxu.c:207
typedefABC_NAMESPACE_HEADER_START struct FxuDataStruct Fxu_Data_t
INCLUDES ///.
Definition: fxu.h:42
int Abc_NtkFastExtract(Abc_Ntk_t *pNtk, Fxu_Data_t *p)
Definition: abcFxu.c:83
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
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_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition: abcNtk.c:50
static void check(int expr)
Definition: satSolver.c:46
ABC_DLL void Abc_NtkAddDummyPoNames(Abc_Ntk_t *pNtk)
Definition: abcNames.c:398
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, char *pName)
DECLARATIONS ///.
Definition: abcSop.c:56
char * Extra_FileNameGeneric(char *FileName)
if(last==0)
Definition: sparse_int.h:34
static Abc_Obj_t * Abc_NtkCreatePi(Abc_Ntk_t *pNtk)
Definition: abc.h:303
void Abc_NtkSetDefaultFxParams(Fxu_Data_t *p)
FUNCTION DEFINITIONS ///.
Definition: abcFxu.c:52
static Abc_Obj_t * Abc_NtkPo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:316
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition: abcSop.c:536
#define assert(ex)
Definition: util_old.h:213
ABC_DLL void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
Definition: abcNames.c:378
static Abc_Obj_t * Abc_NtkCreatePo(Abc_Ntk_t *pNtk)
Definition: abc.h:304
char * pName
Definition: abc.h:158
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
void Abc_NtkFromPlaTest ( )

Definition at line 2746 of file abcUtil.c.

2747 {
2748  char * pPlas[2] = { "1000 1\n", "0110 1\n0011 1\n" };
2749  Abc_Ntk_t * pNtkAig = Abc_NtkFromPla( pPlas, 4, 2 );
2750  Io_WriteBlifLogic( pNtkAig, "temp.blif", 0 );
2751  Abc_NtkDelete( pNtkAig );
2752 }
Abc_Ntk_t * Abc_NtkFromPla(char **pPlas, int nInputs, int nOutputs)
Definition: abcUtil.c:2708
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
void Io_WriteBlifLogic(Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches)
FUNCTION DEFINITIONS ///.
Definition: ioWriteBlif.c:59
int Abc_NtkGetAigNodeNum ( Abc_Ntk_t pNtk)

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

Synopsis [Reads the number of BDD nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 266 of file abcUtil.c.

267 {
268  Abc_Obj_t * pNode;
269  int i, nNodes = 0;
270  assert( Abc_NtkIsAigLogic(pNtk) );
271  Abc_NtkForEachNode( pNtk, pNode, i )
272  {
273  assert( pNode->pData );
274  if ( Abc_ObjFaninNum(pNode) < 2 )
275  continue;
276 //printf( "%d ", Hop_DagSize( pNode->pData ) );
277  nNodes += pNode->pData? Hop_DagSize( (Hop_Obj_t *)pNode->pData ) : 0;
278  }
279  return nNodes;
280 }
int Hop_DagSize(Hop_Obj_t *pObj)
Definition: hopDfs.c:279
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_NtkIsAigLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:266
Definition: hop.h:65
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
int Abc_NtkGetBddNodeNum ( Abc_Ntk_t pNtk)

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

Synopsis [Reads the number of BDD nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 240 of file abcUtil.c.

241 {
242  Abc_Obj_t * pNode;
243  int i, nNodes = 0;
244  assert( Abc_NtkIsBddLogic(pNtk) );
245  Abc_NtkForEachNode( pNtk, pNode, i )
246  {
247  assert( pNode->pData );
248  if ( Abc_ObjFaninNum(pNode) < 2 )
249  continue;
250  nNodes += pNode->pData? -1 + Cudd_DagSize( (DdNode *)pNode->pData ) : 0;
251  }
252  return nNodes;
253 }
Definition: cudd.h:278
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static int Abc_NtkIsBddLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:265
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
int Cudd_DagSize(DdNode *node)
Definition: cuddUtil.c:442
int Abc_NtkGetBufNum ( Abc_Ntk_t pNtk)

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

Synopsis [Counts the number of exors.]

Description []

SideEffects []

SeeAlso []

Definition at line 410 of file abcUtil.c.

411 {
412  Abc_Obj_t * pNode;
413  int i, Counter = 0;
414  Abc_NtkForEachNode( pNtk, pNode, i )
415  Counter += (Abc_ObjFaninNum(pNode) == 1);
416  return Counter;
417 }
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Counter
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
int Abc_NtkGetChoiceNum ( Abc_Ntk_t pNtk)

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

Synopsis [Returns 1 if it is an AIG with choice nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 430 of file abcUtil.c.

431 {
432  Abc_Obj_t * pNode;
433  int i, Counter;
434  if ( !Abc_NtkIsStrash(pNtk) )
435  return 0;
436  Counter = 0;
437  Abc_NtkForEachNode( pNtk, pNode, i )
438  Counter += Abc_AigNodeIsChoice( pNode );
439  return Counter;
440 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Counter
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static int Abc_AigNodeIsChoice(Abc_Obj_t *pNode)
Definition: abc.h:398
Vec_Int_t* Abc_NtkGetCiIds ( Abc_Ntk_t pNtk)

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

Synopsis [Returns the array of CI IDs.]

Description []

SideEffects []

SeeAlso []

Definition at line 1747 of file abcUtil.c.

1748 {
1749  Vec_Int_t * vCiIds;
1750  Abc_Obj_t * pObj;
1751  int i;
1752  vCiIds = Vec_IntAlloc( Abc_NtkCiNum(pNtk) );
1753  Abc_NtkForEachCi( pNtk, pObj, i )
1754  Vec_IntPush( vCiIds, pObj->Id );
1755  return vCiIds;
1756 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
int Abc_NtkGetClauseNum ( Abc_Ntk_t pNtk)

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

Synopsis [Reads the number of BDD nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 293 of file abcUtil.c.

294 {
295  extern int Abc_CountZddCubes( DdManager * dd, DdNode * zCover );
296  Abc_Obj_t * pNode;
297  DdNode * bCover, * zCover, * bFunc;
298  DdManager * dd = (DdManager *)pNtk->pManFunc;
299  int i, nClauses = 0;
300  assert( Abc_NtkIsBddLogic(pNtk) );
301  Abc_NtkForEachNode( pNtk, pNode, i )
302  {
303  assert( pNode->pData );
304  bFunc = (DdNode *)pNode->pData;
305 
306  bCover = Cudd_zddIsop( dd, bFunc, bFunc, &zCover );
307  Cudd_Ref( bCover );
308  Cudd_Ref( zCover );
309  nClauses += Abc_CountZddCubes( dd, zCover );
310  Cudd_RecursiveDeref( dd, bCover );
311  Cudd_RecursiveDerefZdd( dd, zCover );
312 
313  bCover = Cudd_zddIsop( dd, Cudd_Not(bFunc), Cudd_Not(bFunc), &zCover );
314  Cudd_Ref( bCover );
315  Cudd_Ref( zCover );
316  nClauses += Abc_CountZddCubes( dd, zCover );
317  Cudd_RecursiveDeref( dd, bCover );
318  Cudd_RecursiveDerefZdd( dd, zCover );
319  }
320  return nClauses;
321 }
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
void * pManFunc
Definition: abc.h:191
DdNode * Cudd_zddIsop(DdManager *dd, DdNode *L, DdNode *U, DdNode **zdd_I)
Definition: cuddZddIsop.c:136
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static int Abc_NtkIsBddLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:265
#define assert(ex)
Definition: util_old.h:213
int Abc_CountZddCubes(DdManager *dd, DdNode *zCover)
Definition: abcFunc.c:593
void * pData
Definition: abc.h:145
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
int Abc_NtkGetCubeNum ( Abc_Ntk_t pNtk)

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

Synopsis [Reads the number of cubes of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 112 of file abcUtil.c.

113 {
114  Abc_Obj_t * pNode;
115  int i, nCubes = 0;
116  assert( Abc_NtkHasSop(pNtk) );
117  Abc_NtkForEachNode( pNtk, pNode, i )
118  {
119  if ( Abc_NodeIsConst(pNode) )
120  continue;
121  assert( pNode->pData );
122  nCubes += Abc_SopGetCubeNum( (char *)pNode->pData );
123  }
124  return nCubes;
125 }
static int Abc_NtkHasSop(Abc_Ntk_t *pNtk)
Definition: abc.h:253
ABC_DLL int Abc_NodeIsConst(Abc_Obj_t *pNode)
Definition: abcObj.c:843
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
Definition: abcSop.c:489
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
int Abc_NtkGetCubePairNum ( Abc_Ntk_t pNtk)

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

Synopsis [Reads the number of cubes of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 138 of file abcUtil.c.

139 {
140  Abc_Obj_t * pNode;
141  int i, nCubes, nCubePairs = 0;
142  assert( Abc_NtkHasSop(pNtk) );
143  Abc_NtkForEachNode( pNtk, pNode, i )
144  {
145  if ( Abc_NodeIsConst(pNode) )
146  continue;
147  assert( pNode->pData );
148  nCubes = Abc_SopGetCubeNum( (char *)pNode->pData );
149  nCubePairs += nCubes * (nCubes - 1) / 2;
150  }
151  return nCubePairs;
152 }
static int Abc_NtkHasSop(Abc_Ntk_t *pNtk)
Definition: abc.h:253
ABC_DLL int Abc_NodeIsConst(Abc_Obj_t *pNode)
Definition: abcObj.c:843
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
Definition: abcSop.c:489
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
int Abc_NtkGetExorNum ( Abc_Ntk_t pNtk)

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

Synopsis [Counts the number of exors.]

Description []

SideEffects []

SeeAlso []

Definition at line 370 of file abcUtil.c.

371 {
372  Abc_Obj_t * pNode;
373  int i, Counter = 0;
374  Abc_NtkForEachNode( pNtk, pNode, i )
375  Counter += pNode->fExor;
376  return Counter;
377 }
static int Counter
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
int Abc_NtkGetFaninMax ( Abc_Ntk_t pNtk)

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

Synopsis [Reads the maximum number of fanins.]

Description []

SideEffects []

SeeAlso []

Definition at line 453 of file abcUtil.c.

454 {
455  Abc_Obj_t * pNode;
456  int i, nFaninsMax = 0;
457  Abc_NtkForEachNode( pNtk, pNode, i )
458  {
459  if ( nFaninsMax < Abc_ObjFaninNum(pNode) )
460  nFaninsMax = Abc_ObjFaninNum(pNode);
461  }
462  return nFaninsMax;
463 }
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
int Abc_NtkGetFanoutMax ( Abc_Ntk_t pNtk)

Definition at line 464 of file abcUtil.c.

465 {
466  Abc_Obj_t * pNode;
467  int i, nFaninsMax = 0;
468  Abc_NtkForEachNode( pNtk, pNode, i )
469  {
470  if ( nFaninsMax < Abc_ObjFanoutNum(pNode) )
471  nFaninsMax = Abc_ObjFanoutNum(pNode);
472  }
473  return nFaninsMax;
474 }
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
int Abc_NtkGetLitFactNum ( Abc_Ntk_t pNtk)

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

Synopsis [Counts the number of literals in the factored forms.]

Description []

SideEffects []

SeeAlso []

Definition at line 189 of file abcUtil.c.

190 {
191  Dec_Graph_t * pFactor;
192  Abc_Obj_t * pNode;
193  int nNodes, i;
194  assert( Abc_NtkHasSop(pNtk) );
195  nNodes = 0;
196  Abc_NtkForEachNode( pNtk, pNode, i )
197  {
198  if ( Abc_NodeIsConst(pNode) )
199  continue;
200  pFactor = Dec_Factor( (char *)pNode->pData );
201  nNodes += 1 + Dec_GraphNodeNum(pFactor);
202  Dec_GraphFree( pFactor );
203  }
204  return nNodes;
205 }
static int Abc_NtkHasSop(Abc_Ntk_t *pNtk)
Definition: abc.h:253
ABC_DLL int Abc_NodeIsConst(Abc_Obj_t *pNode)
Definition: abcObj.c:843
static int Dec_GraphNodeNum(Dec_Graph_t *pGraph)
Definition: dec.h:421
Dec_Graph_t * Dec_Factor(char *pSop)
FUNCTION DECLARATIONS ///.
Definition: decFactor.c:55
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static void Dec_GraphFree(Dec_Graph_t *pGraph)
Definition: dec.h:307
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
int Abc_NtkGetLitNum ( Abc_Ntk_t pNtk)

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

Synopsis [Reads the number of literals in the SOPs of the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 165 of file abcUtil.c.

166 {
167  Abc_Obj_t * pNode;
168  int i, nLits = 0;
169  assert( Abc_NtkHasSop(pNtk) );
170  Abc_NtkForEachNode( pNtk, pNode, i )
171  {
172  assert( pNode->pData );
173  nLits += Abc_SopGetLitNum( (char *)pNode->pData );
174  }
175  return nLits;
176 }
static int Abc_NtkHasSop(Abc_Ntk_t *pNtk)
Definition: abc.h:253
ABC_DLL int Abc_SopGetLitNum(char *pSop)
Definition: abcSop.c:511
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
double Abc_NtkGetMappedArea ( Abc_Ntk_t pNtk)

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

Synopsis [Computes the area of the mapped circuit.]

Description []

SideEffects []

SeeAlso []

Definition at line 334 of file abcUtil.c.

335 {
336  Abc_Obj_t * pObj;
337  double TotalArea;
338  int i;
339  assert( Abc_NtkHasMapping(pNtk) );
340  TotalArea = 0.0;
341  Abc_NtkForEachNode( pNtk, pObj, i )
342  {
343  if ( Abc_ObjIsBarBuf(pObj) )
344  continue;
345 // assert( pObj->pData );
346  if ( pObj->pData == NULL )
347  {
348  printf( "Node without mapping is encountered.\n" );
349  continue;
350  }
351  TotalArea += Mio_GateReadArea( (Mio_Gate_t *)pObj->pData );
352  // assuming that twin gates follow each other
353  if ( Abc_NtkFetchTwinNode(pObj) )
354  i++;
355  }
356  return TotalArea;
357 }
static int Abc_ObjIsBarBuf(Abc_Obj_t *pObj)
Definition: abc.h:360
static int Abc_NtkHasMapping(Abc_Ntk_t *pNtk)
Definition: abc.h:256
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
double Mio_GateReadArea(Mio_Gate_t *pGate)
Definition: mioApi.c:145
ABC_DLL Abc_Obj_t * Abc_NtkFetchTwinNode(Abc_Obj_t *pNode)
Definition: abcMap.c:740
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
int Abc_NtkGetMultiRefNum ( Abc_Ntk_t pNtk)

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

Synopsis [Counts the number of nodes with more than 1 reference.]

Description []

SideEffects []

SeeAlso []

Definition at line 218 of file abcUtil.c.

219 {
220  Abc_Obj_t * pNode;
221  int nNodes, i;
222  assert( Abc_NtkIsStrash(pNtk) );
223  nNodes = 0;
224  Abc_NtkForEachNode( pNtk, pNode, i )
225  nNodes += (int)(Abc_ObjFanoutNum(pNode) > 1);
226  return nNodes;
227 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define assert(ex)
Definition: util_old.h:213
int Abc_NtkGetMuxNum ( Abc_Ntk_t pNtk)

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

Synopsis [Counts the number of exors.]

Description []

SideEffects []

SeeAlso []

Definition at line 390 of file abcUtil.c.

391 {
392  Abc_Obj_t * pNode;
393  int i, Counter = 0;
394  Abc_NtkForEachNode( pNtk, pNode, i )
395  Counter += Abc_NodeIsMuxType(pNode);
396  return Counter;
397 }
int Abc_NodeIsMuxType(Abc_Obj_t *pNode)
Definition: abcUtil.c:1301
static int Counter
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
int Abc_NtkGetTotalFanins ( Abc_Ntk_t pNtk)

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

Synopsis [Reads the total number of all fanins.]

Description []

SideEffects []

SeeAlso []

Definition at line 487 of file abcUtil.c.

488 {
489  Abc_Obj_t * pNode;
490  int i, nFanins = 0;
491  Abc_NtkForEachNode( pNtk, pNode, i )
492  nFanins += Abc_ObjFaninNum(pNode);
493  return nFanins;
494 }
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
void Abc_NtkInvertConstraints ( Abc_Ntk_t pNtk)

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

Synopsis [Complements the constraint outputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 2204 of file abcUtil.c.

2205 {
2206  Abc_Obj_t * pObj;
2207  int i;
2208  if ( Abc_NtkConstrNum(pNtk) == 0 )
2209  return;
2210  Abc_NtkForEachPo( pNtk, pObj, i )
2211  {
2212  if ( i >= Abc_NtkPoNum(pNtk) - Abc_NtkConstrNum(pNtk) )
2213  Abc_ObjXorFaninC( pObj, 0 );
2214  }
2215 }
static int Abc_NtkConstrNum(Abc_Ntk_t *pNtk)
Definition: abc.h:299
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
static void Abc_ObjXorFaninC(Abc_Obj_t *pObj, int i)
Definition: abc.h:381
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
int Abc_NtkIsTopo ( Abc_Ntk_t pNtk)

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

Synopsis [Checks if the logic network is in the topological order.]

Description []

SideEffects []

SeeAlso []

Definition at line 2839 of file abcUtil.c.

2840 {
2841  Abc_Obj_t * pObj, * pFanin;
2842  int i, k, Counter = 0;
2843  Abc_NtkIncrementTravId( pNtk );
2844  Abc_NtkForEachCi( pNtk, pObj, i )
2846  Abc_NtkForEachNode( pNtk, pObj, i )
2847  {
2848  // check if fanins are in the topo order
2849  Abc_ObjForEachFanin( pObj, pFanin, k )
2850  if ( !Abc_NodeIsTravIdCurrent(pFanin) )
2851  break;
2852  if ( k != Abc_ObjFaninNum(pObj) )
2853  {
2854  if ( Counter++ == 0 )
2855  printf( "Node %d is out of topo order.\n", Abc_ObjId(pObj) );
2856  }
2858  }
2859  if ( Counter )
2860  printf( "Topological order does not hold for %d internal nodes.\n", Counter );
2861  return (int)(Counter == 0);
2862 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
if(last==0)
Definition: sparse_int.h:34
static int Counter
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
void Abc_NtkLoadCopy ( Abc_Ntk_t pNtk,
Vec_Ptr_t vCopies 
)

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

Synopsis [Loads copy field of the objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 617 of file abcUtil.c.

618 {
619  Abc_Obj_t * pObj;
620  int i;
621  Abc_NtkForEachObj( pNtk, pObj, i )
622  pObj->pCopy = (Abc_Obj_t *)Vec_PtrEntry( vCopies, i );
623 }
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
int Abc_NtkLogicHasSimpleCos ( Abc_Ntk_t pNtk)

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

Synopsis [Returns 1 if COs of a logic network are simple.]

Description [The COs of a logic network are simple under three conditions: (1) The edge from CO to its driver is not complemented. (2) If CI is a driver of a CO, they have the same name.] (3) If two COs share the same driver, they have the same name.]

SideEffects []

SeeAlso []

Definition at line 909 of file abcUtil.c.

910 {
911  Abc_Obj_t * pNode, * pDriver;
912  int i;
913  assert( Abc_NtkIsLogic(pNtk) );
914  Abc_NtkIncrementTravId( pNtk );
915  Abc_NtkForEachCo( pNtk, pNode, i )
916  {
917  // if the driver is complemented, this is an error
918  pDriver = Abc_ObjFanin0(pNode);
919  if ( Abc_ObjFaninC0(pNode) )
920  return 0;
921  // if the driver is a CI and has different name, this is an error
922  if ( Abc_ObjIsCi(pDriver) && strcmp(Abc_ObjName(pDriver), Abc_ObjName(pNode)) )
923  return 0;
924  // if the driver is visited for the first time, remember the CO name
925  if ( !Abc_NodeIsTravIdCurrent(pDriver) )
926  {
927  pDriver->pNext = (Abc_Obj_t *)Abc_ObjName(pNode);
928  Abc_NodeSetTravIdCurrent(pDriver);
929  continue;
930  }
931  // the driver has second CO - if they have different name, this is an error
932  if ( strcmp((char *)pDriver->pNext, Abc_ObjName(pNode)) ) // diff names
933  return 0;
934  }
935  return 1;
936 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
int strcmp()
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
Abc_Obj_t * pNext
Definition: abc.h:131
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
int Abc_NtkLogicMakeSimpleCos ( Abc_Ntk_t pNtk,
int  fDuplicate 
)

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

Synopsis [Transforms the network to have simple COs.]

Description []

SideEffects []

SeeAlso []

Definition at line 1047 of file abcUtil.c.

1048 {
1049  Vec_Ptr_t * vDrivers, * vCoTerms;
1050  Abc_Obj_t * pNode, * pDriver, * pDriverNew, * pFanin;
1051  int i, k, LevelMax, nTotal = 0;
1052  assert( Abc_NtkIsLogic(pNtk) );
1053  LevelMax = Abc_NtkLevel(pNtk);
1054 // Abc_NtkLogicMakeSimpleCosTest( pNtk, fDuplicate );
1055 
1056  // fix constant drivers
1057  Abc_NtkForEachCo( pNtk, pNode, i )
1058  {
1059  pDriver = Abc_ObjFanin0(pNode);
1060  if ( !Abc_NodeIsConst(pDriver) )
1061  continue;
1062  pDriverNew = (Abc_ObjFaninC0(pNode) == Abc_NodeIsConst0(pDriver)) ? Abc_NtkCreateNodeConst1(pNtk) : Abc_NtkCreateNodeConst0(pNtk);
1063  if ( Abc_ObjFaninC0(pNode) )
1064  Abc_ObjXorFaninC( pNode, 0 );
1065  Abc_ObjPatchFanin( pNode, pDriver, pDriverNew );
1066  if ( Abc_ObjFanoutNum(pDriver) == 0 )
1067  Abc_NtkDeleteObj( pDriver );
1068  }
1069 
1070  // collect drivers pointed by complemented edges
1071  vDrivers = Vec_PtrAlloc( 100 );
1072  Abc_NtkIncrementTravId( pNtk );
1073  Abc_NtkForEachCo( pNtk, pNode, i )
1074  {
1075  if ( !Abc_ObjFaninC0(pNode) )
1076  continue;
1077  pDriver = Abc_ObjFanin0(pNode);
1078  if ( Abc_NodeIsTravIdCurrent(pDriver) )
1079  continue;
1080  Abc_NodeSetTravIdCurrent(pDriver);
1081  Vec_PtrPush( vDrivers, pDriver );
1082  }
1083  // fix complemented drivers
1084  if ( Vec_PtrSize(vDrivers) > 0 )
1085  {
1086  int nDupGates = 0, nDupInvs = 0, nDupChange = 0;
1087  Vec_Ptr_t * vFanouts = Vec_PtrAlloc( 100 );
1088  Vec_PtrForEachEntry( Abc_Obj_t *, vDrivers, pDriver, i )
1089  {
1090  int fHasDir = 0, fHasInv = 0, fHasOther = 0;
1091  Abc_ObjForEachFanout( pDriver, pNode, k )
1092  {
1093  if ( !Abc_ObjIsCo(pNode) )
1094  {
1095  assert( !Abc_ObjFaninC0(pNode) );
1096  fHasOther = 1;
1097  continue;
1098  }
1099  if ( Abc_ObjFaninC0(pNode) )
1100  fHasInv = 1;
1101  else //if ( Abc_ObjFaninC0(pNode) )
1102  fHasDir = 1;
1103  }
1104  assert( fHasInv );
1105  if ( Abc_ObjIsCi(pDriver) || fHasDir || (fHasOther && Abc_NtkHasMapping(pNtk)) ) // cannot change
1106  {
1107  // duplicate if critical
1108  if ( fDuplicate && Abc_ObjIsNode(pDriver) && Abc_ObjLevel(pDriver) == LevelMax )
1109  {
1110  pDriverNew = Abc_NtkDupObj( pNtk, pDriver, 0 );
1111  Abc_ObjForEachFanin( pDriver, pFanin, k )
1112  Abc_ObjAddFanin( pDriverNew, pFanin );
1113  Abc_NodeComplement( pDriverNew );
1114  nDupGates++;
1115  }
1116  else // add inverter
1117  {
1118  pDriverNew = Abc_NtkCreateNodeInv( pNtk, pDriver );
1119  nDupInvs++;
1120  }
1121  // collect CO fanouts to be redirected to the new node
1122  Vec_PtrClear( vFanouts );
1123  Abc_ObjForEachFanout( pDriver, pNode, k )
1124  if ( Abc_ObjIsCo(pNode) && Abc_ObjFaninC0(pNode) )
1125  Vec_PtrPush( vFanouts, pNode );
1126  assert( Vec_PtrSize(vFanouts) > 0 );
1127  Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pNode, k )
1128  {
1129  Abc_ObjXorFaninC( pNode, 0 );
1130  Abc_ObjPatchFanin( pNode, pDriver, pDriverNew );
1131  assert( Abc_ObjIsCi(pDriver) || Abc_ObjFanoutNum(pDriver) > 0 );
1132  }
1133  }
1134  else // can change
1135  {
1136  // change polarity of the driver
1137  assert( Abc_ObjIsNode(pDriver) );
1138  Abc_NodeComplement( pDriver );
1139  Abc_ObjForEachFanout( pDriver, pNode, k )
1140  {
1141  if ( Abc_ObjIsCo(pNode) )
1142  {
1143  assert( Abc_ObjFaninC0(pNode) );
1144  Abc_ObjXorFaninC( pNode, 0 );
1145  }
1146  else if ( Abc_ObjIsNode(pNode) )
1147  Abc_NodeComplementInput( pNode, pDriver );
1148  else assert( 0 );
1149  }
1150  nDupChange++;
1151  }
1152  }
1153  Vec_PtrFree( vFanouts );
1154 // printf( "Resolving inverted CO drivers: Invs = %d. Dups = %d. Changes = %d.\n",
1155 // nDupInvs, nDupGates, nDupChange );
1156  nTotal += nDupInvs + nDupGates;
1157  }
1158  Vec_PtrFree( vDrivers );
1159 
1160  // collect COs that needs fixing by adding buffers or duplicating
1161  vCoTerms = Vec_PtrAlloc( 100 );
1162  Abc_NtkIncrementTravId( pNtk );
1163  Abc_NtkForEachCo( pNtk, pNode, i )
1164  {
1165  // if the driver is a CI and has different name, this is an error
1166  pDriver = Abc_ObjFanin0(pNode);
1167  if ( Abc_ObjIsCi(pDriver) && strcmp(Abc_ObjName(pDriver), Abc_ObjName(pNode)) )
1168  {
1169  Vec_PtrPush( vCoTerms, pNode );
1170  continue;
1171  }
1172  // if the driver is visited for the first time, remember the CO name
1173  if ( !Abc_NodeIsTravIdCurrent(pDriver) )
1174  {
1175  pDriver->pNext = (Abc_Obj_t *)Abc_ObjName(pNode);
1176  Abc_NodeSetTravIdCurrent(pDriver);
1177  continue;
1178  }
1179  // the driver has second CO - if they have different name, this is an error
1180  if ( strcmp((char *)pDriver->pNext, Abc_ObjName(pNode)) ) // diff names
1181  {
1182  Vec_PtrPush( vCoTerms, pNode );
1183  continue;
1184  }
1185  }
1186  // fix duplication problem
1187  if ( Vec_PtrSize(vCoTerms) > 0 )
1188  {
1189  int nDupBufs = 0, nDupGates = 0;
1190  Vec_PtrForEachEntry( Abc_Obj_t *, vCoTerms, pNode, i )
1191  {
1192  pDriver = Abc_ObjFanin0(pNode);
1193  // duplicate if critical
1194  if ( fDuplicate && Abc_ObjIsNode(pDriver) && Abc_ObjLevel(pDriver) == LevelMax )
1195  {
1196  pDriverNew = Abc_NtkDupObj( pNtk, pDriver, 0 );
1197  Abc_ObjForEachFanin( pDriver, pFanin, k )
1198  Abc_ObjAddFanin( pDriverNew, pFanin );
1199  nDupGates++;
1200  }
1201  else // add buffer
1202  {
1203  pDriverNew = Abc_NtkCreateNodeBuf( pNtk, pDriver );
1204  nDupBufs++;
1205  }
1206  // swing the PO
1207  Abc_ObjPatchFanin( pNode, pDriver, pDriverNew );
1208  assert( Abc_ObjIsCi(pDriver) || Abc_ObjFanoutNum(pDriver) > 0 );
1209  }
1210 // printf( "Resolving shared CO drivers: Bufs = %d. Dups = %d.\n", nDupBufs, nDupGates );
1211  nTotal += nDupBufs + nDupGates;
1212  }
1213  Vec_PtrFree( vCoTerms );
1214  return nTotal;
1215 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
ABC_DLL int Abc_NodeIsConst(Abc_Obj_t *pNode)
Definition: abcObj.c:843
ABC_DLL int Abc_NodeIsConst0(Abc_Obj_t *pNode)
Definition: abcObj.c:860
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static int Abc_NtkHasMapping(Abc_Ntk_t *pNtk)
Definition: abc.h:256
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition: abcObj.c:337
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
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
int strcmp()
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Definition: abcFanio.c:172
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
Definition: abcObj.c:167
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:662
static int Abc_ObjLevel(Abc_Obj_t *pObj)
Definition: abc.h:330
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:692
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition: abcObj.c:604
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
static void Abc_ObjXorFaninC(Abc_Obj_t *pObj, int i)
Definition: abc.h:381
Abc_Obj_t * pNext
Definition: abc.h:131
#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
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1265
ABC_DLL void Abc_NodeComplement(Abc_Obj_t *pNode)
Definition: abcObj.c:980
int nTotal
DECLARATIONS ///.
Definition: cutTruth.c:37
ABC_DLL void Abc_NodeComplementInput(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
Definition: abcObj.c:1005
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Abc_NtkLogicMakeSimpleCos2 ( Abc_Ntk_t pNtk,
int  fDuplicate 
)

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

Synopsis [Transforms the network to have simple COs.]

Description [The COs of a logic network are simple under three conditions: (1) The edge from CO to its driver is not complemented. (2) If CI is a driver of a CO, they have the same name.] (3) If two COs share the same driver, they have the same name. In some cases, such as FPGA mapping, we prevent the increase in delay by duplicating the driver nodes, rather than adding invs/bufs.]

SideEffects []

SeeAlso []

Definition at line 954 of file abcUtil.c.

955 {
956  Abc_Obj_t * pNode, * pDriver;
957  int i, nDupGates = 0;
958  assert( Abc_NtkIsLogic(pNtk) );
959  Abc_NtkIncrementTravId( pNtk );
960  Abc_NtkForEachCo( pNtk, pNode, i )
961  {
962  // if the driver is complemented, this is an error
963  pDriver = Abc_ObjFanin0(pNode);
964  if ( Abc_ObjFaninC0(pNode) )
965  {
966  Abc_NtkFixCoDriverProblem( pDriver, pNode, fDuplicate );
967  nDupGates++;
968  continue;
969  }
970  // if the driver is a CI and has different name, this is an error
971  if ( Abc_ObjIsCi(pDriver) && strcmp(Abc_ObjName(pDriver), Abc_ObjName(pNode)) )
972  {
973  Abc_NtkFixCoDriverProblem( pDriver, pNode, fDuplicate );
974  nDupGates++;
975  continue;
976  }
977  // if the driver is visited for the first time, remember the CO name
978  if ( !Abc_NodeIsTravIdCurrent(pDriver) )
979  {
980  pDriver->pNext = (Abc_Obj_t *)Abc_ObjName(pNode);
981  Abc_NodeSetTravIdCurrent(pDriver);
982  continue;
983  }
984  // the driver has second CO - if they have different name, this is an error
985  if ( strcmp((char *)pDriver->pNext, Abc_ObjName(pNode)) ) // diff names
986  {
987  Abc_NtkFixCoDriverProblem( pDriver, pNode, fDuplicate );
988  nDupGates++;
989  continue;
990  }
991  }
993  return nDupGates;
994 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
void Abc_NtkFixCoDriverProblem(Abc_Obj_t *pDriver, Abc_Obj_t *pNodeCo, int fDuplicate)
Definition: abcUtil.c:858
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
int strcmp()
int Abc_NtkLogicHasSimpleCos(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:909
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
Abc_Obj_t * pNext
Definition: abc.h:131
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
void Abc_NtkLogicMakeSimpleCosTest ( Abc_Ntk_t pNtk,
int  fDuplicate 
)

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

Synopsis [Transforms the network to have simple COs.]

Description []

SideEffects []

SeeAlso []

Definition at line 1008 of file abcUtil.c.

1009 {
1010  int nObjs = Abc_NtkObjNumMax(pNtk);
1011  unsigned * pType = ABC_CALLOC( unsigned, nObjs );
1012  Abc_Obj_t * pNode;
1013  int i, Counts[4] = {0}, Consts[2] = {0}, Inputs[2] = {0};
1014  // collect info
1015  Abc_NtkForEachCo( pNtk, pNode, i )
1016  {
1017  if ( Abc_ObjFaninId0(pNode) == 0 )
1018  Consts[Abc_ObjFaninC0(pNode)]++;
1019  if ( Abc_ObjIsCi(Abc_ObjFanin0(pNode)) )
1020  Inputs[Abc_ObjFaninC0(pNode)]++;
1021  pType[Abc_ObjFaninId0(pNode)] |= (1 << Abc_ObjFaninC0(pNode));
1022  }
1023  // count the numbers
1024  for ( i = 0; i < nObjs; i++ )
1025  Counts[pType[i]]++;
1026  for ( i = 0; i < 4; i++ )
1027  printf( "%d = %d ", i, Counts[i] );
1028  for ( i = 0; i < 2; i++ )
1029  printf( "c%d = %d ", i, Consts[i] );
1030  for ( i = 0; i < 2; i++ )
1031  printf( "i%d = %d ", i, Inputs[i] );
1032  printf( "\n" );
1033  ABC_FREE( pType );
1034 }
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_ObjFaninId0(Abc_Obj_t *pObj)
Definition: abc.h:367
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
void Abc_NtkOrderCisCos ( Abc_Ntk_t pNtk)

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

Synopsis [Order CI/COs.]

Description []

SideEffects []

SeeAlso []

Definition at line 71 of file abcUtil.c.

72 {
73  Abc_Obj_t * pObj, * pTerm;
74  int i, k;
75  Vec_PtrClear( pNtk->vCis );
76  Vec_PtrClear( pNtk->vCos );
77  Abc_NtkForEachPi( pNtk, pObj, i )
78  Vec_PtrPush( pNtk->vCis, pObj );
79  Abc_NtkForEachPo( pNtk, pObj, i )
80  Vec_PtrPush( pNtk->vCos, pObj );
81  Abc_NtkForEachBox( pNtk, pObj, i )
82  {
83  if ( Abc_ObjIsLatch(pObj) )
84  continue;
85  Abc_ObjForEachFanin( pObj, pTerm, k )
86  Vec_PtrPush( pNtk->vCos, pTerm );
87  Abc_ObjForEachFanout( pObj, pTerm, k )
88  Vec_PtrPush( pNtk->vCis, pTerm );
89  }
90  Abc_NtkForEachBox( pNtk, pObj, i )
91  {
92  if ( !Abc_ObjIsLatch(pObj) )
93  continue;
94  Abc_ObjForEachFanin( pObj, pTerm, k )
95  Vec_PtrPush( pNtk->vCos, pTerm );
96  Abc_ObjForEachFanout( pObj, pTerm, k )
97  Vec_PtrPush( pNtk->vCis, pTerm );
98  }
99 }
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
Vec_Ptr_t * vCis
Definition: abc.h:165
Vec_Ptr_t * vCos
Definition: abc.h:166
#define Abc_NtkForEachBox(pNtk, pObj, i)
Definition: abc.h:495
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
int Abc_NtkPrepareTwoNtks ( FILE *  pErr,
Abc_Ntk_t pNtk,
char **  argv,
int  argc,
Abc_Ntk_t **  ppNtk1,
Abc_Ntk_t **  ppNtk2,
int *  pfDelete1,
int *  pfDelete2 
)

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

Synopsis [Prepares two network for a two-argument command similar to "verify".]

Description []

SideEffects []

SeeAlso []

Definition at line 1481 of file abcUtil.c.

1483 {
1484  int fCheck = 1;
1485  FILE * pFile;
1486  Abc_Ntk_t * pNtk1, * pNtk2, * pNtkTemp;
1487  int util_optind = 0;
1488 
1489  *pfDelete1 = 0;
1490  *pfDelete2 = 0;
1491  if ( argc == util_optind )
1492  { // use the spec
1493  if ( pNtk == NULL )
1494  {
1495  fprintf( pErr, "Empty current network.\n" );
1496  return 0;
1497  }
1498  if ( pNtk->pSpec == NULL )
1499  {
1500  fprintf( pErr, "The external spec is not given.\n" );
1501  return 0;
1502  }
1503  pFile = fopen( pNtk->pSpec, "r" );
1504  if ( pFile == NULL )
1505  {
1506  fprintf( pErr, "Cannot open the external spec file \"%s\".\n", pNtk->pSpec );
1507  return 0;
1508  }
1509  else
1510  fclose( pFile );
1511  pNtk1 = Abc_NtkDup(pNtk);
1512  pNtk2 = Io_Read( pNtk->pSpec, Io_ReadFileType(pNtk->pSpec), fCheck, 0 );
1513  if ( pNtk2 == NULL )
1514  return 0;
1515  *pfDelete1 = 1;
1516  *pfDelete2 = 1;
1517  }
1518  else if ( argc == util_optind + 1 )
1519  {
1520  if ( pNtk == NULL )
1521  {
1522  fprintf( pErr, "Empty current network.\n" );
1523  return 0;
1524  }
1525  pNtk1 = Abc_NtkDup(pNtk);
1526  pNtk2 = Io_Read( argv[util_optind], Io_ReadFileType(argv[util_optind]), fCheck, 0 );
1527  if ( pNtk2 == NULL )
1528  return 0;
1529  *pfDelete1 = 1;
1530  *pfDelete2 = 1;
1531  }
1532  else if ( argc == util_optind + 2 )
1533  {
1534  pNtk1 = Io_Read( argv[util_optind], Io_ReadFileType(argv[util_optind]), fCheck, 0 );
1535  if ( pNtk1 == NULL )
1536  return 0;
1537  pNtk2 = Io_Read( argv[util_optind+1], Io_ReadFileType(argv[util_optind+1]), fCheck, 0 );
1538  if ( pNtk2 == NULL )
1539  {
1540  Abc_NtkDelete( pNtk1 );
1541  return 0;
1542  }
1543  *pfDelete1 = 1;
1544  *pfDelete2 = 1;
1545  }
1546  else
1547  {
1548  fprintf( pErr, "Wrong number of arguments.\n" );
1549  return 0;
1550  }
1551 
1552  // make sure the networks are strashed
1553  if ( !Abc_NtkIsStrash(pNtk1) )
1554  {
1555  pNtkTemp = Abc_NtkStrash( pNtk1, 0, 1, 0 );
1556  if ( *pfDelete1 )
1557  Abc_NtkDelete( pNtk1 );
1558  pNtk1 = pNtkTemp;
1559  *pfDelete1 = 1;
1560  }
1561  if ( !Abc_NtkIsStrash(pNtk2) )
1562  {
1563  pNtkTemp = Abc_NtkStrash( pNtk2, 0, 1, 0 );
1564  if ( *pfDelete2 )
1565  Abc_NtkDelete( pNtk2 );
1566  pNtk2 = pNtkTemp;
1567  *pfDelete2 = 1;
1568  }
1569 
1570  *ppNtk1 = pNtk1;
1571  *ppNtk2 = pNtk2;
1572  return 1;
1573 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
int util_optind
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Definition: abcStrash.c:265
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:419
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
Abc_Ntk_t * Io_Read(char *pFileName, Io_FileType_t FileType, int fCheck, int fBarBufs)
Definition: ioUtil.c:238
Io_FileType_t Io_ReadFileType(char *pFileName)
DECLARATIONS ///.
Definition: ioUtil.c:46
char * pSpec
Definition: abc.h:159
void Abc_NtkPrint256 ( )

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

Synopsis [Prints all 3-var functions.]

Description []

SideEffects []

SeeAlso []

Definition at line 2038 of file abcUtil.c.

2039 {
2040  FILE * pFile;
2041  unsigned i;
2042  pFile = fopen( "4varfs.txt", "w" );
2043  for ( i = 1; i < (1<<16)-1; i++ )
2044  {
2045  fprintf( pFile, "read_truth " );
2046  Extra_PrintBinary( pFile, &i, 16 );
2047  fprintf( pFile, "; clp; st; w 1.blif; map; cec 1.blif\n" );
2048  }
2049  fclose( pFile );
2050 }
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
void Abc_NtkPrintCiLevels ( Abc_Ntk_t pNtk)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 2228 of file abcUtil.c.

2229 {
2230  Abc_Obj_t * pObj;
2231  int i;
2232  Abc_NtkForEachCi( pNtk, pObj, i )
2233  printf( "%c=%d ", 'a'+i, pObj->Level );
2234  printf( "\n" );
2235 }
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
void Abc_NtkReassignIds ( Abc_Ntk_t pNtk)

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

Synopsis [Puts the nodes into the DFS order and reassign their IDs.]

Description []

SideEffects []

SeeAlso []

Definition at line 1769 of file abcUtil.c.

1770 {
1771  Vec_Ptr_t * vNodes;
1772  Vec_Ptr_t * vObjsNew;
1773  Abc_Obj_t * pNode, * pTemp, * pConst1;
1774  int i, k;
1775  assert( Abc_NtkIsStrash(pNtk) );
1776 //printf( "Total = %d. Current = %d.\n", Abc_NtkObjNumMax(pNtk), Abc_NtkObjNum(pNtk) );
1777  // start the array of objects with new IDs
1778  vObjsNew = Vec_PtrAlloc( pNtk->nObjs );
1779  // put constant node first
1780  pConst1 = Abc_AigConst1(pNtk);
1781  assert( pConst1->Id == 0 );
1782  Vec_PtrPush( vObjsNew, pConst1 );
1783  // put PI nodes next
1784  Abc_NtkForEachPi( pNtk, pNode, i )
1785  {
1786  pNode->Id = Vec_PtrSize( vObjsNew );
1787  Vec_PtrPush( vObjsNew, pNode );
1788  }
1789  // put PO nodes next
1790  Abc_NtkForEachPo( pNtk, pNode, i )
1791  {
1792  pNode->Id = Vec_PtrSize( vObjsNew );
1793  Vec_PtrPush( vObjsNew, pNode );
1794  }
1795  // put latches and their inputs/outputs next
1796  Abc_NtkForEachBox( pNtk, pNode, i )
1797  {
1798  pNode->Id = Vec_PtrSize( vObjsNew );
1799  Vec_PtrPush( vObjsNew, pNode );
1800  Abc_ObjForEachFanin( pNode, pTemp, k )
1801  {
1802  pTemp->Id = Vec_PtrSize( vObjsNew );
1803  Vec_PtrPush( vObjsNew, pTemp );
1804  }
1805  Abc_ObjForEachFanout( pNode, pTemp, k )
1806  {
1807  pTemp->Id = Vec_PtrSize( vObjsNew );
1808  Vec_PtrPush( vObjsNew, pTemp );
1809  }
1810  }
1811  // finally, internal nodes in the DFS order
1812  vNodes = Abc_AigDfs( pNtk, 1, 0 );
1813  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
1814  {
1815  if ( pNode == pConst1 )
1816  continue;
1817  pNode->Id = Vec_PtrSize( vObjsNew );
1818  Vec_PtrPush( vObjsNew, pNode );
1819  }
1820  Vec_PtrFree( vNodes );
1821  assert( Vec_PtrSize(vObjsNew) == pNtk->nObjs );
1822 
1823  // update the fanin/fanout arrays
1824  Abc_NtkForEachObj( pNtk, pNode, i )
1825  {
1826  Abc_ObjForEachFanin( pNode, pTemp, k )
1827  pNode->vFanins.pArray[k] = pTemp->Id;
1828  Abc_ObjForEachFanout( pNode, pTemp, k )
1829  pNode->vFanouts.pArray[k] = pTemp->Id;
1830  }
1831 
1832  // replace the array of objs
1833  Vec_PtrFree( pNtk->vObjs );
1834  pNtk->vObjs = vObjsNew;
1835 
1836  // rehash the AIG
1837  Abc_AigRehash( (Abc_Aig_t *)pNtk->pManFunc );
1838 
1839  // update the name manager!!!
1840 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
ABC_DLL void Abc_AigRehash(Abc_Aig_t *pMan)
Definition: abcAig.c:628
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
DECLARATIONS ///.
Definition: abcAig.c:52
int nObjs
Definition: abc.h:172
#define Abc_NtkForEachBox(pNtk, pObj, i)
Definition: abc.h:495
ABC_DLL Vec_Ptr_t * Abc_AigDfs(Abc_Ntk_t *pNtk, int fCollectAll, int fCollectCos)
Definition: abcDfs.c:1014
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
int Id
Definition: abc.h:132
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Abc_NtkReverse_rec ( Abc_Obj_t pObj,
Vec_Int_t vVisited 
)

Definition at line 2633 of file abcUtil.c.

2634 {
2635  Abc_Obj_t * pNext;
2636  int i;
2637  if ( Abc_NodeIsTravIdCurrent( pObj ) )
2638  return;
2639  Abc_NodeSetTravIdCurrent( pObj );
2640  Abc_ObjForEachFanout( pObj, pNext, i )
2641  Abc_NtkReverse_rec( pNext, vVisited );
2642  Vec_IntPush( vVisited, Abc_ObjId(pObj) );
2643 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
void Abc_NtkReverse_rec(Abc_Obj_t *pObj, Vec_Int_t *vVisited)
Definition: abcUtil.c:2633
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
void Abc_NtkReverseTopoOrder ( Abc_Ntk_t p)

Definition at line 2615 of file abcUtil.c.

2616 {
2617  Abc_Obj_t * pObj;
2618  int i;
2619  assert( p->vTopo == NULL );
2620  p->vTopo = Vec_IntAlloc( 10 * Abc_NtkObjNumMax(p) );
2621  Vec_IntFill( p->vTopo, 2 * Abc_NtkObjNumMax(p), 0 );
2622  Abc_NtkForEachNode( p, pObj, i )
2623  {
2624  if ( Abc_NtkTopoHasBeg(pObj) )
2625  continue;
2626  Abc_NtkIncrementTravId( p );
2627  Abc_NtkReverseTopoOrder_rec( pObj, 1 );
2628  }
2629  printf( "Nodes = %d. Size = %d. Ratio = %f.\n",
2631 }
Vec_Int_t * vTopo
Definition: abc.h:213
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static int Abc_NtkTopoHasBeg(Abc_Obj_t *p)
Definition: abcUtil.c:2575
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
#define assert(ex)
Definition: util_old.h:213
void Abc_NtkReverseTopoOrder_rec(Abc_Obj_t *pObj, int fThisIsPivot)
Definition: abcUtil.c:2581
void Abc_NtkReverseTopoOrder_rec ( Abc_Obj_t pObj,
int  fThisIsPivot 
)

Definition at line 2581 of file abcUtil.c.

2582 {
2583  Abc_Obj_t * pNext, * pPivot = NULL;
2584  int i;
2585  if ( Abc_NodeIsTravIdCurrent( pObj ) )
2586  return;
2587  Abc_NodeSetTravIdCurrent( pObj );
2588  if ( Abc_ObjIsPo(pObj) )
2589  {
2590  Vec_IntPush( pObj->pNtk->vTopo, Abc_ObjId(pObj) );
2591  return;
2592  }
2593  assert( Abc_ObjIsNode(pObj) );
2594  // mark begining
2595  if ( fThisIsPivot )
2596  Abc_NtkTopoSetBeg( pObj );
2597  // find fanout without topo
2598  Abc_ObjForEachFanout( pObj, pNext, i )
2599  if ( !Abc_NtkTopoHasBeg(pNext) )
2600  {
2601  assert( !Abc_NtkTopoHasEnd(pNext) );
2602  Abc_NtkReverseTopoOrder_rec( pNext, 1 );
2603  pPivot = pNext;
2604  break;
2605  }
2606  Abc_ObjForEachFanout( pObj, pNext, i )
2607  if ( pNext != pPivot )
2608  Abc_NtkReverseTopoOrder_rec( pNext, 0 );
2609  // mark end
2610  if ( fThisIsPivot )
2611  Abc_NtkTopoSetEnd( pObj );
2612  // save current node
2613  Vec_IntPush( pObj->pNtk->vTopo, Abc_ObjId(pObj) );
2614 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
Vec_Int_t * vTopo
Definition: abc.h:213
static void Abc_NtkTopoSetBeg(Abc_Obj_t *p)
Definition: abcUtil.c:2578
static void Abc_NtkTopoSetEnd(Abc_Obj_t *p)
Definition: abcUtil.c:2579
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
if(last==0)
Definition: sparse_int.h:34
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Abc_NtkTopoHasBeg(Abc_Obj_t *p)
Definition: abcUtil.c:2575
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
Abc_Ntk_t * pNtk
Definition: abc.h:130
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static int Abc_ObjIsPo(Abc_Obj_t *pObj)
Definition: abc.h:348
#define assert(ex)
Definition: util_old.h:213
static int Abc_NtkTopoHasEnd(Abc_Obj_t *p)
Definition: abcUtil.c:2576
void Abc_NtkReverseTopoOrder_rec(Abc_Obj_t *pObj, int fThisIsPivot)
Definition: abcUtil.c:2581
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
void Abc_NtkReverseTopoOrderTest ( Abc_Ntk_t p)

Definition at line 2644 of file abcUtil.c.

2645 {
2646  Vec_Int_t * vVisited;
2647  Abc_Obj_t * pObj;
2648  int i;//, k, iBeg, iEnd;
2649  abctime clk = Abc_Clock();
2651 /*
2652  printf( "Reverse topological order for nodes:\n" );
2653  Abc_NtkForEachNode( p, pObj, i )
2654  {
2655  iBeg = Abc_NtkTopoHasBeg( pObj );
2656  iEnd = Abc_NtkTopoHasEnd( pObj );
2657  printf( "Node %4d : ", Abc_ObjId(pObj) );
2658  for ( k = iEnd - 1; k >= iBeg; k-- )
2659  printf( "%d ", Vec_IntEntry(p->vTopo, k) );
2660  printf( "\n" );
2661  }
2662 */
2663  Vec_IntFreeP( &p->vTopo );
2664  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
2665  // compute regular fanout orders
2666  clk = Abc_Clock();
2667  vVisited = Vec_IntAlloc( 1000 );
2668  Abc_NtkForEachNode( p, pObj, i )
2669  {
2670  Vec_IntClear( vVisited );
2671  Abc_NtkIncrementTravId( p );
2672  Abc_NtkReverse_rec( pObj, vVisited );
2673  }
2674  Vec_IntFree( vVisited );
2675  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
2676 }
Vec_Int_t * vTopo
Definition: abc.h:213
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Abc_NtkReverseTopoOrder(Abc_Ntk_t *p)
Definition: abcUtil.c:2615
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
void Abc_NtkReverse_rec(Abc_Obj_t *pObj, Vec_Int_t *vVisited)
Definition: abcUtil.c:2633
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
ABC_INT64_T abctime
Definition: abc_global.h:278
Vec_Ptr_t* Abc_NtkSaveCopy ( Abc_Ntk_t pNtk)

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

Synopsis [Saves copy field of the objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 595 of file abcUtil.c.

596 {
597  Vec_Ptr_t * vCopies;
598  Abc_Obj_t * pObj;
599  int i;
600  vCopies = Vec_PtrStart( Abc_NtkObjNumMax(pNtk) );
601  Abc_NtkForEachObj( pNtk, pObj, i )
602  Vec_PtrWriteEntry( vCopies, i, pObj->pCopy );
603  return vCopies;
604 }
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
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
Abc_Ntk_t* Abc_NtkSopToCubes ( Abc_Ntk_t pNtk)

Definition at line 2539 of file abcUtil.c.

2540 {
2541  Abc_Ntk_t * pNtkNew;
2542  Abc_Obj_t * pNode;
2543  Vec_Ptr_t * vNodes;
2544  int i;
2545  assert( Abc_NtkIsSopLogic(pNtk) );
2546  Abc_NtkCleanCopy( pNtk );
2547  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
2548  // perform conversion in the topological order
2549  vNodes = Abc_NtkDfs( pNtk, 0 );
2550  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
2551  Abc_NodeSopToCubes( pNode, pNtkNew );
2552  Vec_PtrFree( vNodes );
2553  // make sure everything is okay
2554  Abc_NtkFinalize( pNtk, pNtkNew );
2555  if ( !Abc_NtkCheck( pNtkNew ) )
2556  {
2557  printf( "Abc_NtkSopToCubes: The network check has failed.\n" );
2558  Abc_NtkDelete( pNtkNew );
2559  return NULL;
2560  }
2561  return pNtkNew;
2562 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
static int Abc_NtkIsSopLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:264
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
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
if(last==0)
Definition: sparse_int.h:34
ABC_DLL void Abc_NtkFinalize(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Definition: abcNtk.c:302
void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
void Abc_NodeSopToCubes(Abc_Obj_t *pNodeOld, Abc_Ntk_t *pNtkNew)
Definition: abcUtil.c:2492
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Abc_Ntk_t* Abc_NtkSplitSop ( Abc_Ntk_t pNtk,
int  nCubesMax,
int  fVerbose 
)

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

Synopsis [Checks if the logic network is in the topological order.]

Description []

SideEffects []

SeeAlso []

Definition at line 2765 of file abcUtil.c.

2766 {
2767  Vec_Ptr_t * vNodes;
2768  Abc_Ntk_t * pNtkNew;
2769  Abc_Obj_t * pObj, * pFanin, * pObjNew, * pObjNewRoot;
2770  int i, k, j, nCubes, nCubesThis, nSplits;
2771  char * pSopStr, * pSopStr2, * pTempSop, Symb;
2772  if ( pNtk == NULL )
2773  return NULL;
2774  assert( !Abc_NtkIsStrash(pNtk) && !Abc_NtkIsNetlist(pNtk) );
2775  // start the network
2776  pNtkNew = Abc_NtkStartFrom( pNtk, pNtk->ntkType, pNtk->ntkFunc );
2777  // copy the internal nodes
2778  vNodes = Abc_NtkDfs( pNtk, 0 );
2779  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
2780  {
2781  assert( Abc_ObjIsNode(pObj) );
2782  pObjNewRoot = Abc_NtkDupObj( pNtkNew, pObj, 0 );
2783  nCubes = Abc_SopGetCubeNum( (char *)pObj->pData );
2784  if ( nCubes <= nCubesMax )
2785  {
2786  Abc_ObjForEachFanin( pObj, pFanin, k )
2787  Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
2788  continue;
2789  }
2790  nSplits = (nCubes / nCubesMax) + (int)(nCubes % nCubesMax > 0);
2791  pSopStr = (char *)pObjNewRoot->pData;
2792  pObjNewRoot->pData = Abc_SopCreateOr((Mem_Flex_t *)pNtkNew->pManFunc, nSplits, NULL);
2793  if ( Abc_SopIsComplement(pSopStr) )
2794  {
2795  Abc_SopComplement( pSopStr );
2796  Abc_SopComplement( (char *)pObjNewRoot->pData );
2797  }
2798  pTempSop = (char *)pObj->pData; pObj->pData = (char *)"?";
2799  for ( j = 0; j < nSplits; j++ )
2800  {
2801  // clone the node
2802  pObjNew = Abc_NtkDupObj( pNtkNew, pObj, 0 );
2803  Abc_ObjAddFanin( pObjNewRoot, pObjNew );
2804  // get its cubes
2805  Abc_ObjForEachFanin( pObj, pFanin, k )
2806  Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
2807  // create SOP for this node
2808  nCubesThis = (j < nCubes / nCubesMax) ? nCubesMax : nCubes % nCubesMax;
2809  pSopStr2 = pSopStr + (Abc_ObjFaninNum(pObj) + 3) * nCubesThis;
2810  Symb = *pSopStr2; *pSopStr2 = 0;
2811  pObjNew->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, pSopStr );
2812  *pSopStr2 = Symb;
2813  pSopStr = pSopStr2;
2814  }
2815  // update
2816  pObj->pData = pTempSop;
2817  pObj->pCopy = pObjNewRoot;
2818  }
2819  Vec_PtrFree( vNodes );
2820  Abc_NtkFinalize( pNtk, pNtkNew );
2821  // check correctness
2822  if ( !Abc_NtkCheck( pNtkNew ) )
2823  fprintf( stdout, "Abc_NtkDup(): Network check has failed.\n" );
2824  pNtk->pCopy = pNtkNew;
2825  return pNtkNew;
2826 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
Definition: abcSop.c:489
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition: abcObj.c:337
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:419
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
static void check(int expr)
Definition: satSolver.c:46
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_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
if(last==0)
Definition: sparse_int.h:34
ABC_DLL void Abc_NtkFinalize(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Definition: abcNtk.c:302
ABC_DLL void Abc_SopComplement(char *pSop)
Definition: abcSop.c:600
Abc_NtkFunc_t ntkFunc
Definition: abc.h:157
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_DLL int Abc_SopIsComplement(char *pSop)
Definition: abcSop.c:655
ABC_DLL char * Abc_SopCreateOr(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition: abcSop.c:206
Abc_NtkType_t ntkType
Definition: abc.h:156
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static int Abc_NtkTopoHasBeg ( Abc_Obj_t p)
inlinestatic

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

Synopsis [Creates precomputed reverse topological order for each node.]

Description []

SideEffects []

SeeAlso []

Definition at line 2575 of file abcUtil.c.

2575 { return Vec_IntEntry(p->pNtk->vTopo, 2*Abc_ObjId(p) ); }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
Vec_Int_t * vTopo
Definition: abc.h:213
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
Abc_Ntk_t * pNtk
Definition: abc.h:130
static int Abc_NtkTopoHasEnd ( Abc_Obj_t p)
inlinestatic

Definition at line 2576 of file abcUtil.c.

2576 { return Vec_IntEntry(p->pNtk->vTopo, 2*Abc_ObjId(p)+1); }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
Vec_Int_t * vTopo
Definition: abc.h:213
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
Abc_Ntk_t * pNtk
Definition: abc.h:130
static void Abc_NtkTopoSetBeg ( Abc_Obj_t p)
inlinestatic

Definition at line 2578 of file abcUtil.c.

static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
Vec_Int_t * vTopo
Definition: abc.h:213
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
Abc_Ntk_t * pNtk
Definition: abc.h:130
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static void Abc_NtkTopoSetEnd ( Abc_Obj_t p)
inlinestatic

Definition at line 2579 of file abcUtil.c.

2579 { Vec_IntWriteEntry(p->pNtk->vTopo, 2*Abc_ObjId(p)+1, Vec_IntSize(p->pNtk->vTopo)); }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
Vec_Int_t * vTopo
Definition: abc.h:213
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
Abc_Ntk_t * pNtk
Definition: abc.h:130
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
void Abc_NtkTransferCopy ( Abc_Ntk_t pNtk)

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

Synopsis [Adjusts the copy pointers.]

Description [This procedure assumes that the network was transformed into another network, which was in turn transformed into yet another network. It makes the pCopy pointers of the original network point to the objects of the yet another network.]

SideEffects []

SeeAlso []

Definition at line 1922 of file abcUtil.c.

1923 {
1924  Abc_Obj_t * pObj;
1925  int i;
1926  Abc_NtkForEachObj( pNtk, pObj, i )
1927  if ( !Abc_ObjIsNet(pObj) )
1928  pObj->pCopy = pObj->pCopy? Abc_ObjCopyCond(pObj->pCopy) : NULL;
1929 }
static Abc_Obj_t * Abc_ObjCopyCond(Abc_Obj_t *pObj)
Definition: abc.h:338
if(last==0)
Definition: sparse_int.h:34
static int Abc_ObjIsNet(Abc_Obj_t *pObj)
Definition: abc.h:354
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkTransferPhases ( Abc_Ntk_t pNtkNew,
Abc_Ntk_t pNtk 
)

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

Synopsis [Transfers phase information to the new network.]

Description []

SideEffects []

SeeAlso []

Definition at line 2875 of file abcUtil.c.

2876 {
2877  Abc_Obj_t * pObj;
2878  int i;
2879  assert( pNtk->vPhases != NULL );
2880  assert( Vec_IntSize(pNtk->vPhases) == Abc_NtkObjNumMax(pNtk) );
2881  assert( pNtkNew->vPhases == NULL );
2882  pNtkNew->vPhases = Vec_IntStart( Abc_NtkObjNumMax(pNtkNew) );
2883  Abc_NtkForEachObj( pNtk, pObj, i )
2884  if ( pObj->pCopy && !Abc_ObjIsNone( (Abc_Obj_t *)pObj->pCopy ) )
2885  Vec_IntWriteEntry( pNtkNew->vPhases, Abc_ObjId( (Abc_Obj_t *)pObj->pCopy ), Vec_IntEntry(pNtk->vPhases, i) );
2886 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static int Abc_ObjIsNone(Abc_Obj_t *pObj)
Definition: abc.h:346
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
if(last==0)
Definition: sparse_int.h:34
Vec_Int_t * vPhases
Definition: abc.h:208
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
static int Abc_ObjCrossCutInc ( Abc_Obj_t pObj)
inlinestatic

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

Synopsis [Increaments the cut counter.]

Description [Returns 1 if it becomes equal to the ref counter.]

SideEffects []

SeeAlso []

Definition at line 1943 of file abcUtil.c.

1944 {
1945 // pObj->pCopy = (void *)(((int)pObj->pCopy)++);
1946  int Value = (int)(ABC_PTRINT_T)pObj->pCopy;
1947  pObj->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)(Value + 1);
1948  return (int)(ABC_PTRINT_T)pObj->pCopy == Abc_ObjFanoutNum(pObj);
1949 }
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
Abc_Obj_t * pCopy
Definition: abc.h:148
int Abc_ObjPointerCompare ( void **  pp1,
void **  pp2 
)

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

Synopsis [Compares the pointers.]

Description []

SideEffects []

SeeAlso []

Definition at line 1899 of file abcUtil.c.

1900 {
1901  if ( *pp1 < *pp2 )
1902  return -1;
1903  if ( *pp1 > *pp2 )
1904  return 1;
1905  return 0;
1906 }
void Abc_VecObjPushUniqueOrderByLevel ( Vec_Ptr_t p,
Abc_Obj_t pNode 
)

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

Synopsis [Inserts a new node in the order by levels.]

Description []

SideEffects []

SeeAlso []

Definition at line 1228 of file abcUtil.c.

1229 {
1230  Abc_Obj_t * pNode1, * pNode2;
1231  int i;
1232  if ( Vec_PtrPushUnique(p, pNode) )
1233  return;
1234  // find the p of the node
1235  for ( i = p->nSize-1; i > 0; i-- )
1236  {
1237  pNode1 = (Abc_Obj_t *)p->pArray[i ];
1238  pNode2 = (Abc_Obj_t *)p->pArray[i-1];
1239  if ( Abc_ObjRegular(pNode1)->Level <= Abc_ObjRegular(pNode2)->Level )
1240  break;
1241  p->pArray[i ] = pNode2;
1242  p->pArray[i-1] = pNode1;
1243  }
1244 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_PtrPushUnique(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:656
unsigned Level
Definition: abc.h:142
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323

Variable Documentation

int* pSupps
static

Definition at line 2053 of file abcUtil.c.