src/base/abc/abc.h File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <time.h>
#include "cuddInt.h"
#include "hop.h"
#include "extra.h"
#include "vec.h"
#include "stmm.h"
#include "nm.h"
Include dependency graph for abc.h:

Go to the source code of this file.

Data Structures

struct  Abc_Time_t_
struct  Abc_Obj_t_
struct  Abc_Ntk_t_
struct  Abc_Lib_t_

Defines

#define bool   int
#define ABC_MIN(a, b)   (((a) < (b))? (a) : (b))
#define ABC_MAX(a, b)   (((a) > (b))? (a) : (b))
#define ABC_ABS(a)   (((a) >= 0)? (a) :-(a))
#define ABC_INFINITY   (100000000)
#define PRT(a, t)   printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))
#define Abc_NtkForEachObj(pNtk, pObj, i)
#define Abc_NtkForEachNet(pNtk, pNet, i)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define Abc_NtkForEachGate(pNtk, pNode, i)
#define Abc_AigForEachAnd(pNtk, pNode, i)
#define Abc_NtkForEachBox(pNtk, pObj, i)   for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)) && (((pObj) = Abc_NtkBox(pNtk, i)), 1); i++ )
#define Abc_NtkForEachLatch(pNtk, pObj, i)
#define Abc_NtkForEachLatchInput(pNtk, pObj, i)
#define Abc_NtkForEachLatchOutput(pNtk, pObj, i)
#define Abc_NtkForEachWhitebox(pNtk, pObj, i)
#define Abc_NtkForEachBlackbox(pNtk, pObj, i)
#define Abc_NtkForEachPi(pNtk, pPi, i)   for ( i = 0; (i < Abc_NtkPiNum(pNtk)) && (((pPi) = Abc_NtkPi(pNtk, i)), 1); i++ )
#define Abc_NtkForEachCi(pNtk, pCi, i)   for ( i = 0; (i < Abc_NtkCiNum(pNtk)) && (((pCi) = Abc_NtkCi(pNtk, i)), 1); i++ )
#define Abc_NtkForEachPo(pNtk, pPo, i)   for ( i = 0; (i < Abc_NtkPoNum(pNtk)) && (((pPo) = Abc_NtkPo(pNtk, i)), 1); i++ )
#define Abc_NtkForEachCo(pNtk, pCo, i)   for ( i = 0; (i < Abc_NtkCoNum(pNtk)) && (((pCo) = Abc_NtkCo(pNtk, i)), 1); i++ )
#define Abc_NtkForEachAssert(pNtk, pObj, i)   for ( i = 0; (i < Vec_PtrSize((pNtk)->vAsserts)) && (((pObj) = Abc_NtkAssert(pNtk, i)), 1); i++ )
#define Abc_ObjForEachFanin(pObj, pFanin, i)   for ( i = 0; (i < Abc_ObjFaninNum(pObj)) && (((pFanin) = Abc_ObjFanin(pObj, i)), 1); i++ )
#define Abc_ObjForEachFanout(pObj, pFanout, i)   for ( i = 0; (i < Abc_ObjFanoutNum(pObj)) && (((pFanout) = Abc_ObjFanout(pObj, i)), 1); i++ )
#define Abc_SopForEachCube(pSop, nFanins, pCube)   for ( pCube = (pSop); *pCube; pCube += (nFanins) + 3 )
#define Abc_CubeForEachVar(pCube, Value, i)   for ( i = 0; (pCube[i] != ' ') && (Value = pCube[i]); i++ )

Typedefs

typedef long long sint64
typedef struct Abc_Lib_t_ Abc_Lib_t
typedef struct Abc_Ntk_t_ Abc_Ntk_t
typedef struct Abc_Obj_t_ Abc_Obj_t
typedef struct Abc_Aig_t_ Abc_Aig_t
typedef struct Abc_ManTime_t_ Abc_ManTime_t
typedef struct Abc_ManCut_t_ Abc_ManCut_t
typedef struct Abc_Time_t_ Abc_Time_t

Enumerations

enum  Abc_NtkType_t {
  ABC_NTK_NONE = 0, ABC_NTK_NETLIST, ABC_NTK_LOGIC, ABC_NTK_STRASH,
  ABC_NTK_OTHER
}
enum  Abc_NtkFunc_t {
  ABC_FUNC_NONE = 0, ABC_FUNC_SOP, ABC_FUNC_BDD, ABC_FUNC_AIG,
  ABC_FUNC_MAP, ABC_FUNC_BLIFMV, ABC_FUNC_BLACKBOX, ABC_FUNC_OTHER
}
enum  Abc_ObjType_t {
  ABC_OBJ_NONE = 0, ABC_OBJ_CONST1, ABC_OBJ_PIO, ABC_OBJ_PI,
  ABC_OBJ_PO, ABC_OBJ_BI, ABC_OBJ_BO, ABC_OBJ_ASSERT,
  ABC_OBJ_NET, ABC_OBJ_NODE, ABC_OBJ_LATCH, ABC_OBJ_WHITEBOX,
  ABC_OBJ_BLACKBOX, ABC_OBJ_NUMBER
}
enum  Abc_InitType_t {
  ABC_INIT_NONE = 0, ABC_INIT_ZERO, ABC_INIT_ONE, ABC_INIT_DC,
  ABC_INIT_OTHER
}

Functions

static int Abc_Float2Int (float Val)
static float Abc_Int2Float (int Num)
static int Abc_BitWordNum (int nBits)
static int Abc_TruthWordNum (int nVars)
static int Abc_InfoHasBit (unsigned *p, int i)
static void Abc_InfoSetBit (unsigned *p, int i)
static void Abc_InfoXorBit (unsigned *p, int i)
static unsigned Abc_InfoRandomWord ()
static void Abc_InfoRandom (unsigned *p, int nWords)
static void Abc_InfoClear (unsigned *p, int nWords)
static void Abc_InfoFill (unsigned *p, int nWords)
static void Abc_InfoNot (unsigned *p, int nWords)
static int Abc_InfoIsZero (unsigned *p, int nWords)
static int Abc_InfoIsOne (unsigned *p, int nWords)
static void Abc_InfoCopy (unsigned *p, unsigned *q, int nWords)
static void Abc_InfoAnd (unsigned *p, unsigned *q, int nWords)
static void Abc_InfoOr (unsigned *p, unsigned *q, int nWords)
static void Abc_InfoXor (unsigned *p, unsigned *q, int nWords)
static int Abc_InfoIsOrOne (unsigned *p, unsigned *q, int nWords)
static int Abc_InfoIsOrOne3 (unsigned *p, unsigned *q, unsigned *r, int nWords)
static bool Abc_NtkIsNetlist (Abc_Ntk_t *pNtk)
static bool Abc_NtkIsLogic (Abc_Ntk_t *pNtk)
static bool Abc_NtkIsStrash (Abc_Ntk_t *pNtk)
static bool Abc_NtkHasSop (Abc_Ntk_t *pNtk)
static bool Abc_NtkHasBdd (Abc_Ntk_t *pNtk)
static bool Abc_NtkHasAig (Abc_Ntk_t *pNtk)
static bool Abc_NtkHasMapping (Abc_Ntk_t *pNtk)
static bool Abc_NtkHasBlifMv (Abc_Ntk_t *pNtk)
static bool Abc_NtkHasBlackbox (Abc_Ntk_t *pNtk)
static bool Abc_NtkIsSopNetlist (Abc_Ntk_t *pNtk)
static bool Abc_NtkIsAigNetlist (Abc_Ntk_t *pNtk)
static bool Abc_NtkIsMappedNetlist (Abc_Ntk_t *pNtk)
static bool Abc_NtkIsBlifMvNetlist (Abc_Ntk_t *pNtk)
static bool Abc_NtkIsSopLogic (Abc_Ntk_t *pNtk)
static bool Abc_NtkIsBddLogic (Abc_Ntk_t *pNtk)
static bool Abc_NtkIsAigLogic (Abc_Ntk_t *pNtk)
static bool Abc_NtkIsMappedLogic (Abc_Ntk_t *pNtk)
static char * Abc_NtkName (Abc_Ntk_t *pNtk)
static char * Abc_NtkSpec (Abc_Ntk_t *pNtk)
static int Abc_NtkTravId (Abc_Ntk_t *pNtk)
static Abc_Ntk_tAbc_NtkExdc (Abc_Ntk_t *pNtk)
static Abc_Ntk_tAbc_NtkBackup (Abc_Ntk_t *pNtk)
static int Abc_NtkStep (Abc_Ntk_t *pNtk)
static void Abc_NtkSetName (Abc_Ntk_t *pNtk, char *pName)
static void Abc_NtkSetSpec (Abc_Ntk_t *pNtk, char *pName)
static void Abc_NtkSetBackup (Abc_Ntk_t *pNtk, Abc_Ntk_t *pNetBackup)
static void Abc_NtkSetStep (Abc_Ntk_t *pNtk, int iStep)
static int Abc_NtkObjNum (Abc_Ntk_t *pNtk)
static int Abc_NtkObjNumMax (Abc_Ntk_t *pNtk)
static int Abc_NtkPiNum (Abc_Ntk_t *pNtk)
static int Abc_NtkPoNum (Abc_Ntk_t *pNtk)
static int Abc_NtkCiNum (Abc_Ntk_t *pNtk)
static int Abc_NtkCoNum (Abc_Ntk_t *pNtk)
static int Abc_NtkAssertNum (Abc_Ntk_t *pNtk)
static int Abc_NtkBoxNum (Abc_Ntk_t *pNtk)
static int Abc_NtkBiNum (Abc_Ntk_t *pNtk)
static int Abc_NtkBoNum (Abc_Ntk_t *pNtk)
static int Abc_NtkNetNum (Abc_Ntk_t *pNtk)
static int Abc_NtkNodeNum (Abc_Ntk_t *pNtk)
static int Abc_NtkLatchNum (Abc_Ntk_t *pNtk)
static int Abc_NtkWhiteboxNum (Abc_Ntk_t *pNtk)
static int Abc_NtkBlackboxNum (Abc_Ntk_t *pNtk)
static bool Abc_NtkIsComb (Abc_Ntk_t *pNtk)
static bool Abc_NtkHasOnlyLatchBoxes (Abc_Ntk_t *pNtk)
Abc_Obj_tAbc_NtkCreateObj (Abc_Ntk_t *pNtk, Abc_ObjType_t Type)
static Abc_Obj_tAbc_NtkCreatePi (Abc_Ntk_t *pNtk)
static Abc_Obj_tAbc_NtkCreatePo (Abc_Ntk_t *pNtk)
static Abc_Obj_tAbc_NtkCreateBi (Abc_Ntk_t *pNtk)
static Abc_Obj_tAbc_NtkCreateBo (Abc_Ntk_t *pNtk)
static Abc_Obj_tAbc_NtkCreateAssert (Abc_Ntk_t *pNtk)
static Abc_Obj_tAbc_NtkCreateNet (Abc_Ntk_t *pNtk)
static Abc_Obj_tAbc_NtkCreateNode (Abc_Ntk_t *pNtk)
static Abc_Obj_tAbc_NtkCreateLatch (Abc_Ntk_t *pNtk)
static Abc_Obj_tAbc_NtkCreateWhitebox (Abc_Ntk_t *pNtk)
static Abc_Obj_tAbc_NtkCreateBlackbox (Abc_Ntk_t *pNtk)
static Abc_Obj_tAbc_NtkObj (Abc_Ntk_t *pNtk, int i)
static Abc_Obj_tAbc_NtkPi (Abc_Ntk_t *pNtk, int i)
static Abc_Obj_tAbc_NtkPo (Abc_Ntk_t *pNtk, int i)
static Abc_Obj_tAbc_NtkCi (Abc_Ntk_t *pNtk, int i)
static Abc_Obj_tAbc_NtkCo (Abc_Ntk_t *pNtk, int i)
static Abc_Obj_tAbc_NtkAssert (Abc_Ntk_t *pNtk, int i)
static Abc_Obj_tAbc_NtkBox (Abc_Ntk_t *pNtk, int i)
static bool Abc_ObjIsComplement (Abc_Obj_t *p)
static Abc_Obj_tAbc_ObjRegular (Abc_Obj_t *p)
static Abc_Obj_tAbc_ObjNot (Abc_Obj_t *p)
static Abc_Obj_tAbc_ObjNotCond (Abc_Obj_t *p, int c)
static unsigned Abc_ObjType (Abc_Obj_t *pObj)
static unsigned Abc_ObjId (Abc_Obj_t *pObj)
static int Abc_ObjTravId (Abc_Obj_t *pObj)
static int Abc_ObjLevel (Abc_Obj_t *pObj)
static Vec_Int_tAbc_ObjFaninVec (Abc_Obj_t *pObj)
static Vec_Int_tAbc_ObjFanoutVec (Abc_Obj_t *pObj)
static Abc_Obj_tAbc_ObjCopy (Abc_Obj_t *pObj)
static Abc_Ntk_tAbc_ObjNtk (Abc_Obj_t *pObj)
static void * Abc_ObjData (Abc_Obj_t *pObj)
static Hop_Obj_tAbc_ObjEquiv (Abc_Obj_t *pObj)
static Abc_Obj_tAbc_ObjCopyCond (Abc_Obj_t *pObj)
static void Abc_ObjSetLevel (Abc_Obj_t *pObj, int Level)
static void Abc_ObjSetCopy (Abc_Obj_t *pObj, Abc_Obj_t *pCopy)
static void Abc_ObjSetData (Abc_Obj_t *pObj, void *pData)
static bool Abc_ObjIsPio (Abc_Obj_t *pObj)
static bool Abc_ObjIsPi (Abc_Obj_t *pObj)
static bool Abc_ObjIsPo (Abc_Obj_t *pObj)
static bool Abc_ObjIsBi (Abc_Obj_t *pObj)
static bool Abc_ObjIsBo (Abc_Obj_t *pObj)
static bool Abc_ObjIsAssert (Abc_Obj_t *pObj)
static bool Abc_ObjIsCi (Abc_Obj_t *pObj)
static bool Abc_ObjIsCo (Abc_Obj_t *pObj)
static bool Abc_ObjIsTerm (Abc_Obj_t *pObj)
static bool Abc_ObjIsNet (Abc_Obj_t *pObj)
static bool Abc_ObjIsNode (Abc_Obj_t *pObj)
static bool Abc_ObjIsLatch (Abc_Obj_t *pObj)
static bool Abc_ObjIsBox (Abc_Obj_t *pObj)
static bool Abc_ObjIsWhitebox (Abc_Obj_t *pObj)
static bool Abc_ObjIsBlackbox (Abc_Obj_t *pObj)
static void Abc_ObjBlackboxToWhitebox (Abc_Obj_t *pObj)
static int Abc_ObjFaninNum (Abc_Obj_t *pObj)
static int Abc_ObjFanoutNum (Abc_Obj_t *pObj)
static int Abc_ObjFaninId (Abc_Obj_t *pObj, int i)
static int Abc_ObjFaninId0 (Abc_Obj_t *pObj)
static int Abc_ObjFaninId1 (Abc_Obj_t *pObj)
static int Abc_ObjFanoutEdgeNum (Abc_Obj_t *pObj, Abc_Obj_t *pFanout)
static Abc_Obj_tAbc_ObjFanout (Abc_Obj_t *pObj, int i)
static Abc_Obj_tAbc_ObjFanout0 (Abc_Obj_t *pObj)
static Abc_Obj_tAbc_ObjFanin (Abc_Obj_t *pObj, int i)
static Abc_Obj_tAbc_ObjFanin0 (Abc_Obj_t *pObj)
static Abc_Obj_tAbc_ObjFanin1 (Abc_Obj_t *pObj)
static Abc_Obj_tAbc_ObjFanin0Ntk (Abc_Obj_t *pObj)
static Abc_Obj_tAbc_ObjFanout0Ntk (Abc_Obj_t *pObj)
static bool Abc_ObjFaninC0 (Abc_Obj_t *pObj)
static bool Abc_ObjFaninC1 (Abc_Obj_t *pObj)
static bool Abc_ObjFaninC (Abc_Obj_t *pObj, int i)
static void Abc_ObjSetFaninC (Abc_Obj_t *pObj, int i)
static void Abc_ObjXorFaninC (Abc_Obj_t *pObj, int i)
static Abc_Obj_tAbc_ObjChild (Abc_Obj_t *pObj, int i)
static Abc_Obj_tAbc_ObjChild0 (Abc_Obj_t *pObj)
static Abc_Obj_tAbc_ObjChild1 (Abc_Obj_t *pObj)
static Abc_Obj_tAbc_ObjChildCopy (Abc_Obj_t *pObj, int i)
static Abc_Obj_tAbc_ObjChild0Copy (Abc_Obj_t *pObj)
static Abc_Obj_tAbc_ObjChild1Copy (Abc_Obj_t *pObj)
static Abc_Obj_tAbc_ObjChild0Data (Abc_Obj_t *pObj)
static Abc_Obj_tAbc_ObjChild1Data (Abc_Obj_t *pObj)
static Hop_Obj_tAbc_ObjChild0Equiv (Abc_Obj_t *pObj)
static Hop_Obj_tAbc_ObjChild1Equiv (Abc_Obj_t *pObj)
static bool Abc_AigNodeIsConst (Abc_Obj_t *pNode)
static bool Abc_AigNodeIsAnd (Abc_Obj_t *pNode)
static bool Abc_AigNodeIsChoice (Abc_Obj_t *pNode)
static int Abc_NodeIsPersistant (Abc_Obj_t *pNode)
static void Abc_NodeSetPersistant (Abc_Obj_t *pNode)
static void Abc_NodeClearPersistant (Abc_Obj_t *pNode)
static void Abc_NodeSetTravId (Abc_Obj_t *pNode, int TravId)
static void Abc_NodeSetTravIdCurrent (Abc_Obj_t *pNode)
static void Abc_NodeSetTravIdPrevious (Abc_Obj_t *pNode)
static bool Abc_NodeIsTravIdCurrent (Abc_Obj_t *pNode)
static bool Abc_NodeIsTravIdPrevious (Abc_Obj_t *pNode)
static void Abc_LatchSetInitNone (Abc_Obj_t *pLatch)
static void Abc_LatchSetInit0 (Abc_Obj_t *pLatch)
static void Abc_LatchSetInit1 (Abc_Obj_t *pLatch)
static void Abc_LatchSetInitDc (Abc_Obj_t *pLatch)
static bool Abc_LatchIsInitNone (Abc_Obj_t *pLatch)
static bool Abc_LatchIsInit0 (Abc_Obj_t *pLatch)
static bool Abc_LatchIsInit1 (Abc_Obj_t *pLatch)
static bool Abc_LatchIsInitDc (Abc_Obj_t *pLatch)
static int Abc_LatchInit (Abc_Obj_t *pLatch)
static void * Abc_NtkGlobalBdd (Abc_Ntk_t *pNtk)
static DdManagerAbc_NtkGlobalBddMan (Abc_Ntk_t *pNtk)
static DdNode ** Abc_NtkGlobalBddArray (Abc_Ntk_t *pNtk)
static DdNodeAbc_ObjGlobalBdd (Abc_Obj_t *pObj)
static void Abc_ObjSetGlobalBdd (Abc_Obj_t *pObj, DdNode *bF)
static void * Abc_NtkMvVar (Abc_Ntk_t *pNtk)
static void * Abc_NtkMvVarMan (Abc_Ntk_t *pNtk)
static void * Abc_ObjMvVar (Abc_Obj_t *pObj)
static int Abc_ObjMvVarNum (Abc_Obj_t *pObj)
static void Abc_ObjSetMvVar (Abc_Obj_t *pObj, void *pV)
Abc_Aig_tAbc_AigAlloc (Abc_Ntk_t *pNtk)
void Abc_AigFree (Abc_Aig_t *pMan)
int Abc_AigCleanup (Abc_Aig_t *pMan)
bool Abc_AigCheck (Abc_Aig_t *pMan)
int Abc_AigLevel (Abc_Ntk_t *pNtk)
Abc_Obj_tAbc_AigConst1 (Abc_Ntk_t *pNtk)
Abc_Obj_tAbc_AigAnd (Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Abc_Obj_tAbc_AigAndLookup (Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Abc_Obj_tAbc_AigXorLookup (Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1, int *pType)
Abc_Obj_tAbc_AigMuxLookup (Abc_Aig_t *pMan, Abc_Obj_t *pC, Abc_Obj_t *pT, Abc_Obj_t *pE, int *pType)
Abc_Obj_tAbc_AigOr (Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Abc_Obj_tAbc_AigXor (Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Abc_Obj_tAbc_AigMiter (Abc_Aig_t *pMan, Vec_Ptr_t *vPairs)
void Abc_AigReplace (Abc_Aig_t *pMan, Abc_Obj_t *pOld, Abc_Obj_t *pNew, bool fUpdateLevel)
void Abc_AigDeleteNode (Abc_Aig_t *pMan, Abc_Obj_t *pOld)
void Abc_AigRehash (Abc_Aig_t *pMan)
bool Abc_AigNodeHasComplFanoutEdge (Abc_Obj_t *pNode)
bool Abc_AigNodeHasComplFanoutEdgeTrav (Abc_Obj_t *pNode)
void Abc_AigPrintNode (Abc_Obj_t *pNode)
bool Abc_AigNodeIsAcyclic (Abc_Obj_t *pNode, Abc_Obj_t *pRoot)
void Abc_AigCheckFaninOrder (Abc_Aig_t *pMan)
void Abc_AigSetNodePhases (Abc_Ntk_t *pNtk)
Vec_Ptr_tAbc_AigUpdateStart (Abc_Aig_t *pMan, Vec_Ptr_t **pvUpdatedNets)
void Abc_AigUpdateStop (Abc_Aig_t *pMan)
void Abc_AigUpdateReset (Abc_Aig_t *pMan)
int Abc_NtkAttach (Abc_Ntk_t *pNtk)
void Abc_NtkStartMvVars (Abc_Ntk_t *pNtk)
void Abc_NtkFreeMvVars (Abc_Ntk_t *pNtk)
void Abc_NtkSetMvVarValues (Abc_Obj_t *pObj, int nValues)
Abc_Ntk_tAbc_NtkStrashBlifMv (Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_NtkInsertBlifMv (Abc_Ntk_t *pNtkBase, Abc_Ntk_t *pNtkLogic)
int Abc_NtkConvertToBlifMv (Abc_Ntk_t *pNtk)
char * Abc_NodeConvertSopToMvSop (int nVars, Vec_Int_t *vSop0, Vec_Int_t *vSop1)
int Abc_NodeEvalMvCost (int nVars, Vec_Int_t *vSop0, Vec_Int_t *vSop1)
Abc_Ntk_tAbc_NtkBalance (Abc_Ntk_t *pNtk, bool fDuplicate, bool fSelective, bool fUpdateLevel)
bool Abc_NtkCheck (Abc_Ntk_t *pNtk)
bool Abc_NtkCheckRead (Abc_Ntk_t *pNtk)
bool Abc_NtkDoCheck (Abc_Ntk_t *pNtk)
bool Abc_NtkCheckObj (Abc_Ntk_t *pNtk, Abc_Obj_t *pObj)
bool Abc_NtkCompareSignals (Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int fOnlyPis, int fComb)
int Abc_NtkIsAcyclicHierarchy (Abc_Ntk_t *pNtk)
int Abc_NtkCheckUniqueCiNames (Abc_Ntk_t *pNtk)
int Abc_NtkCheckUniqueCoNames (Abc_Ntk_t *pNtk)
int Abc_NtkCheckUniqueCioNames (Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_NtkCollapse (Abc_Ntk_t *pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fVerbose)
void * Abc_NodeGetCutsRecursive (void *p, Abc_Obj_t *pObj, int fDag, int fTree)
void * Abc_NodeGetCuts (void *p, Abc_Obj_t *pObj, int fDag, int fTree)
void Abc_NodeGetCutsSeq (void *p, Abc_Obj_t *pObj, int fFirst)
void * Abc_NodeReadCuts (void *p, Abc_Obj_t *pObj)
void Abc_NodeFreeCuts (void *p, Abc_Obj_t *pObj)
Vec_Ptr_tAbc_NtkDfs (Abc_Ntk_t *pNtk, int fCollectAll)
Vec_Ptr_tAbc_NtkDfsNodes (Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Vec_Ptr_tAbc_NtkDfsReverse (Abc_Ntk_t *pNtk)
Vec_Ptr_tAbc_NtkDfsReverseNodes (Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Vec_Ptr_tAbc_NtkDfsReverseNodesContained (Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Vec_Ptr_tAbc_NtkDfsSeq (Abc_Ntk_t *pNtk)
Vec_Ptr_tAbc_NtkDfsSeqReverse (Abc_Ntk_t *pNtk)
Vec_Ptr_tAbc_NtkDfsIter (Abc_Ntk_t *pNtk, int fCollectAll)
Vec_Ptr_tAbc_NtkDfsHie (Abc_Ntk_t *pNtk, int fCollectAll)
bool Abc_NtkIsDfsOrdered (Abc_Ntk_t *pNtk)
Vec_Ptr_tAbc_NtkSupport (Abc_Ntk_t *pNtk)
Vec_Ptr_tAbc_NtkNodeSupport (Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Vec_Ptr_tAbc_AigDfs (Abc_Ntk_t *pNtk, int fCollectAll, int fCollectCos)
Vec_Vec_tAbc_DfsLevelized (Abc_Obj_t *pNode, bool fTfi)
int Abc_NtkLevel (Abc_Ntk_t *pNtk)
int Abc_NtkLevelReverse (Abc_Ntk_t *pNtk)
bool Abc_NtkIsAcyclic (Abc_Ntk_t *pNtk)
Vec_Ptr_tAbc_AigGetLevelizedOrder (Abc_Ntk_t *pNtk, int fCollectCis)
void Abc_ObjAddFanin (Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
void Abc_ObjDeleteFanin (Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
void Abc_ObjRemoveFanins (Abc_Obj_t *pObj)
void Abc_ObjPatchFanin (Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Abc_Obj_tAbc_ObjInsertBetween (Abc_Obj_t *pNodeIn, Abc_Obj_t *pNodeOut, Abc_ObjType_t Type)
void Abc_ObjTransferFanout (Abc_Obj_t *pObjOld, Abc_Obj_t *pObjNew)
void Abc_ObjReplace (Abc_Obj_t *pObjOld, Abc_Obj_t *pObjNew)
int Abc_ObjFanoutFaninNum (Abc_Obj_t *pFanout, Abc_Obj_t *pFanin)
Abc_Ntk_tAbc_NtkFraig (Abc_Ntk_t *pNtk, void *pParams, int fAllNodes, int fExdc)
void * Abc_NtkToFraig (Abc_Ntk_t *pNtk, void *pParams, int fAllNodes, int fExdc)
Abc_Ntk_tAbc_NtkFraigTrust (Abc_Ntk_t *pNtk)
int Abc_NtkFraigStore (Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_NtkFraigRestore ()
void Abc_NtkFraigStoreClean ()
int Abc_NtkSopToBdd (Abc_Ntk_t *pNtk)
DdNodeAbc_ConvertSopToBdd (DdManager *dd, char *pSop)
char * Abc_ConvertBddToSop (Extra_MmFlex_t *pMan, DdManager *dd, DdNode *bFuncOn, DdNode *bFuncOnDc, int nFanins, int fAllPrimes, Vec_Str_t *vCube, int fMode)
int Abc_NtkBddToSop (Abc_Ntk_t *pNtk, int fDirect)
void Abc_NodeBddToCnf (Abc_Obj_t *pNode, Extra_MmFlex_t *pMmMan, Vec_Str_t *vCube, int fAllPrimes, char **ppSop0, char **ppSop1)
int Abc_CountZddCubes (DdManager *dd, DdNode *zCover)
void Abc_NtkLogicMakeDirectSops (Abc_Ntk_t *pNtk)
int Abc_NtkSopToAig (Abc_Ntk_t *pNtk)
int Abc_NtkAigToBdd (Abc_Ntk_t *pNtk)
unsigned * Abc_ConvertAigToTruth (Hop_Man_t *p, Hop_Obj_t *pRoot, int nVars, Vec_Int_t *vTruth, int fMsbFirst)
int Abc_NtkMapToSop (Abc_Ntk_t *pNtk)
int Abc_NtkToSop (Abc_Ntk_t *pNtk, int fDirect)
int Abc_NtkToBdd (Abc_Ntk_t *pNtk)
int Abc_NtkToAig (Abc_Ntk_t *pNtk)
int Abc_NtkHaigStart (Abc_Ntk_t *pNtk)
int Abc_NtkHaigStop (Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_NtkHaigUse (Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_NtkFlattenLogicHierarchy (Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_NtkConvertBlackboxes (Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_NtkInsertNewLogic (Abc_Ntk_t *pNtkH, Abc_Ntk_t *pNtkL)
bool Abc_NtkLatchIsSelfFeed (Abc_Obj_t *pLatch)
int Abc_NtkCountSelfFeedLatches (Abc_Ntk_t *pNtk)
int Abc_NtkRemoveSelfFeedLatches (Abc_Ntk_t *pNtk)
Vec_Int_tAbc_NtkCollectLatchValues (Abc_Ntk_t *pNtk)
void Abc_NtkInsertLatchValues (Abc_Ntk_t *pNtk, Vec_Int_t *vValues)
Abc_Obj_tAbc_NtkAddLatch (Abc_Ntk_t *pNtk, Abc_Obj_t *pDriver, Abc_InitType_t Init)
void Abc_NtkConvertDcLatches (Abc_Ntk_t *pNtk)
Abc_Lib_tAbc_LibCreate (char *pName)
void Abc_LibFree (Abc_Lib_t *pLib, Abc_Ntk_t *pNtk)
void Abc_LibPrint (Abc_Lib_t *pLib)
int Abc_LibAddModel (Abc_Lib_t *pLib, Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_LibFindModelByName (Abc_Lib_t *pLib, char *pName)
int Abc_LibFindTopLevelModels (Abc_Lib_t *pLib)
Abc_Ntk_tAbc_LibDeriveRoot (Abc_Lib_t *pLib)
int Abc_NtkMinimumBase (Abc_Ntk_t *pNtk)
int Abc_NodeMinimumBase (Abc_Obj_t *pNode)
int Abc_NtkRemoveDupFanins (Abc_Ntk_t *pNtk)
int Abc_NodeRemoveDupFanins (Abc_Obj_t *pNode)
Abc_Ntk_tAbc_NtkMiter (Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int fComb, int nPartSize)
void Abc_NtkMiterAddCone (Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkMiter, Abc_Obj_t *pNode)
Abc_Ntk_tAbc_NtkMiterAnd (Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int fOr, int fCompl2)
Abc_Ntk_tAbc_NtkMiterCofactor (Abc_Ntk_t *pNtk, Vec_Int_t *vPiValues)
Abc_Ntk_tAbc_NtkMiterForCofactors (Abc_Ntk_t *pNtk, int Out, int In1, int In2)
Abc_Ntk_tAbc_NtkMiterQuantify (Abc_Ntk_t *pNtk, int In, int fExist)
Abc_Ntk_tAbc_NtkMiterQuantifyPis (Abc_Ntk_t *pNtk)
int Abc_NtkMiterIsConstant (Abc_Ntk_t *pMiter)
void Abc_NtkMiterReport (Abc_Ntk_t *pMiter)
Abc_Ntk_tAbc_NtkFrames (Abc_Ntk_t *pNtk, int nFrames, int fInitial)
char * Abc_ObjName (Abc_Obj_t *pNode)
char * Abc_ObjAssignName (Abc_Obj_t *pObj, char *pName, char *pSuffix)
char * Abc_ObjNameSuffix (Abc_Obj_t *pObj, char *pSuffix)
char * Abc_ObjNameDummy (char *pPrefix, int Num, int nDigits)
void Abc_NtkTrasferNames (Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
void Abc_NtkTrasferNamesNoLatches (Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Vec_Ptr_tAbc_NodeGetFaninNames (Abc_Obj_t *pNode)
Vec_Ptr_tAbc_NodeGetFakeNames (int nNames)
void Abc_NodeFreeNames (Vec_Ptr_t *vNames)
char ** Abc_NtkCollectCioNames (Abc_Ntk_t *pNtk, int fCollectCos)
int Abc_NodeCompareNames (Abc_Obj_t **pp1, Abc_Obj_t **pp2)
void Abc_NtkOrderObjsByName (Abc_Ntk_t *pNtk, int fComb)
void Abc_NtkAddDummyPiNames (Abc_Ntk_t *pNtk)
void Abc_NtkAddDummyPoNames (Abc_Ntk_t *pNtk)
void Abc_NtkAddDummyAssertNames (Abc_Ntk_t *pNtk)
void Abc_NtkAddDummyBoxNames (Abc_Ntk_t *pNtk)
void Abc_NtkShortNames (Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_NtkToLogic (Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_NtkToNetlist (Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_NtkToNetlistBench (Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_NtkDeriveFromBdd (DdManager *dd, DdNode *bFunc, char *pNamePo, Vec_Ptr_t *vNamesPi)
Abc_Ntk_tAbc_NtkBddToMuxes (Abc_Ntk_t *pNtk)
DdManagerAbc_NtkBuildGlobalBdds (Abc_Ntk_t *pNtk, int fBddSizeMax, int fDropInternal, int fReorder, int fVerbose)
DdManagerAbc_NtkFreeGlobalBdds (Abc_Ntk_t *pNtk, int fFreeMan)
int Abc_NtkSizeOfGlobalBdds (Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_NtkAlloc (Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
Abc_Ntk_tAbc_NtkStartFrom (Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Abc_Ntk_tAbc_NtkStartFromNoLatches (Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
void Abc_NtkFinalize (Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Abc_Ntk_tAbc_NtkStartRead (char *pName)
void Abc_NtkFinalizeRead (Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_NtkDup (Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_NtkCreateCone (Abc_Ntk_t *pNtk, Abc_Obj_t *pNode, char *pNodeName, int fUseAllCis)
Abc_Ntk_tAbc_NtkCreateConeArray (Abc_Ntk_t *pNtk, Vec_Ptr_t *vRoots, int fUseAllCis)
void Abc_NtkAppendToCone (Abc_Ntk_t *pNtkNew, Abc_Ntk_t *pNtk, Vec_Ptr_t *vRoots)
Abc_Ntk_tAbc_NtkCreateMffc (Abc_Ntk_t *pNtk, Abc_Obj_t *pNode, char *pNodeName)
Abc_Ntk_tAbc_NtkCreateTarget (Abc_Ntk_t *pNtk, Vec_Ptr_t *vRoots, Vec_Int_t *vValues)
Abc_Ntk_tAbc_NtkCreateFromNode (Abc_Ntk_t *pNtk, Abc_Obj_t *pNode)
Abc_Ntk_tAbc_NtkCreateWithNode (char *pSop)
void Abc_NtkDelete (Abc_Ntk_t *pNtk)
void Abc_NtkFixNonDrivenNets (Abc_Ntk_t *pNtk)
void Abc_NtkMakeComb (Abc_Ntk_t *pNtk)
Abc_Obj_tAbc_ObjAlloc (Abc_Ntk_t *pNtk, Abc_ObjType_t Type)
void Abc_ObjRecycle (Abc_Obj_t *pObj)
void Abc_NtkDeleteObj (Abc_Obj_t *pObj)
void Abc_NtkDeleteObj_rec (Abc_Obj_t *pObj, int fOnlyNodes)
void Abc_NtkDeleteAll_rec (Abc_Obj_t *pObj)
Abc_Obj_tAbc_NtkDupObj (Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Abc_Obj_tAbc_NtkDupBox (Abc_Ntk_t *pNtkNew, Abc_Obj_t *pBox, int fCopyName)
Abc_Obj_tAbc_NtkCloneObj (Abc_Obj_t *pNode)
Abc_Obj_tAbc_NtkFindNode (Abc_Ntk_t *pNtk, char *pName)
Abc_Obj_tAbc_NtkFindNet (Abc_Ntk_t *pNtk, char *pName)
Abc_Obj_tAbc_NtkFindCi (Abc_Ntk_t *pNtk, char *pName)
Abc_Obj_tAbc_NtkFindCo (Abc_Ntk_t *pNtk, char *pName)
Abc_Obj_tAbc_NtkFindOrCreateNet (Abc_Ntk_t *pNtk, char *pName)
Abc_Obj_tAbc_NtkCreateNodeConst0 (Abc_Ntk_t *pNtk)
Abc_Obj_tAbc_NtkCreateNodeConst1 (Abc_Ntk_t *pNtk)
Abc_Obj_tAbc_NtkCreateNodeInv (Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Abc_Obj_tAbc_NtkCreateNodeBuf (Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Abc_Obj_tAbc_NtkCreateNodeAnd (Abc_Ntk_t *pNtk, Vec_Ptr_t *vFanins)
Abc_Obj_tAbc_NtkCreateNodeOr (Abc_Ntk_t *pNtk, Vec_Ptr_t *vFanins)
Abc_Obj_tAbc_NtkCreateNodeExor (Abc_Ntk_t *pNtk, Vec_Ptr_t *vFanins)
Abc_Obj_tAbc_NtkCreateNodeMux (Abc_Ntk_t *pNtk, Abc_Obj_t *pNodeC, Abc_Obj_t *pNode1, Abc_Obj_t *pNode0)
bool Abc_NodeIsConst (Abc_Obj_t *pNode)
bool Abc_NodeIsConst0 (Abc_Obj_t *pNode)
bool Abc_NodeIsConst1 (Abc_Obj_t *pNode)
bool Abc_NodeIsBuf (Abc_Obj_t *pNode)
bool Abc_NodeIsInv (Abc_Obj_t *pNode)
void Abc_NodeComplement (Abc_Obj_t *pNode)
void Abc_NtkPrintStats (FILE *pFile, Abc_Ntk_t *pNtk, int fFactored)
void Abc_NtkPrintIo (FILE *pFile, Abc_Ntk_t *pNtk)
void Abc_NtkPrintLatch (FILE *pFile, Abc_Ntk_t *pNtk)
void Abc_NtkPrintFanio (FILE *pFile, Abc_Ntk_t *pNtk)
void Abc_NodePrintFanio (FILE *pFile, Abc_Obj_t *pNode)
void Abc_NtkPrintFactor (FILE *pFile, Abc_Ntk_t *pNtk, int fUseRealNames)
void Abc_NodePrintFactor (FILE *pFile, Abc_Obj_t *pNode, int fUseRealNames)
void Abc_NtkPrintLevel (FILE *pFile, Abc_Ntk_t *pNtk, int fProfile, int fListNodes)
void Abc_NodePrintLevel (FILE *pFile, Abc_Obj_t *pNode)
void Abc_NtkPrintSkews (FILE *pFile, Abc_Ntk_t *pNtk, int fPrintAll)
void Abc_ObjPrint (FILE *pFile, Abc_Obj_t *pObj)
int Abc_NtkMiterProve (Abc_Ntk_t **ppNtk, void *pParams)
int Abc_NtkIvyProve (Abc_Ntk_t **ppNtk, void *pPars)
void Abc_NtkRecStart (Abc_Ntk_t *pNtk, int nVars, int nCuts)
void Abc_NtkRecStop ()
void Abc_NtkRecAdd (Abc_Ntk_t *pNtk)
void Abc_NtkRecPs ()
void Abc_NtkRecFilter (int iVar, int iPlus)
Abc_Ntk_tAbc_NtkRecUse ()
int Abc_NtkRecIsRunning ()
int Abc_NtkRecVarNum ()
Vec_Int_tAbc_NtkRecMemory ()
int Abc_NtkRecStrashNode (Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, unsigned *pTruth, int nVars)
Abc_ManCut_tAbc_NtkManCutStart (int nNodeSizeMax, int nConeSizeMax, int nNodeFanStop, int nConeFanStop)
void Abc_NtkManCutStop (Abc_ManCut_t *p)
Vec_Ptr_tAbc_NtkManCutReadCutLarge (Abc_ManCut_t *p)
Vec_Ptr_tAbc_NtkManCutReadCutSmall (Abc_ManCut_t *p)
Vec_Ptr_tAbc_NtkManCutReadVisited (Abc_ManCut_t *p)
Vec_Ptr_tAbc_NodeFindCut (Abc_ManCut_t *p, Abc_Obj_t *pRoot, bool fContain)
void Abc_NodeConeCollect (Abc_Obj_t **ppRoots, int nRoots, Vec_Ptr_t *vFanins, Vec_Ptr_t *vVisited, int fIncludeFanins)
DdNodeAbc_NodeConeBdd (DdManager *dd, DdNode **pbVars, Abc_Obj_t *pNode, Vec_Ptr_t *vFanins, Vec_Ptr_t *vVisited)
DdNodeAbc_NodeConeDcs (DdManager *dd, DdNode **pbVarsX, DdNode **pbVarsY, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vRoots, Vec_Ptr_t *vVisited)
Vec_Ptr_tAbc_NodeCollectTfoCands (Abc_ManCut_t *p, Abc_Obj_t *pRoot, Vec_Ptr_t *vFanins, int LevelMax)
int Abc_NodeMffcSize (Abc_Obj_t *pNode)
int Abc_NodeMffcSizeSupp (Abc_Obj_t *pNode)
int Abc_NodeMffcSizeStop (Abc_Obj_t *pNode)
int Abc_NodeMffcLabelAig (Abc_Obj_t *pNode)
int Abc_NodeMffcLabel (Abc_Obj_t *pNode)
void Abc_NodeMffsConeSupp (Abc_Obj_t *pNode, Vec_Ptr_t *vCone, Vec_Ptr_t *vSupp)
int Abc_NodeDeref_rec (Abc_Obj_t *pNode)
int Abc_NodeRef_rec (Abc_Obj_t *pNode)
int Abc_NtkRefactor (Abc_Ntk_t *pNtk, int nNodeSizeMax, int nConeSizeMax, bool fUpdateLevel, bool fUseZeros, bool fUseDcs, bool fVerbose)
int Abc_NtkRewrite (Abc_Ntk_t *pNtk, int fUpdateLevel, int fUseZeros, int fVerbose, int fVeryVerbose, int fPlaceEnable)
int Abc_NtkMiterSat (Abc_Ntk_t *pNtk, sint64 nConfLimit, sint64 nInsLimit, int fVerbose, sint64 *pNumConfs, sint64 *pNumInspects)
void * Abc_NtkMiterSatCreate (Abc_Ntk_t *pNtk, int fAllPrimes)
char * Abc_SopRegister (Extra_MmFlex_t *pMan, char *pName)
char * Abc_SopStart (Extra_MmFlex_t *pMan, int nCubes, int nVars)
char * Abc_SopCreateConst0 (Extra_MmFlex_t *pMan)
char * Abc_SopCreateConst1 (Extra_MmFlex_t *pMan)
char * Abc_SopCreateAnd2 (Extra_MmFlex_t *pMan, int fCompl0, int fCompl1)
char * Abc_SopCreateAnd (Extra_MmFlex_t *pMan, int nVars, int *pfCompl)
char * Abc_SopCreateNand (Extra_MmFlex_t *pMan, int nVars)
char * Abc_SopCreateOr (Extra_MmFlex_t *pMan, int nVars, int *pfCompl)
char * Abc_SopCreateOrMultiCube (Extra_MmFlex_t *pMan, int nVars, int *pfCompl)
char * Abc_SopCreateNor (Extra_MmFlex_t *pMan, int nVars)
char * Abc_SopCreateXor (Extra_MmFlex_t *pMan, int nVars)
char * Abc_SopCreateXorSpecial (Extra_MmFlex_t *pMan, int nVars)
char * Abc_SopCreateNxor (Extra_MmFlex_t *pMan, int nVars)
char * Abc_SopCreateMux (Extra_MmFlex_t *pMan)
char * Abc_SopCreateInv (Extra_MmFlex_t *pMan)
char * Abc_SopCreateBuf (Extra_MmFlex_t *pMan)
char * Abc_SopCreateFromTruth (Extra_MmFlex_t *pMan, int nVars, unsigned *pTruth)
char * Abc_SopCreateFromIsop (Extra_MmFlex_t *pMan, int nVars, Vec_Int_t *vCover)
int Abc_SopGetCubeNum (char *pSop)
int Abc_SopGetLitNum (char *pSop)
int Abc_SopGetVarNum (char *pSop)
int Abc_SopGetPhase (char *pSop)
int Abc_SopGetIthCareLit (char *pSop, int i)
void Abc_SopComplement (char *pSop)
bool Abc_SopIsComplement (char *pSop)
bool Abc_SopIsConst0 (char *pSop)
bool Abc_SopIsConst1 (char *pSop)
bool Abc_SopIsBuf (char *pSop)
bool Abc_SopIsInv (char *pSop)
bool Abc_SopIsAndType (char *pSop)
bool Abc_SopIsOrType (char *pSop)
int Abc_SopIsExorType (char *pSop)
bool Abc_SopCheck (char *pSop, int nFanins)
char * Abc_SopFromTruthBin (char *pTruth)
char * Abc_SopFromTruthHex (char *pTruth)
char * Abc_SopEncoderPos (Extra_MmFlex_t *pMan, int iValue, int nValues)
char * Abc_SopEncoderLog (Extra_MmFlex_t *pMan, int iBit, int nValues)
char * Abc_SopDecoderPos (Extra_MmFlex_t *pMan, int nValues)
char * Abc_SopDecoderLog (Extra_MmFlex_t *pMan, int nValues)
Abc_Ntk_tAbc_NtkStrash (Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Abc_Obj_tAbc_NodeStrash (Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNode, int fRecord)
int Abc_NtkAppend (Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int fAddPos)
Abc_Ntk_tAbc_NtkTopmost (Abc_Ntk_t *pNtk, int nLevels)
int Abc_NtkSweep (Abc_Ntk_t *pNtk, int fVerbose)
int Abc_NtkCleanup (Abc_Ntk_t *pNtk, int fVerbose)
int Abc_NtkCleanupSeq (Abc_Ntk_t *pNtk, int fLatchSweep, int fAutoSweep, int fVerbose)
Abc_Time_tAbc_NodeReadArrival (Abc_Obj_t *pNode)
Abc_Time_tAbc_NodeReadRequired (Abc_Obj_t *pNode)
Abc_Time_tAbc_NtkReadDefaultArrival (Abc_Ntk_t *pNtk)
Abc_Time_tAbc_NtkReadDefaultRequired (Abc_Ntk_t *pNtk)
void Abc_NtkTimeSetDefaultArrival (Abc_Ntk_t *pNtk, float Rise, float Fall)
void Abc_NtkTimeSetDefaultRequired (Abc_Ntk_t *pNtk, float Rise, float Fall)
void Abc_NtkTimeSetArrival (Abc_Ntk_t *pNtk, int ObjId, float Rise, float Fall)
void Abc_NtkTimeSetRequired (Abc_Ntk_t *pNtk, int ObjId, float Rise, float Fall)
void Abc_NtkTimeInitialize (Abc_Ntk_t *pNtk)
void Abc_ManTimeStop (Abc_ManTime_t *p)
void Abc_ManTimeDup (Abc_Ntk_t *pNtkOld, Abc_Ntk_t *pNtkNew)
void Abc_NtkSetNodeLevelsArrival (Abc_Ntk_t *pNtk)
float * Abc_NtkGetCiArrivalFloats (Abc_Ntk_t *pNtk)
Abc_Time_tAbc_NtkGetCiArrivalTimes (Abc_Ntk_t *pNtk)
float Abc_NtkDelayTrace (Abc_Ntk_t *pNtk)
int Abc_ObjLevelNew (Abc_Obj_t *pObj)
int Abc_ObjReverseLevelNew (Abc_Obj_t *pObj)
int Abc_ObjRequiredLevel (Abc_Obj_t *pObj)
int Abc_ObjReverseLevel (Abc_Obj_t *pObj)
void Abc_ObjSetReverseLevel (Abc_Obj_t *pObj, int LevelR)
void Abc_NtkStartReverseLevels (Abc_Ntk_t *pNtk, int nMaxLevelIncrease)
void Abc_NtkStopReverseLevels (Abc_Ntk_t *pNtk)
void Abc_NtkUpdateLevel (Abc_Obj_t *pObjNew, Vec_Vec_t *vLevels)
void Abc_NtkUpdateReverseLevel (Abc_Obj_t *pObjNew, Vec_Vec_t *vLevels)
void Abc_NtkUpdate (Abc_Obj_t *pObj, Abc_Obj_t *pObjNew, Vec_Vec_t *vLevels)
void * Abc_NtkAttrFree (Abc_Ntk_t *pNtk, int Attr, int fFreeMan)
void Abc_NtkIncrementTravId (Abc_Ntk_t *pNtk)
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_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_NtkGetChoiceNum (Abc_Ntk_t *pNtk)
int Abc_NtkGetFaninMax (Abc_Ntk_t *pNtk)
int Abc_NtkGetTotalFanins (Abc_Ntk_t *pNtk)
void Abc_NtkCleanCopy (Abc_Ntk_t *pNtk)
void Abc_NtkCleanData (Abc_Ntk_t *pNtk)
void Abc_NtkCleanEquiv (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_NtkCleanMarkA (Abc_Ntk_t *pNtk)
Abc_Obj_tAbc_NodeFindCoFanout (Abc_Obj_t *pNode)
Abc_Obj_tAbc_NodeFindNonCoFanout (Abc_Obj_t *pNode)
Abc_Obj_tAbc_NodeHasUniqueCoFanout (Abc_Obj_t *pNode)
bool Abc_NtkLogicHasSimpleCos (Abc_Ntk_t *pNtk)
int Abc_NtkLogicMakeSimpleCos (Abc_Ntk_t *pNtk, bool fDuplicate)
void Abc_VecObjPushUniqueOrderByLevel (Vec_Ptr_t *p, Abc_Obj_t *pNode)
bool Abc_NodeIsExorType (Abc_Obj_t *pNode)
bool Abc_NodeIsMuxType (Abc_Obj_t *pNode)
bool 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)
int Abc_ObjPointerCompare (void **pp1, void **pp2)
void Abc_NtkTransferCopy (Abc_Ntk_t *pNtk)
int * Abc_NtkVerifyGetCleanModel (Abc_Ntk_t *pNtk, int nFrames)
int * Abc_NtkVerifySimulatePattern (Abc_Ntk_t *pNtk, int *pModel)

Define Documentation

#define ABC_ABS (  )     (((a) >= 0)? (a) :-(a))

Definition at line 237 of file abc.h.

#define Abc_AigForEachAnd ( pNtk,
pNode,
 ) 
Value:
for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i++ )   \
        if ( (pNode) == NULL || !Abc_AigNodeIsAnd(pNode) ) {} else

Definition at line 472 of file abc.h.

#define Abc_CubeForEachVar ( pCube,
Value,
 )     for ( i = 0; (pCube[i] != ' ') && (Value = pCube[i]); i++ )

Definition at line 512 of file abc.h.

#define ABC_INFINITY   (100000000)

Definition at line 238 of file abc.h.

#define ABC_MAX ( a,
 )     (((a) > (b))? (a) : (b))

Definition at line 236 of file abc.h.

#define ABC_MIN ( a,
 )     (((a) < (b))? (a) : (b))

MACRO DEFINITIONS ///

Definition at line 235 of file abc.h.

#define Abc_NtkForEachAssert ( pNtk,
pObj,
 )     for ( i = 0; (i < Vec_PtrSize((pNtk)->vAsserts)) && (((pObj) = Abc_NtkAssert(pNtk, i)), 1); i++ )

Definition at line 502 of file abc.h.

#define Abc_NtkForEachBlackbox ( pNtk,
pObj,
 ) 
Value:
for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)) && (((pObj) = Abc_NtkBox(pNtk, i)), 1); i++ )   \
        if ( !Abc_ObjIsBlackbox(pObj) ) {} else

Definition at line 490 of file abc.h.

#define Abc_NtkForEachBox ( pNtk,
pObj,
 )     for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)) && (((pObj) = Abc_NtkBox(pNtk, i)), 1); i++ )

Definition at line 476 of file abc.h.

#define Abc_NtkForEachCi ( pNtk,
pCi,
 )     for ( i = 0; (i < Abc_NtkCiNum(pNtk)) && (((pCi) = Abc_NtkCi(pNtk, i)), 1); i++ )

Definition at line 496 of file abc.h.

#define Abc_NtkForEachCo ( pNtk,
pCo,
 )     for ( i = 0; (i < Abc_NtkCoNum(pNtk)) && (((pCo) = Abc_NtkCo(pNtk, i)), 1); i++ )

Definition at line 500 of file abc.h.

#define Abc_NtkForEachGate ( pNtk,
pNode,
 ) 
Value:
for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i++ )   \
        if ( (pNode) == NULL || !Abc_ObjIsGate(pNode) ) {} else

Definition at line 469 of file abc.h.

#define Abc_NtkForEachLatch ( pNtk,
pObj,
 ) 
Value:
for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)) && (((pObj) = Abc_NtkBox(pNtk, i)), 1); i++ )   \
        if ( !Abc_ObjIsLatch(pObj) ) {} else

Definition at line 478 of file abc.h.

#define Abc_NtkForEachLatchInput ( pNtk,
pObj,
 ) 
Value:
for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)); i++ )                                          \
        if ( !(Abc_ObjIsLatch(Abc_NtkBox(pNtk, i)) && (((pObj) = Abc_ObjFanin0(Abc_NtkBox(pNtk, i))), 1)) ) {} else

Definition at line 481 of file abc.h.

#define Abc_NtkForEachLatchOutput ( pNtk,
pObj,
 ) 
Value:
for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)); i++ )                                          \
        if ( !(Abc_ObjIsLatch(Abc_NtkBox(pNtk, i)) && (((pObj) = Abc_ObjFanout0(Abc_NtkBox(pNtk, i))), 1)) ) {} else

Definition at line 484 of file abc.h.

#define Abc_NtkForEachNet ( pNtk,
pNet,
 ) 
Value:
for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pNet) = Abc_NtkObj(pNtk, i)), 1); i++ )    \
        if ( (pNet) == NULL || !Abc_ObjIsNet(pNet) ) {} else

Definition at line 463 of file abc.h.

#define Abc_NtkForEachNode ( pNtk,
pNode,
 ) 
Value:
for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i++ )   \
        if ( (pNode) == NULL || !Abc_ObjIsNode(pNode) ) {} else

Definition at line 466 of file abc.h.

#define Abc_NtkForEachObj ( pNtk,
pObj,
 ) 
Value:
for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pObj) = Abc_NtkObj(pNtk, i)), 1); i++ )    \
        if ( (pObj) == NULL ) {} else

ITERATORS ///

Definition at line 460 of file abc.h.

#define Abc_NtkForEachPi ( pNtk,
pPi,
 )     for ( i = 0; (i < Abc_NtkPiNum(pNtk)) && (((pPi) = Abc_NtkPi(pNtk, i)), 1); i++ )

Definition at line 494 of file abc.h.

#define Abc_NtkForEachPo ( pNtk,
pPo,
 )     for ( i = 0; (i < Abc_NtkPoNum(pNtk)) && (((pPo) = Abc_NtkPo(pNtk, i)), 1); i++ )

Definition at line 498 of file abc.h.

#define Abc_NtkForEachWhitebox ( pNtk,
pObj,
 ) 
Value:
for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)) && (((pObj) = Abc_NtkBox(pNtk, i)), 1); i++ )   \
        if ( !Abc_ObjIsWhitebox(pObj) ) {} else

Definition at line 487 of file abc.h.

#define Abc_ObjForEachFanin ( pObj,
pFanin,
 )     for ( i = 0; (i < Abc_ObjFaninNum(pObj)) && (((pFanin) = Abc_ObjFanin(pObj, i)), 1); i++ )

Definition at line 505 of file abc.h.

#define Abc_ObjForEachFanout ( pObj,
pFanout,
 )     for ( i = 0; (i < Abc_ObjFanoutNum(pObj)) && (((pFanout) = Abc_ObjFanout(pObj, i)), 1); i++ )

Definition at line 507 of file abc.h.

#define Abc_SopForEachCube ( pSop,
nFanins,
pCube   )     for ( pCube = (pSop); *pCube; pCube += (nFanins) + 3 )

Definition at line 510 of file abc.h.

#define bool   int

BASIC TYPES ///

Definition at line 115 of file abc.h.

#define PRT ( a,
 )     printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))

Definition at line 453 of file abc.h.


Typedef Documentation

typedef struct Abc_Aig_t_ Abc_Aig_t

Definition at line 133 of file abc.h.

typedef struct Abc_Lib_t_ Abc_Lib_t

Definition at line 130 of file abc.h.

typedef struct Abc_ManCut_t_ Abc_ManCut_t

Definition at line 135 of file abc.h.

typedef struct Abc_ManTime_t_ Abc_ManTime_t

Definition at line 134 of file abc.h.

typedef struct Abc_Ntk_t_ Abc_Ntk_t

Definition at line 131 of file abc.h.

typedef struct Abc_Obj_t_ Abc_Obj_t

Definition at line 132 of file abc.h.

typedef struct Abc_Time_t_ Abc_Time_t

Definition at line 136 of file abc.h.

typedef long long sint64

Definition at line 125 of file abc.h.


Enumeration Type Documentation

Enumerator:
ABC_INIT_NONE 
ABC_INIT_ZERO 
ABC_INIT_ONE 
ABC_INIT_DC 
ABC_INIT_OTHER 

Definition at line 100 of file abc.h.

00100              { 
00101     ABC_INIT_NONE = 0,  // 0:  unknown
00102     ABC_INIT_ZERO,      // 1:  zero
00103     ABC_INIT_ONE,       // 2:  one
00104     ABC_INIT_DC,        // 3:  don't-care
00105     ABC_INIT_OTHER      // 4:  unused
00106 } Abc_InitType_t;

Enumerator:
ABC_FUNC_NONE 
ABC_FUNC_SOP 
ABC_FUNC_BDD 
ABC_FUNC_AIG 
ABC_FUNC_MAP 
ABC_FUNC_BLIFMV 
ABC_FUNC_BLACKBOX 
ABC_FUNC_OTHER 

Definition at line 59 of file abc.h.

00059              { 
00060     ABC_FUNC_NONE = 0,  // 0:  unknown
00061     ABC_FUNC_SOP,       // 1:  sum-of-products
00062     ABC_FUNC_BDD,       // 2:  binary decision diagrams
00063     ABC_FUNC_AIG,       // 3:  and-inverter graphs
00064     ABC_FUNC_MAP,       // 4:  standard cell library
00065     ABC_FUNC_BLIFMV,    // 5:  BLIF-MV node functions
00066     ABC_FUNC_BLACKBOX,  // 6:  black box about which nothing is known
00067     ABC_FUNC_OTHER      // 7:  unused
00068 } Abc_NtkFunc_t;

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

FileName [abc.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id
abc.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

] INCLUDES /// PARAMETERS ///

Enumerator:
ABC_NTK_NONE 
ABC_NTK_NETLIST 
ABC_NTK_LOGIC 
ABC_NTK_STRASH 
ABC_NTK_OTHER 

Definition at line 50 of file abc.h.

00050              { 
00051     ABC_NTK_NONE = 0,   // 0:  unknown
00052     ABC_NTK_NETLIST,    // 1:  network with PIs/POs, latches, nodes, and nets
00053     ABC_NTK_LOGIC,      // 2:  network with PIs/POs, latches, and nodes
00054     ABC_NTK_STRASH,     // 3:  structurally hashed AIG (two input AND gates with c-attributes on edges)
00055     ABC_NTK_OTHER       // 4:  unused
00056 } Abc_NtkType_t;

Enumerator:
ABC_OBJ_NONE 
ABC_OBJ_CONST1 
ABC_OBJ_PIO 
ABC_OBJ_PI 
ABC_OBJ_PO 
ABC_OBJ_BI 
ABC_OBJ_BO 
ABC_OBJ_ASSERT 
ABC_OBJ_NET 
ABC_OBJ_NODE 
ABC_OBJ_LATCH 
ABC_OBJ_WHITEBOX 
ABC_OBJ_BLACKBOX 
ABC_OBJ_NUMBER 

Definition at line 82 of file abc.h.

00082              { 
00083     ABC_OBJ_NONE = 0,   //  0:  unknown
00084     ABC_OBJ_CONST1,     //  1:  constant 1 node (AIG only)
00085     ABC_OBJ_PIO,        //  2:  inout terminal
00086     ABC_OBJ_PI,         //  3:  primary input terminal
00087     ABC_OBJ_PO,         //  4:  primary output terminal
00088     ABC_OBJ_BI,         //  5:  box input terminal
00089     ABC_OBJ_BO,         //  6:  box output terminal
00090     ABC_OBJ_ASSERT,     //  7:  assertion terminal
00091     ABC_OBJ_NET,        //  8:  net
00092     ABC_OBJ_NODE,       //  9:  node
00093     ABC_OBJ_LATCH,      // 10:  latch
00094     ABC_OBJ_WHITEBOX,   // 11:  box with known contents
00095     ABC_OBJ_BLACKBOX,   // 12:  box with unknown contents
00096     ABC_OBJ_NUMBER      // 13:  unused
00097 } Abc_ObjType_t;


Function Documentation

Abc_Aig_t* Abc_AigAlloc ( Abc_Ntk_t pNtkAig  ) 

FUNCTION DECLARATIONS ///

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

Synopsis [Allocates the local AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 125 of file abcAig.c.

00126 {
00127     Abc_Aig_t * pMan;
00128     // start the manager
00129     pMan = ALLOC( Abc_Aig_t, 1 );
00130     memset( pMan, 0, sizeof(Abc_Aig_t) );
00131     // allocate the table
00132     pMan->nBins    = Cudd_PrimeCopy( 10000 );
00133     pMan->pBins    = ALLOC( Abc_Obj_t *, pMan->nBins );
00134     memset( pMan->pBins, 0, sizeof(Abc_Obj_t *) * pMan->nBins );
00135     pMan->vNodes   = Vec_PtrAlloc( 100 );
00136     pMan->vLevels  = Vec_VecAlloc( 100 );
00137     pMan->vLevelsR = Vec_VecAlloc( 100 );
00138     pMan->vStackReplaceOld = Vec_PtrAlloc( 100 );
00139     pMan->vStackReplaceNew = Vec_PtrAlloc( 100 );
00140     // create the constant node
00141     assert( pNtkAig->vObjs->nSize == 0 );
00142     pMan->pConst1 = Abc_NtkCreateObj( pNtkAig, ABC_OBJ_NODE );
00143     pMan->pConst1->Type = ABC_OBJ_CONST1;
00144     pMan->pConst1->fPhase = 1;
00145     pNtkAig->nObjCounts[ABC_OBJ_NODE]--;
00146     // save the current network
00147     pMan->pNtkAig = pNtkAig;
00148     return pMan;
00149 }

Abc_Obj_t* Abc_AigAnd ( Abc_Aig_t pMan,
Abc_Obj_t p0,
Abc_Obj_t p1 
)

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

Synopsis [Performs canonicization step.]

Description [The argument nodes can be complemented.]

SideEffects []

SeeAlso []

Definition at line 700 of file abcAig.c.

00701 {
00702     Abc_Obj_t * pAnd;
00703     if ( (pAnd = Abc_AigAndLookup( pMan, p0, p1 )) )
00704         return pAnd;
00705     return Abc_AigAndCreate( pMan, p0, p1 );
00706 }

Abc_Obj_t* Abc_AigAndLookup ( Abc_Aig_t pMan,
Abc_Obj_t p0,
Abc_Obj_t p1 
)

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

Synopsis [Performs canonicization step.]

Description [The argument nodes can be complemented.]

SideEffects []

SeeAlso []

Definition at line 404 of file abcAig.c.

00405 {
00406     Abc_Obj_t * pAnd, * pConst1;
00407     unsigned Key;
00408     assert( Abc_ObjRegular(p0)->pNtk->pManFunc == pMan );
00409     assert( Abc_ObjRegular(p1)->pNtk->pManFunc == pMan );
00410     // check for trivial cases
00411     pConst1 = Abc_AigConst1(pMan->pNtkAig);
00412     if ( p0 == p1 )
00413         return p0;
00414     if ( p0 == Abc_ObjNot(p1) )
00415         return Abc_ObjNot(pConst1);
00416     if ( Abc_ObjRegular(p0) == pConst1 )
00417     {
00418         if ( p0 == pConst1 )
00419             return p1;
00420         return Abc_ObjNot(pConst1);
00421     }
00422     if ( Abc_ObjRegular(p1) == pConst1 )
00423     {
00424         if ( p1 == pConst1 )
00425             return p0;
00426         return Abc_ObjNot(pConst1);
00427     }
00428 /*
00429     {
00430         int nFans0 = Abc_ObjFanoutNum( Abc_ObjRegular(p0) );
00431         int nFans1 = Abc_ObjFanoutNum( Abc_ObjRegular(p1) );
00432         if ( nFans0 == 0 || nFans1 == 0 )
00433             pMan->nStrash0++;
00434         else if ( nFans0 == 1 || nFans1 == 1 )
00435             pMan->nStrash1++;
00436         else if ( nFans0 <= 100 && nFans1 <= 100 )
00437             pMan->nStrash5++;
00438         else
00439             pMan->nStrash2++;
00440     }
00441 */
00442     {
00443         int nFans0 = Abc_ObjFanoutNum( Abc_ObjRegular(p0) );
00444         int nFans1 = Abc_ObjFanoutNum( Abc_ObjRegular(p1) );
00445         if ( nFans0 == 0 || nFans1 == 0 )
00446             return NULL;
00447     }
00448 
00449     // order the arguments
00450     if ( Abc_ObjRegular(p0)->Id > Abc_ObjRegular(p1)->Id )
00451         pAnd = p0, p0 = p1, p1 = pAnd;
00452     // get the hash key for these two nodes
00453     Key = Abc_HashKey2( p0, p1, pMan->nBins );
00454     // find the matching node in the table
00455     Abc_AigBinForEachEntry( pMan->pBins[Key], pAnd )
00456         if ( p0 == Abc_ObjChild0(pAnd) && p1 == Abc_ObjChild1(pAnd) )
00457         {
00458 //            assert( Abc_ObjFanoutNum(Abc_ObjRegular(p0)) && Abc_ObjFanoutNum(p1) );
00459              return pAnd;
00460         }
00461     return NULL;
00462 }

bool Abc_AigCheck ( Abc_Aig_t pMan  ) 

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

Synopsis [Makes sure that every node in the table is in the network and vice versa.]

Description []

SideEffects []

SeeAlso []

Definition at line 223 of file abcAig.c.

00224 {
00225     Abc_Obj_t * pObj, * pAnd;
00226     int i, nFanins, Counter;
00227     Abc_NtkForEachNode( pMan->pNtkAig, pObj, i )
00228     {
00229         nFanins = Abc_ObjFaninNum(pObj);
00230         if ( nFanins == 0 )
00231         {
00232             if ( !Abc_AigNodeIsConst(pObj) )
00233             {
00234                 printf( "Abc_AigCheck: The AIG has non-standard constant nodes.\n" );
00235                 return 0;
00236             }
00237             continue;
00238         }
00239         if ( nFanins == 1 )
00240         {
00241             printf( "Abc_AigCheck: The AIG has single input nodes.\n" );
00242             return 0;
00243         }
00244         if ( nFanins > 2 )
00245         {
00246             printf( "Abc_AigCheck: The AIG has non-standard nodes.\n" );
00247             return 0;
00248         }
00249         if ( pObj->Level != 1 + ABC_MAX( Abc_ObjFanin0(pObj)->Level, Abc_ObjFanin1(pObj)->Level ) )
00250             printf( "Abc_AigCheck: Node \"%s\" has level that does not agree with the fanin levels.\n", Abc_ObjName(pObj) );
00251         pAnd = Abc_AigAndLookup( pMan, Abc_ObjChild0(pObj), Abc_ObjChild1(pObj) );
00252         if ( pAnd != pObj )
00253             printf( "Abc_AigCheck: Node \"%s\" is not in the structural hashing table.\n", Abc_ObjName(pObj) );
00254     }
00255     // count the number of nodes in the table
00256     Counter = 0;
00257     for ( i = 0; i < pMan->nBins; i++ )
00258         Abc_AigBinForEachEntry( pMan->pBins[i], pAnd )
00259             Counter++;
00260     if ( Counter != Abc_NtkNodeNum(pMan->pNtkAig) )
00261     {
00262         printf( "Abc_AigCheck: The number of nodes in the structural hashing table is wrong.\n" );
00263         return 0;
00264     }
00265     // if the node is a choice node, nodes in its class should not have fanouts
00266     Abc_NtkForEachNode( pMan->pNtkAig, pObj, i )
00267         if ( Abc_AigNodeIsChoice(pObj) )
00268             for ( pAnd = pObj->pData; pAnd; pAnd = pAnd->pData )
00269                 if ( Abc_ObjFanoutNum(pAnd) > 0 )
00270                 {
00271                     printf( "Abc_AigCheck: Representative %s", Abc_ObjName(pAnd) );
00272                     printf( " of choice node %s has %d fanouts.\n", Abc_ObjName(pObj), Abc_ObjFanoutNum(pAnd) );
00273                     return 0;
00274                 }
00275     return 1;
00276 }

void Abc_AigCheckFaninOrder ( Abc_Aig_t pMan  ) 

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

Synopsis [Resizes the hash table of AIG nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 1341 of file abcAig.c.

01342 {
01343     Abc_Obj_t * pEnt;
01344     int i;
01345     for ( i = 0; i < pMan->nBins; i++ )
01346         Abc_AigBinForEachEntry( pMan->pBins[i], pEnt )
01347         {
01348             if ( Abc_ObjRegular(Abc_ObjChild0(pEnt))->Id > Abc_ObjRegular(Abc_ObjChild1(pEnt))->Id )
01349             {
01350 //                int i0 = Abc_ObjRegular(Abc_ObjChild0(pEnt))->Id;
01351 //                int i1 = Abc_ObjRegular(Abc_ObjChild1(pEnt))->Id;
01352                 printf( "Node %d has incorrect ordering of fanins.\n", pEnt->Id );
01353             }
01354         }
01355 }

int Abc_AigCleanup ( Abc_Aig_t pMan  ) 

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

Synopsis [Returns the number of dangling nodes removed.]

Description []

SideEffects []

SeeAlso []

Definition at line 191 of file abcAig.c.

00192 {
00193     Vec_Ptr_t * vDangles;
00194     Abc_Obj_t * pAnd;
00195     int i, nNodesOld;
00196 //    printf( "Strash0 = %d.  Strash1 = %d.  Strash100 = %d.  StrashM = %d.\n", 
00197 //        pMan->nStrash0, pMan->nStrash1, pMan->nStrash5, pMan->nStrash2 );
00198     nNodesOld = pMan->nEntries;
00199     // collect the AND nodes that do not fanout
00200     vDangles = Vec_PtrAlloc( 100 );
00201     for ( i = 0; i < pMan->nBins; i++ )
00202         Abc_AigBinForEachEntry( pMan->pBins[i], pAnd )
00203             if ( Abc_ObjFanoutNum(pAnd) == 0 )
00204                 Vec_PtrPush( vDangles, pAnd );
00205     // process the dangling nodes and their MFFCs
00206     Vec_PtrForEachEntry( vDangles, pAnd, i )
00207         Abc_AigDeleteNode( pMan, pAnd );
00208     Vec_PtrFree( vDangles );
00209     return nNodesOld - pMan->nEntries;
00210 }

Abc_Obj_t* Abc_AigConst1 ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Performs canonicization step.]

Description [The argument nodes can be complemented.]

SideEffects []

SeeAlso []

Definition at line 683 of file abcAig.c.

00684 {
00685     assert( Abc_NtkIsStrash(pNtk) );
00686     return ((Abc_Aig_t *)pNtk->pManFunc)->pConst1;
00687 }

void Abc_AigDeleteNode ( Abc_Aig_t pMan,
Abc_Obj_t pNode 
)

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

Synopsis [Performs internal deletion step.]

Description []

SideEffects []

SeeAlso []

Definition at line 951 of file abcAig.c.

00952 {
00953     Abc_Obj_t * pNode0, * pNode1, * pTemp;
00954     int i, k;
00955 
00956     // make sure the node is regular and dangling
00957     assert( !Abc_ObjIsComplement(pNode) );
00958     assert( Abc_ObjIsNode(pNode) );
00959     assert( Abc_ObjFaninNum(pNode) == 2 );
00960     assert( Abc_ObjFanoutNum(pNode) == 0 );
00961 
00962     // when deleting an old node that is scheduled for replacement, remove it from the replacement queue
00963     Vec_PtrForEachEntry( pMan->vStackReplaceOld, pTemp, i )
00964         if ( pNode == pTemp )
00965         {
00966             // remove the entry from the replacement array
00967             for ( k = i; k < pMan->vStackReplaceOld->nSize - 1; k++ )
00968             {
00969                 pMan->vStackReplaceOld->pArray[k] = pMan->vStackReplaceOld->pArray[k+1];
00970                 pMan->vStackReplaceNew->pArray[k] = pMan->vStackReplaceNew->pArray[k+1];
00971             }
00972             pMan->vStackReplaceOld->nSize--;
00973             pMan->vStackReplaceNew->nSize--;
00974         }
00975 
00976     // when deleting a new node that should replace another node, do not delete
00977     Vec_PtrForEachEntry( pMan->vStackReplaceNew, pTemp, i )
00978         if ( pNode == Abc_ObjRegular(pTemp) )
00979             return;
00980 
00981     // remember the node's fanins
00982     pNode0 = Abc_ObjFanin0( pNode );
00983     pNode1 = Abc_ObjFanin1( pNode );
00984 
00985     // add the node to the list of updated nodes
00986     if ( pMan->vUpdatedNets )
00987     {
00988         Vec_PtrPushUnique( pMan->vUpdatedNets, pNode0 );
00989         Vec_PtrPushUnique( pMan->vUpdatedNets, pNode1 );
00990     }
00991 
00992     // remove the node from the table
00993     Abc_AigAndDelete( pMan, pNode );
00994     // if the node is in the level structure, remove it
00995     if ( pNode->fMarkA )
00996         Abc_AigRemoveFromLevelStructure( pMan->vLevels, pNode );
00997     if ( pNode->fMarkB )
00998         Abc_AigRemoveFromLevelStructureR( pMan->vLevelsR, pNode );
00999     // remove the node from the network
01000     Abc_NtkDeleteObj( pNode );
01001 
01002     // call recursively for the fanins
01003     if ( Abc_ObjIsNode(pNode0) && pNode0->vFanouts.nSize == 0 )
01004         Abc_AigDeleteNode( pMan, pNode0 );
01005     if ( Abc_ObjIsNode(pNode1) && pNode1->vFanouts.nSize == 0 )
01006         Abc_AigDeleteNode( pMan, pNode1 );
01007 }

Vec_Ptr_t* Abc_AigDfs ( Abc_Ntk_t pNtk,
int  fCollectAll,
int  fCollectCos 
)

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

Synopsis [Returns the DFS ordered array of logic nodes.]

Description [Collects only the internal nodes, leaving out CIs/COs. However it marks both CIs and COs with the current TravId.]

SideEffects []

SeeAlso []

Definition at line 798 of file abcDfs.c.

00799 {
00800     Vec_Ptr_t * vNodes;
00801     Abc_Obj_t * pNode;
00802     int i;
00803     assert( Abc_NtkIsStrash(pNtk) );
00804     // set the traversal ID
00805     Abc_NtkIncrementTravId( pNtk );
00806     // start the array of nodes
00807     vNodes = Vec_PtrAlloc( 100 );
00808     // go through the PO nodes and call for each of them
00809     Abc_NtkForEachCo( pNtk, pNode, i )
00810     {
00811         Abc_AigDfs_rec( Abc_ObjFanin0(pNode), vNodes );
00812         Abc_NodeSetTravIdCurrent( pNode );
00813         if ( fCollectCos )
00814             Vec_PtrPush( vNodes, pNode );
00815     }
00816     // collect dangling nodes if asked to
00817     if ( fCollectAll )
00818     {
00819         Abc_NtkForEachNode( pNtk, pNode, i )
00820             if ( !Abc_NodeIsTravIdCurrent(pNode) )
00821                 Abc_AigDfs_rec( pNode, vNodes );
00822     }
00823     return vNodes;
00824 }

void Abc_AigFree ( Abc_Aig_t pMan  ) 

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

Synopsis [Deallocates the local AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 162 of file abcAig.c.

00163 {
00164     assert( Vec_PtrSize( pMan->vStackReplaceOld ) == 0 );
00165     assert( Vec_PtrSize( pMan->vStackReplaceNew ) == 0 );
00166     // free the table
00167     if ( pMan->vAddedCells )
00168         Vec_PtrFree( pMan->vAddedCells );
00169     if ( pMan->vUpdatedNets )
00170         Vec_PtrFree( pMan->vUpdatedNets );
00171     Vec_VecFree( pMan->vLevels );
00172     Vec_VecFree( pMan->vLevelsR );
00173     Vec_PtrFree( pMan->vStackReplaceOld );
00174     Vec_PtrFree( pMan->vStackReplaceNew );
00175     Vec_PtrFree( pMan->vNodes );
00176     free( pMan->pBins );
00177     free( pMan );
00178 }

Vec_Ptr_t* Abc_AigGetLevelizedOrder ( Abc_Ntk_t pNtk,
int  fCollectCis 
)

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

Synopsis [Returns nodes by level from the smallest to the largest.]

Description [Correctly handles the case of choice nodes, by first spreading them out across several levels and then collecting.]

SideEffects [What happens with dangling nodes???]

SeeAlso []

Definition at line 1234 of file abcDfs.c.

01235 {
01236     Vec_Ptr_t * vNodes, * vLevels;
01237     Abc_Obj_t * pNode, ** ppHead;
01238     int LevelMax, i;
01239     assert( Abc_NtkIsStrash(pNtk) );
01240     // set the correct levels
01241     Abc_NtkCleanCopy( pNtk );
01242     LevelMax = Abc_AigSetChoiceLevels( pNtk );
01243     // relink nodes by level
01244     vLevels = Vec_PtrStart( LevelMax + 1 );
01245     Abc_NtkForEachNode( pNtk, pNode, i )
01246     {
01247         ppHead = ((Abc_Obj_t **)vLevels->pArray) + (int)pNode->pCopy;
01248         pNode->pCopy = *ppHead;
01249         *ppHead = pNode;
01250     }
01251     // recollect nodes
01252     vNodes = Vec_PtrStart( Abc_NtkNodeNum(pNtk) );
01253     Vec_PtrForEachEntryStart( vLevels, pNode, i, !fCollectCis )
01254         for ( ; pNode; pNode = pNode->pCopy )
01255             Vec_PtrPush( vNodes, pNode );
01256     Vec_PtrFree( vLevels );
01257     return vNodes;
01258 }

int Abc_AigLevel ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Computes the number of logic levels not counting PIs/POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 289 of file abcAig.c.

00290 {
00291     Abc_Obj_t * pNode;
00292     int i, LevelsMax;
00293     assert( Abc_NtkIsStrash(pNtk) );
00294     // perform the traversal
00295     LevelsMax = 0;
00296     Abc_NtkForEachCo( pNtk, pNode, i )
00297         if ( LevelsMax < (int)Abc_ObjFanin0(pNode)->Level )
00298             LevelsMax = (int)Abc_ObjFanin0(pNode)->Level;
00299     return LevelsMax;
00300 }

Abc_Obj_t* Abc_AigMiter ( Abc_Aig_t pMan,
Vec_Ptr_t vPairs 
)

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

Synopsis [Implements the miter.]

Description []

SideEffects []

SeeAlso []

Definition at line 773 of file abcAig.c.

00774 {
00775     int i;
00776     if ( vPairs->nSize == 0 )
00777         return Abc_ObjNot( Abc_AigConst1(pMan->pNtkAig) );
00778     assert( vPairs->nSize % 2 == 0 );
00779     // go through the cubes of the node's SOP
00780     for ( i = 0; i < vPairs->nSize; i += 2 )
00781         vPairs->pArray[i/2] = Abc_AigXor( pMan, vPairs->pArray[i], vPairs->pArray[i+1] );
00782     vPairs->nSize = vPairs->nSize/2;
00783     return Abc_AigMiter_rec( pMan, (Abc_Obj_t **)vPairs->pArray, vPairs->nSize );
00784 }

Abc_Obj_t* Abc_AigMuxLookup ( Abc_Aig_t pMan,
Abc_Obj_t pC,
Abc_Obj_t pT,
Abc_Obj_t pE,
int *  pType 
)

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

Synopsis [Returns the gate implementing EXOR of the two arguments if it exists.]

Description [The argument nodes can be complemented.]

SideEffects []

SeeAlso []

Definition at line 509 of file abcAig.c.

00510 {
00511     Abc_Obj_t * pNode1, * pNode2, * pNode;
00512     // set the flag to zero
00513     if ( pType ) *pType = 0;
00514     // check the case of MUX(c,t,e) = OR(ct', c'e')'
00515     if ( (pNode1 = Abc_AigAndLookup(pMan, pC, Abc_ObjNot(pT))) &&
00516          (pNode2 = Abc_AigAndLookup(pMan, Abc_ObjNot(pC), Abc_ObjNot(pE))) ) 
00517     {
00518         pNode = Abc_AigAndLookup( pMan, Abc_ObjNot(pNode1), Abc_ObjNot(pNode2) );
00519         if ( pNode && pType ) *pType = 1;
00520         return pNode;
00521     }
00522     // check the case of MUX(c,t,e) = OR(ct, c'e)
00523     if ( (pNode1 = Abc_AigAndLookup(pMan, pC, pT)) &&
00524          (pNode2 = Abc_AigAndLookup(pMan, Abc_ObjNot(pC), pE)) ) 
00525     {
00526         pNode = Abc_AigAndLookup( pMan, Abc_ObjNot(pNode1), Abc_ObjNot(pNode2) );
00527         return pNode? Abc_ObjNot(pNode) : NULL;
00528     }
00529     return NULL;
00530 }

bool Abc_AigNodeHasComplFanoutEdge ( Abc_Obj_t pNode  ) 

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

Synopsis [Returns 1 if the node has at least one complemented fanout.]

Description [A fanout is complemented if the fanout's fanin edge pointing to the given node is complemented.]

SideEffects []

SeeAlso []

Definition at line 1203 of file abcAig.c.

01204 {
01205     Abc_Obj_t * pFanout;
01206     int i, iFanin;
01207     Abc_ObjForEachFanout( pNode, pFanout, i )
01208     {
01209         iFanin = Vec_IntFind( &pFanout->vFanins, pNode->Id );
01210         assert( iFanin >= 0 );
01211         if ( Abc_ObjFaninC( pFanout, iFanin ) )
01212             return 1;
01213     }
01214     return 0;
01215 }

bool Abc_AigNodeHasComplFanoutEdgeTrav ( Abc_Obj_t pNode  ) 

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

Synopsis [Returns 1 if the node has at least one complemented fanout.]

Description [A fanout is complemented if the fanout's fanin edge pointing to the given node is complemented. Only the fanouts with current TravId are counted.]

SideEffects []

SeeAlso []

Definition at line 1230 of file abcAig.c.

01231 {
01232     Abc_Obj_t * pFanout;
01233     int i, iFanin;
01234     Abc_ObjForEachFanout( pNode, pFanout, i )
01235     {
01236         if ( !Abc_NodeIsTravIdCurrent(pFanout) )
01237             continue;
01238         iFanin = Vec_IntFind( &pFanout->vFanins, pNode->Id );
01239         assert( iFanin >= 0 );
01240         if ( Abc_ObjFaninC( pFanout, iFanin ) )
01241             return 1;
01242     }
01243     return 0;
01244 }

bool Abc_AigNodeIsAcyclic ( Abc_Obj_t pNode,
Abc_Obj_t pRoot 
)

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

Synopsis [Check if the node has a combination loop of depth 1 or 2.]

Description []

SideEffects []

SeeAlso []

Definition at line 1292 of file abcAig.c.

01293 {
01294     Abc_Obj_t * pFanin0, * pFanin1;
01295     Abc_Obj_t * pChild00, * pChild01;
01296     Abc_Obj_t * pChild10, * pChild11;
01297     if ( !Abc_AigNodeIsAnd(pNode) )
01298         return 1;
01299     pFanin0 = Abc_ObjFanin0(pNode);
01300     pFanin1 = Abc_ObjFanin1(pNode);
01301     if ( pRoot == pFanin0 || pRoot == pFanin1 )
01302         return 0;
01303     if ( Abc_ObjIsCi(pFanin0) )
01304     {
01305         pChild00 = NULL;
01306         pChild01 = NULL;
01307     }
01308     else
01309     {
01310         pChild00 = Abc_ObjFanin0(pFanin0);
01311         pChild01 = Abc_ObjFanin1(pFanin0);
01312         if ( pRoot == pChild00 || pRoot == pChild01 )
01313             return 0;
01314     }
01315     if ( Abc_ObjIsCi(pFanin1) )
01316     {
01317         pChild10 = NULL;
01318         pChild11 = NULL;
01319     }
01320     else
01321     {
01322         pChild10 = Abc_ObjFanin0(pFanin1);
01323         pChild11 = Abc_ObjFanin1(pFanin1);
01324         if ( pRoot == pChild10 || pRoot == pChild11 )
01325             return 0;
01326     }
01327     return 1;
01328 }

static bool Abc_AigNodeIsAnd ( Abc_Obj_t pNode  )  [inline, static]

Definition at line 412 of file abc.h.

00412 { assert(!Abc_ObjIsComplement(pNode)); assert(Abc_NtkIsStrash(pNode->pNtk)); return Abc_ObjFaninNum(pNode) == 2;                         }

static bool Abc_AigNodeIsChoice ( Abc_Obj_t pNode  )  [inline, static]

Definition at line 413 of file abc.h.

00413 { assert(!Abc_ObjIsComplement(pNode)); assert(Abc_NtkIsStrash(pNode->pNtk)); return pNode->pData != NULL && Abc_ObjFanoutNum(pNode) > 0; }

static bool Abc_AigNodeIsConst ( Abc_Obj_t pNode  )  [inline, static]

Definition at line 411 of file abc.h.

00411 { assert(Abc_NtkIsStrash(Abc_ObjRegular(pNode)->pNtk));  return Abc_ObjRegular(pNode)->Type == ABC_OBJ_CONST1;       }

Abc_Obj_t* Abc_AigOr ( Abc_Aig_t pMan,
Abc_Obj_t p0,
Abc_Obj_t p1 
)

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

Synopsis [Implements Boolean OR.]

Description []

SideEffects []

SeeAlso []

Definition at line 719 of file abcAig.c.

00720 {
00721     return Abc_ObjNot( Abc_AigAnd( pMan, Abc_ObjNot(p0), Abc_ObjNot(p1) ) );
00722 }

void Abc_AigPrintNode ( Abc_Obj_t pNode  ) 

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

Synopsis [Prints the AIG node for debugging purposes.]

Description []

SideEffects []

SeeAlso []

Definition at line 1258 of file abcAig.c.

01259 {
01260     Abc_Obj_t * pNodeR = Abc_ObjRegular(pNode);
01261     if ( Abc_ObjIsCi(pNodeR) )
01262     {
01263         printf( "CI %4s%s.\n", Abc_ObjName(pNodeR), Abc_ObjIsComplement(pNode)? "\'" : "" );
01264         return;
01265     }
01266     if ( Abc_AigNodeIsConst(pNodeR) )
01267     {
01268         printf( "Constant 1 %s.\n", Abc_ObjIsComplement(pNode)? "(complemented)" : ""  );
01269         return;
01270     }
01271     // print the node's function
01272     printf( "%7s%s", Abc_ObjName(pNodeR),                Abc_ObjIsComplement(pNode)? "\'" : "" );
01273     printf( " = " );
01274     printf( "%7s%s", Abc_ObjName(Abc_ObjFanin0(pNodeR)), Abc_ObjFaninC0(pNodeR)?     "\'" : "" );
01275     printf( " * " );
01276     printf( "%7s%s", Abc_ObjName(Abc_ObjFanin1(pNodeR)), Abc_ObjFaninC1(pNodeR)?     "\'" : "" );
01277     printf( "\n" );
01278 }

void Abc_AigRehash ( Abc_Aig_t pMan  ) 

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

Synopsis [Resizes the hash table of AIG nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 628 of file abcAig.c.

00629 {
00630     Abc_Obj_t ** pBinsNew;
00631     Abc_Obj_t * pEnt, * pEnt2;
00632     int * pArray;
00633     unsigned Key;
00634     int Counter, Temp, i;
00635 
00636     // allocate a new array
00637     pBinsNew = ALLOC( Abc_Obj_t *, pMan->nBins );
00638     memset( pBinsNew, 0, sizeof(Abc_Obj_t *) * pMan->nBins );
00639     // rehash the entries from the old table
00640     Counter = 0;
00641     for ( i = 0; i < pMan->nBins; i++ )
00642         Abc_AigBinForEachEntrySafe( pMan->pBins[i], pEnt, pEnt2 )
00643         {
00644             // swap the fanins if needed
00645             pArray = pEnt->vFanins.pArray;
00646             if ( pArray[0] > pArray[1] )
00647             {
00648                 Temp = pArray[0];
00649                 pArray[0] = pArray[1];
00650                 pArray[1] = Temp;
00651                 Temp = pEnt->fCompl0;
00652                 pEnt->fCompl0 = pEnt->fCompl1;
00653                 pEnt->fCompl1 = Temp;
00654             }
00655             // rehash the node
00656             Key = Abc_HashKey2( Abc_ObjChild0(pEnt), Abc_ObjChild1(pEnt), pMan->nBins );
00657             pEnt->pNext   = pBinsNew[Key];
00658             pBinsNew[Key] = pEnt;
00659             Counter++;
00660         }
00661     assert( Counter == pMan->nEntries );
00662     // replace the table and the parameters
00663     free( pMan->pBins );
00664     pMan->pBins = pBinsNew;
00665 }

void Abc_AigReplace ( Abc_Aig_t pMan,
Abc_Obj_t pOld,
Abc_Obj_t pNew,
bool  fUpdateLevel 
)

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

Synopsis [Replaces one AIG node by the other.]

Description []

SideEffects []

SeeAlso []

Definition at line 826 of file abcAig.c.

00827 {
00828     assert( Vec_PtrSize(pMan->vStackReplaceOld) == 0 );
00829     assert( Vec_PtrSize(pMan->vStackReplaceNew) == 0 );
00830     Vec_PtrPush( pMan->vStackReplaceOld, pOld );
00831     Vec_PtrPush( pMan->vStackReplaceNew, pNew );
00832     assert( !Abc_ObjIsComplement(pOld) );
00833     // create HAIG
00834     if ( pOld->pNtk->pHaig )
00835         Hop_ObjCreateChoice( pOld->pEquiv, Abc_ObjRegular(pNew)->pEquiv );
00836     // process the replacements
00837     while ( Vec_PtrSize(pMan->vStackReplaceOld) )
00838     {
00839         pOld = Vec_PtrPop( pMan->vStackReplaceOld );
00840         pNew = Vec_PtrPop( pMan->vStackReplaceNew );
00841         Abc_AigReplace_int( pMan, pOld, pNew, fUpdateLevel );
00842     }
00843     if ( fUpdateLevel )
00844     {
00845         Abc_AigUpdateLevel_int( pMan );
00846         if ( pMan->pNtkAig->vLevelsR ) 
00847             Abc_AigUpdateLevelR_int( pMan );
00848     }
00849 }

void Abc_AigSetNodePhases ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Sets the correct phase of the nodes.]

Description [The AIG nodes should be in the DFS order.]

SideEffects []

SeeAlso []

Definition at line 1368 of file abcAig.c.

01369 {
01370     Abc_Obj_t * pObj;
01371     int i;
01372     assert( Abc_NtkIsDfsOrdered(pNtk) );
01373     Abc_AigConst1(pNtk)->fPhase = 1;
01374     Abc_NtkForEachPi( pNtk, pObj, i )
01375         pObj->fPhase = 0;
01376     Abc_NtkForEachLatchOutput( pNtk, pObj, i )
01377         pObj->fPhase = Abc_LatchIsInit1(pObj);
01378     Abc_AigForEachAnd( pNtk, pObj, i )
01379         pObj->fPhase = (Abc_ObjFanin0(pObj)->fPhase ^ Abc_ObjFaninC0(pObj)) & (Abc_ObjFanin1(pObj)->fPhase ^ Abc_ObjFaninC1(pObj));
01380     Abc_NtkForEachPo( pNtk, pObj, i )
01381         pObj->fPhase = (Abc_ObjFanin0(pObj)->fPhase ^ Abc_ObjFaninC0(pObj));
01382     Abc_NtkForEachLatchInput( pNtk, pObj, i )
01383         pObj->fPhase = (Abc_ObjFanin0(pObj)->fPhase ^ Abc_ObjFaninC0(pObj));
01384 }

void Abc_AigUpdateReset ( Abc_Aig_t pMan  ) 

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

Synopsis [Start the update list.]

Description []

SideEffects []

SeeAlso []

Definition at line 1439 of file abcAig.c.

01440 {
01441     assert( pMan->vAddedCells != NULL );
01442     Vec_PtrClear( pMan->vAddedCells );
01443     Vec_PtrClear( pMan->vUpdatedNets );
01444 }

Vec_Ptr_t* Abc_AigUpdateStart ( Abc_Aig_t pMan,
Vec_Ptr_t **  pvUpdatedNets 
)

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

Synopsis [Start the update list.]

Description []

SideEffects []

SeeAlso []

Definition at line 1399 of file abcAig.c.

01400 {
01401     assert( pMan->vAddedCells == NULL );
01402     pMan->vAddedCells  = Vec_PtrAlloc( 1000 );
01403     pMan->vUpdatedNets = Vec_PtrAlloc( 1000 );
01404     *pvUpdatedNets = pMan->vUpdatedNets;
01405     return pMan->vAddedCells;
01406 }

void Abc_AigUpdateStop ( Abc_Aig_t pMan  ) 

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

Synopsis [Start the update list.]

Description []

SideEffects []

SeeAlso []

Definition at line 1419 of file abcAig.c.

01420 {
01421     assert( pMan->vAddedCells != NULL );
01422     Vec_PtrFree( pMan->vAddedCells );
01423     Vec_PtrFree( pMan->vUpdatedNets );
01424     pMan->vAddedCells = NULL;
01425     pMan->vUpdatedNets = NULL;
01426 }

Abc_Obj_t* Abc_AigXor ( Abc_Aig_t pMan,
Abc_Obj_t p0,
Abc_Obj_t p1 
)

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

Synopsis [Implements Boolean XOR.]

Description []

SideEffects []

SeeAlso []

Definition at line 735 of file abcAig.c.

00736 {
00737     return Abc_AigOr( pMan, Abc_AigAnd(pMan, p0, Abc_ObjNot(p1)), 
00738                             Abc_AigAnd(pMan, p1, Abc_ObjNot(p0)) );
00739 }

Abc_Obj_t* Abc_AigXorLookup ( Abc_Aig_t pMan,
Abc_Obj_t p0,
Abc_Obj_t p1,
int *  pType 
)

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

Synopsis [Returns the gate implementing EXOR of the two arguments if it exists.]

Description [The argument nodes can be complemented.]

SideEffects []

SeeAlso []

Definition at line 475 of file abcAig.c.

00476 {
00477     Abc_Obj_t * pNode1, * pNode2, * pNode;
00478     // set the flag to zero
00479     if ( pType ) *pType = 0;
00480     // check the case of XOR(a,b) = OR(ab, a'b')'
00481     if ( (pNode1 = Abc_AigAndLookup(pMan, Abc_ObjNot(p0), Abc_ObjNot(p1))) &&
00482          (pNode2 = Abc_AigAndLookup(pMan, p0, p1)) ) 
00483     {
00484         pNode = Abc_AigAndLookup( pMan, Abc_ObjNot(pNode1), Abc_ObjNot(pNode2) );
00485         if ( pNode && pType ) *pType = 1;
00486         return pNode;
00487     }
00488     // check the case of XOR(a,b) = OR(a'b, ab')
00489     if ( (pNode1 = Abc_AigAndLookup(pMan, p0, Abc_ObjNot(p1))) &&
00490          (pNode2 = Abc_AigAndLookup(pMan, Abc_ObjNot(p0), p1)) ) 
00491     {
00492         pNode = Abc_AigAndLookup( pMan, Abc_ObjNot(pNode1), Abc_ObjNot(pNode2) );
00493         return pNode? Abc_ObjNot(pNode) : NULL;
00494     }
00495     return NULL;
00496 }

static int Abc_BitWordNum ( int  nBits  )  [inline, static]

Definition at line 243 of file abc.h.

00243 { return (nBits>>5) + ((nBits&31) > 0);        }

unsigned* Abc_ConvertAigToTruth ( Hop_Man_t p,
Hop_Obj_t pRoot,
int  nVars,
Vec_Int_t vTruth,
int  fMsbFirst 
)

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

Synopsis [Computes truth table of the node.]

Description [Assumes that the structural support is no more than 8 inputs. Uses array vTruth to store temporary truth tables. The returned pointer should be used immediately.]

SideEffects []

SeeAlso []

Definition at line 869 of file abcFunc.c.

00870 {
00871     static unsigned uTruths[8][8] = { // elementary truth tables
00872         { 0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA },
00873         { 0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC },
00874         { 0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0 },
00875         { 0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00 },
00876         { 0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000 }, 
00877         { 0x00000000,0xFFFFFFFF,0x00000000,0xFFFFFFFF,0x00000000,0xFFFFFFFF,0x00000000,0xFFFFFFFF }, 
00878         { 0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFF,0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFF }, 
00879         { 0x00000000,0x00000000,0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF } 
00880     };
00881     Hop_Obj_t * pObj;
00882     unsigned * pTruth, * pTruth2;
00883     int i, nWords, nNodes;
00884     Vec_Ptr_t * vTtElems;
00885 
00886     // if the number of variables is more than 8, allocate truth tables
00887     if ( nVars > 8 )
00888         vTtElems = Vec_PtrAllocTruthTables( nVars );
00889     else
00890         vTtElems = NULL;
00891 
00892     // clear the data fields and set marks
00893     nNodes = Abc_ConvertAigToTruth_rec1( pRoot );
00894     // prepare memory
00895     nWords = Hop_TruthWordNum( nVars );
00896     Vec_IntClear( vTruth );
00897     Vec_IntGrow( vTruth, nWords * (nNodes+1) );
00898     pTruth = Vec_IntFetch( vTruth, nWords );
00899     // check the case of a constant
00900     if ( Hop_ObjIsConst1( Hop_Regular(pRoot) ) )
00901     {
00902         assert( nNodes == 0 );
00903         if ( Hop_IsComplement(pRoot) )
00904             Extra_TruthClear( pTruth, nVars );
00905         else
00906             Extra_TruthFill( pTruth, nVars );
00907         return pTruth;
00908     }
00909     // set elementary truth tables at the leaves
00910     assert( nVars <= Hop_ManPiNum(p) );
00911 //    assert( Hop_ManPiNum(p) <= 8 ); 
00912     if ( fMsbFirst )
00913     {
00914         Hop_ManForEachPi( p, pObj, i )
00915         {
00916             if ( vTtElems )
00917                 pObj->pData = Vec_PtrEntry(vTtElems, nVars-1-i);
00918             else               
00919                 pObj->pData = (void *)uTruths[nVars-1-i];
00920         }
00921     }
00922     else
00923     {
00924         Hop_ManForEachPi( p, pObj, i )
00925         {
00926             if ( vTtElems )
00927                 pObj->pData = Vec_PtrEntry(vTtElems, i);
00928             else               
00929                 pObj->pData = (void *)uTruths[i];
00930         }
00931     }
00932     // clear the marks and compute the truth table
00933     pTruth2 = Abc_ConvertAigToTruth_rec2( pRoot, vTruth, nWords );
00934     // copy the result
00935     Extra_TruthCopy( pTruth, pTruth2, nVars );
00936     if ( vTtElems )
00937         Vec_PtrFree( vTtElems );
00938     return pTruth;
00939 }

char* Abc_ConvertBddToSop ( Extra_MmFlex_t pMan,
DdManager dd,
DdNode bFuncOn,
DdNode bFuncOnDc,
int  nFanins,
int  fAllPrimes,
Vec_Str_t vCube,
int  fMode 
)

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

Synopsis [Converts the node from BDD to SOP representation.]

Description []

SideEffects []

SeeAlso []

Definition at line 276 of file abcFunc.c.

00277 {
00278     int fVerify = 0;
00279     char * pSop;
00280     DdNode * bFuncNew, * bCover, * zCover, * zCover0, * zCover1;
00281     int nCubes, nCubes0, nCubes1, fPhase;
00282 
00283     assert( bFuncOn == bFuncOnDc || Cudd_bddLeq( dd, bFuncOn, bFuncOnDc ) );
00284     if ( Cudd_IsConstant(bFuncOn) || Cudd_IsConstant(bFuncOnDc) )
00285     {
00286         if ( fMode == -1 ) // if the phase is not known, write constant 1
00287             fMode = 1;
00288         Vec_StrFill( vCube, nFanins, '-' );
00289         Vec_StrPush( vCube, '\0' );
00290         if ( pMan )
00291             pSop = Extra_MmFlexEntryFetch( pMan, nFanins + 4 );
00292         else
00293             pSop = ALLOC( char, nFanins + 4 );
00294         if ( bFuncOn == Cudd_ReadOne(dd) )
00295             sprintf( pSop, "%s %d\n", vCube->pArray, fMode );
00296         else
00297             sprintf( pSop, "%s %d\n", vCube->pArray, !fMode );
00298         return pSop;
00299     }
00300 
00301 
00302     if ( fMode == -1 )
00303     { // try both phases
00304         assert( fAllPrimes == 0 );
00305 
00306         // get the ZDD of the negative polarity
00307         bCover = Cudd_zddIsop( dd, Cudd_Not(bFuncOnDc), Cudd_Not(bFuncOn), &zCover0 );
00308         Cudd_Ref( zCover0 );
00309         Cudd_Ref( bCover );
00310         Cudd_RecursiveDeref( dd, bCover );
00311         nCubes0 = Abc_CountZddCubes( dd, zCover0 );
00312 
00313         // get the ZDD of the positive polarity
00314         bCover = Cudd_zddIsop( dd, bFuncOn, bFuncOnDc, &zCover1 );
00315         Cudd_Ref( zCover1 );
00316         Cudd_Ref( bCover );
00317         Cudd_RecursiveDeref( dd, bCover );
00318         nCubes1 = Abc_CountZddCubes( dd, zCover1 );
00319 
00320         // compare the number of cubes
00321         if ( nCubes1 <= nCubes0 )
00322         { // use positive polarity
00323             nCubes = nCubes1;
00324             zCover = zCover1;
00325             Cudd_RecursiveDerefZdd( dd, zCover0 );
00326             fPhase = 1;
00327         }
00328         else
00329         { // use negative polarity
00330             nCubes = nCubes0;
00331             zCover = zCover0;
00332             Cudd_RecursiveDerefZdd( dd, zCover1 );
00333             fPhase = 0;
00334         }
00335     }
00336     else if ( fMode == 0 )
00337     {
00338         // get the ZDD of the negative polarity
00339         if ( fAllPrimes )
00340         {
00341             zCover = Extra_zddPrimes( dd, Cudd_Not(bFuncOnDc) ); 
00342             Cudd_Ref( zCover );
00343         }
00344         else
00345         {
00346             bCover = Cudd_zddIsop( dd, Cudd_Not(bFuncOnDc), Cudd_Not(bFuncOn), &zCover );
00347             Cudd_Ref( zCover );
00348             Cudd_Ref( bCover );
00349             Cudd_RecursiveDeref( dd, bCover );
00350         }
00351         nCubes = Abc_CountZddCubes( dd, zCover );
00352         fPhase = 0;
00353     }
00354     else if ( fMode == 1 )
00355     {
00356         // get the ZDD of the positive polarity
00357         if ( fAllPrimes )
00358         {
00359             zCover = Extra_zddPrimes( dd, bFuncOnDc ); 
00360             Cudd_Ref( zCover );
00361         }
00362         else
00363         {
00364             bCover = Cudd_zddIsop( dd, bFuncOn, bFuncOnDc, &zCover );
00365             Cudd_Ref( zCover );
00366             Cudd_Ref( bCover );
00367             Cudd_RecursiveDeref( dd, bCover );
00368         }
00369         nCubes = Abc_CountZddCubes( dd, zCover );
00370         fPhase = 1;
00371     }
00372     else
00373     {
00374         assert( 0 );
00375     }
00376 
00377     if ( nCubes > ABC_MUX_CUBES )
00378     {
00379         Cudd_RecursiveDerefZdd( dd, zCover );
00380         printf( "The number of cubes exceeded the predefined limit (%d).\n", ABC_MUX_CUBES );
00381         return NULL;
00382     }
00383 
00384     // allocate memory for the cover
00385     if ( pMan )
00386         pSop = Extra_MmFlexEntryFetch( pMan, (nFanins + 3) * nCubes + 1 );
00387     else 
00388         pSop = ALLOC( char, (nFanins + 3) * nCubes + 1 );
00389     pSop[(nFanins + 3) * nCubes] = 0;
00390     // create the SOP
00391     Vec_StrFill( vCube, nFanins, '-' );
00392     Vec_StrPush( vCube, '\0' );
00393     Abc_ConvertZddToSop( dd, zCover, pSop, nFanins, vCube, fPhase );
00394     Cudd_RecursiveDerefZdd( dd, zCover );
00395 
00396     // verify
00397     if ( fVerify )
00398     {
00399         bFuncNew = Abc_ConvertSopToBdd( dd, pSop );  Cudd_Ref( bFuncNew );
00400         if ( bFuncOn == bFuncOnDc )
00401         {
00402             if ( bFuncNew != bFuncOn )
00403                 printf( "Verification failed.\n" );
00404         }
00405         else
00406         {
00407             if ( !Cudd_bddLeq(dd, bFuncOn, bFuncNew) || !Cudd_bddLeq(dd, bFuncNew, bFuncOnDc) )
00408                 printf( "Verification failed.\n" );
00409         }
00410         Cudd_RecursiveDeref( dd, bFuncNew );
00411     }
00412     return pSop;
00413 }

DdNode* Abc_ConvertSopToBdd ( DdManager dd,
char *  pSop 
)

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

Synopsis [Converts the node from SOP to BDD representation.]

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file abcFunc.c.

00098 {
00099     DdNode * bSum, * bCube, * bTemp, * bVar;
00100     char * pCube;
00101     int nVars, Value, v;
00102 
00103     // start the cover
00104     nVars = Abc_SopGetVarNum(pSop);
00105     bSum = Cudd_ReadLogicZero(dd);   Cudd_Ref( bSum );
00106     if ( Abc_SopIsExorType(pSop) )
00107     {
00108         for ( v = 0; v < nVars; v++ )
00109         {
00110             bSum  = Cudd_bddXor( dd, bTemp = bSum, Cudd_bddIthVar(dd, v) );   Cudd_Ref( bSum );
00111             Cudd_RecursiveDeref( dd, bTemp );
00112         }
00113     }
00114     else
00115     {
00116         // check the logic function of the node
00117         Abc_SopForEachCube( pSop, nVars, pCube )
00118         {
00119             bCube = Cudd_ReadOne(dd);   Cudd_Ref( bCube );
00120             Abc_CubeForEachVar( pCube, Value, v )
00121             {
00122                 if ( Value == '0' )
00123                     bVar = Cudd_Not( Cudd_bddIthVar( dd, v ) );
00124                 else if ( Value == '1' )
00125                     bVar = Cudd_bddIthVar( dd, v );
00126                 else
00127                     continue;
00128                 bCube  = Cudd_bddAnd( dd, bTemp = bCube, bVar );   Cudd_Ref( bCube );
00129                 Cudd_RecursiveDeref( dd, bTemp );
00130             }
00131             bSum = Cudd_bddOr( dd, bTemp = bSum, bCube );   
00132             Cudd_Ref( bSum );
00133             Cudd_RecursiveDeref( dd, bTemp );
00134             Cudd_RecursiveDeref( dd, bCube );
00135         }
00136     }
00137     // complement the result if necessary
00138     bSum = Cudd_NotCond( bSum, !Abc_SopGetPhase(pSop) );
00139     Cudd_Deref( bSum );
00140     return bSum;
00141 }

int Abc_CountZddCubes ( DdManager dd,
DdNode zCover 
)

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

Synopsis [Count the number of paths in the ZDD.]

Description []

SideEffects []

SeeAlso []

Definition at line 532 of file abcFunc.c.

00533 {
00534     int nCubes = 0;
00535     Abc_CountZddCubes_rec( dd, zCover, &nCubes );
00536     return nCubes;
00537 }

Vec_Vec_t* Abc_DfsLevelized ( Abc_Obj_t pNode,
bool  fTfi 
)

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

Synopsis [Collects nodes in the DFS manner by level.]

Description [The number of levels should be set!!!]

SideEffects []

SeeAlso []

Definition at line 869 of file abcDfs.c.

00870 {
00871     Vec_Vec_t * vLevels;
00872     Abc_Obj_t * pFanout;
00873     int i;
00874     assert( fTfi == 0 );
00875     assert( !Abc_NtkIsNetlist(pNode->pNtk) );
00876     // set the traversal ID
00877     Abc_NtkIncrementTravId( pNode->pNtk );
00878     vLevels = Vec_VecAlloc( 100 );
00879     if ( Abc_ObjIsNode(pNode) )
00880         Abc_DfsLevelizedTfo_rec( pNode, vLevels );
00881     else
00882     {
00883         assert( Abc_ObjIsCi(pNode) );
00884         Abc_NodeSetTravIdCurrent( pNode );
00885         Abc_ObjForEachFanout( pNode, pFanout, i )
00886             Abc_DfsLevelizedTfo_rec( pFanout, vLevels );
00887     }
00888     return vLevels;
00889 }

static int Abc_Float2Int ( float  Val  )  [inline, static]

Definition at line 241 of file abc.h.

00241 { return *((int *)&Val);                       }

static void Abc_InfoAnd ( unsigned *  p,
unsigned *  q,
int  nWords 
) [inline, static]

Definition at line 256 of file abc.h.

00256 { int i; for ( i = nWords - 1; i >= 0; i-- ) p[i] &= q[i];  } 

static void Abc_InfoClear ( unsigned *  p,
int  nWords 
) [inline, static]

Definition at line 250 of file abc.h.

00250 { memset( p, 0, sizeof(unsigned) * nWords );   } 

static void Abc_InfoCopy ( unsigned *  p,
unsigned *  q,
int  nWords 
) [inline, static]

Definition at line 255 of file abc.h.

00255 { int i; for ( i = nWords - 1; i >= 0; i-- ) p[i]  = q[i];  } 

static void Abc_InfoFill ( unsigned *  p,
int  nWords 
) [inline, static]

Definition at line 251 of file abc.h.

00251 { memset( p, 0xff, sizeof(unsigned) * nWords );} 

static int Abc_InfoHasBit ( unsigned *  p,
int  i 
) [inline, static]

Definition at line 245 of file abc.h.

00245 { return (p[(i)>>5] & (1<<((i) & 31))) > 0;    }

static int Abc_InfoIsOne ( unsigned *  p,
int  nWords 
) [inline, static]

Definition at line 254 of file abc.h.

00254 { int i; for ( i = nWords - 1; i >= 0; i-- ) if ( ~p[i] ) return 0; return 1; } 

static int Abc_InfoIsOrOne ( unsigned *  p,
unsigned *  q,
int  nWords 
) [inline, static]

Definition at line 259 of file abc.h.

00259 { int i; for ( i = nWords - 1; i >= 0; i-- ) if ( ~(p[i] | q[i]) ) return 0; return 1; } 

static int Abc_InfoIsOrOne3 ( unsigned *  p,
unsigned *  q,
unsigned *  r,
int  nWords 
) [inline, static]

Definition at line 260 of file abc.h.

00260 { int i; for ( i = nWords - 1; i >= 0; i-- ) if ( ~(p[i] | q[i] | r[i]) ) return 0; return 1; } 

static int Abc_InfoIsZero ( unsigned *  p,
int  nWords 
) [inline, static]

Definition at line 253 of file abc.h.

00253 { int i; for ( i = nWords - 1; i >= 0; i-- ) if ( p[i] )  return 0; return 1; } 

static void Abc_InfoNot ( unsigned *  p,
int  nWords 
) [inline, static]

Definition at line 252 of file abc.h.

00252 { int i; for ( i = nWords - 1; i >= 0; i-- ) p[i] = ~p[i];   } 

static void Abc_InfoOr ( unsigned *  p,
unsigned *  q,
int  nWords 
) [inline, static]

Definition at line 257 of file abc.h.

00257 { int i; for ( i = nWords - 1; i >= 0; i-- ) p[i] |= q[i];  } 

static void Abc_InfoRandom ( unsigned *  p,
int  nWords 
) [inline, static]

Definition at line 249 of file abc.h.

00249 { int i; for ( i = nWords - 1; i >= 0; i-- ) p[i] = Abc_InfoRandomWord();   } 

static unsigned Abc_InfoRandomWord (  )  [inline, static]

Definition at line 248 of file abc.h.

00248 { return ((((unsigned)rand()) << 24) ^ (((unsigned)rand()) << 12) ^ ((unsigned)rand())); } // #define RAND_MAX 0x7fff

static void Abc_InfoSetBit ( unsigned *  p,
int  i 
) [inline, static]

Definition at line 246 of file abc.h.

00246 { p[(i)>>5] |= (1<<((i) & 31));                }

static void Abc_InfoXor ( unsigned *  p,
unsigned *  q,
int  nWords 
) [inline, static]

Definition at line 258 of file abc.h.

00258 { int i; for ( i = nWords - 1; i >= 0; i-- ) p[i] ^= q[i];  } 

static void Abc_InfoXorBit ( unsigned *  p,
int  i 
) [inline, static]

Definition at line 247 of file abc.h.

00247 { p[(i)>>5] ^= (1<<((i) & 31));                }

static float Abc_Int2Float ( int  Num  )  [inline, static]

Definition at line 242 of file abc.h.

00242 { return *((float *)&Num);                     }

static int Abc_LatchInit ( Abc_Obj_t pLatch  )  [inline, static]

Definition at line 436 of file abc.h.

00436 { assert(Abc_ObjIsLatch(pLatch)); return (int)pLatch->pData;                     }

static bool Abc_LatchIsInit0 ( Abc_Obj_t pLatch  )  [inline, static]

Definition at line 433 of file abc.h.

00433 { assert(Abc_ObjIsLatch(pLatch)); return pLatch->pData == (void *)ABC_INIT_ZERO; }

static bool Abc_LatchIsInit1 ( Abc_Obj_t pLatch  )  [inline, static]

Definition at line 434 of file abc.h.

00434 { assert(Abc_ObjIsLatch(pLatch)); return pLatch->pData == (void *)ABC_INIT_ONE;  }

static bool Abc_LatchIsInitDc ( Abc_Obj_t pLatch  )  [inline, static]

Definition at line 435 of file abc.h.

00435 { assert(Abc_ObjIsLatch(pLatch)); return pLatch->pData == (void *)ABC_INIT_DC;   }

static bool Abc_LatchIsInitNone ( Abc_Obj_t pLatch  )  [inline, static]

Definition at line 432 of file abc.h.

00432 { assert(Abc_ObjIsLatch(pLatch)); return pLatch->pData == (void *)ABC_INIT_NONE; }

static void Abc_LatchSetInit0 ( Abc_Obj_t pLatch  )  [inline, static]

Definition at line 429 of file abc.h.

00429 { assert(Abc_ObjIsLatch(pLatch)); pLatch->pData = (void *)ABC_INIT_ZERO;         }

static void Abc_LatchSetInit1 ( Abc_Obj_t pLatch  )  [inline, static]

Definition at line 430 of file abc.h.

00430 { assert(Abc_ObjIsLatch(pLatch)); pLatch->pData = (void *)ABC_INIT_ONE;          }

static void Abc_LatchSetInitDc ( Abc_Obj_t pLatch  )  [inline, static]

Definition at line 431 of file abc.h.

00431 { assert(Abc_ObjIsLatch(pLatch)); pLatch->pData = (void *)ABC_INIT_DC;           }

static void Abc_LatchSetInitNone ( Abc_Obj_t pLatch  )  [inline, static]

Definition at line 428 of file abc.h.

00428 { assert(Abc_ObjIsLatch(pLatch)); pLatch->pData = (void *)ABC_INIT_NONE;         }

int Abc_LibAddModel ( Abc_Lib_t pLib,
Abc_Ntk_t pNtk 
)

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

Synopsis [Create the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 167 of file abcLib.c.

00168 {
00169     if ( st_is_member( pLib->tModules, (char *)pNtk->pName ) )
00170         return 0;
00171     st_insert( pLib->tModules, (char *)pNtk->pName, (char *)pNtk );
00172     Vec_PtrPush( pLib->vModules, pNtk );
00173     pNtk->pDesign = pLib;
00174     return 1;
00175 }

Abc_Lib_t* Abc_LibCreate ( char *  pName  ) 

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

FileName [abcLib.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Functions to manipulate verilog libraries.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Create the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file abcLib.c.

00043 {
00044     Abc_Lib_t * p;
00045     p = ALLOC( Abc_Lib_t, 1 );
00046     memset( p, 0, sizeof(Abc_Lib_t) );
00047     p->pName    = Extra_UtilStrsav( pName );
00048     p->tModules = st_init_table( strcmp, st_strhash );
00049     p->vTops    = Vec_PtrAlloc( 100 );
00050     p->vModules = Vec_PtrAlloc( 100 );
00051     p->pManFunc = Hop_ManStart();
00052     p->pLibrary = NULL;
00053     return p;
00054 }

Abc_Ntk_t* Abc_LibDeriveRoot ( Abc_Lib_t pLib  ) 

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

Synopsis [Frees the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 208 of file abcLib.c.

00209 {
00210     Abc_Ntk_t * pNtk;
00211     if ( Vec_PtrSize(pLib->vModules) > 1 )
00212     {
00213         printf( "The design includes more than one module and is currently not used.\n" );
00214         return NULL;
00215     }
00216     pNtk = Vec_PtrEntry( pLib->vModules, 0 );  Vec_PtrClear( pLib->vModules );
00217     pNtk->pManFunc = pLib->pManFunc;           pLib->pManFunc = NULL;
00218     return pNtk;
00219 }

Abc_Ntk_t* Abc_LibFindModelByName ( Abc_Lib_t pLib,
char *  pName 
)

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

Synopsis [Create the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 188 of file abcLib.c.

00189 {
00190     Abc_Ntk_t * pNtk;
00191     if ( !st_is_member( pLib->tModules, (char *)pName ) )
00192         return NULL;
00193     st_lookup( pLib->tModules, (char *)pName, (char **)&pNtk );
00194     return pNtk;
00195 }

int Abc_LibFindTopLevelModels ( Abc_Lib_t pLib  ) 

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

Synopsis [Detects the top-level models.]

Description []

SideEffects []

SeeAlso []

Definition at line 232 of file abcLib.c.

00233 {
00234     Abc_Ntk_t * pNtk, * pNtkBox;
00235     Abc_Obj_t * pObj;
00236     int i, k;
00237     assert( Vec_PtrSize( pLib->vModules ) > 0 );
00238     // clear the models
00239     Vec_PtrForEachEntry( pLib->vModules, pNtk, i )
00240         pNtk->fHieVisited = 0;
00241     // mark all the models reachable from other models
00242     Vec_PtrForEachEntry( pLib->vModules, pNtk, i )
00243     {
00244         Abc_NtkForEachBox( pNtk, pObj, k )
00245         {
00246             if ( Abc_ObjIsLatch(pObj) )
00247                 continue;
00248             if ( pObj->pData == NULL )
00249                 continue;
00250             pNtkBox = pObj->pData;
00251             pNtkBox->fHieVisited = 1;
00252         }
00253     }
00254     // collect the models that are not marked
00255     Vec_PtrClear( pLib->vTops );
00256     Vec_PtrForEachEntry( pLib->vModules, pNtk, i )
00257     {
00258         if ( pNtk->fHieVisited == 0 )
00259             Vec_PtrPush( pLib->vTops, pNtk );
00260         else
00261             pNtk->fHieVisited = 0;
00262     }
00263     return Vec_PtrSize( pLib->vTops );
00264 }

void Abc_LibFree ( Abc_Lib_t pLib,
Abc_Ntk_t pNtkSave 
)

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

Synopsis [Frees the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 67 of file abcLib.c.

00068 {
00069     Abc_Ntk_t * pNtk;
00070     int i;
00071     if ( pLib->pName )
00072         free( pLib->pName );
00073     if ( pLib->pManFunc )
00074         Hop_ManStop( pLib->pManFunc );
00075     if ( pLib->tModules )
00076         st_free_table( pLib->tModules );
00077     if ( pLib->vModules )
00078     {
00079         Vec_PtrForEachEntry( pLib->vModules, pNtk, i )
00080         {
00081 //            pNtk->pManFunc = NULL;
00082             if ( pNtk == pNtkSave )
00083                 continue;
00084             pNtk->pManFunc = NULL;
00085             pNtk->pDesign = NULL;
00086             Abc_NtkDelete( pNtk );
00087         }
00088         Vec_PtrFree( pLib->vModules );
00089     }
00090     if ( pLib->vTops )
00091         Vec_PtrFree( pLib->vTops );
00092     free( pLib );
00093 }

void Abc_LibPrint ( Abc_Lib_t pLib  ) 

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

Synopsis [Prints the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 135 of file abcLib.c.

00136 {
00137     Abc_Ntk_t * pNtk;
00138     Abc_Obj_t * pObj;
00139     int i, k;
00140     printf( "Models of design %s:\n", pLib->pName );
00141     Vec_PtrForEachEntry( pLib->vModules, pNtk, i )
00142     {
00143         printf( "%2d : %20s   ", i+1, pNtk->pName );
00144         printf( "nd = %6d   lat = %6d   whitebox = %3d   blackbox = %3d\n", 
00145             Abc_NtkNodeNum(pNtk), Abc_NtkLatchNum(pNtk), 
00146             Abc_NtkWhiteboxNum(pNtk), Abc_NtkBlackboxNum(pNtk) );
00147         if ( Abc_NtkBlackboxNum(pNtk) == 0 )
00148             continue;
00149         Abc_NtkForEachWhitebox( pNtk, pObj, k )
00150             printf( "     %20s (whitebox)\n", Abc_NtkName(pObj->pData) );
00151         Abc_NtkForEachBlackbox( pNtk, pObj, k )
00152             printf( "     %20s (blackbox)\n", Abc_NtkName(pObj->pData) );
00153     }
00154 }

void Abc_ManTimeDup ( Abc_Ntk_t pNtkOld,
Abc_Ntk_t pNtkNew 
)

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

Synopsis [Duplicates the timing manager with the PI/PO timing info.]

Description [The PIs/POs of the new network should be allocated.]

SideEffects []

SeeAlso []

Definition at line 367 of file abcTiming.c.

00368 {
00369     Abc_Obj_t * pObj;
00370     Abc_Time_t ** ppTimesOld, ** ppTimesNew;
00371     int i;
00372     if ( pNtkOld->pManTime == NULL )
00373         return;
00374     assert( Abc_NtkPiNum(pNtkOld) == Abc_NtkPiNum(pNtkNew) );
00375     assert( Abc_NtkPoNum(pNtkOld) == Abc_NtkPoNum(pNtkNew) );
00376     assert( Abc_NtkLatchNum(pNtkOld) == Abc_NtkLatchNum(pNtkNew) );
00377     // create the new timing manager
00378     pNtkNew->pManTime = Abc_ManTimeStart();
00379     Abc_ManTimeExpand( pNtkNew->pManTime, Abc_NtkObjNumMax(pNtkNew), 0 );
00380     // set the default timing
00381     pNtkNew->pManTime->tArrDef = pNtkOld->pManTime->tArrDef;
00382     pNtkNew->pManTime->tReqDef = pNtkOld->pManTime->tReqDef;
00383     // set the CI timing
00384     ppTimesOld = (Abc_Time_t **)pNtkOld->pManTime->vArrs->pArray;
00385     ppTimesNew = (Abc_Time_t **)pNtkNew->pManTime->vArrs->pArray;
00386     Abc_NtkForEachCi( pNtkOld, pObj, i )
00387         *ppTimesNew[ Abc_NtkCi(pNtkNew,i)->Id ] = *ppTimesOld[ pObj->Id ];
00388     // set the CO timing
00389     ppTimesOld = (Abc_Time_t **)pNtkOld->pManTime->vReqs->pArray;
00390     ppTimesNew = (Abc_Time_t **)pNtkNew->pManTime->vReqs->pArray;
00391     Abc_NtkForEachCo( pNtkOld, pObj, i )
00392         *ppTimesNew[ Abc_NtkCo(pNtkNew,i)->Id ] = *ppTimesOld[ pObj->Id ];
00393 }

void Abc_ManTimeStop ( Abc_ManTime_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 341 of file abcTiming.c.

00342 {
00343     if ( p->vArrs->nSize > 0 )
00344     {
00345         free( p->vArrs->pArray[0] );
00346         Vec_PtrFree( p->vArrs );
00347     }
00348     if ( p->vReqs->nSize > 0 )
00349     {
00350         free( p->vReqs->pArray[0] );
00351         Vec_PtrFree( p->vReqs );
00352     }
00353     free( p );
00354 }

void Abc_NodeBddToCnf ( Abc_Obj_t pNode,
Extra_MmFlex_t pMmMan,
Vec_Str_t vCube,
int  fAllPrimes,
char **  ppSop0,
char **  ppSop1 
)

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

Synopsis [Computes the SOPs of the negative and positive phase of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 482 of file abcFunc.c.

00483 {
00484     assert( Abc_NtkHasBdd(pNode->pNtk) ); 
00485     *ppSop0 = Abc_ConvertBddToSop( pMmMan, pNode->pNtk->pManFunc, pNode->pData, pNode->pData, Abc_ObjFaninNum(pNode), fAllPrimes, vCube, 0 );
00486     *ppSop1 = Abc_ConvertBddToSop( pMmMan, pNode->pNtk->pManFunc, pNode->pData, pNode->pData, Abc_ObjFaninNum(pNode), fAllPrimes, vCube, 1 );
00487 }

static void Abc_NodeClearPersistant ( Abc_Obj_t pNode  )  [inline, static]

Definition at line 418 of file abc.h.

00418 { assert( Abc_AigNodeIsAnd(pNode) ); pNode->fPersist = 0;    } 

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 1165 of file abcUtil.c.

01166 {
01167     Abc_Obj_t * pFanin;
01168     int i;
01169     Vec_PtrClear(vNodes);
01170     Abc_ObjForEachFanin( pNode, pFanin, i )
01171         Vec_PtrPush( vNodes, pFanin );
01172 }

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 1185 of file abcUtil.c.

01186 {
01187     Abc_Obj_t * pFanout;
01188     int i;
01189     Vec_PtrClear(vNodes);
01190     Abc_ObjForEachFanout( pNode, pFanout, i )
01191         Vec_PtrPush( vNodes, pFanout );
01192 }

Vec_Ptr_t* Abc_NodeCollectTfoCands ( Abc_ManCut_t p,
Abc_Obj_t pRoot,
Vec_Ptr_t vLeaves,
int  LevelMax 
)

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

Synopsis [Collects the TFO of the cut in the topological order.]

Description [TFO of the cut is defined as a set of nodes, for which the cut is a cut, that is, every path from the collected nodes to the CIs goes through a node in the cut. The nodes are collected if their level does not exceed the given number (LevelMax). The nodes are returned in the topological order. If the root node is given, its MFFC is marked, so that the collected nodes do not contain any nodes in the MFFC.]

SideEffects []

SeeAlso []

Definition at line 687 of file abcReconv.c.

00688 {
00689     Abc_Ntk_t * pNtk = pRoot->pNtk;
00690     Vec_Ptr_t * vVec;
00691     Abc_Obj_t * pNode, * pFanout;
00692     int i, k, v, LevelMin;
00693     assert( Abc_NtkIsStrash(pNtk) );
00694 
00695     // assuming that the structure is clean
00696     Vec_VecForEachLevel( p->vLevels, vVec, i )
00697         assert( vVec->nSize == 0 );
00698 
00699     // put fanins into the structure while labeling them
00700     Abc_NtkIncrementTravId( pNtk );
00701     LevelMin = -1;
00702     Vec_PtrForEachEntry( vLeaves, pNode, i )
00703     {
00704         if ( pNode->Level > (unsigned)LevelMax )
00705             continue;
00706         Abc_NodeSetTravIdCurrent( pNode );
00707         Vec_VecPush( p->vLevels, pNode->Level, pNode );
00708         if ( LevelMin < (int)pNode->Level )
00709             LevelMin = pNode->Level;
00710     }
00711     assert( LevelMin >= 0 );
00712 
00713     // mark MFFC 
00714     if ( pRoot )
00715         Abc_NodeMffcLabelAig( pRoot );
00716 
00717     // go through the levels up
00718     Vec_PtrClear( p->vNodesTfo );
00719     Vec_VecForEachEntryStart( p->vLevels, pNode, i, k, LevelMin )
00720     {
00721         if ( i > LevelMax )
00722             break;
00723         // if the node is not marked, it is not a fanin
00724         if ( !Abc_NodeIsTravIdCurrent(pNode) )
00725         {
00726             // check if it belongs to the TFO
00727             if ( !Abc_NodeIsTravIdCurrent(Abc_ObjFanin0(pNode)) || 
00728                  !Abc_NodeIsTravIdCurrent(Abc_ObjFanin1(pNode)) )
00729                  continue;
00730             // save the node in the TFO and label it
00731             Vec_PtrPush( p->vNodesTfo, pNode );
00732             Abc_NodeSetTravIdCurrent( pNode );
00733         }
00734         // go through the fanouts and add them to the structure if they meet the conditions
00735         Abc_ObjForEachFanout( pNode, pFanout, v )
00736         {
00737             // skip if fanout is a CO or its level exceeds
00738             if ( Abc_ObjIsCo(pFanout) || pFanout->Level > (unsigned)LevelMax )
00739                 continue;
00740             // skip if it is already added or if it is in MFFC
00741             if ( Abc_NodeIsTravIdCurrent(pFanout) )
00742                 continue;
00743             // add it to the structure but do not mark it (until tested later)
00744             Vec_VecPushUnique( p->vLevels, pFanout->Level, pFanout );
00745         }
00746     }
00747 
00748     // clear the levelized structure
00749     Vec_VecForEachLevelStart( p->vLevels, vVec, i, LevelMin )
00750     {
00751         if ( i > LevelMax )
00752             break;
00753         Vec_PtrClear( vVec );
00754     }
00755     return p->vNodesTfo;
00756 }

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 1248 of file abcUtil.c.

01249 {
01250     int Diff = Abc_ObjRegular(*pp1)->Level - Abc_ObjRegular(*pp2)->Level;
01251     if ( Diff > 0 )
01252         return -1;
01253     if ( Diff < 0 ) 
01254         return 1;
01255     return 0; 
01256 }

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 1227 of file abcUtil.c.

01228 {
01229     int Diff = Abc_ObjRegular(*pp1)->Level - Abc_ObjRegular(*pp2)->Level;
01230     if ( Diff < 0 )
01231         return -1;
01232     if ( Diff > 0 ) 
01233         return 1;
01234     return 0; 
01235 }

int Abc_NodeCompareNames ( 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 290 of file abcNames.c.

00291 {
00292     int Diff = strcmp( (char *)(*pp1)->pCopy, (char *)(*pp2)->pCopy );
00293     if ( Diff < 0 )
00294         return -1;
00295     if ( Diff > 0 ) 
00296         return 1;
00297     return 0; 
00298 }

void Abc_NodeComplement ( Abc_Obj_t pNode  ) 

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

Synopsis [Complements the local functions of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 959 of file abcObj.c.

00960 {
00961     assert( Abc_NtkIsLogic(pNode->pNtk) || Abc_NtkIsNetlist(pNode->pNtk) );
00962     assert( Abc_ObjIsNode(pNode) ); 
00963     if ( Abc_NtkHasSop(pNode->pNtk) )
00964         Abc_SopComplement( pNode->pData );
00965     else if ( Abc_NtkHasBdd(pNode->pNtk) )
00966         pNode->pData = Cudd_Not( pNode->pData );
00967     else if ( Abc_NtkHasAig(pNode->pNtk) )
00968         pNode->pData = Hop_Not( pNode->pData );
00969     else
00970         assert( 0 );
00971 }

DdNode* Abc_NodeConeBdd ( DdManager dd,
DdNode **  pbVars,
Abc_Obj_t pRoot,
Vec_Ptr_t vLeaves,
Vec_Ptr_t vVisited 
)

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

Synopsis [Returns BDD representing the logic function of the cone.]

Description []

SideEffects []

SeeAlso []

Definition at line 494 of file abcReconv.c.

00495 {
00496     Abc_Obj_t * pNode;
00497     DdNode * bFunc0, * bFunc1, * bFunc;
00498     int i;
00499     // get the nodes in the cut without fanins in the DFS order
00500     Abc_NodeConeCollect( &pRoot, 1, vLeaves, vVisited, 0 );
00501     // set the elementary BDDs
00502     Vec_PtrForEachEntry( vLeaves, pNode, i )
00503         pNode->pCopy = (Abc_Obj_t *)pbVars[i];
00504     // compute the BDDs for the collected nodes
00505     Vec_PtrForEachEntry( vVisited, pNode, i )
00506     {
00507         assert( !Abc_ObjIsPi(pNode) );
00508         bFunc0 = Cudd_NotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) );
00509         bFunc1 = Cudd_NotCond( Abc_ObjFanin1(pNode)->pCopy, Abc_ObjFaninC1(pNode) );
00510         bFunc  = Cudd_bddAnd( dd, bFunc0, bFunc1 );    Cudd_Ref( bFunc );
00511         pNode->pCopy = (Abc_Obj_t *)bFunc;
00512     }
00513     Cudd_Ref( bFunc );
00514     // dereference the intermediate ones
00515     Vec_PtrForEachEntry( vVisited, pNode, i )
00516         Cudd_RecursiveDeref( dd, (DdNode *)pNode->pCopy );
00517     Cudd_Deref( bFunc );
00518     return bFunc;
00519 }

void Abc_NodeConeCollect ( Abc_Obj_t **  ppRoots,
int  nRoots,
Vec_Ptr_t vLeaves,
Vec_Ptr_t vVisited,
int  fIncludeFanins 
)

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

Synopsis [Get the nodes contained in the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 437 of file abcReconv.c.

00438 {
00439     Abc_Obj_t * pTemp;
00440     int i;
00441     // mark the fanins of the cone
00442     Abc_NodesMark( vLeaves );
00443     // collect the nodes in the DFS order
00444     Vec_PtrClear( vVisited );
00445     // add the fanins
00446     if ( fIncludeFanins )
00447         Vec_PtrForEachEntry( vLeaves, pTemp, i )
00448             Vec_PtrPush( vVisited, pTemp );
00449     // add other nodes
00450     for ( i = 0; i < nRoots; i++ )
00451         Abc_NodeConeMarkCollect_rec( ppRoots[i], vVisited );
00452     // unmark both sets
00453     Abc_NodesUnmark( vLeaves );
00454     Abc_NodesUnmark( vVisited );
00455 }

DdNode* Abc_NodeConeDcs ( DdManager dd,
DdNode **  pbVarsX,
DdNode **  pbVarsY,
Vec_Ptr_t vLeaves,
Vec_Ptr_t vRoots,
Vec_Ptr_t vVisited 
)

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

Synopsis [Returns BDD representing the transition relation of the cone.]

Description []

SideEffects []

SeeAlso []

Definition at line 532 of file abcReconv.c.

00533 {
00534     DdNode * bFunc0, * bFunc1, * bFunc, * bTrans, * bTemp, * bCube, * bResult;
00535     Abc_Obj_t * pNode;
00536     int i;
00537     // get the nodes in the cut without fanins in the DFS order
00538     Abc_NodeConeCollect( (Abc_Obj_t **)vRoots->pArray, vRoots->nSize, vLeaves, vVisited, 0 );
00539     // set the elementary BDDs
00540     Vec_PtrForEachEntry( vLeaves, pNode, i )
00541         pNode->pCopy = (Abc_Obj_t *)pbVarsX[i];
00542     // compute the BDDs for the collected nodes
00543     Vec_PtrForEachEntry( vVisited, pNode, i )
00544     {
00545         bFunc0 = Cudd_NotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) );
00546         bFunc1 = Cudd_NotCond( Abc_ObjFanin1(pNode)->pCopy, Abc_ObjFaninC1(pNode) );
00547         bFunc  = Cudd_bddAnd( dd, bFunc0, bFunc1 );    Cudd_Ref( bFunc );
00548         pNode->pCopy = (Abc_Obj_t *)bFunc;
00549     }
00550     // compute the transition relation of the cone
00551     bTrans = b1;    Cudd_Ref( bTrans );
00552     Vec_PtrForEachEntry( vRoots, pNode, i )
00553     {
00554         bFunc = Cudd_bddXnor( dd, (DdNode *)pNode->pCopy, pbVarsY[i] );  Cudd_Ref( bFunc );
00555                 bTrans = Cudd_bddAnd( dd, bTemp = bTrans, bFunc );               Cudd_Ref( bTrans );
00556                 Cudd_RecursiveDeref( dd, bTemp );
00557                 Cudd_RecursiveDeref( dd, bFunc );
00558     }
00559     // dereference the intermediate ones
00560     Vec_PtrForEachEntry( vVisited, pNode, i )
00561         Cudd_RecursiveDeref( dd, (DdNode *)pNode->pCopy );
00562     // compute don't-cares
00563     bCube = Extra_bddComputeRangeCube( dd, vRoots->nSize, vRoots->nSize + vLeaves->nSize );  Cudd_Ref( bCube );
00564     bResult = Cudd_bddExistAbstract( dd, bTrans, bCube );                Cudd_Ref( bResult );
00565     bResult = Cudd_Not( bResult );
00566         Cudd_RecursiveDeref( dd, bCube );
00567         Cudd_RecursiveDeref( dd, bTrans );
00568     Cudd_Deref( bResult );
00569     return bResult;
00570 }

char* Abc_NodeConvertSopToMvSop ( int  nVars,
Vec_Int_t vSop0,
Vec_Int_t vSop1 
)

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

Synopsis [Converts SOP into MV-SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 838 of file abcBlifMv.c.

00839 {
00840     char * pMvSop, * pCur;
00841     unsigned uCube;
00842     int nCubes, nSize, Value, i, k;
00843     // consider the case of the constant node
00844     if ( Vec_IntSize(vSop0) == 0 || Vec_IntSize(vSop1) == 0 )
00845     {
00846         // (temporary) create a tautology cube
00847         pMvSop = ALLOC( char, nVars + 3 );
00848         for ( k = 0; k < nVars; k++ )
00849             pMvSop[k] = '-';
00850         pMvSop[nVars] = '0' + (int)(Vec_IntSize(vSop1) > 0);
00851         pMvSop[nVars+1] = '\n';
00852         pMvSop[nVars+2] = 0;
00853         return pMvSop;
00854     }
00855     // find the total number of cubes
00856     nCubes = Vec_IntSize(vSop0) + Vec_IntSize(vSop1);
00857     // find the size of the MVSOP represented as a C-string
00858     // (each cube has nVars variables + one output literal + end-of-line,
00859     // and the string is zero-terminated)
00860     nSize = nCubes * (nVars + 2) + 1; 
00861     // allocate memory
00862     pMvSop = pCur = ALLOC( char, nSize );
00863     // fill in the negative polarity cubes
00864     Vec_IntForEachEntry( vSop0, uCube, i )
00865     {
00866         for ( k = 0; k < nVars; k++ )
00867         {
00868             Value = (uCube >> (2*k)) & 3;
00869             if ( Value == 1 )
00870                 *pCur++ = '0';
00871             else if ( Value == 2 )
00872                 *pCur++ = '1';
00873             else if ( Value == 0 )
00874                 *pCur++ = '-';
00875             else
00876                 assert( 0 );
00877         }
00878         *pCur++ = '0';
00879         *pCur++ = '\n';
00880     }
00881     // fill in the positive polarity cubes
00882     Vec_IntForEachEntry( vSop1, uCube, i )
00883     {
00884         for ( k = 0; k < nVars; k++ )
00885         {
00886             Value = (uCube >> (2*k)) & 3;
00887             if ( Value == 1 )
00888                 *pCur++ = '0';
00889             else if ( Value == 2 )
00890                 *pCur++ = '1';
00891             else if ( Value == 0 )
00892                 *pCur++ = '-';
00893             else
00894                 assert( 0 );
00895         }
00896         *pCur++ = '1';
00897         *pCur++ = '\n';
00898     }
00899     *pCur++ = 0;
00900     assert( pCur - pMvSop == nSize );
00901     return pMvSop;
00902 }

int Abc_NodeDeref_rec ( Abc_Obj_t pNode  ) 

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

Synopsis [Dereferences the node's MFFC.]

Description []

SideEffects []

SeeAlso []

Definition at line 212 of file abcRefs.c.

00213 {
00214     Abc_Obj_t * pFanin;
00215     int i, Counter = 1;
00216     if ( Abc_ObjIsCi(pNode) )
00217         return 0;
00218     Abc_ObjForEachFanin( pNode, pFanin, i )
00219     {
00220         assert( pFanin->vFanouts.nSize > 0 );
00221         if ( --pFanin->vFanouts.nSize == 0 )
00222             Counter += Abc_NodeDeref_rec( pFanin );
00223     }
00224     return Counter;
00225 }

int Abc_NodeEvalMvCost ( int  nVars,
Vec_Int_t vSop0,
Vec_Int_t vSop1 
)

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

Synopsis [Evaluates the cost of the cut.]

Description [The Boolean function of the cut is specified by two SOPs, which represent the negative/positive polarities of the cut function. Converts these two SOPs into a mutually-agreed-upon representation to be passed to the internal cost-evaluation procedure (see the above prototype Abc_NodeEvalMvCostInternal).]

SideEffects []

SeeAlso []

Definition at line 945 of file abcBlifMv.c.

00946 {
00947     char * pMvSop;
00948     int * pVarValues;
00949     int i, RetValue;
00950     // collect the input and output values (currently, they are binary)
00951     pVarValues = ALLOC( int, nVars + 1 );
00952     for ( i = 0; i <= nVars; i++ )
00953         pVarValues[i] = 2;
00954     // prepare MV-SOP for evaluation
00955     pMvSop = Abc_NodeConvertSopToMvSop( nVars, vSop0, vSop1 );
00956     // have a look at the MV-SOP:
00957 //    printf( "%s\n", pMvSop );
00958     // get the result of internal cost evaluation
00959     RetValue = Abc_NodeEvalMvCostInternal( nVars, pVarValues, pMvSop );
00960     // cleanup
00961     free( pVarValues );
00962     free( pMvSop );
00963     return RetValue;
00964 }

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 629 of file abcUtil.c.

00630 {
00631     Abc_Obj_t * pFanout;
00632     int i;
00633     Abc_ObjForEachFanout( pNode, pFanout, i )
00634         if ( Abc_ObjIsCo(pFanout) )
00635             return pFanout;
00636     return NULL;
00637 }

Vec_Ptr_t* Abc_NodeFindCut ( Abc_ManCut_t p,
Abc_Obj_t pRoot,
bool  fContain 
)

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

Synopsis [Finds a fanin-limited, reconvergence-driven cut for the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 249 of file abcReconv.c.

00250 {
00251     Abc_Obj_t * pNode;
00252     int i;
00253 
00254     assert( !Abc_ObjIsComplement(pRoot) );
00255     assert( Abc_ObjIsNode(pRoot) );
00256 
00257     // start the visited nodes and mark them
00258     Vec_PtrClear( p->vVisited );
00259     Vec_PtrPush( p->vVisited, pRoot );
00260     Vec_PtrPush( p->vVisited, Abc_ObjFanin0(pRoot) );
00261     Vec_PtrPush( p->vVisited, Abc_ObjFanin1(pRoot) );
00262     pRoot->fMarkB = 1;
00263     Abc_ObjFanin0(pRoot)->fMarkB = 1;
00264     Abc_ObjFanin1(pRoot)->fMarkB = 1;
00265 
00266     // start the cut 
00267     Vec_PtrClear( p->vNodeLeaves );
00268     Vec_PtrPush( p->vNodeLeaves, Abc_ObjFanin0(pRoot) );
00269     Vec_PtrPush( p->vNodeLeaves, Abc_ObjFanin1(pRoot) );
00270 
00271     // compute the cut
00272     while ( Abc_NodeBuildCutLevelOne_int( p->vVisited, p->vNodeLeaves, p->nNodeSizeMax, p->nNodeFanStop ) );
00273     assert( Vec_PtrSize(p->vNodeLeaves) <= p->nNodeSizeMax );
00274 
00275     // return if containing cut is not requested
00276     if ( !fContain )
00277     {
00278         // unmark both fMarkA and fMarkB in tbe TFI
00279         Abc_NodesUnmarkB( p->vVisited );
00280         return p->vNodeLeaves;
00281     }
00282 
00283 //printf( "\n\n\n" );
00284     // compute the containing cut
00285     assert( p->nNodeSizeMax < p->nConeSizeMax );
00286     // copy the current boundary
00287     Vec_PtrClear( p->vConeLeaves );
00288     Vec_PtrForEachEntry( p->vNodeLeaves, pNode, i )
00289         Vec_PtrPush( p->vConeLeaves, pNode );
00290     // compute the containing cut
00291     while ( Abc_NodeBuildCutLevelOne_int( p->vVisited, p->vConeLeaves, p->nConeSizeMax, p->nConeFanStop ) );
00292     assert( Vec_PtrSize(p->vConeLeaves) <= p->nConeSizeMax );
00293     // unmark TFI using fMarkA and fMarkB
00294     Abc_NodesUnmarkB( p->vVisited );
00295     return p->vNodeLeaves;
00296 }

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 650 of file abcUtil.c.

00651 {
00652     Abc_Obj_t * pFanout;
00653     int i;
00654     Abc_ObjForEachFanout( pNode, pFanout, i )
00655         if ( !Abc_ObjIsCo(pFanout) )
00656             return pFanout;
00657     return NULL;
00658 }

void Abc_NodeFreeCuts ( void *  p,
Abc_Obj_t pObj 
)

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

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 444 of file abcCut.c.

00445 {
00446     Cut_NodeFreeCuts( p, pObj->Id );
00447 }

void Abc_NodeFreeNames ( Vec_Ptr_t vNames  ) 

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

Synopsis [Gets fanin node names.]

Description []

SideEffects []

SeeAlso []

Definition at line 238 of file abcNames.c.

00239 {
00240     int i;
00241     if ( vNames == NULL )
00242         return;
00243     for ( i = 0; i < vNames->nSize; i++ )
00244         free( vNames->pArray[i] );
00245     Vec_PtrFree( vNames );
00246 }

void* Abc_NodeGetCuts ( void *  p,
Abc_Obj_t pObj,
int  fDag,
int  fTree 
)

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

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 348 of file abcCut.c.

00349 {
00350     Abc_Obj_t * pFanin;
00351     int fDagNode, fTriv, TreeCode = 0;
00352 //    assert( Abc_NtkIsStrash(pObj->pNtk) );
00353     assert( Abc_ObjFaninNum(pObj) == 2 );
00354 
00355 
00356     // check if the node is a DAG node
00357     fDagNode = (Abc_ObjFanoutNum(pObj) > 1 && !Abc_NodeIsMuxControlType(pObj));
00358     // increment the counter of DAG nodes
00359     if ( fDagNode ) Cut_ManIncrementDagNodes( p );
00360     // add the trivial cut if the node is a DAG node, or if we compute all cuts
00361     fTriv = fDagNode || !fDag;
00362     // check if fanins are DAG nodes
00363     if ( fTree )
00364     {
00365         pFanin = Abc_ObjFanin0(pObj);
00366         TreeCode |=  (Abc_ObjFanoutNum(pFanin) > 1 && !Abc_NodeIsMuxControlType(pFanin));
00367         pFanin = Abc_ObjFanin1(pObj);
00368         TreeCode |= ((Abc_ObjFanoutNum(pFanin) > 1 && !Abc_NodeIsMuxControlType(pFanin)) << 1);
00369     }
00370 
00371 
00372     // changes due to the global/local cut computation
00373     {
00374         Cut_Params_t * pParams = Cut_ManReadParams(p);
00375         if ( pParams->fLocal )
00376         {
00377             Vec_Int_t * vNodeAttrs = Cut_ManReadNodeAttrs(p);
00378             fDagNode = Vec_IntEntry( vNodeAttrs, pObj->Id );
00379             if ( fDagNode ) Cut_ManIncrementDagNodes( p );
00380 //            fTriv = fDagNode || !pParams->fGlobal;
00381             fTriv = !Vec_IntEntry( vNodeAttrs, pObj->Id );
00382             TreeCode = 0;
00383             pFanin = Abc_ObjFanin0(pObj);
00384             TreeCode |=  Vec_IntEntry( vNodeAttrs, pFanin->Id );
00385             pFanin = Abc_ObjFanin1(pObj);
00386             TreeCode |= (Vec_IntEntry( vNodeAttrs, pFanin->Id ) << 1);
00387         }
00388     }
00389     return Cut_NodeComputeCuts( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),  
00390         Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj), fTriv, TreeCode );  
00391 }

void* Abc_NodeGetCutsRecursive ( void *  p,
Abc_Obj_t pObj,
int  fDag,
int  fTree 
)

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

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 327 of file abcCut.c.

00328 {
00329     void * pList;
00330     if ( pList = Abc_NodeReadCuts( p, pObj ) )
00331         return pList;
00332     Abc_NodeGetCutsRecursive( p, Abc_ObjFanin0(pObj), fDag, fTree );
00333     Abc_NodeGetCutsRecursive( p, Abc_ObjFanin1(pObj), fDag, fTree );
00334     return Abc_NodeGetCuts( p, pObj, fDag, fTree );
00335 }

void Abc_NodeGetCutsSeq ( void *  p,
Abc_Obj_t pObj,
int  fTriv 
)

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

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 404 of file abcCut.c.

00405 {
00406 /*
00407     int CutSetNum;
00408     assert( Abc_NtkIsSeq(pObj->pNtk) );
00409     assert( Abc_ObjFaninNum(pObj) == 2 );
00410     fTriv     = pObj->fMarkC ? 0 : fTriv;
00411     CutSetNum = pObj->fMarkC ? (int)pObj->pCopy : -1;
00412     Cut_NodeComputeCutsSeq( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),  
00413         Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj), Seq_ObjFaninL0(pObj), Seq_ObjFaninL1(pObj), fTriv, CutSetNum );  
00414 */
00415 }

Vec_Ptr_t* Abc_NodeGetFakeNames ( int  nNames  ) 

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

Synopsis [Gets fanin node names.]

Description []

SideEffects []

SeeAlso []

Definition at line 202 of file abcNames.c.

00203 {
00204     Vec_Ptr_t * vNames;
00205     char Buffer[5];
00206     int i;
00207 
00208     vNames = Vec_PtrAlloc( nNames );
00209     for ( i = 0; i < nNames; i++ )
00210     {
00211         if ( nNames < 26 )
00212         {
00213             Buffer[0] = 'a' + i;
00214             Buffer[1] = 0;
00215         }
00216         else
00217         {
00218             Buffer[0] = 'a' + i%26;
00219             Buffer[1] = '0' + i/26;
00220             Buffer[2] = 0;
00221         }
00222         Vec_PtrPush( vNames, Extra_UtilStrsav(Buffer) );
00223     }
00224     return vNames;
00225 }

Vec_Ptr_t* Abc_NodeGetFaninNames ( Abc_Obj_t pNode  ) 

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

Synopsis [Gets fanin node names.]

Description []

SideEffects []

SeeAlso []

Definition at line 180 of file abcNames.c.

00181 {
00182     Vec_Ptr_t * vNodes;
00183     Abc_Obj_t * pFanin;
00184     int i;
00185     vNodes = Vec_PtrAlloc( 100 );
00186     Abc_ObjForEachFanin( pNode, pFanin, i )
00187         Vec_PtrPush( vNodes, Extra_UtilStrsav(Abc_ObjName(pFanin)) );
00188     return vNodes;
00189 }

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 673 of file abcUtil.c.

00674 {
00675     Abc_Obj_t * pFanout, * pFanoutCo;
00676     int i;
00677     pFanoutCo = NULL;
00678     Abc_ObjForEachFanout( pNode, pFanout, i )
00679     {
00680         if ( !Abc_ObjIsCo(pFanout) )
00681             continue;
00682         if ( Abc_ObjFaninC0(pFanout) )
00683             continue;
00684         if ( pFanoutCo == NULL )
00685         {
00686             assert( Abc_ObjFaninNum(pFanout) == 1 );
00687             assert( Abc_ObjFanin0(pFanout) == pNode );
00688             pFanoutCo = pFanout;
00689             continue;
00690         }
00691         if ( strcmp( Abc_ObjName(pFanoutCo), Abc_ObjName(pFanout) ) ) // they have diff names
00692             return NULL;
00693     }
00694     return pFanoutCo;
00695 }

bool Abc_NodeIsBuf ( Abc_Obj_t pNode  ) 

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

Synopsis [Returns 1 if the node is a buffer.]

Description []

SideEffects []

SeeAlso []

Definition at line 899 of file abcObj.c.

00900 { 
00901     Abc_Ntk_t * pNtk = pNode->pNtk;
00902     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00903     assert( Abc_ObjIsNode(pNode) ); 
00904     if ( Abc_ObjFaninNum(pNode) != 1 )
00905         return 0;
00906     if ( Abc_NtkHasSop(pNtk) )
00907         return Abc_SopIsBuf(pNode->pData);
00908     if ( Abc_NtkHasBdd(pNtk) )
00909         return !Cudd_IsComplement(pNode->pData);
00910     if ( Abc_NtkHasAig(pNtk) )
00911         return !Hop_IsComplement(pNode->pData);
00912     if ( Abc_NtkHasMapping(pNtk) )
00913         return pNode->pData == Mio_LibraryReadBuf(Abc_FrameReadLibGen());
00914     assert( 0 );
00915     return 0;
00916 }

bool Abc_NodeIsConst ( Abc_Obj_t pNode  ) 

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

Synopsis [Returns 1 if the node is a constant 0 node.]

Description []

SideEffects []

SeeAlso []

Definition at line 822 of file abcObj.c.

00823 { 
00824     assert( Abc_NtkIsLogic(pNode->pNtk) || Abc_NtkIsNetlist(pNode->pNtk) );
00825     return Abc_ObjIsNode(pNode) && Abc_ObjFaninNum(pNode) == 0;
00826 }

bool Abc_NodeIsConst0 ( Abc_Obj_t pNode  ) 

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

Synopsis [Returns 1 if the node is a constant 0 node.]

Description []

SideEffects []

SeeAlso []

Definition at line 839 of file abcObj.c.

00840 { 
00841     Abc_Ntk_t * pNtk = pNode->pNtk;
00842     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00843     assert( Abc_ObjIsNode(pNode) );      
00844     if ( !Abc_NodeIsConst(pNode) )
00845         return 0;
00846     if ( Abc_NtkHasSop(pNtk) )
00847         return Abc_SopIsConst0(pNode->pData);
00848     if ( Abc_NtkHasBdd(pNtk) )
00849         return Cudd_IsComplement(pNode->pData);
00850     if ( Abc_NtkHasAig(pNtk) )
00851         return Hop_IsComplement(pNode->pData);
00852     if ( Abc_NtkHasMapping(pNtk) )
00853         return pNode->pData == Mio_LibraryReadConst0(Abc_FrameReadLibGen());
00854     assert( 0 );
00855     return 0;
00856 }

bool Abc_NodeIsConst1 ( Abc_Obj_t pNode  ) 

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

Synopsis [Returns 1 if the node is a constant 1 node.]

Description []

SideEffects []

SeeAlso []

Definition at line 869 of file abcObj.c.

00870 { 
00871     Abc_Ntk_t * pNtk = pNode->pNtk;
00872     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00873     assert( Abc_ObjIsNode(pNode) );      
00874     if ( !Abc_NodeIsConst(pNode) )
00875         return 0;
00876     if ( Abc_NtkHasSop(pNtk) )
00877         return Abc_SopIsConst1(pNode->pData);
00878     if ( Abc_NtkHasBdd(pNtk) )
00879         return !Cudd_IsComplement(pNode->pData);
00880     if ( Abc_NtkHasAig(pNtk) )
00881         return !Hop_IsComplement(pNode->pData);
00882     if ( Abc_NtkHasMapping(pNtk) )
00883         return pNode->pData == Mio_LibraryReadConst1(Abc_FrameReadLibGen());
00884     assert( 0 );
00885     return 0;
00886 }

bool 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 888 of file abcUtil.c.

00889 {
00890     Abc_Obj_t * pNode0, * pNode1;
00891     // check that the node is regular
00892     assert( !Abc_ObjIsComplement(pNode) );
00893     // if the node is not AND, this is not EXOR
00894     if ( !Abc_AigNodeIsAnd(pNode) )
00895         return 0;
00896     // if the children are not complemented, this is not EXOR
00897     if ( !Abc_ObjFaninC0(pNode) || !Abc_ObjFaninC1(pNode) )
00898         return 0;
00899     // get children
00900     pNode0 = Abc_ObjFanin0(pNode);
00901     pNode1 = Abc_ObjFanin1(pNode);
00902     // if the children are not ANDs, this is not EXOR
00903     if ( Abc_ObjFaninNum(pNode0) != 2 || Abc_ObjFaninNum(pNode1) != 2 )
00904         return 0;
00905     // otherwise, the node is EXOR iff its grand-children are the same
00906     return (Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId0(pNode1) || Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId1(pNode1)) &&
00907            (Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId0(pNode1) || Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId1(pNode1));
00908 }

bool Abc_NodeIsInv ( Abc_Obj_t pNode  ) 

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

Synopsis [Returns 1 if the node is an inverter.]

Description []

SideEffects []

SeeAlso []

Definition at line 929 of file abcObj.c.

00930 { 
00931     Abc_Ntk_t * pNtk = pNode->pNtk;
00932     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00933     assert( Abc_ObjIsNode(pNode) ); 
00934     if ( Abc_ObjFaninNum(pNode) != 1 )
00935         return 0;
00936     if ( Abc_NtkHasSop(pNtk) )
00937         return Abc_SopIsInv(pNode->pData);
00938     if ( Abc_NtkHasBdd(pNtk) )
00939         return Cudd_IsComplement(pNode->pData);
00940     if ( Abc_NtkHasAig(pNtk) )
00941         return Hop_IsComplement(pNode->pData);
00942     if ( Abc_NtkHasMapping(pNtk) )
00943         return pNode->pData == Mio_LibraryReadInv(Abc_FrameReadLibGen());
00944     assert( 0 );
00945     return 0;
00946 }

bool 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 956 of file abcUtil.c.

00957 {
00958     Abc_Obj_t * pNode0, * pNode1;
00959     // check that the node is regular
00960     assert( !Abc_ObjIsComplement(pNode) );
00961     // skip the node that do not have two fanouts
00962     if ( Abc_ObjFanoutNum(pNode) != 2 )
00963         return 0;
00964     // get the fanouts
00965     pNode0 = Abc_ObjFanout( pNode, 0 );
00966     pNode1 = Abc_ObjFanout( pNode, 1 );
00967     // if they have more than one fanout, we are not interested
00968     if ( Abc_ObjFanoutNum(pNode0) != 1 ||  Abc_ObjFanoutNum(pNode1) != 1 )
00969         return 0;
00970     // if the fanouts have the same fanout, this is MUX or EXOR (or a redundant gate (CA)(CB))
00971     return Abc_ObjFanout0(pNode0) == Abc_ObjFanout0(pNode1);
00972 }

bool 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 921 of file abcUtil.c.

00922 {
00923     Abc_Obj_t * pNode0, * pNode1;
00924     // check that the node is regular
00925     assert( !Abc_ObjIsComplement(pNode) );
00926     // if the node is not AND, this is not MUX
00927     if ( !Abc_AigNodeIsAnd(pNode) )
00928         return 0;
00929     // if the children are not complemented, this is not MUX
00930     if ( !Abc_ObjFaninC0(pNode) || !Abc_ObjFaninC1(pNode) )
00931         return 0;
00932     // get children
00933     pNode0 = Abc_ObjFanin0(pNode);
00934     pNode1 = Abc_ObjFanin1(pNode);
00935     // if the children are not ANDs, this is not MUX
00936     if ( Abc_ObjFaninNum(pNode0) != 2 || Abc_ObjFaninNum(pNode1) != 2 )
00937         return 0;
00938     // otherwise the node is MUX iff it has a pair of equal grandchildren
00939     return (Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC0(pNode1))) || 
00940            (Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC1(pNode1))) ||
00941            (Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC0(pNode1))) ||
00942            (Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC1(pNode1)));
00943 }

static int Abc_NodeIsPersistant ( Abc_Obj_t pNode  )  [inline, static]

Definition at line 416 of file abc.h.

00416 { assert( Abc_AigNodeIsAnd(pNode) ); return pNode->fPersist; } 

static bool Abc_NodeIsTravIdCurrent ( Abc_Obj_t pNode  )  [inline, static]

Definition at line 424 of file abc.h.

00424 { return (bool)(pNode->TravId == pNode->pNtk->nTravIds);     }

static bool Abc_NodeIsTravIdPrevious ( Abc_Obj_t pNode  )  [inline, static]

Definition at line 425 of file abc.h.

00425 { return (bool)(pNode->TravId == pNode->pNtk->nTravIds - 1); }

int Abc_NodeMffcLabel ( Abc_Obj_t pNode  ) 

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

Synopsis [Collects the internal nodes of the MFFC limited by cut.]

Description []

SideEffects [Increments the trav ID and marks visited nodes.]

SeeAlso []

Definition at line 434 of file abcRefs.c.

00435 {
00436     int Count1, Count2;
00437     // dereference the node
00438     Count1 = Abc_NodeDeref_rec( pNode );
00439     // collect the nodes inside the MFFC
00440     Abc_NtkIncrementTravId( pNode->pNtk );
00441     Abc_NodeMffcLabel_rec( pNode, 1 );
00442     // reference it back
00443     Count2 = Abc_NodeRef_rec( pNode );
00444     assert( Count1 == Count2 );
00445     return Count1;
00446 }

int Abc_NodeMffcLabelAig ( Abc_Obj_t pNode  ) 

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

Synopsis [Labels MFFC with the current traversal ID.]

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file abcRefs.c.

00098 {
00099     int nConeSize1, nConeSize2;
00100     assert( Abc_NtkIsStrash(pNode->pNtk) );
00101     assert( !Abc_ObjIsComplement( pNode ) );
00102     assert( Abc_ObjIsNode( pNode ) );
00103     if ( Abc_ObjFaninNum(pNode) == 0 )
00104         return 0;
00105     nConeSize1 = Abc_NodeRefDeref( pNode, 0, 1 ); // dereference
00106     nConeSize2 = Abc_NodeRefDeref( pNode, 1, 0 ); // reference
00107     assert( nConeSize1 == nConeSize2 );
00108     assert( nConeSize1 > 0 );
00109     return nConeSize1;
00110 }

int Abc_NodeMffcSize ( Abc_Obj_t pNode  ) 

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

Synopsis [Returns the MFFC size.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file abcRefs.c.

00046 {
00047     int nConeSize1, nConeSize2;
00048 //    assert( Abc_NtkIsStrash(pNode->pNtk) );
00049 //    assert( !Abc_ObjIsComplement( pNode ) );
00050     assert( Abc_ObjIsNode( pNode ) );
00051     if ( Abc_ObjFaninNum(pNode) == 0 )
00052         return 0;
00053     nConeSize1 = Abc_NodeRefDeref( pNode, 0, 0 ); // dereference
00054     nConeSize2 = Abc_NodeRefDeref( pNode, 1, 0 ); // reference
00055     assert( nConeSize1 == nConeSize2 );
00056     assert( nConeSize1 > 0 );
00057     return nConeSize1;
00058 }

int Abc_NodeMffcSizeStop ( Abc_Obj_t pNode  ) 

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

Synopsis [Returns the MFFC size while stopping at the complemented edges.]

Description []

SideEffects []

SeeAlso []

Definition at line 71 of file abcRefs.c.

00072 {
00073     int nConeSize1, nConeSize2;
00074     assert( Abc_NtkIsStrash(pNode->pNtk) );
00075     assert( !Abc_ObjIsComplement( pNode ) );
00076     assert( Abc_ObjIsNode( pNode ) );
00077     if ( Abc_ObjFaninNum(pNode) == 0 )
00078         return 0;
00079     nConeSize1 = Abc_NodeRefDerefStop( pNode, 0 ); // dereference
00080     nConeSize2 = Abc_NodeRefDerefStop( pNode, 1 ); // reference
00081     assert( nConeSize1 == nConeSize2 );
00082     assert( nConeSize1 > 0 );
00083     return nConeSize1;
00084 }

int Abc_NodeMffcSizeSupp ( Abc_Obj_t pNode  ) 
void Abc_NodeMffsConeSupp ( Abc_Obj_t pNode,
Vec_Ptr_t vCone,
Vec_Ptr_t vSupp 
)

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

Synopsis [Collects the support of the derefed MFFC.]

Description []

SideEffects []

SeeAlso []

Definition at line 296 of file abcRefs.c.

00297 {
00298     assert( Abc_ObjIsNode(pNode) );
00299     assert( !Abc_ObjIsComplement(pNode) );
00300     if ( vCone ) Vec_PtrClear( vCone );
00301     if ( vSupp ) Vec_PtrClear( vSupp );
00302     Abc_NtkIncrementTravId( pNode->pNtk );
00303     Abc_NodeMffsConeSupp_rec( pNode, vCone, vSupp, 1 );
00304 //    printf( "\n" );
00305 }

int Abc_NodeMinimumBase ( Abc_Obj_t pNode  ) 

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

Synopsis [Makes one node minimum base.]

Description [Returns 1 if the node is changed.]

SideEffects []

SeeAlso []

Definition at line 66 of file abcMinBase.c.

00067 {
00068     Vec_Str_t * vSupport;
00069     Vec_Ptr_t * vFanins;
00070     DdNode * bTemp;
00071     int i, nVars;
00072 
00073     assert( Abc_NtkIsBddLogic(pNode->pNtk) );
00074     assert( Abc_ObjIsNode(pNode) );
00075 
00076     // compute support
00077     vSupport = Vec_StrAlloc( 10 );
00078     nVars = Abc_NodeSupport( Cudd_Regular(pNode->pData), vSupport, Abc_ObjFaninNum(pNode) );
00079     if ( nVars == Abc_ObjFaninNum(pNode) )
00080     {
00081         Vec_StrFree( vSupport );
00082         return 0;
00083     }
00084 
00085     // remove unused fanins
00086     vFanins = Vec_PtrAlloc( Abc_ObjFaninNum(pNode) );
00087     Abc_NodeCollectFanins( pNode, vFanins );
00088     for ( i = 0; i < vFanins->nSize; i++ )
00089         if ( vSupport->pArray[i] == 0 )
00090             Abc_ObjDeleteFanin( pNode, vFanins->pArray[i] );
00091     assert( nVars == Abc_ObjFaninNum(pNode) );
00092 
00093     // update the function of the node
00094     pNode->pData = Extra_bddRemapUp( pNode->pNtk->pManFunc, bTemp = pNode->pData );   Cudd_Ref( pNode->pData );
00095     Cudd_RecursiveDeref( pNode->pNtk->pManFunc, bTemp );
00096     Vec_PtrFree( vFanins );
00097     Vec_StrFree( vSupport );
00098     return 1;
00099 }

void Abc_NodePrintFactor ( FILE *  pFile,
Abc_Obj_t pNode,
int  fUseRealNames 
)

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

Synopsis [Prints the factored form of one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 482 of file abcPrint.c.

00483 {
00484     Dec_Graph_t * pGraph;
00485     Vec_Ptr_t * vNamesIn;
00486     if ( Abc_ObjIsCo(pNode) )
00487         pNode = Abc_ObjFanin0(pNode);
00488     if ( Abc_ObjIsPi(pNode) )
00489     {
00490         fprintf( pFile, "Skipping the PI node.\n" );
00491         return;
00492     }
00493     if ( Abc_ObjIsLatch(pNode) )
00494     {
00495         fprintf( pFile, "Skipping the latch.\n" );
00496         return;
00497     }
00498     assert( Abc_ObjIsNode(pNode) );
00499     pGraph = Dec_Factor( pNode->pData );
00500     if ( fUseRealNames )
00501     {
00502         vNamesIn = Abc_NodeGetFaninNames(pNode);
00503         Dec_GraphPrint( stdout, pGraph, (char **)vNamesIn->pArray, Abc_ObjName(pNode) );
00504         Abc_NodeFreeNames( vNamesIn );
00505     }
00506     else
00507         Dec_GraphPrint( stdout, pGraph, (char **)NULL, Abc_ObjName(pNode) );
00508     Dec_GraphFree( pGraph );
00509 }

void Abc_NodePrintFanio ( FILE *  pFile,
Abc_Obj_t pNode 
)

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

Synopsis [Prints the fanins/fanouts of a node.]

Description []

SideEffects []

SeeAlso []

Definition at line 410 of file abcPrint.c.

00411 {
00412     Abc_Obj_t * pNode2;
00413     int i;
00414     if ( Abc_ObjIsPo(pNode) )
00415         pNode = Abc_ObjFanin0(pNode);
00416 
00417     fprintf( pFile, "Node %s", Abc_ObjName(pNode) );    
00418     fprintf( pFile, "\n" ); 
00419 
00420     fprintf( pFile, "Fanins (%d): ", Abc_ObjFaninNum(pNode) );    
00421     Abc_ObjForEachFanin( pNode, pNode2, i )
00422         fprintf( pFile, " %s", Abc_ObjName(pNode2) );
00423     fprintf( pFile, "\n" ); 
00424     
00425     fprintf( pFile, "Fanouts (%d): ", Abc_ObjFaninNum(pNode) );    
00426     Abc_ObjForEachFanout( pNode, pNode2, i )
00427         fprintf( pFile, " %s", Abc_ObjName(pNode2) );
00428     fprintf( pFile, "\n" );   
00429 }

void Abc_NodePrintLevel ( FILE *  pFile,
Abc_Obj_t pNode 
)

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

Synopsis [Prints the factored form of one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 634 of file abcPrint.c.

00635 {
00636     Abc_Obj_t * pDriver;
00637     Vec_Ptr_t * vNodes;
00638 
00639     pDriver = Abc_ObjIsCo(pNode)? Abc_ObjFanin0(pNode) : pNode;
00640     if ( Abc_ObjIsPi(pDriver) )
00641     {
00642         fprintf( pFile, "Primary input.\n" );
00643         return;
00644     }
00645     if ( Abc_ObjIsLatch(pDriver) )
00646     {
00647         fprintf( pFile, "Latch.\n" );
00648         return;
00649     }
00650     if ( Abc_NodeIsConst(pDriver) )
00651     {
00652         fprintf( pFile, "Constant %d.\n", !Abc_ObjFaninC0(pNode) );
00653         return;
00654     }
00655     // print the level
00656     fprintf( pFile, "Level = %3d.  ", pDriver->Level );
00657     // print the size of MFFC
00658     fprintf( pFile, "Mffc = %5d.  ", Abc_NodeMffcSize(pDriver) );
00659     // print the size of the shole cone
00660     vNodes = Abc_NtkDfsNodes( pNode->pNtk, &pDriver, 1 );
00661     fprintf( pFile, "Cone = %5d.  ", Vec_PtrSize(vNodes) );
00662     Vec_PtrFree( vNodes );
00663     fprintf( pFile, "\n" );
00664 }

Abc_Time_t* Abc_NodeReadArrival ( Abc_Obj_t pNode  ) 

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

Synopsis [Reads the arrival time of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 63 of file abcTiming.c.

00064 {
00065     assert( pNode->pNtk->pManTime );
00066     return Abc_NodeArrival(pNode);
00067 }

void* Abc_NodeReadCuts ( void *  p,
Abc_Obj_t pObj 
)

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

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 428 of file abcCut.c.

00429 {
00430     return Cut_NodeReadCutsNew( p, pObj->Id );  
00431 }

Abc_Time_t* Abc_NodeReadRequired ( Abc_Obj_t pNode  ) 

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

Synopsis [Reads the arrival time of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 80 of file abcTiming.c.

00081 {
00082     assert( pNode->pNtk->pManTime );
00083     return Abc_NodeRequired(pNode);
00084 }

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 988 of file abcUtil.c.

00989 {
00990     Abc_Obj_t * pNode0, * pNode1;
00991     assert( !Abc_ObjIsComplement(pNode) );
00992     assert( Abc_NodeIsMuxType(pNode) );
00993     // get children
00994     pNode0 = Abc_ObjFanin0(pNode);
00995     pNode1 = Abc_ObjFanin1(pNode);
00996     // find the control variable
00997 //    if ( pNode1->p1 == Fraig_Not(pNode2->p1) )
00998     if ( Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC0(pNode1)) )
00999     {
01000 //        if ( Fraig_IsComplement(pNode1->p1) )
01001         if ( Abc_ObjFaninC0(pNode0) )
01002         { // pNode2->p1 is positive phase of C
01003             *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode1));//pNode2->p2);
01004             *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode0));//pNode1->p2);
01005             return Abc_ObjChild0(pNode1);//pNode2->p1;
01006         }
01007         else
01008         { // pNode1->p1 is positive phase of C
01009             *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode0));//pNode1->p2);
01010             *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode1));//pNode2->p2);
01011             return Abc_ObjChild0(pNode0);//pNode1->p1;
01012         }
01013     }
01014 //    else if ( pNode1->p1 == Fraig_Not(pNode2->p2) )
01015     else if ( Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC1(pNode1)) )
01016     {
01017 //        if ( Fraig_IsComplement(pNode1->p1) )
01018         if ( Abc_ObjFaninC0(pNode0) )
01019         { // pNode2->p2 is positive phase of C
01020             *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode1));//pNode2->p1);
01021             *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode0));//pNode1->p2);
01022             return Abc_ObjChild1(pNode1);//pNode2->p2;
01023         }
01024         else
01025         { // pNode1->p1 is positive phase of C
01026             *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode0));//pNode1->p2);
01027             *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode1));//pNode2->p1);
01028             return Abc_ObjChild0(pNode0);//pNode1->p1;
01029         }
01030     }
01031 //    else if ( pNode1->p2 == Fraig_Not(pNode2->p1) )
01032     else if ( Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC0(pNode1)) )
01033     {
01034 //        if ( Fraig_IsComplement(pNode1->p2) )
01035         if ( Abc_ObjFaninC1(pNode0) )
01036         { // pNode2->p1 is positive phase of C
01037             *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode1));//pNode2->p2);
01038             *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode0));//pNode1->p1);
01039             return Abc_ObjChild0(pNode1);//pNode2->p1;
01040         }
01041         else
01042         { // pNode1->p2 is positive phase of C
01043             *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode0));//pNode1->p1);
01044             *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode1));//pNode2->p2);
01045             return Abc_ObjChild1(pNode0);//pNode1->p2;
01046         }
01047     }
01048 //    else if ( pNode1->p2 == Fraig_Not(pNode2->p2) )
01049     else if ( Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC1(pNode1)) )
01050     {
01051 //        if ( Fraig_IsComplement(pNode1->p2) )
01052         if ( Abc_ObjFaninC1(pNode0) )
01053         { // pNode2->p2 is positive phase of C
01054             *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode1));//pNode2->p1);
01055             *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode0));//pNode1->p1);
01056             return Abc_ObjChild1(pNode1);//pNode2->p2;
01057         }
01058         else
01059         { // pNode1->p2 is positive phase of C
01060             *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode0));//pNode1->p1);
01061             *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode1));//pNode2->p1);
01062             return Abc_ObjChild1(pNode0);//pNode1->p2;
01063         }
01064     }
01065     assert( 0 ); // this is not MUX
01066     return NULL;
01067 }

int Abc_NodeRef_rec ( Abc_Obj_t pNode  ) 

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

Synopsis [References the node's MFFC.]

Description []

SideEffects []

SeeAlso []

Definition at line 238 of file abcRefs.c.

00239 {
00240     Abc_Obj_t * pFanin;
00241     int i, Counter = 1;
00242     if ( Abc_ObjIsCi(pNode) )
00243         return 0;
00244     Abc_ObjForEachFanin( pNode, pFanin, i )
00245     {
00246         if ( pFanin->vFanouts.nSize++ == 0 )
00247             Counter += Abc_NodeRef_rec( pFanin );
00248     }
00249     return Counter;
00250 }

int Abc_NodeRemoveDupFanins ( Abc_Obj_t pNode  ) 

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

Synopsis [Removes duplicated fanins if present.]

Description [Returns the number of fanins removed.]

SideEffects []

SeeAlso []

Definition at line 176 of file abcMinBase.c.

00177 {
00178     int Counter = 0;
00179     while ( Abc_NodeRemoveDupFanins_int(pNode) )
00180         Counter++;
00181     return Counter;
00182 }

static void Abc_NodeSetPersistant ( Abc_Obj_t pNode  )  [inline, static]

Definition at line 417 of file abc.h.

00417 { assert( Abc_AigNodeIsAnd(pNode) ); pNode->fPersist = 1;    } 

static void Abc_NodeSetTravId ( Abc_Obj_t pNode,
int  TravId 
) [inline, static]

Definition at line 421 of file abc.h.

00421 { pNode->TravId = TravId;                                    }

static void Abc_NodeSetTravIdCurrent ( Abc_Obj_t pNode  )  [inline, static]

Definition at line 422 of file abc.h.

00422 { pNode->TravId = pNode->pNtk->nTravIds;                     }

static void Abc_NodeSetTravIdPrevious ( Abc_Obj_t pNode  )  [inline, static]

Definition at line 423 of file abc.h.

00423 { pNode->TravId = pNode->pNtk->nTravIds - 1;                 }

Abc_Obj_t* Abc_NodeStrash ( Abc_Ntk_t pNtkNew,
Abc_Obj_t pNodeOld,
int  fRecord 
)

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

Synopsis [Strashes one logic node.]

Description [Assume the network is in the AIG form]

SideEffects []

SeeAlso []

Definition at line 363 of file abcStrash.c.

00364 {
00365     Hop_Man_t * pMan;
00366     Hop_Obj_t * pRoot;
00367     Abc_Obj_t * pFanin;
00368     int i;
00369     assert( Abc_ObjIsNode(pNodeOld) );
00370     assert( Abc_NtkHasAig(pNodeOld->pNtk) && !Abc_NtkIsStrash(pNodeOld->pNtk) );
00371     // get the local AIG manager and the local root node
00372     pMan = pNodeOld->pNtk->pManFunc;
00373     pRoot = pNodeOld->pData;
00374     // check the constant case
00375     if ( Abc_NodeIsConst(pNodeOld) || Hop_Regular(pRoot) == Hop_ManConst1(pMan) )
00376         return Abc_ObjNotCond( Abc_AigConst1(pNtkNew), Hop_IsComplement(pRoot) );
00377     // perform special case-strashing using the record of AIG subgraphs
00378     if ( fRecord && Abc_NtkRecIsRunning() && Abc_ObjFaninNum(pNodeOld) > 2 && Abc_ObjFaninNum(pNodeOld) <= Abc_NtkRecVarNum() )
00379     {
00380         extern Vec_Int_t * Abc_NtkRecMemory();
00381         extern int Abc_NtkRecStrashNode( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj, unsigned * pTruth, int nVars );
00382         int nVars = Abc_NtkRecVarNum();
00383         Vec_Int_t * vMemory = Abc_NtkRecMemory();
00384         unsigned * pTruth = Abc_ConvertAigToTruth( pMan, Hop_Regular(pRoot), nVars, vMemory, 0 );
00385         assert( Extra_TruthSupportSize(pTruth, nVars) == Abc_ObjFaninNum(pNodeOld) ); // should be swept
00386         if ( Hop_IsComplement(pRoot) )
00387             Extra_TruthNot( pTruth, pTruth, nVars );
00388         if ( Abc_NtkRecStrashNode( pNtkNew, pNodeOld, pTruth, nVars ) )
00389             return pNodeOld->pCopy;
00390     }
00391     // set elementary variables
00392     Abc_ObjForEachFanin( pNodeOld, pFanin, i )
00393         Hop_IthVar(pMan, i)->pData = pFanin->pCopy;
00394     // strash the AIG of this node
00395     Abc_NodeStrash_rec( pNtkNew->pManFunc, Hop_Regular(pRoot) );
00396     Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
00397     // return the final node
00398     return Abc_ObjNotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
00399 }

void Abc_NtkAddDummyAssertNames ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Adds dummy names.]

Description []

SideEffects []

SeeAlso []

Definition at line 395 of file abcNames.c.

00396 {
00397     Abc_Obj_t * pObj;
00398     int nDigits, i;
00399     nDigits = Extra_Base10Log( Abc_NtkAssertNum(pNtk) );
00400     Abc_NtkForEachAssert( pNtk, pObj, i )
00401         Abc_ObjAssignName( pObj, Abc_ObjNameDummy("a", i, nDigits), NULL );
00402 }

void Abc_NtkAddDummyBoxNames ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Adds dummy names.]

Description []

SideEffects []

SeeAlso []

Definition at line 415 of file abcNames.c.

00416 {
00417     Abc_Obj_t * pObj;
00418     int nDigits, i;
00419     assert( !Abc_NtkIsNetlist(pNtk) );
00420     nDigits = Extra_Base10Log( Abc_NtkLatchNum(pNtk) );
00421     Abc_NtkForEachLatch( pNtk, pObj, i )
00422     {
00423         Abc_ObjAssignName( pObj, Abc_ObjNameDummy("l", i, nDigits), NULL );
00424         Abc_ObjAssignName( Abc_ObjFanin0(pObj),  Abc_ObjNameDummy("li", i, nDigits), NULL );
00425         Abc_ObjAssignName( Abc_ObjFanout0(pObj), Abc_ObjNameDummy("lo", i, nDigits), NULL );
00426     }
00427 /*
00428     nDigits = Extra_Base10Log( Abc_NtkBlackboxNum(pNtk) );
00429     Abc_NtkForEachBlackbox( pNtk, pObj, i )
00430     {
00431         pName = Abc_ObjAssignName( pObj, Abc_ObjNameDummy("B", i, nDigits), NULL );
00432         nDigitsF = Extra_Base10Log( Abc_ObjFaninNum(pObj) );
00433         Abc_ObjForEachFanin( pObj, pTerm, k )
00434             Abc_ObjAssignName( Abc_ObjFanin0(pObj), pName, Abc_ObjNameDummy("i", k, nDigitsF) );
00435         nDigitsF = Extra_Base10Log( Abc_ObjFanoutNum(pObj) );
00436         Abc_ObjForEachFanout( pObj, pTerm, k )
00437             Abc_ObjAssignName( Abc_ObjFanin0(pObj), pName, Abc_ObjNameDummy("o", k, nDigitsF) );
00438     }
00439 */
00440 }

void Abc_NtkAddDummyPiNames ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Adds dummy names.]

Description []

SideEffects []

SeeAlso []

Definition at line 355 of file abcNames.c.

00356 {
00357     Abc_Obj_t * pObj;
00358     int nDigits, i;
00359     nDigits = Extra_Base10Log( Abc_NtkPiNum(pNtk) );
00360     Abc_NtkForEachPi( pNtk, pObj, i )
00361         Abc_ObjAssignName( pObj, Abc_ObjNameDummy("pi", i, nDigits), NULL );
00362 }

void Abc_NtkAddDummyPoNames ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Adds dummy names.]

Description []

SideEffects []

SeeAlso []

Definition at line 375 of file abcNames.c.

00376 {
00377     Abc_Obj_t * pObj;
00378     int nDigits, i;
00379     nDigits = Extra_Base10Log( Abc_NtkPoNum(pNtk) );
00380     Abc_NtkForEachPo( pNtk, pObj, i )
00381         Abc_ObjAssignName( pObj, Abc_ObjNameDummy("po", i, nDigits), NULL );
00382 }

Abc_Obj_t* Abc_NtkAddLatch ( Abc_Ntk_t pNtk,
Abc_Obj_t pDriver,
Abc_InitType_t  Init 
)

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

Synopsis [Creates latch with the given initial value.]

Description []

SideEffects []

SeeAlso []

Definition at line 225 of file abcLatch.c.

00226 {
00227     Abc_Obj_t * pLatchOut, * pLatch, * pLatchIn;
00228     pLatchOut = Abc_NtkCreateBo(pNtk);
00229     pLatch    = Abc_NtkCreateLatch(pNtk);
00230     pLatchIn  = Abc_NtkCreateBi(pNtk);
00231     Abc_ObjAssignName( pLatchOut, Abc_ObjName(pLatch), "_lo" );
00232     Abc_ObjAssignName( pLatchIn,  Abc_ObjName(pLatch), "_li" );
00233     Abc_ObjAddFanin( pLatchOut, pLatch );
00234     Abc_ObjAddFanin( pLatch, pLatchIn );
00235     Abc_ObjAddFanin( pLatchIn, pDriver );
00236     pLatch->pData = (void *)Init;
00237     return pLatchOut;
00238 }

int Abc_NtkAigToBdd ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Converts the network from AIG to BDD representation.]

Description []

SideEffects []

SeeAlso []

Definition at line 660 of file abcFunc.c.

00661 {
00662     Abc_Obj_t * pNode;
00663     Hop_Man_t * pMan;
00664     DdManager * dd;
00665     int nFaninsMax, i;
00666 
00667     assert( Abc_NtkHasAig(pNtk) ); 
00668 
00669     // start the functionality manager
00670     nFaninsMax = Abc_NtkGetFaninMax( pNtk );
00671     if ( nFaninsMax == 0 )
00672         printf( "Warning: The network has only constant nodes.\n" );
00673 
00674     dd = Cudd_Init( nFaninsMax, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
00675 
00676     // set the mapping of elementary AIG nodes into the elementary BDD nodes
00677     pMan = pNtk->pManFunc;
00678     assert( Hop_ManPiNum(pMan) >= nFaninsMax ); 
00679     for ( i = 0; i < nFaninsMax; i++ )
00680     {
00681         Hop_ManPi(pMan, i)->pData = Cudd_bddIthVar(dd, i);
00682         Cudd_Ref( Hop_ManPi(pMan, i)->pData );
00683     }
00684 
00685     // convert each node from SOP to BDD
00686     Abc_NtkForEachNode( pNtk, pNode, i )
00687     {
00688         assert( pNode->pData );
00689         pNode->pData = Abc_ConvertAigToBdd( dd, pNode->pData );
00690         if ( pNode->pData == NULL )
00691         {
00692             printf( "Abc_NtkSopToBdd: Error while converting SOP into BDD.\n" );
00693             return 0;
00694         }
00695         Cudd_Ref( pNode->pData );
00696     }
00697 
00698     // dereference intermediate BDD nodes
00699     for ( i = 0; i < nFaninsMax; i++ )
00700         Cudd_RecursiveDeref( dd, Hop_ManPi(pMan, i)->pData );
00701 
00702     Hop_ManStop( pNtk->pManFunc );
00703     pNtk->pManFunc = dd;
00704 
00705     // update the network type
00706     pNtk->ntkFunc = ABC_FUNC_BDD;
00707     return 1;
00708 }

Abc_Ntk_t* Abc_NtkAlloc ( Abc_NtkType_t  Type,
Abc_NtkFunc_t  Func,
int  fUseMemMan 
)

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

FileName [abcNtk.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Network creation/duplication/deletion procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Creates a new Ntk.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file abcNtk.c.

00046 {
00047     Abc_Ntk_t * pNtk;
00048     pNtk = ALLOC( Abc_Ntk_t, 1 );
00049     memset( pNtk, 0, sizeof(Abc_Ntk_t) );
00050     pNtk->ntkType     = Type;
00051     pNtk->ntkFunc     = Func;
00052     // start the object storage
00053     pNtk->vObjs       = Vec_PtrAlloc( 100 );
00054     pNtk->vAsserts    = Vec_PtrAlloc( 100 );
00055     pNtk->vPios       = Vec_PtrAlloc( 100 );
00056     pNtk->vPis        = Vec_PtrAlloc( 100 );
00057     pNtk->vPos        = Vec_PtrAlloc( 100 );
00058     pNtk->vCis        = Vec_PtrAlloc( 100 );
00059     pNtk->vCos        = Vec_PtrAlloc( 100 );
00060     pNtk->vBoxes      = Vec_PtrAlloc( 100 );
00061     // start the memory managers
00062     pNtk->pMmObj      = fUseMemMan? Extra_MmFixedStart( sizeof(Abc_Obj_t) ) : NULL;
00063     pNtk->pMmStep     = fUseMemMan? Extra_MmStepStart( ABC_NUM_STEPS ) : NULL;
00064     // get ready to assign the first Obj ID
00065     pNtk->nTravIds    = 1;
00066     // start the functionality manager
00067     if ( Abc_NtkIsStrash(pNtk) )
00068         pNtk->pManFunc = Abc_AigAlloc( pNtk );
00069     else if ( Abc_NtkHasSop(pNtk) || Abc_NtkHasBlifMv(pNtk) )
00070         pNtk->pManFunc = Extra_MmFlexStart();
00071     else if ( Abc_NtkHasBdd(pNtk) )
00072         pNtk->pManFunc = Cudd_Init( 20, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
00073     else if ( Abc_NtkHasAig(pNtk) )
00074         pNtk->pManFunc = Hop_ManStart();
00075     else if ( Abc_NtkHasMapping(pNtk) )
00076         pNtk->pManFunc = Abc_FrameReadLibGen();
00077     else if ( !Abc_NtkHasBlackbox(pNtk) )
00078         assert( 0 );
00079     // name manager
00080     pNtk->pManName = Nm_ManCreate( 200 );
00081     // attribute manager
00082     pNtk->vAttrs = Vec_PtrStart( VEC_ATTR_TOTAL_NUM );
00083     return pNtk;
00084 }

int Abc_NtkAppend ( Abc_Ntk_t pNtk1,
Abc_Ntk_t pNtk2,
int  fAddPos 
)

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

Synopsis [Appends the second network to the first.]

Description [Modifies the first network by adding the logic of the second. Performs structural hashing while appending the networks. Does not change the second network. Returns 0 if the appending failed, 1 otherise.]

SideEffects []

SeeAlso []

Definition at line 216 of file abcStrash.c.

00217 {
00218     Abc_Obj_t * pObj;
00219     char * pName;
00220     int i, nNewCis;
00221     // the first network should be an AIG
00222     assert( Abc_NtkIsStrash(pNtk1) );
00223     assert( Abc_NtkIsLogic(pNtk2) || Abc_NtkIsStrash(pNtk2) ); 
00224     if ( Abc_NtkIsLogic(pNtk2) && !Abc_NtkToAig(pNtk2) )
00225     {
00226         printf( "Converting to AIGs has failed.\n" );
00227         return 0;
00228     }
00229     // check that the networks have the same PIs
00230     // reorder PIs of pNtk2 according to pNtk1
00231     if ( !Abc_NtkCompareSignals( pNtk1, pNtk2, 1, 1 ) )
00232         printf( "Abc_NtkAppend(): The union of the network PIs is computed (warning).\n" );
00233     // perform strashing
00234     nNewCis = 0;
00235     Abc_NtkCleanCopy( pNtk2 );
00236     if ( Abc_NtkIsStrash(pNtk2) )
00237         Abc_AigConst1(pNtk2)->pCopy = Abc_AigConst1(pNtk1);
00238     Abc_NtkForEachCi( pNtk2, pObj, i )
00239     {
00240         pName = Abc_ObjName(pObj);
00241         pObj->pCopy = Abc_NtkFindCi(pNtk1, Abc_ObjName(pObj));
00242         if ( pObj->pCopy == NULL )
00243         {
00244             pObj->pCopy = Abc_NtkDupObj(pNtk1, pObj, 1);
00245             nNewCis++;
00246         }
00247     }
00248     if ( nNewCis )
00249         printf( "Warning: Procedure Abc_NtkAppend() added %d new CIs.\n", nNewCis );
00250     // add pNtk2 to pNtk1 while strashing
00251     if ( Abc_NtkIsLogic(pNtk2) )
00252         Abc_NtkStrashPerform( pNtk2, pNtk1, 1, 0 );
00253     else
00254         Abc_NtkForEachNode( pNtk2, pObj, i )
00255             pObj->pCopy = Abc_AigAnd( pNtk1->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
00256     // add the COs of the second network
00257     if ( fAddPos )
00258     {
00259         Abc_NtkForEachPo( pNtk2, pObj, i )
00260         {
00261             Abc_NtkDupObj( pNtk1, pObj, 0 );
00262             Abc_ObjAddFanin( pObj->pCopy, Abc_ObjChild0Copy(pObj) );
00263             Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj->pCopy), NULL );
00264         }
00265     }
00266     else
00267     {
00268         Abc_Obj_t * pObjOld, * pDriverOld, * pDriverNew;
00269         int fCompl, iNodeId;
00270         // OR the choices
00271         Abc_NtkForEachCo( pNtk2, pObj, i )
00272         {
00273             iNodeId = Nm_ManFindIdByNameTwoTypes( pNtk1->pManName, Abc_ObjName(pObj), ABC_OBJ_PO, ABC_OBJ_BI );
00274             assert( iNodeId >= 0 );
00275             pObjOld = Abc_NtkObj( pNtk1, iNodeId );
00276             // derive the new driver
00277             pDriverOld = Abc_ObjChild0( pObjOld );
00278             pDriverNew = Abc_ObjChild0Copy( pObj );
00279             pDriverNew = Abc_AigOr( pNtk1->pManFunc, pDriverOld, pDriverNew );
00280             if ( Abc_ObjRegular(pDriverOld) == Abc_ObjRegular(pDriverNew) )
00281                 continue;
00282             // replace the old driver by the new driver
00283             fCompl = Abc_ObjRegular(pDriverOld)->fPhase ^ Abc_ObjRegular(pDriverNew)->fPhase;
00284             Abc_ObjPatchFanin( pObjOld, Abc_ObjRegular(pDriverOld), Abc_ObjNotCond(Abc_ObjRegular(pDriverNew), fCompl) );
00285         }
00286     }
00287     // make sure that everything is okay
00288     if ( !Abc_NtkCheck( pNtk1 ) )
00289     {
00290         printf( "Abc_NtkAppend: The network check has failed.\n" );
00291         return 0;
00292     }
00293     return 1;
00294 }

void Abc_NtkAppendToCone ( Abc_Ntk_t pNtkNew,
Abc_Ntk_t pNtk,
Vec_Ptr_t vRoots 
)

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

Synopsis [Adds new nodes to the cone.]

Description []

SideEffects []

SeeAlso []

Definition at line 661 of file abcNtk.c.

00662 {
00663     Vec_Ptr_t * vNodes;
00664     Abc_Obj_t * pObj;
00665     int i, iNodeId;
00666 
00667     assert( Abc_NtkIsStrash(pNtkNew) );
00668     assert( Abc_NtkIsStrash(pNtk) );
00669 
00670     // collect the nodes in the TFI of the output (mark the TFI)
00671     vNodes = Abc_NtkDfsNodes( pNtk, (Abc_Obj_t **)Vec_PtrArray(vRoots), Vec_PtrSize(vRoots) );
00672 
00673     // establish connection between the constant nodes
00674     Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
00675 
00676     // create the PIs
00677     Abc_NtkForEachCi( pNtk, pObj, i )
00678     {
00679         // skip CIs that are not used
00680         if ( !Abc_NodeIsTravIdCurrent(pObj) )
00681             continue;
00682         // find the corresponding CI in the new network
00683         iNodeId = Nm_ManFindIdByNameTwoTypes( pNtkNew->pManName, Abc_ObjName(pObj), ABC_OBJ_PI, ABC_OBJ_BO );
00684         if ( iNodeId == -1 )
00685         {
00686             pObj->pCopy = Abc_NtkCreatePi(pNtkNew);
00687             Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
00688         }
00689         else
00690             pObj->pCopy = Abc_NtkObj( pNtkNew, iNodeId );
00691     }
00692 
00693     // copy the nodes
00694     Vec_PtrForEachEntry( vNodes, pObj, i )
00695         pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
00696     Vec_PtrFree( vNodes );
00697 
00698     // do not add the COs
00699     if ( !Abc_NtkCheck( pNtkNew ) )
00700         fprintf( stdout, "Abc_NtkAppendToCone(): Network check has failed.\n" );
00701 }

static Abc_Obj_t* Abc_NtkAssert ( Abc_Ntk_t pNtk,
int  i 
) [inline, static]

Definition at line 335 of file abc.h.

00335 { return (Abc_Obj_t *)Vec_PtrEntry( pNtk->vAsserts, i );}

static int Abc_NtkAssertNum ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 304 of file abc.h.

00304 { return Vec_PtrSize(pNtk->vAsserts);        }

int Abc_NtkAttach ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Attaches gates from the current library to the internal nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 57 of file abcAttach.c.

00058 {
00059     Mio_Library_t * pGenlib;
00060     unsigned ** puTruthGates;
00061     unsigned uTruths[6][2];
00062     Abc_Obj_t * pNode;
00063     Mio_Gate_t ** ppGates;
00064     int nGates, nFanins, i;
00065 
00066     assert( Abc_NtkIsSopLogic(pNtk) );
00067 
00068     // check that the library is available
00069     pGenlib = Abc_FrameReadLibGen();
00070     if ( pGenlib == NULL )
00071     {
00072         printf( "The current library is not available.\n" );
00073         return 0;
00074     }
00075 
00076     // start the truth tables
00077     Abc_AttachSetupTruthTables( uTruths );
00078     
00079     // collect all the gates
00080     ppGates = Mio_CollectRoots( pGenlib, 6, (float)1.0e+20, 1, &nGates );
00081 
00082     // derive the gate truth tables
00083     puTruthGates    = ALLOC( unsigned *, nGates );
00084     puTruthGates[0] = ALLOC( unsigned, 2 * nGates );
00085     for ( i = 1; i < nGates; i++ )
00086         puTruthGates[i] = puTruthGates[i-1] + 2;
00087     for ( i = 0; i < nGates; i++ )
00088         Mio_DeriveTruthTable( ppGates[i], uTruths, Mio_GateReadInputs(ppGates[i]), 6, puTruthGates[i] );
00089 
00090     // assign the gates to pNode->pCopy
00091     Abc_NtkCleanCopy( pNtk );
00092     Abc_NtkForEachNode( pNtk, pNode, i )
00093     {
00094         nFanins = Abc_ObjFaninNum(pNode);
00095         if ( nFanins == 0 )
00096         {
00097             if ( Abc_SopIsConst1(pNode->pData) )
00098                 pNode->pCopy = (Abc_Obj_t *)Mio_LibraryReadConst1(pGenlib);
00099             else
00100                 pNode->pCopy = (Abc_Obj_t *)Mio_LibraryReadConst0(pGenlib);
00101         }
00102         else if ( nFanins == 1 )
00103         {
00104             if ( Abc_SopIsBuf(pNode->pData) )
00105                 pNode->pCopy = (Abc_Obj_t *)Mio_LibraryReadBuf(pGenlib);
00106             else
00107                 pNode->pCopy = (Abc_Obj_t *)Mio_LibraryReadInv(pGenlib);
00108         }
00109         else if ( nFanins > 6 )
00110         {
00111             printf( "Cannot attach gate with more than 6 inputs to node %s.\n", Abc_ObjName(pNode) );
00112             free( puTruthGates[0] );
00113             free( puTruthGates );
00114             free( ppGates );
00115             return 0;
00116         }
00117         else if ( !Abc_NodeAttach( pNode, ppGates, puTruthGates, nGates, uTruths ) )
00118         {
00119             printf( "Could not attach the library gate to node %s.\n", Abc_ObjName(pNode) );
00120             free( puTruthGates[0] );
00121             free( puTruthGates );
00122             free( ppGates );
00123             return 0;
00124         }
00125     }
00126     free( puTruthGates[0] );
00127     free( puTruthGates );
00128     free( ppGates );
00129     FREE( s_pPerms );
00130 
00131     // perform the final transformation
00132     Abc_NtkForEachNode( pNtk, pNode, i )
00133     {
00134         if ( pNode->pCopy == NULL )
00135         {
00136             printf( "Some elementary gates (constant, buffer, or inverter) are missing in the library.\n" );
00137             return 0;
00138         }
00139     }
00140 
00141     // replace SOP representation by the gate representation
00142     Abc_NtkForEachNode( pNtk, pNode, i )
00143         pNode->pData = pNode->pCopy, pNode->pCopy = NULL;
00144     pNtk->ntkFunc = ABC_FUNC_MAP;
00145     Extra_MmFlexStop( pNtk->pManFunc );
00146     pNtk->pManFunc = pGenlib;
00147 
00148     printf( "Library gates are successfully attached to the nodes.\n" );
00149 
00150     // make sure that everything is okay
00151     if ( !Abc_NtkCheck( pNtk ) )
00152     {
00153         printf( "Abc_NtkAttach: The network check has failed.\n" );
00154         return 0;
00155     }
00156     return 1;
00157 }

void* Abc_NtkAttrFree ( Abc_Ntk_t pNtk,
int  Attr,
int  fFreeMan 
)

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

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

Synopsis [Frees one attribute manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file abcUtil.c.

00047 {  
00048     void * pUserMan;
00049     Vec_Att_t * pAttrMan;
00050     pAttrMan = Vec_PtrEntry( pNtk->vAttrs, Attr );
00051     Vec_PtrWriteEntry( pNtk->vAttrs, Attr, NULL );
00052     pUserMan = Vec_AttFree( pAttrMan, fFreeMan );
00053     return pUserMan;
00054 }

static Abc_Ntk_t* Abc_NtkBackup ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 288 of file abc.h.

00288 { return pNtk->pNetBackup;       }

Abc_Ntk_t* Abc_NtkBalance ( Abc_Ntk_t pNtk,
bool  fDuplicate,
bool  fSelective,
bool  fUpdateLevel 
)

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

Synopsis [Balances the AIG network.]

Description []

SideEffects []

SeeAlso []

Definition at line 50 of file abcBalance.c.

00051 {
00052     extern void Abc_NtkHaigTranfer( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew );
00053     Abc_Ntk_t * pNtkAig;
00054     assert( Abc_NtkIsStrash(pNtk) );
00055     // compute the required times
00056     if ( fSelective )
00057     {
00058         Abc_NtkStartReverseLevels( pNtk, 0 );
00059         Abc_NtkMarkCriticalNodes( pNtk );
00060     }
00061     // perform balancing
00062     pNtkAig = Abc_NtkStartFrom( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG );
00063     // transfer HAIG
00064     Abc_NtkHaigTranfer( pNtk, pNtkAig );
00065     // perform balancing
00066     Abc_NtkBalancePerform( pNtk, pNtkAig, fDuplicate, fSelective, fUpdateLevel );
00067     Abc_NtkFinalize( pNtk, pNtkAig );
00068     // undo the required times
00069     if ( fSelective )
00070     {
00071         Abc_NtkStopReverseLevels( pNtk );
00072         Abc_NtkCleanMarkA( pNtk );
00073     }
00074     if ( pNtk->pExdc )
00075         pNtkAig->pExdc = Abc_NtkDup( pNtk->pExdc );
00076     // make sure everything is okay
00077     if ( !Abc_NtkCheck( pNtkAig ) )
00078     {
00079         printf( "Abc_NtkBalance: The network check has failed.\n" );
00080         Abc_NtkDelete( pNtkAig );
00081         return NULL;
00082     }
00083     return pNtkAig;
00084 }

Abc_Ntk_t* Abc_NtkBddToMuxes ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Creates the network isomorphic to the union of local BDDs of the nodes.]

Description [The nodes of the local BDDs are converted into the network nodes with logic functions equal to the MUX.]

SideEffects []

SeeAlso []

Definition at line 120 of file abcNtbdd.c.

00121 {
00122     Abc_Ntk_t * pNtkNew;
00123     assert( Abc_NtkIsBddLogic(pNtk) );
00124     pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
00125     Abc_NtkBddToMuxesPerform( pNtk, pNtkNew );
00126     Abc_NtkFinalize( pNtk, pNtkNew );
00127     // make sure everything is okay
00128     if ( !Abc_NtkCheck( pNtkNew ) )
00129     {
00130         printf( "Abc_NtkBddToMuxes: The network check has failed.\n" );
00131         Abc_NtkDelete( pNtkNew );
00132         return NULL;
00133     }
00134     return pNtkNew;
00135 }

int Abc_NtkBddToSop ( Abc_Ntk_t pNtk,
int  fDirect 
)

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

Synopsis [Converts the network from BDD to SOP representation.]

Description [If the flag is set to 1, forces the direct phase of all covers.]

SideEffects []

SeeAlso []

Definition at line 210 of file abcFunc.c.

00211 {
00212     Abc_Obj_t * pNode;
00213     Extra_MmFlex_t * pManNew;
00214     DdManager * dd = pNtk->pManFunc;
00215     DdNode * bFunc;
00216     Vec_Str_t * vCube;
00217     int i, fMode;
00218 
00219     if ( fDirect )
00220         fMode = 1;
00221     else
00222         fMode = -1;
00223 
00224     assert( Abc_NtkHasBdd(pNtk) );
00225     if ( dd->size > 0 )
00226     Cudd_zddVarsFromBddVars( dd, 2 );
00227     // create the new manager
00228     pManNew = Extra_MmFlexStart();
00229 
00230     // go through the objects
00231     vCube = Vec_StrAlloc( 100 );
00232     Abc_NtkForEachNode( pNtk, pNode, i )
00233     {
00234         assert( pNode->pData );
00235         bFunc = pNode->pData;
00236         pNode->pNext = (Abc_Obj_t *)Abc_ConvertBddToSop( pManNew, dd, bFunc, bFunc, Abc_ObjFaninNum(pNode), 0, vCube, fMode );
00237         if ( pNode->pNext == NULL )
00238         {
00239             Extra_MmFlexStop( pManNew );
00240             Abc_NtkCleanNext( pNtk );
00241 //            printf( "Converting from BDDs to SOPs has failed.\n" );
00242             Vec_StrFree( vCube );
00243             return 0;
00244         }
00245     }
00246     Vec_StrFree( vCube );
00247 
00248     // update the network type
00249     pNtk->ntkFunc = ABC_FUNC_SOP;
00250     // set the new manager
00251     pNtk->pManFunc = pManNew;
00252     // transfer from next to data
00253     Abc_NtkForEachNode( pNtk, pNode, i )
00254     {
00255         Cudd_RecursiveDeref( dd, pNode->pData );
00256         pNode->pData = pNode->pNext;
00257         pNode->pNext = NULL;
00258     }
00259 
00260     // check for remaining references in the package
00261     Extra_StopManager( dd );
00262     return 1;
00263 }

static int Abc_NtkBiNum ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 306 of file abc.h.

00306 { return pNtk->nObjCounts[ABC_OBJ_BI];       }

static int Abc_NtkBlackboxNum ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 312 of file abc.h.

00312 { return pNtk->nObjCounts[ABC_OBJ_BLACKBOX]; }

static int Abc_NtkBoNum ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 307 of file abc.h.

00307 { return pNtk->nObjCounts[ABC_OBJ_BO];       }

static Abc_Obj_t* Abc_NtkBox ( Abc_Ntk_t pNtk,
int  i 
) [inline, static]

Definition at line 336 of file abc.h.

00336 { return (Abc_Obj_t *)Vec_PtrEntry( pNtk->vBoxes, i );  }

static int Abc_NtkBoxNum ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 305 of file abc.h.

00305 { return Vec_PtrSize(pNtk->vBoxes);          }

DdManager* Abc_NtkBuildGlobalBdds ( Abc_Ntk_t pNtk,
int  nBddSizeMax,
int  fDropInternal,
int  fReorder,
int  fVerbose 
)

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

Synopsis [Derives global BDDs for the COs of the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 246 of file abcNtbdd.c.

00247 {
00248     ProgressBar * pProgress;
00249     Abc_Obj_t * pObj, * pFanin;
00250     Vec_Att_t * pAttMan;
00251     DdManager * dd;
00252     DdNode * bFunc;
00253     int i, k, Counter;
00254 
00255     // remove dangling nodes
00256     Abc_AigCleanup( pNtk->pManFunc );
00257 
00258     // start the manager
00259     assert( Abc_NtkGlobalBdd(pNtk) == NULL );
00260     dd = Cudd_Init( Abc_NtkCiNum(pNtk), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
00261     pAttMan = Vec_AttAlloc( 0, Abc_NtkObjNumMax(pNtk) + 1, dd, Extra_StopManager, NULL, Cudd_RecursiveDeref );
00262     Vec_PtrWriteEntry( pNtk->vAttrs, VEC_ATTR_GLOBAL_BDD, pAttMan );
00263 
00264     // set reordering
00265     if ( fReorder )
00266         Cudd_AutodynEnable( dd, CUDD_REORDER_SYMM_SIFT );
00267 
00268     // assign the constant node BDD
00269     pObj = Abc_AigConst1(pNtk);
00270     if ( Abc_ObjFanoutNum(pObj) > 0 )
00271     {
00272         bFunc = dd->one;
00273         Abc_ObjSetGlobalBdd( pObj, bFunc );   Cudd_Ref( bFunc );
00274     }
00275     // set the elementary variables
00276     Abc_NtkForEachCi( pNtk, pObj, i )
00277         if ( Abc_ObjFanoutNum(pObj) > 0 )
00278         {
00279             bFunc = dd->vars[i];
00280 //            bFunc = dd->vars[Abc_NtkCiNum(pNtk) - 1 - i];
00281             Abc_ObjSetGlobalBdd( pObj, bFunc );  Cudd_Ref( bFunc );
00282         }
00283 
00284     // collect the global functions of the COs
00285     Counter = 0;
00286     // construct the BDDs
00287     pProgress = Extra_ProgressBarStart( stdout, Abc_NtkNodeNum(pNtk) );
00288     Abc_NtkForEachCo( pNtk, pObj, i )
00289     {
00290         bFunc = Abc_NodeGlobalBdds_rec( dd, Abc_ObjFanin0(pObj), nBddSizeMax, fDropInternal, pProgress, &Counter, fVerbose );
00291         if ( bFunc == NULL )
00292         {
00293             if ( fVerbose )
00294             printf( "Constructing global BDDs is aborted.\n" );
00295             Abc_NtkFreeGlobalBdds( pNtk, 0 );
00296             Cudd_Quit( dd );
00297             return NULL;
00298         }
00299         bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pObj) );  Cudd_Ref( bFunc ); 
00300         Abc_ObjSetGlobalBdd( pObj, bFunc );
00301     }
00302     Extra_ProgressBarStop( pProgress );
00303 
00304 /*
00305     // derefence the intermediate BDDs
00306     Abc_NtkForEachNode( pNtk, pObj, i )
00307         if ( pObj->pCopy ) 
00308         {
00309             Cudd_RecursiveDeref( dd, (DdNode *)pObj->pCopy );
00310             pObj->pCopy = NULL;
00311         }
00312 */
00313 /*
00314     // make sure all nodes are derefed
00315     Abc_NtkForEachObj( pNtk, pObj, i )
00316     {
00317         if ( pObj->pCopy != NULL )
00318             printf( "Abc_NtkBuildGlobalBdds() error: Node %d has BDD assigned\n", pObj->Id );
00319         if ( pObj->vFanouts.nSize > 0 )
00320             printf( "Abc_NtkBuildGlobalBdds() error: Node %d has refs assigned\n", pObj->Id );
00321     }
00322 */
00323     // reset references
00324     Abc_NtkForEachObj( pNtk, pObj, i )
00325         if ( !Abc_ObjIsBox(pObj) && !Abc_ObjIsBo(pObj) )
00326             Abc_ObjForEachFanin( pObj, pFanin, k )
00327                 pFanin->vFanouts.nSize++;
00328 
00329     // reorder one more time
00330     if ( fReorder )
00331     {
00332         Cudd_ReduceHeap( dd, CUDD_REORDER_SYMM_SIFT, 1 );
00333         Cudd_AutodynDisable( dd );
00334     }
00335 //    Cudd_PrintInfo( dd, stdout );
00336     return dd;
00337 }

bool Abc_NtkCheck ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Checks the integrity of the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 58 of file abcCheck.c.

00059 { 
00060    return !Abc_FrameIsFlagEnabled( "check" ) || Abc_NtkDoCheck( pNtk );
00061 }

bool Abc_NtkCheckObj ( Abc_Ntk_t pNtk,
Abc_Obj_t pObj 
)

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

Synopsis [Checks the connectivity of the object.]

Description []

SideEffects []

SeeAlso []

Definition at line 412 of file abcCheck.c.

00413 {
00414     Abc_Obj_t * pFanin, * pFanout;
00415     int i, Value = 1;
00416     int k;
00417 
00418     // check the network
00419     if ( pObj->pNtk != pNtk )
00420     {
00421         fprintf( stdout, "NetworkCheck: Object \"%s\" does not belong to the network.\n", Abc_ObjName(pObj) );
00422         return 0;
00423     }
00424     // check the object ID
00425     if ( pObj->Id < 0 || (int)pObj->Id >= Abc_NtkObjNumMax(pNtk) )
00426     {
00427         fprintf( stdout, "NetworkCheck: Object \"%s\" has incorrect ID.\n", Abc_ObjName(pObj) );
00428         return 0;
00429     }
00430 
00431     if ( !Abc_FrameIsFlagEnabled("checkfio") )
00432         return Value;
00433 
00434     // go through the fanins of the object and make sure fanins have this object as a fanout
00435     Abc_ObjForEachFanin( pObj, pFanin, i )
00436     {
00437         if ( Vec_IntFind( &pFanin->vFanouts, pObj->Id ) == -1 )
00438         {
00439             fprintf( stdout, "NodeCheck: Object \"%s\" has fanin ", Abc_ObjName(pObj) );
00440             fprintf( stdout, "\"%s\" but the fanin does not have it as a fanout.\n", Abc_ObjName(pFanin) );
00441             Value = 0;
00442         }
00443     }
00444     // go through the fanouts of the object and make sure fanouts have this object as a fanin
00445     Abc_ObjForEachFanout( pObj, pFanout, i )
00446     {
00447         if ( Vec_IntFind( &pFanout->vFanins, pObj->Id ) == -1 )
00448         {
00449             fprintf( stdout, "NodeCheck: Object \"%s\" has fanout ", Abc_ObjName(pObj) );
00450             fprintf( stdout, "\"%s\" but the fanout does not have it as a fanin.\n", Abc_ObjName(pFanout) );
00451             Value = 0;
00452         }
00453     }
00454 
00455     // make sure fanins are not duplicated
00456     for ( i = 0; i < pObj->vFanins.nSize; i++ )
00457         for ( k = i + 1; k < pObj->vFanins.nSize; k++ )
00458             if ( pObj->vFanins.pArray[k] == pObj->vFanins.pArray[i] )
00459             {
00460                 printf( "Warning: Node %s has", Abc_ObjName(pObj) );
00461                 printf( " duplicated fanin %s.\n", Abc_ObjName(Abc_ObjFanin(pObj,k)) );
00462             }
00463 
00464     // save time: do not check large fanout lists
00465     if ( pObj->vFanouts.nSize > 100 )
00466         return Value;
00467 
00468     // make sure fanouts are not duplicated
00469     for ( i = 0; i < pObj->vFanouts.nSize; i++ )
00470         for ( k = i + 1; k < pObj->vFanouts.nSize; k++ )
00471             if ( pObj->vFanouts.pArray[k] == pObj->vFanouts.pArray[i] )
00472             {
00473                 printf( "Warning: Node %s has", Abc_ObjName(pObj) );
00474                 printf( " duplicated fanout %s.\n", Abc_ObjName(Abc_ObjFanout(pObj,k)) );
00475             }
00476 
00477     return Value;
00478 }

bool Abc_NtkCheckRead ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Checks the integrity of the network after reading.]

Description []

SideEffects []

SeeAlso []

Definition at line 74 of file abcCheck.c.

00075 {
00076    return !Abc_FrameIsFlagEnabled( "checkread" ) || Abc_NtkDoCheck( pNtk );
00077 }

int Abc_NtkCheckUniqueCiNames ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Returns 0 if CI names are repeated.]

Description []

SideEffects []

SeeAlso []

Definition at line 849 of file abcCheck.c.

00850 {
00851     Vec_Ptr_t * vNames;
00852     Abc_Obj_t * pObj;
00853     int i, fRetValue = 1;
00854     assert( !Abc_NtkIsNetlist(pNtk) );
00855     vNames = Vec_PtrAlloc( Abc_NtkCiNum(pNtk) );
00856     Abc_NtkForEachCi( pNtk, pObj, i )
00857         Vec_PtrPush( vNames, Abc_ObjName(pObj) );
00858     Vec_PtrSort( vNames, Abc_NtkNamesCompare );
00859     for ( i = 1; i < Abc_NtkCiNum(pNtk); i++ )
00860         if ( !strcmp( Vec_PtrEntry(vNames,i-1), Vec_PtrEntry(vNames,i) ) )
00861         {
00862             printf( "Abc_NtkCheck: Repeated CI names: %s and %s.\n", Vec_PtrEntry(vNames,i-1), Vec_PtrEntry(vNames,i) );
00863             fRetValue = 0;
00864         }
00865     Vec_PtrFree( vNames );
00866     return fRetValue;
00867 }

int Abc_NtkCheckUniqueCioNames ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Returns 0 if there is a pair of CI/CO with the same name and logic in between.]

Description []

SideEffects []

SeeAlso []

Definition at line 914 of file abcCheck.c.

00915 {
00916     Abc_Obj_t * pObj, * pObjCi;
00917     int i, nCiId, fRetValue = 1;
00918     assert( !Abc_NtkIsNetlist(pNtk) );
00919     Abc_NtkForEachCo( pNtk, pObj, i )
00920     {
00921         nCiId = Nm_ManFindIdByNameTwoTypes( pNtk->pManName, Abc_ObjName(pObj), ABC_OBJ_PI, ABC_OBJ_BO );
00922         if ( nCiId == -1 )
00923             continue;
00924         pObjCi = Abc_NtkObj( pNtk, nCiId );
00925         assert( !strcmp( Abc_ObjName(pObj), Abc_ObjName(pObjCi) ) );
00926         if ( Abc_ObjFanin0(pObj) != pObjCi )
00927         {
00928             printf( "Abc_NtkCheck: A CI/CO pair share the name (%s) but do not link directly.\n", Abc_ObjName(pObj) );
00929             fRetValue = 0;
00930         }
00931     }
00932     return fRetValue;
00933 }

int Abc_NtkCheckUniqueCoNames ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Returns 0 if CO names are repeated.]

Description []

SideEffects []

SeeAlso []

Definition at line 880 of file abcCheck.c.

00881 {
00882     Vec_Ptr_t * vNames;
00883     Abc_Obj_t * pObj;
00884     int i, fRetValue = 1;
00885     assert( !Abc_NtkIsNetlist(pNtk) );
00886     vNames = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
00887     Abc_NtkForEachCo( pNtk, pObj, i )
00888         Vec_PtrPush( vNames, Abc_ObjName(pObj) );
00889     Vec_PtrSort( vNames, Abc_NtkNamesCompare );
00890     for ( i = 1; i < Abc_NtkCoNum(pNtk); i++ )
00891     {
00892 //        printf( "%s\n", Vec_PtrEntry(vNames,i) );
00893         if ( !strcmp( Vec_PtrEntry(vNames,i-1), Vec_PtrEntry(vNames,i) ) )
00894         {
00895             printf( "Abc_NtkCheck: Repeated CO names: %s and %s.\n", Vec_PtrEntry(vNames,i-1), Vec_PtrEntry(vNames,i) );
00896             fRetValue = 0;
00897         }
00898     }
00899     Vec_PtrFree( vNames );
00900     return fRetValue;
00901 }

static Abc_Obj_t* Abc_NtkCi ( Abc_Ntk_t pNtk,
int  i 
) [inline, static]

Definition at line 333 of file abc.h.

00333 { return (Abc_Obj_t *)Vec_PtrEntry( pNtk->vCis, i );    }

static int Abc_NtkCiNum ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 302 of file abc.h.

00302 { return Vec_PtrSize(pNtk->vCis);            }

void Abc_NtkCleanCopy ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Cleans the copy field of all objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 470 of file abcUtil.c.

00471 {
00472     Abc_Obj_t * pObj;
00473     int i;
00474     Abc_NtkForEachObj( pNtk, pObj, i )
00475         pObj->pCopy = NULL;
00476 }

void Abc_NtkCleanData ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Cleans the copy field of all objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 489 of file abcUtil.c.

00490 {
00491     Abc_Obj_t * pObj;
00492     int i;
00493     Abc_NtkForEachObj( pNtk, pObj, i )
00494         pObj->pData = NULL;
00495 }

void Abc_NtkCleanEquiv ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Cleans the copy field of all objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 508 of file abcUtil.c.

00509 {
00510     Abc_Obj_t * pObj;
00511     int i;
00512     Abc_NtkForEachObj( pNtk, pObj, i )
00513         pObj->pEquiv = NULL;
00514 }

void Abc_NtkCleanMarkA ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Cleans the copy field of all objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 610 of file abcUtil.c.

00611 {
00612     Abc_Obj_t * pObj;
00613     int i = 0;
00614     Abc_NtkForEachObj( pNtk, pObj, i )
00615         pObj->fMarkA = 0;
00616 }

void Abc_NtkCleanNext ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Cleans the copy field of all objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 591 of file abcUtil.c.

00592 {
00593     Abc_Obj_t * pObj;
00594     int i = 0;
00595     Abc_NtkForEachObj( pNtk, pObj, i )
00596         pObj->pNext = NULL;
00597 }

int Abc_NtkCleanup ( Abc_Ntk_t pNtk,
int  fVerbose 
)

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

Synopsis [Removes dangling nodes.]

Description [Returns the number of nodes removed.]

SideEffects []

SeeAlso []

Definition at line 472 of file abcSweep.c.

00473 {
00474     Vec_Ptr_t * vNodes;
00475     int Counter;
00476     assert( Abc_NtkIsLogic(pNtk) );
00477     // mark the nodes reachable from the POs
00478     vNodes = Abc_NtkDfs( pNtk, 0 );
00479     Counter = Abc_NtkReduceNodes( pNtk, vNodes );
00480     if ( fVerbose )
00481         printf( "Cleanup removed %d dangling nodes.\n", Counter );
00482     Vec_PtrFree( vNodes );
00483     return Counter;
00484 }

int Abc_NtkCleanupSeq ( Abc_Ntk_t pNtk,
int  fLatchSweep,
int  fAutoSweep,
int  fVerbose 
)

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

Synopsis [Sequential cleanup.]

Description [Performs three tasks:

  • Removes logic that does not feed into POs.
  • Removes latches driven by constant values equal to the initial state.
  • Replaces the autonomous components by additional PI variables.]

SideEffects []

SeeAlso []

Definition at line 904 of file abcSweep.c.

00905 {
00906     Vec_Ptr_t * vNodes;
00907     int Counter;
00908     assert( Abc_NtkIsLogic(pNtk) );
00909     // mark the nodes reachable from the POs
00910     vNodes = Abc_NtkDfsSeq( pNtk );
00911     Vec_PtrFree( vNodes );
00912     // remove the non-marked nodes
00913     Counter = Abc_NodeRemoveNonCurrentObjects( pNtk );
00914     if ( fVerbose )
00915         printf( "Cleanup removed %4d dangling objects.\n", Counter );
00916     // check if some of the latches can be removed
00917     if ( fLatchSweep )
00918     {
00919         Counter = Abc_NtkLatchSweep( pNtk );
00920         if ( fVerbose )
00921             printf( "Cleanup removed %4d redundant latches.\n", Counter );
00922     }
00923     // detect the autonomous components
00924     if ( fAutoSweep )
00925     {
00926         vNodes = Abc_NtkDfsSeqReverse( pNtk );
00927         Vec_PtrFree( vNodes );
00928         // replace them by PIs
00929         Counter = Abc_NtkReplaceAutonomousLogic( pNtk );
00930         if ( fVerbose )
00931             printf( "Cleanup added   %4d additional PIs.\n", Counter );
00932         // remove the non-marked nodes
00933         Counter = Abc_NodeRemoveNonCurrentObjects( pNtk );
00934         if ( fVerbose )
00935             printf( "Cleanup removed %4d autonomous objects.\n", Counter );
00936     }
00937     // check
00938     if ( !Abc_NtkCheck( pNtk ) )
00939         printf( "Abc_NtkCleanupSeq: The network check has failed.\n" );
00940     return 1;
00941 }

Abc_Obj_t* Abc_NtkCloneObj ( Abc_Obj_t pObj  ) 

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

Synopsis [Clones the objects in the same network but does not assign its function.]

Description []

SideEffects []

SeeAlso []

Definition at line 413 of file abcObj.c.

00414 {
00415     Abc_Obj_t * pClone, * pFanin;
00416     int i;
00417     pClone = Abc_NtkCreateObj( pObj->pNtk, pObj->Type );   
00418     Abc_ObjForEachFanin( pObj, pFanin, i )
00419         Abc_ObjAddFanin( pClone, pFanin );
00420     return pClone;
00421 }

static Abc_Obj_t* Abc_NtkCo ( Abc_Ntk_t pNtk,
int  i 
) [inline, static]

Definition at line 334 of file abc.h.

00334 { return (Abc_Obj_t *)Vec_PtrEntry( pNtk->vCos, i );    }

Abc_Ntk_t* Abc_NtkCollapse ( Abc_Ntk_t pNtk,
int  fBddSizeMax,
int  fDualRail,
int  fReorder,
int  fVerbose 
)

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

Synopsis [Collapses the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file abcClpBdd.c.

00046 {
00047     Abc_Ntk_t * pNtkNew;
00048     int clk = clock();
00049 
00050     assert( Abc_NtkIsStrash(pNtk) );
00051     // compute the global BDDs
00052     if ( Abc_NtkBuildGlobalBdds(pNtk, fBddSizeMax, 1, fReorder, fVerbose) == NULL )
00053         return NULL;
00054     if ( fVerbose )
00055     {
00056         DdManager * dd = Abc_NtkGlobalBddMan( pNtk );
00057         printf( "Shared BDD size = %6d nodes.  ", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) );
00058         PRT( "BDD construction time", clock() - clk );
00059     }
00060 
00061     // create the new network
00062     pNtkNew = Abc_NtkFromGlobalBdds( pNtk );
00063 //    Abc_NtkFreeGlobalBdds( pNtk );
00064     Abc_NtkFreeGlobalBdds( pNtk, 1 );
00065     if ( pNtkNew == NULL )
00066     {
00067 //        Cudd_Quit( pNtk->pManGlob );
00068 //        pNtk->pManGlob = NULL;
00069         return NULL;
00070     }
00071 //    Extra_StopManager( pNtk->pManGlob );
00072 //    pNtk->pManGlob = NULL;
00073 
00074     // make the network minimum base
00075     Abc_NtkMinimumBase( pNtkNew );
00076 
00077     if ( pNtk->pExdc )
00078         pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
00079 
00080     // make sure that everything is okay
00081     if ( !Abc_NtkCheck( pNtkNew ) )
00082     {
00083         printf( "Abc_NtkCollapse: The network check has failed.\n" );
00084         Abc_NtkDelete( pNtkNew );
00085         return NULL;
00086     }
00087     return pNtkNew;
00088 }

char** Abc_NtkCollectCioNames ( Abc_Ntk_t pNtk,
int  fCollectCos 
)

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

Synopsis [Collects the CI or CO names.]

Description []

SideEffects []

SeeAlso []

Definition at line 259 of file abcNames.c.

00260 {
00261     Abc_Obj_t * pObj;
00262     char ** ppNames;
00263     int i;
00264     if ( fCollectCos )
00265     {
00266         ppNames = ALLOC( char *, Abc_NtkCoNum(pNtk) );
00267         Abc_NtkForEachCo( pNtk, pObj, i )
00268             ppNames[i] = Abc_ObjName(pObj);
00269     }
00270     else
00271     {
00272         ppNames = ALLOC( char *, Abc_NtkCiNum(pNtk) );
00273         Abc_NtkForEachCi( pNtk, pObj, i )
00274             ppNames[i] = Abc_ObjName(pObj);
00275     }
00276     return ppNames;
00277 }

Vec_Ptr_t* Abc_NtkCollectLatches ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Collects all latches in the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 1205 of file abcUtil.c.

01206 {
01207     Vec_Ptr_t * vLatches;
01208     Abc_Obj_t * pObj;
01209     int i;
01210     vLatches = Vec_PtrAlloc( 10 );
01211     Abc_NtkForEachObj( pNtk, pObj, i )
01212         Vec_PtrPush( vLatches, pObj );
01213     return vLatches;
01214 }

Vec_Int_t* Abc_NtkCollectLatchValues ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Strashes one logic node using its SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 184 of file abcLatch.c.

00185 {
00186     Vec_Int_t * vValues;
00187     Abc_Obj_t * pLatch;
00188     int i;
00189     vValues = Vec_IntAlloc( Abc_NtkLatchNum(pNtk) );
00190     Abc_NtkForEachLatch( pNtk, pLatch, i )
00191         Vec_IntPush( vValues, Abc_LatchIsInit1(pLatch) );
00192     return vValues;
00193 }

Vec_Ptr_t* Abc_NtkCollectObjects ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Collects all objects into one array.]

Description []

SideEffects []

SeeAlso []

Definition at line 1293 of file abcUtil.c.

01294 {
01295     Vec_Ptr_t * vNodes;
01296     Abc_Obj_t * pNode;
01297     int i;
01298     vNodes = Vec_PtrAlloc( 100 );
01299     Abc_NtkForEachObj( pNtk, pNode, i )
01300         Vec_PtrPush( vNodes, pNode );
01301     return vNodes;
01302 }

bool Abc_NtkCompareSignals ( Abc_Ntk_t pNtk1,
Abc_Ntk_t pNtk2,
int  fOnlyPis,
int  fComb 
)

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

Synopsis [Compares the signals of the networks.]

Description []

SideEffects []

SeeAlso []

Definition at line 736 of file abcCheck.c.

00737 {
00738     Abc_NtkOrderObjsByName( pNtk1, fComb );
00739     Abc_NtkOrderObjsByName( pNtk2, fComb );
00740     if ( !Abc_NtkComparePis( pNtk1, pNtk2, fComb ) )
00741         return 0;
00742     if ( !fOnlyPis )
00743     {
00744         if ( !Abc_NtkCompareBoxes( pNtk1, pNtk2, fComb ) )
00745             return 0;
00746         if ( !Abc_NtkComparePos( pNtk1, pNtk2, fComb ) )
00747             return 0;
00748     }
00749     return 1;
00750 }

static int Abc_NtkCoNum ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 303 of file abc.h.

00303 { return Vec_PtrSize(pNtk->vCos);            }

Abc_Ntk_t* Abc_NtkConvertBlackboxes ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Extracts blackboxes by making them into additional PIs/POs.]

Description [The input netlist has not logic hierarchy. The resulting netlist has additional PIs/POs for each blackbox input/output.]

SideEffects []

SeeAlso []

Definition at line 246 of file abcHie.c.

00247 {
00248     Abc_Ntk_t * pNtkNew;
00249     Abc_Obj_t * pObj, * pNet, * pFanin, * pTerm;
00250     int i, k;
00251 
00252     assert( Abc_NtkIsNetlist(pNtk) );
00253     assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
00254 
00255     // start the network
00256     pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
00257     // duplicate the name and the spec
00258     pNtkNew->pName = Extra_UtilStrsav( pNtk->pName );
00259     pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec );
00260 
00261     // clean the node copy fields
00262     Abc_NtkCleanCopy( pNtk );
00263 
00264     // mark the nodes that should not be connected
00265     Abc_NtkIncrementTravId( pNtk );
00266     Abc_NtkForEachBlackbox( pNtk, pObj, i )
00267         Abc_NodeSetTravIdCurrent( pObj );
00268     Abc_NtkForEachCi( pNtk, pTerm, i )
00269         Abc_NodeSetTravIdCurrent( pTerm );
00270     Abc_NtkForEachCo( pNtk, pTerm, i )
00271         Abc_NodeSetTravIdCurrent( pTerm );
00272     // unmark PIs and LIs/LOs
00273     Abc_NtkForEachPi( pNtk, pTerm, i )
00274         Abc_NodeSetTravIdPrevious( pTerm );
00275     Abc_NtkForEachLatchInput( pNtk, pTerm, i )
00276         Abc_NodeSetTravIdPrevious( pTerm );
00277     Abc_NtkForEachLatchOutput( pNtk, pTerm, i )
00278         Abc_NodeSetTravIdPrevious( pTerm );
00279     // copy the box outputs
00280     Abc_NtkForEachBlackbox( pNtk, pObj, i )
00281         Abc_ObjForEachFanout( pObj, pTerm, k )
00282             pTerm->pCopy = Abc_NtkCreatePi( pNtkNew );
00283 
00284     // duplicate other objects
00285     Abc_NtkForEachObj( pNtk, pObj, i )
00286         if ( !Abc_NodeIsTravIdCurrent(pObj) )
00287             Abc_NtkDupObj( pNtkNew, pObj, Abc_ObjIsNet(pObj) );
00288 
00289     // connect all objects
00290     Abc_NtkForEachObj( pNtk, pObj, i )
00291         if ( !Abc_NodeIsTravIdCurrent(pObj) )
00292             Abc_ObjForEachFanin( pObj, pFanin, k )
00293                 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
00294 
00295     // create unique PO for each net feeding into blackboxes or POs
00296     Abc_NtkIncrementTravId( pNtk );
00297     Abc_NtkForEachCo( pNtk, pTerm, i )
00298     {
00299         // skip latch inputs
00300         assert( Abc_ObjFanoutNum(pTerm) <= 1 );
00301         if ( Abc_ObjFanoutNum(pTerm) > 0 && Abc_ObjIsLatch(Abc_ObjFanout0(pTerm)) )
00302             continue;
00303         // check if the net is visited
00304         pNet = Abc_ObjFanin0(pTerm);
00305         if ( Abc_NodeIsTravIdCurrent(pNet) )
00306             continue;
00307         // create PO
00308         Abc_NodeSetTravIdCurrent( pNet );
00309         Abc_ObjAddFanin( Abc_NtkCreatePo(pNtkNew), pNet->pCopy );
00310     }
00311 
00312     // check integrity
00313     if ( !Abc_NtkCheck( pNtkNew ) )
00314     {
00315         fprintf( stdout, "Abc_NtkConvertBlackboxes(): Network check has failed.\n" );
00316         Abc_NtkDelete( pNtkNew );
00317         return NULL;
00318     }
00319     return pNtkNew;
00320 }

void Abc_NtkConvertDcLatches ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Converts registers with DC values into additional PIs.]

Description []

SideEffects []

SeeAlso []

Definition at line 278 of file abcLatch.c.

00279 {
00280     Abc_Obj_t * pCtrl, * pLatch, * pMux, * pPi;
00281     Abc_InitType_t Init = ABC_INIT_ZERO;
00282     int i, fFound = 0, Counter;
00283     // check if there are latches with DC values
00284     Abc_NtkForEachLatch( pNtk, pLatch, i )
00285         if ( Abc_LatchIsInitDc(pLatch) )
00286         {
00287             fFound = 1;
00288             break;
00289         }
00290     if ( !fFound )
00291         return;
00292     // add control latch
00293     pCtrl = Abc_NtkAddLatch( pNtk, Abc_NtkCreateNodeConst1(pNtk), Init );
00294     // add fanouts for each latch with DC values
00295     Counter = 0;
00296     Abc_NtkForEachLatch( pNtk, pLatch, i )
00297     {
00298         if ( !Abc_LatchIsInitDc(pLatch) )
00299             continue;
00300         // change latch value
00301         pLatch->pData = (void *)Init;
00302         // if the latch output has the same name as a PO, rename it
00303         if ( Abc_NodeFindCoFanout( Abc_ObjFanout0(pLatch) ) )
00304         {
00305             Nm_ManDeleteIdName( pLatch->pNtk->pManName, Abc_ObjFanout0(pLatch)->Id );
00306             Abc_ObjAssignName( Abc_ObjFanout0(pLatch), Abc_ObjName(pLatch), "_lo" );
00307         }
00308         // create new PIs
00309         pPi = Abc_NtkCreatePi( pNtk );
00310         Abc_ObjAssignName( pPi, Abc_ObjName(pLatch), "_pi" );
00311         // create a new node and transfer fanout from latch output to the new node
00312         pMux = Abc_NtkCreateNode( pNtk );
00313         Abc_ObjTransferFanout( Abc_ObjFanout0(pLatch), pMux );
00314         // convert the node into a mux
00315         Abc_NtkNodeConvertToMux( pNtk, pCtrl, Abc_ObjFanout0(pLatch), pPi, pMux );
00316         Counter++;
00317     }
00318     printf( "The number of converted latches with DC values = %d.\n", Counter );
00319 }

int Abc_NtkConvertToBlifMv ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Converts SOP netlist into BLIF-MV netlist.]

Description []

SideEffects []

SeeAlso []

Definition at line 764 of file abcBlifMv.c.

00765 {
00766     Extra_MmFlex_t * pMmFlex;
00767     Abc_Obj_t * pNode;
00768     Vec_Str_t * vCube;
00769     char * pSop0, * pSop1, * pBlifMv, * pCube, * pCur;
00770     int Value, nCubes, nSize, i, k;
00771 
00772     assert( Abc_NtkIsNetlist(pNtk) );
00773     if ( !Abc_NtkToBdd(pNtk) )
00774     {
00775         printf( "Converting logic functions to BDDs has failed.\n" );
00776         return 0;
00777     }
00778 
00779     pMmFlex = Extra_MmFlexStart();
00780     vCube   = Vec_StrAlloc( 100 );
00781     Abc_NtkForEachNode( pNtk, pNode, i )
00782     {
00783         // convert BDD into cubes for on-set and off-set
00784         Abc_NodeBddToCnf( pNode, pMmFlex, vCube, 0, &pSop0, &pSop1 );
00785         // allocate room for the MV-SOP
00786         nCubes = Abc_SopGetCubeNum(pSop0) + Abc_SopGetCubeNum(pSop1);
00787         nSize = nCubes*(2*Abc_ObjFaninNum(pNode) + 2)+1;
00788         pBlifMv = Extra_MmFlexEntryFetch( pMmFlex, nSize );
00789         // add the cubes
00790         pCur = pBlifMv;
00791         Abc_SopForEachCube( pSop0, Abc_ObjFaninNum(pNode), pCube )
00792         {
00793             Abc_CubeForEachVar( pCube, Value, k )
00794             {
00795                 *pCur++ = Value;
00796                 *pCur++ = ' ';
00797             }
00798             *pCur++ = '0';
00799             *pCur++ = '\n';
00800         }
00801         Abc_SopForEachCube( pSop1, Abc_ObjFaninNum(pNode), pCube )
00802         {
00803             Abc_CubeForEachVar( pCube, Value, k )
00804             {
00805                 *pCur++ = Value;
00806                 *pCur++ = ' ';
00807             }
00808             *pCur++ = '1';
00809             *pCur++ = '\n';
00810         }
00811         *pCur++ = 0;
00812         assert( pCur - pBlifMv == nSize );
00813         // update the node representation
00814         Cudd_RecursiveDeref( pNtk->pManFunc, pNode->pData );
00815         pNode->pData = pBlifMv;
00816     }
00817 
00818     // update the functionality type
00819     pNtk->ntkFunc = ABC_FUNC_BLIFMV;
00820     Cudd_Quit( pNtk->pManFunc );
00821     pNtk->pManFunc = pMmFlex;
00822 
00823     Vec_StrFree( vCube );
00824     return 1;
00825 }

int Abc_NtkCountCopy ( Abc_Ntk_t pNtk  ) 

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 527 of file abcUtil.c.

00528 {
00529     Abc_Obj_t * pObj;
00530     int i, Counter = 0;
00531     Abc_NtkForEachObj( pNtk, pObj, i )
00532     {
00533         if ( Abc_ObjIsNode(pObj) )
00534             Counter += (pObj->pCopy != NULL);
00535     }
00536     return Counter;
00537 }

int Abc_NtkCountSelfFeedLatches ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Checks if latches form self-loop.]

Description []

SideEffects []

SeeAlso []

Definition at line 86 of file abcLatch.c.

00087 {
00088     Abc_Obj_t * pLatch;
00089     int i, Counter;
00090     Counter = 0;
00091     Abc_NtkForEachLatch( pNtk, pLatch, i )
00092     {
00093 //        if ( Abc_NtkLatchIsSelfFeed(pLatch) && Abc_ObjFanoutNum(pLatch) > 1 )
00094 //            printf( "Fanouts = %d.\n", Abc_ObjFanoutNum(pLatch) );
00095         Counter += Abc_NtkLatchIsSelfFeed( pLatch );
00096     }
00097     return Counter;
00098 }

static Abc_Obj_t* Abc_NtkCreateAssert ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 322 of file abc.h.

00322 { return Abc_NtkCreateObj( pNtk, ABC_OBJ_ASSERT );     }

static Abc_Obj_t* Abc_NtkCreateBi ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 320 of file abc.h.

00320 { return Abc_NtkCreateObj( pNtk, ABC_OBJ_BI );         }

static Abc_Obj_t* Abc_NtkCreateBlackbox ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 327 of file abc.h.

00327 { return Abc_NtkCreateObj( pNtk, ABC_OBJ_BLACKBOX );   }

static Abc_Obj_t* Abc_NtkCreateBo ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 321 of file abc.h.

00321 { return Abc_NtkCreateObj( pNtk, ABC_OBJ_BO );         }

Abc_Ntk_t* Abc_NtkCreateCone ( Abc_Ntk_t pNtk,
Abc_Obj_t pNode,
char *  pNodeName,
int  fUseAllCis 
)

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

Synopsis [Creates the network composed of one logic cone.]

Description []

SideEffects []

SeeAlso []

Definition at line 511 of file abcNtk.c.

00512 {
00513     Abc_Ntk_t * pNtkNew; 
00514     Vec_Ptr_t * vNodes;
00515     Abc_Obj_t * pObj, * pFanin, * pNodeCoNew;
00516     char Buffer[1000];
00517     int i, k;
00518 
00519     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsStrash(pNtk) );
00520     assert( Abc_ObjIsNode(pNode) ); 
00521     
00522     // start the network
00523     pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
00524     // set the name
00525     sprintf( Buffer, "%s_%s", pNtk->pName, pNodeName );
00526     pNtkNew->pName = Extra_UtilStrsav(Buffer);
00527 
00528     // establish connection between the constant nodes
00529     if ( Abc_NtkIsStrash(pNtk) )
00530         Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
00531 
00532     // collect the nodes in the TFI of the output (mark the TFI)
00533     vNodes = Abc_NtkDfsNodes( pNtk, &pNode, 1 );
00534     // create the PIs
00535     Abc_NtkForEachCi( pNtk, pObj, i )
00536     {
00537         if ( fUseAllCis || Abc_NodeIsTravIdCurrent(pObj) ) // TravId is set by DFS
00538         {
00539             pObj->pCopy = Abc_NtkCreatePi(pNtkNew);
00540             Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
00541         }
00542     }
00543     // add the PO corresponding to this output
00544     pNodeCoNew = Abc_NtkCreatePo( pNtkNew );
00545     Abc_ObjAssignName( pNodeCoNew, pNodeName, NULL );
00546     // copy the nodes
00547     Vec_PtrForEachEntry( vNodes, pObj, i )
00548     {
00549         // if it is an AIG, add to the hash table
00550         if ( Abc_NtkIsStrash(pNtk) )
00551         {
00552             pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
00553         }
00554         else
00555         {
00556             Abc_NtkDupObj( pNtkNew, pObj, 0 );
00557             Abc_ObjForEachFanin( pObj, pFanin, k )
00558                 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
00559         }
00560     }
00561     // connect the internal nodes to the new CO
00562     Abc_ObjAddFanin( pNodeCoNew, pNode->pCopy );
00563     Vec_PtrFree( vNodes );
00564 
00565     if ( !Abc_NtkCheck( pNtkNew ) )
00566         fprintf( stdout, "Abc_NtkCreateCone(): Network check has failed.\n" );
00567     return pNtkNew;
00568 }

Abc_Ntk_t* Abc_NtkCreateConeArray ( Abc_Ntk_t pNtk,
Vec_Ptr_t vRoots,
int  fUseAllCis 
)

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

Synopsis [Creates the network composed of several logic cones.]

Description []

SideEffects []

SeeAlso []

Definition at line 581 of file abcNtk.c.

00582 {
00583     Abc_Ntk_t * pNtkNew; 
00584     Vec_Ptr_t * vNodes;
00585     Abc_Obj_t * pObj, * pFanin, * pNodeCoNew;
00586     char Buffer[1000];
00587     int i, k;
00588 
00589     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsStrash(pNtk) );
00590     
00591     // start the network
00592     pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
00593     // set the name
00594     sprintf( Buffer, "%s_part", pNtk->pName );
00595     pNtkNew->pName = Extra_UtilStrsav(Buffer);
00596 
00597     // establish connection between the constant nodes
00598     if ( Abc_NtkIsStrash(pNtk) )
00599         Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
00600 
00601     // collect the nodes in the TFI of the output (mark the TFI)
00602     vNodes = Abc_NtkDfsNodes( pNtk, (Abc_Obj_t **)Vec_PtrArray(vRoots), Vec_PtrSize(vRoots) );
00603 
00604     // create the PIs
00605     Abc_NtkForEachCi( pNtk, pObj, i )
00606     {
00607         if ( fUseAllCis || Abc_NodeIsTravIdCurrent(pObj) ) // TravId is set by DFS
00608         {
00609             pObj->pCopy = Abc_NtkCreatePi(pNtkNew);
00610             Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
00611         }
00612     }
00613 
00614     // copy the nodes
00615     Vec_PtrForEachEntry( vNodes, pObj, i )
00616     {
00617         // if it is an AIG, add to the hash table
00618         if ( Abc_NtkIsStrash(pNtk) )
00619         {
00620             pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
00621         }
00622         else
00623         {
00624             Abc_NtkDupObj( pNtkNew, pObj, 0 );
00625             Abc_ObjForEachFanin( pObj, pFanin, k )
00626                 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
00627         }
00628     }
00629     Vec_PtrFree( vNodes );
00630 
00631     // add the POs corresponding to the root nodes
00632     Vec_PtrForEachEntry( vRoots, pObj, i )
00633     {
00634         // create the PO node
00635         pNodeCoNew = Abc_NtkCreatePo( pNtkNew );
00636         // connect the internal nodes to the new CO
00637         if ( Abc_ObjIsCo(pObj) )
00638             Abc_ObjAddFanin( pNodeCoNew, Abc_ObjChild0Copy(pObj) );
00639         else
00640             Abc_ObjAddFanin( pNodeCoNew, pObj->pCopy );
00641         // assign the name
00642         Abc_ObjAssignName( pNodeCoNew, Abc_ObjName(pObj), NULL );
00643     }
00644 
00645     if ( !Abc_NtkCheck( pNtkNew ) )
00646         fprintf( stdout, "Abc_NtkCreateConeArray(): Network check has failed.\n" );
00647     return pNtkNew;
00648 }

Abc_Ntk_t* Abc_NtkCreateFromNode ( Abc_Ntk_t pNtk,
Abc_Obj_t pNode 
)

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

Synopsis [Creates the network composed of one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 846 of file abcNtk.c.

00847 {    
00848     Abc_Ntk_t * pNtkNew; 
00849     Abc_Obj_t * pFanin, * pNodePo;
00850     int i;
00851     // start the network
00852     pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
00853     pNtkNew->pName = Extra_UtilStrsav(Abc_ObjName(pNode));
00854     // add the PIs corresponding to the fanins of the node
00855     Abc_ObjForEachFanin( pNode, pFanin, i )
00856     {
00857         pFanin->pCopy = Abc_NtkCreatePi( pNtkNew );
00858         Abc_ObjAssignName( pFanin->pCopy, Abc_ObjName(pFanin), NULL );
00859     }
00860     // duplicate and connect the node
00861     pNode->pCopy = Abc_NtkDupObj( pNtkNew, pNode, 0 );
00862     Abc_ObjForEachFanin( pNode, pFanin, i )
00863         Abc_ObjAddFanin( pNode->pCopy, pFanin->pCopy );
00864     // create the only PO
00865     pNodePo = Abc_NtkCreatePo( pNtkNew );
00866     Abc_ObjAddFanin( pNodePo, pNode->pCopy );
00867     Abc_ObjAssignName( pNodePo, Abc_ObjName(pNode), NULL );
00868     if ( !Abc_NtkCheck( pNtkNew ) )
00869         fprintf( stdout, "Abc_NtkCreateFromNode(): Network check has failed.\n" );
00870     return pNtkNew;
00871 }

static Abc_Obj_t* Abc_NtkCreateLatch ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 325 of file abc.h.

00325 { return Abc_NtkCreateObj( pNtk, ABC_OBJ_LATCH );      }

Abc_Ntk_t* Abc_NtkCreateMffc ( Abc_Ntk_t pNtk,
Abc_Obj_t pNode,
char *  pNodeName 
)

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

Synopsis [Creates the network composed of MFFC of one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 714 of file abcNtk.c.

00715 {
00716     Abc_Ntk_t * pNtkNew; 
00717     Abc_Obj_t * pObj, * pFanin, * pNodeCoNew;
00718     Vec_Ptr_t * vCone, * vSupp;
00719     char Buffer[1000];
00720     int i, k;
00721 
00722     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsStrash(pNtk) );
00723     assert( Abc_ObjIsNode(pNode) ); 
00724     
00725     // start the network
00726     pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
00727     // set the name
00728     sprintf( Buffer, "%s_%s", pNtk->pName, pNodeName );
00729     pNtkNew->pName = Extra_UtilStrsav(Buffer);
00730 
00731     // establish connection between the constant nodes
00732     if ( Abc_NtkIsStrash(pNtk) )
00733         Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
00734 
00735     // collect the nodes in MFFC
00736     vCone = Vec_PtrAlloc( 100 );
00737     vSupp = Vec_PtrAlloc( 100 );
00738     Abc_NodeDeref_rec( pNode );
00739     Abc_NodeMffsConeSupp( pNode, vCone, vSupp );
00740     Abc_NodeRef_rec( pNode );
00741     // create the PIs
00742     Vec_PtrForEachEntry( vSupp, pObj, i )
00743     {
00744         pObj->pCopy = Abc_NtkCreatePi(pNtkNew);
00745         Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
00746     }
00747     // create the PO
00748     pNodeCoNew = Abc_NtkCreatePo( pNtkNew );
00749     Abc_ObjAssignName( pNodeCoNew, pNodeName, NULL );
00750     // copy the nodes
00751     Vec_PtrForEachEntry( vCone, pObj, i )
00752     {
00753         // if it is an AIG, add to the hash table
00754         if ( Abc_NtkIsStrash(pNtk) )
00755         {
00756             pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
00757         }
00758         else
00759         {
00760             Abc_NtkDupObj( pNtkNew, pObj, 0 );
00761             Abc_ObjForEachFanin( pObj, pFanin, k )
00762                 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
00763         }
00764     }
00765     // connect the topmost node
00766     Abc_ObjAddFanin( pNodeCoNew, pNode->pCopy );
00767     Vec_PtrFree( vCone );
00768     Vec_PtrFree( vSupp );
00769 
00770     if ( !Abc_NtkCheck( pNtkNew ) )
00771         fprintf( stdout, "Abc_NtkCreateMffc(): Network check has failed.\n" );
00772     return pNtkNew;
00773 }

static Abc_Obj_t* Abc_NtkCreateNet ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 323 of file abc.h.

00323 { return Abc_NtkCreateObj( pNtk, ABC_OBJ_NET );        }

static Abc_Obj_t* Abc_NtkCreateNode ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 324 of file abc.h.

00324 { return Abc_NtkCreateObj( pNtk, ABC_OBJ_NODE );       }

Abc_Obj_t* Abc_NtkCreateNodeAnd ( Abc_Ntk_t pNtk,
Vec_Ptr_t vFanins 
)

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

Synopsis [Creates AND.]

Description []

SideEffects []

SeeAlso []

Definition at line 701 of file abcObj.c.

00702 {
00703     Abc_Obj_t * pNode;
00704     int i;
00705     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00706     pNode = Abc_NtkCreateNode( pNtk );   
00707     for ( i = 0; i < vFanins->nSize; i++ )
00708         Abc_ObjAddFanin( pNode, vFanins->pArray[i] );
00709     if ( Abc_NtkHasSop(pNtk) )
00710         pNode->pData = Abc_SopCreateAnd( pNtk->pManFunc, Vec_PtrSize(vFanins), NULL );
00711     else if ( Abc_NtkHasBdd(pNtk) )
00712         pNode->pData = Extra_bddCreateAnd( pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref(pNode->pData); 
00713     else if ( Abc_NtkHasAig(pNtk) )
00714         pNode->pData = Hop_CreateAnd( pNtk->pManFunc, Vec_PtrSize(vFanins) ); 
00715     else
00716         assert( 0 );
00717     return pNode;
00718 }

Abc_Obj_t* Abc_NtkCreateNodeBuf ( Abc_Ntk_t pNtk,
Abc_Obj_t pFanin 
)

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

Synopsis [Creates buffer.]

Description []

SideEffects []

SeeAlso []

Definition at line 671 of file abcObj.c.

00672 {
00673     Abc_Obj_t * pNode;
00674     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00675     pNode = Abc_NtkCreateNode( pNtk ); 
00676     if ( pFanin ) Abc_ObjAddFanin( pNode, pFanin );
00677     if ( Abc_NtkHasSop(pNtk) )
00678         pNode->pData = Abc_SopRegister( pNtk->pManFunc, "1 1\n" );
00679     else if ( Abc_NtkHasBdd(pNtk) )
00680         pNode->pData = Cudd_bddIthVar(pNtk->pManFunc,0), Cudd_Ref( pNode->pData );
00681     else if ( Abc_NtkHasAig(pNtk) )
00682         pNode->pData = Hop_IthVar(pNtk->pManFunc,0);
00683     else if ( Abc_NtkHasMapping(pNtk) )
00684         pNode->pData = Mio_LibraryReadBuf(Abc_FrameReadLibGen());
00685     else
00686         assert( 0 );
00687     return pNode;
00688 }

Abc_Obj_t* Abc_NtkCreateNodeConst0 ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Creates constant 0 node.]

Description []

SideEffects []

SeeAlso []

Definition at line 583 of file abcObj.c.

00584 {
00585     Abc_Obj_t * pNode;
00586     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00587     pNode = Abc_NtkCreateNode( pNtk );   
00588     if ( Abc_NtkHasSop(pNtk) || Abc_NtkHasBlifMv(pNtk) )
00589         pNode->pData = Abc_SopRegister( pNtk->pManFunc, " 0\n" );
00590     else if ( Abc_NtkHasBdd(pNtk) )
00591         pNode->pData = Cudd_ReadLogicZero(pNtk->pManFunc), Cudd_Ref( pNode->pData );
00592     else if ( Abc_NtkHasAig(pNtk) )
00593         pNode->pData = Hop_ManConst0(pNtk->pManFunc);
00594     else if ( Abc_NtkHasMapping(pNtk) )
00595         pNode->pData = Mio_LibraryReadConst0(Abc_FrameReadLibGen());
00596     else if ( !Abc_NtkHasBlackbox(pNtk) )
00597         assert( 0 );
00598     return pNode;
00599 }

Abc_Obj_t* Abc_NtkCreateNodeConst1 ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Creates constant 1 node.]

Description []

SideEffects []

SeeAlso []

Definition at line 612 of file abcObj.c.

00613 {
00614     Abc_Obj_t * pNode;
00615     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00616     pNode = Abc_NtkCreateNode( pNtk );   
00617     if ( Abc_NtkHasSop(pNtk) || Abc_NtkHasBlifMv(pNtk) )
00618         pNode->pData = Abc_SopRegister( pNtk->pManFunc, " 1\n" );
00619     else if ( Abc_NtkHasBdd(pNtk) )
00620         pNode->pData = Cudd_ReadOne(pNtk->pManFunc), Cudd_Ref( pNode->pData );
00621     else if ( Abc_NtkHasAig(pNtk) )
00622         pNode->pData = Hop_ManConst1(pNtk->pManFunc);
00623     else if ( Abc_NtkHasMapping(pNtk) )
00624         pNode->pData = Mio_LibraryReadConst1(Abc_FrameReadLibGen());
00625     else if ( !Abc_NtkHasBlackbox(pNtk) )
00626         assert( 0 );
00627     return pNode;
00628 }

Abc_Obj_t* Abc_NtkCreateNodeExor ( Abc_Ntk_t pNtk,
Vec_Ptr_t vFanins 
)

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

Synopsis [Creates EXOR.]

Description []

SideEffects []

SeeAlso []

Definition at line 761 of file abcObj.c.

00762 {
00763     Abc_Obj_t * pNode;
00764     int i;
00765     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00766     pNode = Abc_NtkCreateNode( pNtk );   
00767     for ( i = 0; i < vFanins->nSize; i++ )
00768         Abc_ObjAddFanin( pNode, vFanins->pArray[i] );
00769     if ( Abc_NtkHasSop(pNtk) )
00770         pNode->pData = Abc_SopCreateXorSpecial( pNtk->pManFunc, Vec_PtrSize(vFanins) );
00771     else if ( Abc_NtkHasBdd(pNtk) )
00772         pNode->pData = Extra_bddCreateExor( pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref(pNode->pData); 
00773     else if ( Abc_NtkHasAig(pNtk) )
00774         pNode->pData = Hop_CreateExor( pNtk->pManFunc, Vec_PtrSize(vFanins) ); 
00775     else
00776         assert( 0 );
00777     return pNode;
00778 }

Abc_Obj_t* Abc_NtkCreateNodeInv ( Abc_Ntk_t pNtk,
Abc_Obj_t pFanin 
)

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

Synopsis [Creates inverter.]

Description []

SideEffects []

SeeAlso []

Definition at line 641 of file abcObj.c.

00642 {
00643     Abc_Obj_t * pNode;
00644     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00645     pNode = Abc_NtkCreateNode( pNtk );   
00646     if ( pFanin ) Abc_ObjAddFanin( pNode, pFanin );
00647     if ( Abc_NtkHasSop(pNtk) )
00648         pNode->pData = Abc_SopRegister( pNtk->pManFunc, "0 1\n" );
00649     else if ( Abc_NtkHasBdd(pNtk) )
00650         pNode->pData = Cudd_Not(Cudd_bddIthVar(pNtk->pManFunc,0)), Cudd_Ref( pNode->pData );
00651     else if ( Abc_NtkHasAig(pNtk) )
00652         pNode->pData = Hop_Not(Hop_IthVar(pNtk->pManFunc,0));
00653     else if ( Abc_NtkHasMapping(pNtk) )
00654         pNode->pData = Mio_LibraryReadInv(Abc_FrameReadLibGen());
00655     else
00656         assert( 0 );
00657     return pNode;
00658 }

Abc_Obj_t* Abc_NtkCreateNodeMux ( Abc_Ntk_t pNtk,
Abc_Obj_t pNodeC,
Abc_Obj_t pNode1,
Abc_Obj_t pNode0 
)

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

Synopsis [Creates MUX.]

Description []

SideEffects []

SeeAlso []

Definition at line 791 of file abcObj.c.

00792 {
00793     Abc_Obj_t * pNode;
00794     assert( Abc_NtkIsLogic(pNtk) );
00795     pNode = Abc_NtkCreateNode( pNtk );   
00796     Abc_ObjAddFanin( pNode, pNodeC );
00797     Abc_ObjAddFanin( pNode, pNode1 );
00798     Abc_ObjAddFanin( pNode, pNode0 );
00799     if ( Abc_NtkHasSop(pNtk) )
00800         pNode->pData = Abc_SopRegister( pNtk->pManFunc, "11- 1\n0-1 1\n" );
00801     else if ( Abc_NtkHasBdd(pNtk) )
00802         pNode->pData = Cudd_bddIte(pNtk->pManFunc,Cudd_bddIthVar(pNtk->pManFunc,0),Cudd_bddIthVar(pNtk->pManFunc,1),Cudd_bddIthVar(pNtk->pManFunc,2)), Cudd_Ref( pNode->pData );
00803     else if ( Abc_NtkHasAig(pNtk) )
00804         pNode->pData = Hop_Mux(pNtk->pManFunc,Hop_IthVar(pNtk->pManFunc,0),Hop_IthVar(pNtk->pManFunc,1),Hop_IthVar(pNtk->pManFunc,2));
00805     else
00806         assert( 0 );
00807     return pNode;
00808 }

Abc_Obj_t* Abc_NtkCreateNodeOr ( Abc_Ntk_t pNtk,
Vec_Ptr_t vFanins 
)

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

Synopsis [Creates OR.]

Description []

SideEffects []

SeeAlso []

Definition at line 731 of file abcObj.c.

00732 {
00733     Abc_Obj_t * pNode;
00734     int i;
00735     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00736     pNode = Abc_NtkCreateNode( pNtk );   
00737     for ( i = 0; i < vFanins->nSize; i++ )
00738         Abc_ObjAddFanin( pNode, vFanins->pArray[i] );
00739     if ( Abc_NtkHasSop(pNtk) )
00740         pNode->pData = Abc_SopCreateOr( pNtk->pManFunc, Vec_PtrSize(vFanins), NULL );
00741     else if ( Abc_NtkHasBdd(pNtk) )
00742         pNode->pData = Extra_bddCreateOr( pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref(pNode->pData); 
00743     else if ( Abc_NtkHasAig(pNtk) )
00744         pNode->pData = Hop_CreateOr( pNtk->pManFunc, Vec_PtrSize(vFanins) ); 
00745     else
00746         assert( 0 );
00747     return pNode;
00748 }

Abc_Obj_t * Abc_NtkCreateObj ( Abc_Ntk_t pNtk,
Abc_ObjType_t  Type 
)

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

Synopsis [Adds the node to the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 102 of file abcObj.c.

00103 {
00104     Abc_Obj_t * pObj;
00105     // create new object, assign ID, and add to the array
00106     pObj = Abc_ObjAlloc( pNtk, Type );
00107     pObj->Id = pNtk->vObjs->nSize;
00108     Vec_PtrPush( pNtk->vObjs, pObj );
00109     pNtk->nObjCounts[Type]++;
00110     pNtk->nObjs++;
00111     // perform specialized operations depending on the object type
00112     switch (Type)
00113     {
00114         case ABC_OBJ_NONE:   
00115             assert(0); 
00116             break;
00117         case ABC_OBJ_CONST1: 
00118             assert(0); 
00119             break;
00120         case ABC_OBJ_PIO:    
00121             assert(0); 
00122             break;
00123         case ABC_OBJ_PI:     
00124             Vec_PtrPush( pNtk->vPis, pObj );
00125             Vec_PtrPush( pNtk->vCis, pObj );
00126             break;
00127         case ABC_OBJ_PO:     
00128             Vec_PtrPush( pNtk->vPos, pObj );
00129             Vec_PtrPush( pNtk->vCos, pObj );
00130             break;
00131         case ABC_OBJ_BI:     
00132             if ( pNtk->vCos ) Vec_PtrPush( pNtk->vCos, pObj );
00133             break;
00134         case ABC_OBJ_BO:     
00135             if ( pNtk->vCis ) Vec_PtrPush( pNtk->vCis, pObj );
00136             break;
00137         case ABC_OBJ_ASSERT:     
00138             Vec_PtrPush( pNtk->vAsserts, pObj );
00139             Vec_PtrPush( pNtk->vCos, pObj );
00140             break;
00141         case ABC_OBJ_NET:  
00142         case ABC_OBJ_NODE: 
00143             break;
00144         case ABC_OBJ_LATCH:     
00145             pObj->pData = (void *)ABC_INIT_NONE;
00146         case ABC_OBJ_WHITEBOX:     
00147         case ABC_OBJ_BLACKBOX:     
00148             if ( pNtk->vBoxes ) Vec_PtrPush( pNtk->vBoxes, pObj );
00149             break;
00150         default:
00151             assert(0); 
00152             break;
00153     }
00154     return pObj;
00155 }

static Abc_Obj_t* Abc_NtkCreatePi ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 318 of file abc.h.

00318 { return Abc_NtkCreateObj( pNtk, ABC_OBJ_PI );         }

static Abc_Obj_t* Abc_NtkCreatePo ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 319 of file abc.h.

00319 { return Abc_NtkCreateObj( pNtk, ABC_OBJ_PO );         }

Abc_Ntk_t* Abc_NtkCreateTarget ( Abc_Ntk_t pNtk,
Vec_Ptr_t vRoots,
Vec_Int_t vValues 
)

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

Synopsis [Creates the miter composed of one multi-output cone.]

Description []

SideEffects []

SeeAlso []

Definition at line 786 of file abcNtk.c.

00787 {
00788     Vec_Ptr_t * vNodes;
00789     Abc_Ntk_t * pNtkNew; 
00790     Abc_Obj_t * pObj, * pFinal, * pOther, * pNodePo;
00791     int i;
00792 
00793     assert( Abc_NtkIsLogic(pNtk) );
00794     
00795     // start the network
00796     Abc_NtkCleanCopy( pNtk );
00797     pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
00798     pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
00799 
00800     // collect the nodes in the TFI of the output
00801     vNodes = Abc_NtkDfsNodes( pNtk, (Abc_Obj_t **)vRoots->pArray, vRoots->nSize );
00802     // create the PIs
00803     Abc_NtkForEachCi( pNtk, pObj, i )
00804     {
00805         pObj->pCopy = Abc_NtkCreatePi(pNtkNew);
00806         Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
00807     }
00808     // copy the nodes
00809     Vec_PtrForEachEntry( vNodes, pObj, i )
00810         pObj->pCopy = Abc_NodeStrash( pNtkNew, pObj, 0 );
00811     Vec_PtrFree( vNodes );
00812 
00813     // add the PO
00814     pFinal = Abc_AigConst1( pNtkNew );
00815     Vec_PtrForEachEntry( vRoots, pObj, i )
00816     {
00817         if ( Abc_ObjIsCo(pObj) )
00818             pOther = Abc_ObjFanin0(pObj)->pCopy;
00819         else
00820             pOther = pObj->pCopy;
00821         if ( Vec_IntEntry(vValues, i) == 0 )
00822             pOther = Abc_ObjNot(pOther);
00823         pFinal = Abc_AigAnd( pNtkNew->pManFunc, pFinal, pOther );
00824     }
00825 
00826     // add the PO corresponding to this output
00827     pNodePo = Abc_NtkCreatePo( pNtkNew );
00828     Abc_ObjAddFanin( pNodePo, pFinal );
00829     Abc_ObjAssignName( pNodePo, "miter", NULL );
00830     if ( !Abc_NtkCheck( pNtkNew ) )
00831         fprintf( stdout, "Abc_NtkCreateTarget(): Network check has failed.\n" );
00832     return pNtkNew;
00833 }

static Abc_Obj_t* Abc_NtkCreateWhitebox ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 326 of file abc.h.

00326 { return Abc_NtkCreateObj( pNtk, ABC_OBJ_WHITEBOX );   }

Abc_Ntk_t* Abc_NtkCreateWithNode ( char *  pSop  ) 

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

Synopsis [Creates the network composed of one node with the given SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 884 of file abcNtk.c.

00885 {    
00886     Abc_Ntk_t * pNtkNew; 
00887     Abc_Obj_t * pFanin, * pNode, * pNodePo;
00888     Vec_Ptr_t * vNames;
00889     int i, nVars;
00890     // start the network
00891     pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_SOP, 1 );
00892     pNtkNew->pName = Extra_UtilStrsav("ex");
00893     // create PIs
00894     Vec_PtrPush( pNtkNew->vObjs, NULL );
00895     nVars = Abc_SopGetVarNum( pSop );
00896     vNames = Abc_NodeGetFakeNames( nVars );
00897     for ( i = 0; i < nVars; i++ )
00898         Abc_ObjAssignName( Abc_NtkCreatePi(pNtkNew), Vec_PtrEntry(vNames, i), NULL );
00899     Abc_NodeFreeNames( vNames );
00900     // create the node, add PIs as fanins, set the function
00901     pNode = Abc_NtkCreateNode( pNtkNew );
00902     Abc_NtkForEachPi( pNtkNew, pFanin, i )
00903         Abc_ObjAddFanin( pNode, pFanin );
00904     pNode->pData = Abc_SopRegister( pNtkNew->pManFunc, pSop );
00905     // create the only PO
00906     pNodePo = Abc_NtkCreatePo(pNtkNew);
00907     Abc_ObjAddFanin( pNodePo, pNode );
00908     Abc_ObjAssignName( pNodePo, "F", NULL );
00909     if ( !Abc_NtkCheck( pNtkNew ) )
00910         fprintf( stdout, "Abc_NtkCreateWithNode(): Network check has failed.\n" );
00911     return pNtkNew;
00912 }

float Abc_NtkDelayTrace ( Abc_Ntk_t pNtk  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 548 of file abcTiming.c.

00549 {
00550     Abc_Obj_t * pNode, * pDriver;
00551     Vec_Ptr_t * vNodes;
00552     Abc_Time_t * pTime;
00553     float tArrivalMax;
00554     int i;
00555 
00556     assert( Abc_NtkIsMappedLogic(pNtk) );
00557 
00558     Abc_NtkTimePrepare( pNtk );
00559     vNodes = Abc_NtkDfs( pNtk, 1 );
00560     for ( i = 0; i < vNodes->nSize; i++ )
00561         Abc_NodeDelayTraceArrival( vNodes->pArray[i] );
00562     Vec_PtrFree( vNodes );
00563 
00564     // get the latest arrival times
00565     tArrivalMax = -ABC_INFINITY;
00566     Abc_NtkForEachCo( pNtk, pNode, i )
00567     {
00568         pDriver = Abc_ObjFanin0(pNode);
00569         pTime   = Abc_NodeArrival(pDriver);
00570         if ( tArrivalMax < pTime->Worst )
00571             tArrivalMax = pTime->Worst;
00572     }
00573     return tArrivalMax;
00574 }

void Abc_NtkDelete ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Deletes the Ntk.]

Description []

SideEffects []

SeeAlso []

Definition at line 925 of file abcNtk.c.

00926 {
00927     Abc_Obj_t * pObj;
00928     void * pAttrMan;
00929     int TotalMemory, i;
00930     int LargePiece = (4 << ABC_NUM_STEPS);
00931     if ( pNtk == NULL )
00932         return;
00933     // free the HAIG
00934     if ( pNtk->pHaig )
00935         Abc_NtkHaigStop( pNtk );
00936     // free EXDC Ntk
00937     if ( pNtk->pExdc )
00938         Abc_NtkDelete( pNtk->pExdc );
00939     // dereference the BDDs
00940     if ( Abc_NtkHasBdd(pNtk) )
00941     {
00942         Abc_NtkForEachNode( pNtk, pObj, i )
00943             Cudd_RecursiveDeref( pNtk->pManFunc, pObj->pData );
00944     }
00945     // make sure all the marks are clean
00946     Abc_NtkForEachObj( pNtk, pObj, i )
00947     {
00948         // free large fanout arrays
00949         if ( pNtk->pMmObj && pObj->vFanouts.nCap * 4 > LargePiece )
00950             FREE( pObj->vFanouts.pArray );
00951         // these flags should be always zero
00952         // if this is not true, something is wrong somewhere
00953         assert( pObj->fMarkA == 0 );
00954         assert( pObj->fMarkB == 0 );
00955         assert( pObj->fMarkC == 0 );
00956     }
00957     // free the nodes
00958     if ( pNtk->pMmStep == NULL )
00959     {
00960         Abc_NtkForEachObj( pNtk, pObj, i )
00961         {
00962             FREE( pObj->vFanouts.pArray );
00963             FREE( pObj->vFanins.pArray );
00964         }
00965     }
00966     if ( pNtk->pMmObj == NULL )
00967     {
00968         Abc_NtkForEachObj( pNtk, pObj, i )
00969             free( pObj );
00970     }
00971         
00972     // free the arrays
00973     Vec_PtrFree( pNtk->vPios );
00974     Vec_PtrFree( pNtk->vPis );
00975     Vec_PtrFree( pNtk->vPos );
00976     Vec_PtrFree( pNtk->vCis );
00977     Vec_PtrFree( pNtk->vCos );
00978     Vec_PtrFree( pNtk->vAsserts );
00979     Vec_PtrFree( pNtk->vObjs );
00980     Vec_PtrFree( pNtk->vBoxes );
00981     if ( pNtk->vLevelsR ) Vec_IntFree( pNtk->vLevelsR );
00982     if ( pNtk->pModel ) free( pNtk->pModel );
00983     TotalMemory  = 0;
00984     TotalMemory += pNtk->pMmObj? Extra_MmFixedReadMemUsage(pNtk->pMmObj)  : 0;
00985     TotalMemory += pNtk->pMmStep? Extra_MmStepReadMemUsage(pNtk->pMmStep) : 0;
00986 //    fprintf( stdout, "The total memory allocated internally by the network = %0.2f Mb.\n", ((double)TotalMemory)/(1<<20) );
00987     // free the storage 
00988     if ( pNtk->pMmObj )
00989         Extra_MmFixedStop( pNtk->pMmObj );
00990     if ( pNtk->pMmStep )
00991         Extra_MmStepStop ( pNtk->pMmStep );
00992     // name manager
00993     Nm_ManFree( pNtk->pManName );
00994     // free the timing manager
00995     if ( pNtk->pManTime )
00996         Abc_ManTimeStop( pNtk->pManTime );
00997     // start the functionality manager
00998     if ( Abc_NtkIsStrash(pNtk) )
00999         Abc_AigFree( pNtk->pManFunc );
01000     else if ( Abc_NtkHasSop(pNtk) || Abc_NtkHasBlifMv(pNtk) )
01001         Extra_MmFlexStop( pNtk->pManFunc );
01002     else if ( Abc_NtkHasBdd(pNtk) )
01003         Extra_StopManager( pNtk->pManFunc );
01004     else if ( Abc_NtkHasAig(pNtk) )
01005         { if ( pNtk->pManFunc ) Hop_ManStop( pNtk->pManFunc ); }
01006     else if ( Abc_NtkHasMapping(pNtk) )
01007         pNtk->pManFunc = NULL;
01008     else if ( !Abc_NtkHasBlackbox(pNtk) )
01009         assert( 0 );
01010     // free the hierarchy
01011     if ( pNtk->pDesign )
01012     {
01013         Abc_LibFree( pNtk->pDesign, pNtk );
01014         pNtk->pDesign = NULL;
01015     }
01016 //    if ( pNtk->pBlackBoxes ) 
01017 //        Vec_IntFree( pNtk->pBlackBoxes );
01018     // free node attributes
01019     Vec_PtrForEachEntry( pNtk->vAttrs, pAttrMan, i )
01020         if ( pAttrMan )
01021         {
01022 //printf( "deleting attr\n" );
01023             Vec_AttFree( pAttrMan, 1 );
01024         }
01025     Vec_PtrFree( pNtk->vAttrs );
01026     FREE( pNtk->pName );
01027     FREE( pNtk->pSpec );
01028     free( pNtk );
01029 }

void Abc_NtkDeleteAll_rec ( Abc_Obj_t pObj  ) 

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

Synopsis [Deletes the node and MFFC of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 289 of file abcObj.c.

00290 {
00291     Vec_Ptr_t * vNodes;
00292     int i;
00293     assert( !Abc_ObjIsComplement(pObj) );
00294     assert( Abc_ObjFanoutNum(pObj) == 0 );
00295     // delete fanins and fanouts
00296     vNodes = Vec_PtrAlloc( 100 );
00297     Abc_NodeCollectFanins( pObj, vNodes );
00298     Abc_NtkDeleteObj( pObj );
00299     Vec_PtrForEachEntry( vNodes, pObj, i )
00300         if ( !Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) == 0 )
00301             Abc_NtkDeleteAll_rec( pObj );
00302     Vec_PtrFree( vNodes );
00303 }

void Abc_NtkDeleteObj ( Abc_Obj_t pObj  ) 

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

Synopsis [Deletes the object from the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 168 of file abcObj.c.

00169 {
00170     Abc_Ntk_t * pNtk = pObj->pNtk;
00171     Vec_Ptr_t * vNodes;
00172     int i;
00173     assert( !Abc_ObjIsComplement(pObj) );
00174     // remove from the table of names
00175     if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) )
00176         Nm_ManDeleteIdName(pObj->pNtk->pManName, pObj->Id);
00177     // delete fanins and fanouts
00178     vNodes = Vec_PtrAlloc( 100 );
00179     Abc_NodeCollectFanouts( pObj, vNodes );
00180     for ( i = 0; i < vNodes->nSize; i++ )
00181         Abc_ObjDeleteFanin( vNodes->pArray[i], pObj );
00182     Abc_NodeCollectFanins( pObj, vNodes );
00183     for ( i = 0; i < vNodes->nSize; i++ )
00184         Abc_ObjDeleteFanin( pObj, vNodes->pArray[i] );
00185     Vec_PtrFree( vNodes );
00186     // remove from the list of objects
00187     Vec_PtrWriteEntry( pNtk->vObjs, pObj->Id, NULL );
00188     pObj->Id = (1<<26)-1;
00189     pNtk->nObjCounts[pObj->Type]--;
00190     pNtk->nObjs--;
00191     // perform specialized operations depending on the object type
00192     switch (pObj->Type)
00193     {
00194         case ABC_OBJ_NONE:   
00195             assert(0); 
00196             break;
00197         case ABC_OBJ_CONST1: 
00198             assert(0); 
00199             break;
00200         case ABC_OBJ_PIO:    
00201             assert(0); 
00202             break;
00203         case ABC_OBJ_PI:     
00204             Vec_PtrRemove( pNtk->vPis, pObj );
00205             Vec_PtrRemove( pNtk->vCis, pObj );
00206             break;
00207         case ABC_OBJ_PO:     
00208             Vec_PtrRemove( pNtk->vPos, pObj );
00209             Vec_PtrRemove( pNtk->vCos, pObj );
00210             break;
00211         case ABC_OBJ_BI:     
00212             if ( pNtk->vCos ) Vec_PtrRemove( pNtk->vCos, pObj );
00213             break;
00214         case ABC_OBJ_BO:     
00215             if ( pNtk->vCis ) Vec_PtrRemove( pNtk->vCis, pObj );
00216             break;
00217         case ABC_OBJ_ASSERT:     
00218             Vec_PtrRemove( pNtk->vAsserts, pObj );
00219             Vec_PtrRemove( pNtk->vCos, pObj );
00220             break;
00221         case ABC_OBJ_NET:  
00222             break;
00223         case ABC_OBJ_NODE: 
00224             if ( Abc_NtkHasBdd(pNtk) )
00225                 Cudd_RecursiveDeref( pNtk->pManFunc, pObj->pData );
00226             pObj->pData = NULL;
00227             break;
00228         case ABC_OBJ_LATCH:     
00229         case ABC_OBJ_WHITEBOX:     
00230         case ABC_OBJ_BLACKBOX:     
00231             if ( pNtk->vBoxes ) Vec_PtrRemove( pNtk->vBoxes, pObj );
00232             break;
00233         default:
00234             assert(0); 
00235             break;
00236     }
00237     // recycle the object memory
00238     Abc_ObjRecycle( pObj );
00239 }

void Abc_NtkDeleteObj_rec ( Abc_Obj_t pObj,
int  fOnlyNodes 
)

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

Synopsis [Deletes the node and MFFC of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 252 of file abcObj.c.

00253 {
00254     Vec_Ptr_t * vNodes;
00255     int i;
00256     assert( !Abc_ObjIsComplement(pObj) );
00257     assert( !Abc_ObjIsPi(pObj) );
00258     assert( Abc_ObjFanoutNum(pObj) == 0 );
00259     // delete fanins and fanouts
00260     vNodes = Vec_PtrAlloc( 100 );
00261     Abc_NodeCollectFanins( pObj, vNodes );
00262     Abc_NtkDeleteObj( pObj );
00263     if ( fOnlyNodes )
00264     {
00265         Vec_PtrForEachEntry( vNodes, pObj, i )
00266             if ( Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) == 0 )
00267                 Abc_NtkDeleteObj_rec( pObj, fOnlyNodes );
00268     }
00269     else
00270     {
00271         Vec_PtrForEachEntry( vNodes, pObj, i )
00272             if ( !Abc_ObjIsPi(pObj) && Abc_ObjFanoutNum(pObj) == 0 )
00273                 Abc_NtkDeleteObj_rec( pObj, fOnlyNodes );
00274     }
00275     Vec_PtrFree( vNodes );
00276 }

Abc_Ntk_t* Abc_NtkDeriveFromBdd ( DdManager dd,
DdNode bFunc,
char *  pNamePo,
Vec_Ptr_t vNamesPi 
)

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

Synopsis [Constructs the network isomorphic to the given BDD.]

Description [Assumes that the BDD depends on the variables whose indexes correspond to the names in the array (pNamesPi). Otherwise, returns NULL. The resulting network comes with one node, whose functionality is equal to the given BDD. To decompose this BDD into the network of multiplexers use Abc_NtkBddToMuxes(). To decompose this BDD into an And-Inverter Graph, use Abc_NtkStrash().]

SideEffects []

SeeAlso []

Definition at line 52 of file abcNtbdd.c.

00053 {
00054     Abc_Ntk_t * pNtk; 
00055     Vec_Ptr_t * vNamesPiFake = NULL;
00056     Abc_Obj_t * pNode, * pNodePi, * pNodePo;
00057     DdNode * bSupp, * bTemp;
00058     char * pName;
00059     int i;
00060 
00061     // supply fake names if real names are not given
00062     if ( pNamePo == NULL )
00063         pNamePo = "F";
00064     if ( vNamesPi == NULL )
00065     {
00066         vNamesPiFake = Abc_NodeGetFakeNames( dd->size );
00067         vNamesPi = vNamesPiFake;
00068     }
00069 
00070     // make sure BDD depends on the variables whose index 
00071     // does not exceed the size of the array with PI names
00072     bSupp = Cudd_Support( dd, bFunc );   Cudd_Ref( bSupp );
00073     for ( bTemp = bSupp; bTemp != Cudd_ReadOne(dd); bTemp = cuddT(bTemp) )
00074         if ( (int)Cudd_NodeReadIndex(bTemp) >= Vec_PtrSize(vNamesPi) )
00075             break;
00076     Cudd_RecursiveDeref( dd, bSupp );
00077     if ( bTemp != Cudd_ReadOne(dd) )
00078         return NULL;
00079 
00080     // start the network
00081     pNtk = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_BDD, 1 );
00082     pNtk->pName = Extra_UtilStrsav(pNamePo);
00083     // make sure the new manager has enough inputs
00084     Cudd_bddIthVar( pNtk->pManFunc, Vec_PtrSize(vNamesPi) );
00085     // add the PIs corresponding to the names
00086     Vec_PtrForEachEntry( vNamesPi, pName, i )
00087         Abc_ObjAssignName( Abc_NtkCreatePi(pNtk), pName, NULL );
00088     // create the node
00089     pNode = Abc_NtkCreateNode( pNtk );
00090     pNode->pData = Cudd_bddTransfer( dd, pNtk->pManFunc, bFunc ); Cudd_Ref(pNode->pData);
00091     Abc_NtkForEachPi( pNtk, pNodePi, i )
00092         Abc_ObjAddFanin( pNode, pNodePi );
00093     // create the only PO
00094     pNodePo = Abc_NtkCreatePo( pNtk );
00095     Abc_ObjAddFanin( pNodePo, pNode );
00096     Abc_ObjAssignName( pNodePo, pNamePo, NULL );
00097     // make the network minimum base
00098     Abc_NtkMinimumBase( pNtk );
00099     if ( vNamesPiFake )
00100         Abc_NodeFreeNames( vNamesPiFake );
00101     if ( !Abc_NtkCheck( pNtk ) )
00102         fprintf( stdout, "Abc_NtkDeriveFromBdd(): Network check has failed.\n" );
00103     return pNtk;
00104 }

Vec_Ptr_t* Abc_NtkDfs ( Abc_Ntk_t pNtk,
int  fCollectAll 
)

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

Synopsis [Returns the DFS ordered array of logic nodes.]

Description [Collects only the internal nodes, leaving CIs and CO. However it marks with the current TravId both CIs and COs.]

SideEffects []

SeeAlso []

Definition at line 78 of file abcDfs.c.

00079 {
00080     Vec_Ptr_t * vNodes;
00081     Abc_Obj_t * pObj;
00082     int i;
00083     // set the traversal ID
00084     Abc_NtkIncrementTravId( pNtk );
00085     // start the array of nodes
00086     vNodes = Vec_PtrAlloc( 100 );
00087     Abc_NtkForEachCo( pNtk, pObj, i )
00088     {
00089         Abc_NodeSetTravIdCurrent( pObj );
00090         Abc_NtkDfs_rec( Abc_ObjFanin0Ntk(Abc_ObjFanin0(pObj)), vNodes );
00091     }
00092     // collect dangling nodes if asked to
00093     if ( fCollectAll )
00094     {
00095         Abc_NtkForEachNode( pNtk, pObj, i )
00096             if ( !Abc_NodeIsTravIdCurrent(pObj) )
00097                 Abc_NtkDfs_rec( pObj, vNodes );
00098     }
00099     return vNodes;
00100 }

Vec_Ptr_t* Abc_NtkDfsHie ( Abc_Ntk_t pNtk,
int  fCollectAll 
)

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

Synopsis [Returns the DFS ordered array of all objects.]

Description [This procedure collects everything from POs to PIs.]

SideEffects []

SeeAlso []

Definition at line 597 of file abcDfs.c.

00598 {
00599     Vec_Ptr_t * vNodes;
00600     Abc_Obj_t * pObj;
00601     int i;
00602     // set the traversal ID
00603     Abc_NtkIncrementTravId( pNtk );
00604     // start the array of nodes
00605     vNodes = Vec_PtrAlloc( 100 );
00606     Abc_NtkForEachPo( pNtk, pObj, i )
00607         Abc_NtkDfsHie_rec( pObj, vNodes );
00608     // collect dangling nodes if asked to
00609     if ( fCollectAll )
00610     {
00611         Abc_NtkForEachObj( pNtk, pObj, i )
00612             if ( !Abc_NodeIsTravIdCurrent(pObj) )
00613                 Abc_NtkDfs_rec( pObj, vNodes );
00614     }
00615     return vNodes;
00616 }

Vec_Ptr_t* Abc_NtkDfsIter ( Abc_Ntk_t pNtk,
int  fCollectAll 
)

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

Synopsis [Returns the DFS ordered array of logic nodes.]

Description [Collects only the internal nodes, leaving CIs and CO. However it marks with the current TravId both CIs and COs.]

SideEffects []

SeeAlso []

Definition at line 532 of file abcDfs.c.

00533 {
00534     Vec_Ptr_t * vNodes, * vStack;
00535     Abc_Obj_t * pObj;
00536     int i;
00537     // set the traversal ID
00538     Abc_NtkIncrementTravId( pNtk );
00539     // start the array of nodes
00540     vNodes = Vec_PtrAlloc( 1000 );
00541     vStack = Vec_PtrAlloc( 1000 );
00542     Abc_NtkForEachCo( pNtk, pObj, i )
00543     {
00544         Abc_NodeSetTravIdCurrent( pObj );
00545         Abc_NtkDfs_iter( vStack, Abc_ObjFanin0Ntk(Abc_ObjFanin0(pObj)), vNodes );
00546     }
00547     // collect dangling nodes if asked to
00548     if ( fCollectAll )
00549     {
00550         Abc_NtkForEachNode( pNtk, pObj, i )
00551             if ( !Abc_NodeIsTravIdCurrent(pObj) )
00552                 Abc_NtkDfs_iter( vStack, pObj, vNodes );
00553     }
00554     Vec_PtrFree( vStack );
00555     return vNodes;
00556 }

Vec_Ptr_t* Abc_NtkDfsNodes ( Abc_Ntk_t pNtk,
Abc_Obj_t **  ppNodes,
int  nNodes 
)

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

Synopsis [Returns the DFS ordered array of logic nodes.]

Description [Collects only the internal nodes, leaving out PIs, POs and latches.]

SideEffects []

SeeAlso []

Definition at line 113 of file abcDfs.c.

00114 {
00115     Vec_Ptr_t * vNodes;
00116     int i;
00117     // set the traversal ID
00118     Abc_NtkIncrementTravId( pNtk );
00119     // start the array of nodes
00120     vNodes = Vec_PtrAlloc( 100 );
00121     // go through the PO nodes and call for each of them
00122     for ( i = 0; i < nNodes; i++ )
00123     {
00124         if ( Abc_ObjIsCo(ppNodes[i]) )
00125         {
00126             Abc_NodeSetTravIdCurrent(ppNodes[i]);
00127             Abc_NtkDfs_rec( Abc_ObjFanin0Ntk(Abc_ObjFanin0(ppNodes[i])), vNodes );
00128         }
00129         else if ( Abc_ObjIsNode(ppNodes[i]) )
00130             Abc_NtkDfs_rec( ppNodes[i], vNodes );
00131     }
00132     return vNodes;
00133 }

Vec_Ptr_t* Abc_NtkDfsReverse ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Returns the reverse DFS ordered array of logic nodes.]

Description [Collects only the internal nodes, leaving out CIs/COs. However it marks both CIs and COs with the current TravId.]

SideEffects []

SeeAlso []

Definition at line 181 of file abcDfs.c.

00182 {
00183     Vec_Ptr_t * vNodes;
00184     Abc_Obj_t * pObj, * pFanout;
00185     int i, k;
00186     // set the traversal ID
00187     Abc_NtkIncrementTravId( pNtk );
00188     // start the array of nodes
00189     vNodes = Vec_PtrAlloc( 100 );
00190     Abc_NtkForEachCi( pNtk, pObj, i )
00191     {
00192         Abc_NodeSetTravIdCurrent( pObj );
00193         pObj = Abc_ObjFanout0Ntk(pObj);
00194         Abc_ObjForEachFanout( pObj, pFanout, k )
00195             Abc_NtkDfsReverse_rec( pFanout, vNodes );
00196     }
00197     // add constant nodes in the end
00198     if ( !Abc_NtkIsStrash(pNtk) )
00199         Abc_NtkForEachNode( pNtk, pObj, i )
00200             if ( Abc_NodeIsConst(pObj) )
00201                 Vec_PtrPush( vNodes, pObj );
00202     return vNodes;
00203 }

Vec_Ptr_t* Abc_NtkDfsReverseNodes ( Abc_Ntk_t pNtk,
Abc_Obj_t **  ppNodes,
int  nNodes 
)

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

Synopsis [Returns the levelized array of TFO nodes.]

Description [Collects the levelized array of internal nodes, leaving out CIs/COs. However it marks both CIs and COs with the current TravId.]

SideEffects []

SeeAlso []

Definition at line 253 of file abcDfs.c.

00254 {
00255     Vec_Ptr_t * vNodes;
00256     Abc_Obj_t * pObj, * pFanout;
00257     int i, k;
00258     assert( Abc_NtkIsStrash(pNtk) );
00259     // set the traversal ID
00260     Abc_NtkIncrementTravId( pNtk );
00261     // start the array of nodes
00262     vNodes = Vec_PtrStart( Abc_AigLevel(pNtk) + 1 );
00263     for ( i = 0; i < nNodes; i++ )
00264     {
00265         pObj = ppNodes[i];
00266         assert( Abc_ObjIsCi(pObj) );
00267         Abc_NodeSetTravIdCurrent( pObj );
00268         pObj = Abc_ObjFanout0Ntk(pObj);
00269         Abc_ObjForEachFanout( pObj, pFanout, k )
00270             Abc_NtkDfsReverseNodes_rec( pFanout, vNodes );
00271     }
00272     return vNodes;
00273 }

Vec_Ptr_t* Abc_NtkDfsReverseNodesContained ( Abc_Ntk_t pNtk,
Abc_Obj_t **  ppNodes,
int  nNodes 
)

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

Synopsis [Returns the levelized array of TFO nodes.]

Description [Collects the levelized array of internal nodes, leaving out CIs/COs. However it marks both CIs and COs with the current TravId. Collects only the nodes whose support does not exceed the set of given CI nodes.]

SideEffects []

SeeAlso []

Definition at line 288 of file abcDfs.c.

00289 {
00290     Vec_Ptr_t * vNodes;
00291     Abc_Obj_t * pObj, * pFanout, * pFanin;
00292     int i, k, m, nLevels;
00293     // set the levels
00294     nLevels = Abc_NtkLevel( pNtk );
00295     // set the traversal ID
00296     Abc_NtkIncrementTravId( pNtk );
00297     // start the array of nodes
00298     vNodes = Vec_PtrStart( nLevels + 2 );
00299     for ( i = 0; i < nNodes; i++ )
00300     {
00301         pObj = ppNodes[i];
00302         assert( Abc_ObjIsCi(pObj) );
00303         Abc_NodeSetTravIdCurrent( pObj );
00304         // add to the array
00305         assert( pObj->Level == 0 );
00306         pObj->pCopy = Vec_PtrEntry( vNodes, pObj->Level );
00307         Vec_PtrWriteEntry( vNodes, pObj->Level, pObj );
00308     }
00309     // iterate through the levels
00310     for ( i = 0; i <= nLevels; i++ )
00311     {
00312         // iterate through the nodes on each level
00313         for ( pObj = Vec_PtrEntry(vNodes, i); pObj; pObj = pObj->pCopy )
00314         {
00315             // iterate through the fanouts of each node
00316             Abc_ObjForEachFanout( pObj, pFanout, k )
00317             {
00318                 // skip visited nodes
00319                 if ( Abc_NodeIsTravIdCurrent(pFanout) )
00320                     continue;
00321                 // visit the fanins of this fanout
00322                 Abc_ObjForEachFanin( pFanout, pFanin, m )
00323                 {
00324                     if ( !Abc_NodeIsTravIdCurrent(pFanin) )
00325                         break;
00326                 }
00327                 if ( m < Abc_ObjFaninNum(pFanout) )
00328                     continue;
00329                 // all fanins are already collected
00330 
00331                 // mark the node as visited
00332                 Abc_NodeSetTravIdCurrent( pFanout );
00333                 // handle the COs
00334                 if ( Abc_ObjIsCo(pFanout) )
00335                     pFanout->Level = nLevels + 1;
00336                 // add to the array
00337                 pFanout->pCopy = Vec_PtrEntry( vNodes, pFanout->Level );
00338                 Vec_PtrWriteEntry( vNodes, pFanout->Level, pFanout );
00339                 // handle the COs
00340                 if ( Abc_ObjIsCo(pFanout) )
00341                     pFanout->Level = 0;
00342             }
00343         }
00344     }
00345     return vNodes;
00346 }

Vec_Ptr_t* Abc_NtkDfsSeq ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Returns the array of nodes and latches reachable from POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 387 of file abcDfs.c.

00388 {
00389     Vec_Ptr_t * vNodes;
00390     Abc_Obj_t * pObj;
00391     int i;
00392     assert( !Abc_NtkIsNetlist(pNtk) );
00393     // set the traversal ID
00394     Abc_NtkIncrementTravId( pNtk );
00395     // start the array of nodes
00396     vNodes = Vec_PtrAlloc( 100 );
00397     Abc_NtkForEachPo( pNtk, pObj, i )
00398         Abc_NtkDfsSeq_rec( pObj, vNodes );
00399     // mark the PIs
00400     Abc_NtkForEachPi( pNtk, pObj, i )
00401         Abc_NtkDfsSeq_rec( pObj, vNodes );
00402     return vNodes;
00403 }

Vec_Ptr_t* Abc_NtkDfsSeqReverse ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Returns the array of nodes and latches reachable from POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 444 of file abcDfs.c.

00445 {
00446     Vec_Ptr_t * vNodes;
00447     Abc_Obj_t * pObj;
00448     int i;
00449     assert( !Abc_NtkIsNetlist(pNtk) );
00450     // set the traversal ID
00451     Abc_NtkIncrementTravId( pNtk );
00452     // start the array of nodes
00453     vNodes = Vec_PtrAlloc( 100 );
00454     Abc_NtkForEachPi( pNtk, pObj, i )
00455         Abc_NtkDfsSeqReverse_rec( pObj, vNodes );
00456     // mark the logic feeding into POs
00457     Abc_NtkForEachPo( pNtk, pObj, i )
00458         Abc_NtkDfsSeq_rec( pObj, vNodes );
00459     return vNodes;
00460 }

bool Abc_NtkDoCheck ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Checks the integrity of the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 90 of file abcCheck.c.

00091 {
00092     Abc_Obj_t * pObj, * pNet, * pNode;
00093     int i;
00094 
00095     // check network types
00096     if ( !Abc_NtkIsNetlist(pNtk) && !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
00097     {
00098         fprintf( stdout, "NetworkCheck: Unknown network type.\n" );
00099         return 0;
00100     }
00101     if ( !Abc_NtkHasSop(pNtk) && !Abc_NtkHasBdd(pNtk) && !Abc_NtkHasAig(pNtk) && !Abc_NtkHasMapping(pNtk) && !Abc_NtkHasBlifMv(pNtk) && !Abc_NtkHasBlackbox(pNtk) )
00102     {
00103         fprintf( stdout, "NetworkCheck: Unknown functionality type.\n" );
00104         return 0;
00105     }
00106     if ( Abc_NtkHasMapping(pNtk) )
00107     {
00108         if ( pNtk->pManFunc != Abc_FrameReadLibGen() )
00109         {
00110             fprintf( stdout, "NetworkCheck: The library of the mapped network is not the global library.\n" );
00111             return 0;
00112         }
00113     }
00114 
00115     if ( Abc_NtkHasOnlyLatchBoxes(pNtk) )
00116     {
00117         // check CI/CO numbers
00118         if ( Abc_NtkPiNum(pNtk) + Abc_NtkLatchNum(pNtk) != Abc_NtkCiNum(pNtk) )
00119         {
00120             fprintf( stdout, "NetworkCheck: Number of CIs does not match number of PIs and latches.\n" );
00121             fprintf( stdout, "One possible reason is that latches are added twice:\n" );
00122             fprintf( stdout, "in procedure Abc_NtkCreateObj() and in the user's code.\n" );
00123             return 0;
00124         }
00125         if ( Abc_NtkPoNum(pNtk) + Abc_NtkAssertNum(pNtk) + Abc_NtkLatchNum(pNtk) != Abc_NtkCoNum(pNtk) )
00126         {
00127             fprintf( stdout, "NetworkCheck: Number of COs does not match number of POs, asserts, and latches.\n" );
00128             fprintf( stdout, "One possible reason is that latches are added twice:\n" );
00129             fprintf( stdout, "in procedure Abc_NtkCreateObj() and in the user's code.\n" );
00130             return 0;
00131         }
00132     }
00133 
00134     // check the names
00135     if ( !Abc_NtkCheckNames( pNtk ) )
00136         return 0;
00137 
00138     // check PIs and POs
00139     Abc_NtkCleanCopy( pNtk );
00140     if ( !Abc_NtkCheckPis( pNtk ) )
00141         return 0;
00142     if ( !Abc_NtkCheckPos( pNtk ) )
00143         return 0;
00144 
00145     if ( Abc_NtkHasBlackbox(pNtk) )
00146         return 1;
00147 
00148     // check the connectivity of objects
00149     Abc_NtkForEachObj( pNtk, pObj, i )
00150         if ( !Abc_NtkCheckObj( pNtk, pObj ) )
00151             return 0;
00152 
00153     // if it is a netlist change nets and latches
00154     if ( Abc_NtkIsNetlist(pNtk) )
00155     {
00156         if ( Abc_NtkNetNum(pNtk) == 0 )
00157         {
00158             fprintf( stdout, "NetworkCheck: Netlist has no nets.\n" );
00159             return 0;
00160         }
00161         // check the nets
00162         Abc_NtkForEachNet( pNtk, pNet, i )
00163             if ( !Abc_NtkCheckNet( pNtk, pNet ) )
00164                 return 0;
00165     }
00166     else
00167     {
00168         if ( Abc_NtkNetNum(pNtk) != 0 )
00169         {
00170             fprintf( stdout, "NetworkCheck: A network that is not a netlist has nets.\n" );
00171             return 0;
00172         }
00173     }
00174 
00175     // check the nodes
00176     if ( Abc_NtkIsStrash(pNtk) )
00177         Abc_AigCheck( pNtk->pManFunc );
00178     else
00179     {
00180         Abc_NtkForEachNode( pNtk, pNode, i )
00181             if ( !Abc_NtkCheckNode( pNtk, pNode ) )
00182                 return 0;
00183     }
00184 
00185     // check the latches
00186     Abc_NtkForEachLatch( pNtk, pNode, i )
00187         if ( !Abc_NtkCheckLatch( pNtk, pNode ) )
00188             return 0;
00189 
00190     // finally, check for combinational loops
00191 //  clk = clock();
00192     if ( !Abc_NtkIsAcyclic( pNtk ) )
00193     {
00194         fprintf( stdout, "NetworkCheck: Network contains a combinational loop.\n" );
00195         return 0;
00196     }
00197 //  PRT( "Acyclic  ", clock() - clk );
00198 
00199     // check the EXDC network if present
00200     if ( pNtk->pExdc )
00201         Abc_NtkCheck( pNtk->pExdc );
00202 /*
00203     // check the hierarchy
00204     if ( Abc_NtkIsNetlist(pNtk) && pNtk->tName2Model )
00205     {
00206         stmm_generator * gen;
00207         Abc_Ntk_t * pNtkTemp;
00208         char * pName;
00209         // check other networks
00210         stmm_foreach_item( pNtk->tName2Model, gen, &pName, (char **)&pNtkTemp )
00211         {
00212             pNtkTemp->fHiePath = pNtkTemp->fHieVisited = 0;
00213             if ( !Abc_NtkCheck( pNtkTemp ) )
00214                 return 0;
00215         }
00216         // check acyclic dependency of the models
00217         if ( !Abc_NtkIsAcyclicHierarchy( pNtk ) )
00218         {
00219             fprintf( stdout, "NetworkCheck: Network hierarchical dependences contains a cycle.\n" );
00220             return 0;
00221         }
00222     }
00223 */
00224     return 1;
00225 }

Abc_Ntk_t* Abc_NtkDup ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Duplicate the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 307 of file abcNtk.c.

00308 {
00309     Abc_Ntk_t * pNtkNew; 
00310     Abc_Obj_t * pObj, * pFanin;
00311     int i, k;
00312     if ( pNtk == NULL )
00313         return NULL;
00314     // start the network
00315     pNtkNew = Abc_NtkStartFrom( pNtk, pNtk->ntkType, pNtk->ntkFunc );
00316     // copy the internal nodes
00317     if ( Abc_NtkIsStrash(pNtk) )
00318     {
00319         // copy the AND gates
00320         Abc_AigForEachAnd( pNtk, pObj, i )
00321             pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
00322         // relink the choice nodes
00323         Abc_AigForEachAnd( pNtk, pObj, i )
00324             if ( pObj->pData )
00325                 pObj->pCopy->pData = ((Abc_Obj_t *)pObj->pData)->pCopy;
00326         // relink the CO nodes
00327         Abc_NtkForEachCo( pNtk, pObj, i )
00328             Abc_ObjAddFanin( pObj->pCopy, Abc_ObjChild0Copy(pObj) );
00329         // get the number of nodes before and after
00330         if ( Abc_NtkNodeNum(pNtk) != Abc_NtkNodeNum(pNtkNew) )
00331             printf( "Warning: Structural hashing during duplication reduced %d nodes (this is a minor bug).\n",
00332                 Abc_NtkNodeNum(pNtk) - Abc_NtkNodeNum(pNtkNew) );
00333     }
00334     else
00335     {
00336         // duplicate the nets and nodes (CIs/COs/latches already dupped)
00337         Abc_NtkForEachObj( pNtk, pObj, i )
00338             if ( pObj->pCopy == NULL )
00339                 Abc_NtkDupObj(pNtkNew, pObj, 0);
00340         // reconnect all objects (no need to transfer attributes on edges)
00341         Abc_NtkForEachObj( pNtk, pObj, i )
00342             if ( !Abc_ObjIsBox(pObj) && !Abc_ObjIsBo(pObj) )
00343                 Abc_ObjForEachFanin( pObj, pFanin, k )
00344                     Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
00345     }
00346     // duplicate the EXDC Ntk
00347     if ( pNtk->pExdc )
00348         pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
00349     if ( !Abc_NtkCheck( pNtkNew ) )
00350         fprintf( stdout, "Abc_NtkDup(): Network check has failed.\n" );
00351     pNtk->pCopy = pNtkNew;
00352     return pNtkNew;
00353 }

Abc_Obj_t* Abc_NtkDupBox ( Abc_Ntk_t pNtkNew,
Abc_Obj_t pBox,
int  fCopyName 
)

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

Synopsis [Duplicates the latch with its input/output terminals.]

Description []

SideEffects []

SeeAlso []

Definition at line 386 of file abcObj.c.

00387 {
00388     Abc_Obj_t * pTerm, * pBoxNew;
00389     int i;
00390     assert( Abc_ObjIsBox(pBox) );
00391     // duplicate the box 
00392     pBoxNew = Abc_NtkDupObj( pNtkNew, pBox, fCopyName );
00393     // duplicate the fanins and connect them
00394     Abc_ObjForEachFanin( pBox, pTerm, i )
00395         Abc_ObjAddFanin( pBoxNew, Abc_NtkDupObj(pNtkNew, pTerm, fCopyName) );
00396     // duplicate the fanouts and connect them
00397     Abc_ObjForEachFanout( pBox, pTerm, i )
00398         Abc_ObjAddFanin( Abc_NtkDupObj(pNtkNew, pTerm, fCopyName), pBoxNew );
00399     return pBoxNew;
00400 }

Abc_Obj_t* Abc_NtkDupObj ( Abc_Ntk_t pNtkNew,
Abc_Obj_t pObj,
int  fCopyName 
)

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

Synopsis [Duplicate the Obj.]

Description []

SideEffects []

SeeAlso []

Definition at line 316 of file abcObj.c.

00317 {
00318     Abc_Obj_t * pObjNew;
00319     // create the new object
00320     pObjNew = Abc_NtkCreateObj( pNtkNew, pObj->Type );
00321     // transfer names of the terminal objects
00322     if ( fCopyName )
00323     {
00324         if ( Abc_ObjIsCi(pObj) )
00325         {
00326             if ( !Abc_NtkIsNetlist(pNtkNew) )
00327                 Abc_ObjAssignName( pObjNew, Abc_ObjName(Abc_ObjFanout0Ntk(pObj)), NULL );
00328         }
00329         else if ( Abc_ObjIsCo(pObj) )
00330         {
00331             if ( !Abc_NtkIsNetlist(pNtkNew) )
00332             {
00333                 if ( Abc_ObjIsPo(pObj) )
00334                     Abc_ObjAssignName( pObjNew, Abc_ObjName(Abc_ObjFanin0Ntk(pObj)), NULL );
00335                 else
00336                 {
00337                     assert( Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) );
00338                     Abc_ObjAssignName( pObjNew, Abc_ObjName(pObj), NULL );
00339                 }
00340             }
00341         }
00342         else if ( Abc_ObjIsBox(pObj) || Abc_ObjIsNet(pObj) )
00343             Abc_ObjAssignName( pObjNew, Abc_ObjName(pObj), NULL );
00344     }
00345     // copy functionality/names
00346     if ( Abc_ObjIsNode(pObj) ) // copy the function if functionality is compatible
00347     {
00348         if ( pNtkNew->ntkFunc == pObj->pNtk->ntkFunc ) 
00349         {
00350             if ( Abc_NtkIsStrash(pNtkNew) ) 
00351             {}
00352             else if ( Abc_NtkHasSop(pNtkNew) || Abc_NtkHasBlifMv(pNtkNew) )
00353                 pObjNew->pData = Abc_SopRegister( pNtkNew->pManFunc, pObj->pData );
00354             else if ( Abc_NtkHasBdd(pNtkNew) )
00355                 pObjNew->pData = Cudd_bddTransfer(pObj->pNtk->pManFunc, pNtkNew->pManFunc, pObj->pData), Cudd_Ref(pObjNew->pData);
00356             else if ( Abc_NtkHasAig(pNtkNew) )
00357                 pObjNew->pData = Hop_Transfer(pObj->pNtk->pManFunc, pNtkNew->pManFunc, pObj->pData, Abc_ObjFaninNum(pObj));
00358             else if ( Abc_NtkHasMapping(pNtkNew) )
00359                 pObjNew->pData = pObj->pData;
00360             else assert( 0 );
00361         }
00362     }
00363     else if ( Abc_ObjIsNet(pObj) ) // copy the name
00364     {
00365     }
00366     else if ( Abc_ObjIsLatch(pObj) ) // copy the reset value
00367         pObjNew->pData = pObj->pData;
00368     // transfer HAIG
00369 //    pObjNew->pEquiv = pObj->pEquiv;
00370     // remember the new node in the old node
00371     pObj->pCopy = pObjNew;
00372     return pObjNew;
00373 }

static Abc_Ntk_t* Abc_NtkExdc ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 287 of file abc.h.

00287 { return pNtk->pExdc;            }

Vec_Int_t* Abc_NtkFanoutCounts ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Creates the array of fanout counters.]

Description []

SideEffects []

SeeAlso []

Definition at line 1269 of file abcUtil.c.

01270 {
01271     Vec_Int_t * vFanNums;
01272     Abc_Obj_t * pObj;
01273     int i;
01274     vFanNums = Vec_IntAlloc( 0 );
01275     Vec_IntFill( vFanNums, Abc_NtkObjNumMax(pNtk), -1 );
01276     Abc_NtkForEachObj( pNtk, pObj, i )
01277         if ( Abc_ObjIsCi(pObj) || Abc_ObjIsNode(pObj) )
01278             Vec_IntWriteEntry( vFanNums, i, Abc_ObjFanoutNum(pObj) );
01279     return vFanNums;
01280 }

void Abc_NtkFinalize ( Abc_Ntk_t pNtk,
Abc_Ntk_t pNtkNew 
)

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

Synopsis [Finalizes the network using the existing network as a model.]

Description []

SideEffects []

SeeAlso []

Definition at line 197 of file abcNtk.c.

00198 {
00199     Abc_Obj_t * pObj, * pDriver, * pDriverNew;
00200     int i;
00201     // set the COs of the strashed network
00202     Abc_NtkForEachCo( pNtk, pObj, i )
00203     {
00204         pDriver    = Abc_ObjFanin0Ntk( Abc_ObjFanin0(pObj) );
00205         pDriverNew = Abc_ObjNotCond(pDriver->pCopy, Abc_ObjFaninC0(pObj));
00206         Abc_ObjAddFanin( pObj->pCopy, pDriverNew );
00207     }
00208 }

void Abc_NtkFinalizeRead ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Finalizes the network using the existing network as a model.]

Description []

SideEffects []

SeeAlso []

Definition at line 248 of file abcNtk.c.

00249 {
00250     Abc_Obj_t * pBox, * pObj, * pTerm, * pNet;
00251     int i;
00252     if ( Abc_NtkHasBlackbox(pNtk) && Abc_NtkBoxNum(pNtk) == 0 )
00253     {
00254         pBox = Abc_NtkCreateBlackbox(pNtk);
00255         Abc_NtkForEachPi( pNtk, pObj, i )
00256         {
00257             pTerm = Abc_NtkCreateBi(pNtk);
00258             Abc_ObjAddFanin( pTerm, Abc_ObjFanout0(pObj) );
00259             Abc_ObjAddFanin( pBox, pTerm );
00260         }
00261         Abc_NtkForEachPo( pNtk, pObj, i )
00262         {
00263             pTerm = Abc_NtkCreateBo(pNtk);
00264             Abc_ObjAddFanin( pTerm, pBox );
00265             Abc_ObjAddFanin( Abc_ObjFanin0(pObj), pTerm );
00266         }
00267         return;
00268     }
00269     assert( Abc_NtkIsNetlist(pNtk) );
00270 
00271     // check if constant 0 net is used
00272     pNet = Abc_NtkFindNet( pNtk, "1\'b0" );
00273     if ( pNet )
00274     {
00275         if ( Abc_ObjFanoutNum(pNet) == 0 )
00276             Abc_NtkDeleteObj(pNet);
00277         else if ( Abc_ObjFaninNum(pNet) == 0 )
00278             Abc_ObjAddFanin( pNet, Abc_NtkCreateNodeConst0(pNtk) );
00279     }
00280     // check if constant 1 net is used
00281     pNet = Abc_NtkFindNet( pNtk, "1\'b1" );
00282     if ( pNet )
00283     {
00284         if ( Abc_ObjFanoutNum(pNet) == 0 )
00285             Abc_NtkDeleteObj(pNet);
00286         else if ( Abc_ObjFaninNum(pNet) == 0 )
00287             Abc_ObjAddFanin( pNet, Abc_NtkCreateNodeConst1(pNtk) );
00288     }
00289     // fix the net drivers
00290     Abc_NtkFixNonDrivenNets( pNtk );
00291 
00292     // reorder the CI/COs to PI/POs first
00293     Abc_NtkOrderCisCos( pNtk );
00294 }

Abc_Obj_t* Abc_NtkFindCi ( Abc_Ntk_t pNtk,
char *  pName 
)

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

Synopsis [Returns CI with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 509 of file abcObj.c.

00510 {
00511     int Num;
00512     assert( !Abc_NtkIsNetlist(pNtk) );
00513     Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_PI );
00514     if ( Num >= 0 )
00515         return Abc_NtkObj( pNtk, Num );
00516     Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BO );
00517     if ( Num >= 0 )
00518         return Abc_NtkObj( pNtk, Num );
00519     return NULL;
00520 }

Abc_Obj_t* Abc_NtkFindCo ( Abc_Ntk_t pNtk,
char *  pName 
)

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

Synopsis [Returns CO with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 533 of file abcObj.c.

00534 {
00535     int Num;
00536     assert( !Abc_NtkIsNetlist(pNtk) );
00537     Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_PO );
00538     if ( Num >= 0 )
00539         return Abc_NtkObj( pNtk, Num );
00540     Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BI );
00541     if ( Num >= 0 )
00542         return Abc_NtkObj( pNtk, Num );
00543     return NULL;
00544 }

Abc_Obj_t* Abc_NtkFindNet ( Abc_Ntk_t pNtk,
char *  pName 
)

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

Synopsis [Returns the net with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 486 of file abcObj.c.

00487 {
00488     Abc_Obj_t * pNet;
00489     int ObjId;
00490     assert( Abc_NtkIsNetlist(pNtk) );
00491     ObjId = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_NET );
00492     if ( ObjId == -1 )
00493         return NULL;
00494     pNet = Abc_NtkObj( pNtk, ObjId );
00495     return pNet;
00496 }

Abc_Obj_t* Abc_NtkFindNode ( Abc_Ntk_t pNtk,
char *  pName 
)

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

Synopsis [Returns the net with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 435 of file abcObj.c.

00436 {
00437     Abc_Obj_t * pObj;
00438     int Num;
00439     // try to find the terminal
00440     Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_PO );
00441     if ( Num >= 0 )
00442         return Abc_ObjFanin0( Abc_NtkObj( pNtk, Num ) );
00443     Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BI );
00444     if ( Num >= 0 )
00445         return Abc_ObjFanin0( Abc_NtkObj( pNtk, Num ) );
00446     Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_NODE );
00447     if ( Num >= 0 )
00448         return Abc_NtkObj( pNtk, Num );
00449     // find the internal node
00450     if ( pName[0] != 'n' )
00451     {
00452         printf( "Name \"%s\" is not found among CO or node names (internal names often look as \"n<num>\").\n", pName );
00453         return NULL;
00454     }
00455     Num = atoi( pName + 1 );
00456     if ( Num < 0 || Num >= Abc_NtkObjNumMax(pNtk) )
00457     {
00458         printf( "The node \"%s\" with ID %d is not in the current network.\n", pName, Num );
00459         return NULL;
00460     }
00461     pObj = Abc_NtkObj( pNtk, Num );
00462     if ( pObj == NULL )
00463     {
00464         printf( "The node \"%s\" with ID %d has been removed from the current network.\n", pName, Num );
00465         return NULL;
00466     }
00467     if ( !Abc_ObjIsNode(pObj) )
00468     {
00469         printf( "Object with ID %d is not a node.\n", Num );
00470         return NULL;
00471     }
00472     return pObj;
00473 }

Abc_Obj_t* Abc_NtkFindOrCreateNet ( Abc_Ntk_t pNtk,
char *  pName 
)

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

Synopsis [Finds or creates the net.]

Description []

SideEffects []

SeeAlso []

Definition at line 558 of file abcObj.c.

00559 {
00560     Abc_Obj_t * pNet;
00561     assert( Abc_NtkIsNetlist(pNtk) );
00562     if ( pName && (pNet = Abc_NtkFindNet( pNtk, pName )) )
00563         return pNet;
00564 //printf( "Creating net %s.\n", pName );
00565     // create a new net
00566     pNet = Abc_NtkCreateNet( pNtk );
00567     if ( pName )
00568         Nm_ManStoreIdName( pNtk->pManName, pNet->Id, pNet->Type, pName, NULL );
00569     return pNet;
00570 }

void Abc_NtkFixNonDrivenNets ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Reads the verilog file.]

Description []

SideEffects []

SeeAlso []

Definition at line 1042 of file abcNtk.c.

01043 { 
01044     Vec_Ptr_t * vNets;
01045     Abc_Obj_t * pNet, * pNode;
01046     int i;
01047 
01048     if ( Abc_NtkNodeNum(pNtk) == 0 && Abc_NtkBoxNum(pNtk) == 0 )
01049         return;
01050 
01051     // check for non-driven nets
01052     vNets = Vec_PtrAlloc( 100 );
01053     Abc_NtkForEachNet( pNtk, pNet, i )
01054     {
01055         if ( Abc_ObjFaninNum(pNet) > 0 )
01056             continue;
01057         // add the constant 0 driver
01058         pNode = Abc_NtkCreateNodeConst0( pNtk );
01059         // add the fanout net
01060         Abc_ObjAddFanin( pNet, pNode );
01061         // add the net to those for which the warning will be printed
01062         Vec_PtrPush( vNets, pNet );
01063     }
01064 
01065     // print the warning
01066     if ( vNets->nSize > 0 )
01067     {
01068         printf( "Warning: Constant-0 drivers added to %d non-driven nets in network \"%s\":\n", Vec_PtrSize(vNets), pNtk->pName );
01069         Vec_PtrForEachEntry( vNets, pNet, i )
01070         {
01071             printf( "%s%s", (i? ", ": ""), Abc_ObjName(pNet) );
01072             if ( i == 3 )
01073             {
01074                 if ( Vec_PtrSize(vNets) > 3 )
01075                     printf( " ..." );
01076                 break;
01077             }
01078         }
01079         printf( "\n" );
01080     }
01081     Vec_PtrFree( vNets );
01082 }

Abc_Ntk_t* Abc_NtkFlattenLogicHierarchy ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Flattens the logic hierarchy of the netlist.]

Description []

SideEffects []

SeeAlso []

Definition at line 171 of file abcHie.c.

00172 {
00173     Abc_Ntk_t * pNtkNew; 
00174     Abc_Obj_t * pTerm, * pNet;
00175     int i, Counter;
00176     extern Abc_Lib_t * Abc_LibDupBlackboxes( Abc_Lib_t * pLib, Abc_Ntk_t * pNtkSave );
00177 
00178     assert( Abc_NtkIsNetlist(pNtk) );
00179     // start the network
00180     pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
00181     // duplicate the name and the spec
00182     pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
00183     pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
00184 
00185     // clean the node copy fields
00186     Abc_NtkCleanCopy( pNtk );
00187 
00188     // duplicate PIs/POs and their nets
00189     Abc_NtkForEachPi( pNtk, pTerm, i )
00190     {
00191         Abc_NtkDupObj( pNtkNew, pTerm, 0 );
00192         pNet = Abc_ObjFanout0( pTerm );
00193         pNet->pCopy = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pNet) );
00194         Abc_ObjAddFanin( pNet->pCopy, pTerm->pCopy );
00195     }
00196     Abc_NtkForEachPo( pNtk, pTerm, i )
00197     {
00198         Abc_NtkDupObj( pNtkNew, pTerm, 0 );
00199         pNet = Abc_ObjFanin0( pTerm );
00200         pNet->pCopy = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pNet) );
00201         Abc_ObjAddFanin( pTerm->pCopy, pNet->pCopy );
00202     }
00203 
00204     // recursively flatten hierarchy, create internal logic, add new PI/PO names if there are black boxes
00205     Counter = -1;
00206     Abc_NtkFlattenLogicHierarchy_rec( pNtkNew, pNtk, &Counter );
00207     printf( "Hierarchy reader flattened %d instances of logic boxes and left %d black boxes.\n", 
00208         Counter, Abc_NtkBlackboxNum(pNtkNew) );
00209 
00210     if ( pNtk->pDesign )
00211     {
00212         // pass on the design
00213         assert( Vec_PtrEntry(pNtk->pDesign->vTops, 0) == pNtk );
00214         pNtkNew->pDesign = Abc_LibDupBlackboxes( pNtk->pDesign, pNtkNew );
00215         // update the pointers
00216         Abc_NtkForEachBlackbox( pNtkNew, pTerm, i )
00217             pTerm->pData = ((Abc_Ntk_t *)pTerm->pData)->pCopy;
00218     }
00219 
00220     // copy the timing information
00221 //    Abc_ManTimeDup( pNtk, pNtkNew );
00222     // duplicate EXDC 
00223     if ( pNtk->pExdc )
00224         printf( "EXDC is not transformed.\n" );
00225     if ( !Abc_NtkCheck( pNtkNew ) )
00226     {
00227         fprintf( stdout, "Abc_NtkFlattenLogicHierarchy(): Network check has failed.\n" );
00228         Abc_NtkDelete( pNtkNew );
00229         return NULL;
00230     }
00231     return pNtkNew;
00232 }

Abc_Ntk_t* Abc_NtkFraig ( Abc_Ntk_t pNtk,
void *  pParams,
int  fAllNodes,
int  fExdc 
)

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

Synopsis [Interfaces the network with the FRAIG package.]

Description []

SideEffects []

SeeAlso []

Definition at line 55 of file abcFraig.c.

00056 {
00057     Fraig_Params_t * pPars = pParams;
00058     Abc_Ntk_t * pNtkNew;
00059     Fraig_Man_t * pMan; 
00060     // check if EXDC is present
00061     if ( fExdc && pNtk->pExdc == NULL )
00062         fExdc = 0, printf( "Warning: Networks has no EXDC.\n" );
00063     // perform fraiging
00064     pMan = Abc_NtkToFraig( pNtk, pParams, fAllNodes, fExdc ); 
00065     // add algebraic choices
00066 //    if ( pPars->fChoicing )
00067 //        Fraig_ManAddChoices( pMan, 0, 6 );
00068     // prove the miter if asked to
00069     if ( pPars->fTryProve )
00070         Fraig_ManProveMiter( pMan );
00071     // reconstruct FRAIG in the new network
00072     if ( fExdc ) 
00073         pNtkNew = Abc_NtkFromFraig2( pMan, pNtk );
00074     else
00075         pNtkNew = Abc_NtkFromFraig( pMan, pNtk );
00076     Fraig_ManFree( pMan );
00077     if ( pNtk->pExdc )
00078         pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
00079     // make sure that everything is okay
00080     if ( !Abc_NtkCheck( pNtkNew ) )
00081     {
00082         printf( "Abc_NtkFraig: The network check has failed.\n" );
00083         Abc_NtkDelete( pNtkNew );
00084         return NULL;
00085     }
00086     return pNtkNew;
00087 }

Abc_Ntk_t* Abc_NtkFraigRestore (  ) 

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

Synopsis [Interfaces the network with the FRAIG package.]

Description []

SideEffects []

SeeAlso []

Definition at line 691 of file abcFraig.c.

00692 {
00693     extern Abc_Ntk_t * Abc_NtkFraigPartitioned( Vec_Ptr_t * vStore, void * pParams );
00694     Fraig_Params_t Params;
00695     Vec_Ptr_t * vStore;
00696     Abc_Ntk_t * pNtk, * pFraig;
00697     int nWords1, nWords2, nWordsMin;
00698     int clk = clock();
00699 
00700     // get the stored network
00701     vStore = Abc_FrameReadStore();
00702     if ( Vec_PtrSize(vStore) == 0 )
00703     {
00704         printf( "There are no network currently in storage.\n" );
00705         return NULL;
00706     }
00707 //    printf( "Currently stored %d networks will be fraiged.\n", Vec_PtrSize(vStore) );
00708     pNtk = Vec_PtrEntry( vStore, 0 );
00709 
00710     // swap the first and last network
00711     // this should lead to the primary choice being "better" because of synthesis
00712     pNtk = Vec_PtrPop( vStore );
00713     Vec_PtrPush( vStore, Vec_PtrEntry(vStore,0) );
00714     Vec_PtrWriteEntry( vStore, 0, pNtk );
00715 
00716     // to determine the number of simulation patterns
00717     // use the following strategy
00718     // at least 64 words (32 words random and 32 words dynamic)
00719     // no more than 256M for one circuit (128M + 128M)
00720     nWords1 = 32;
00721     nWords2 = (1<<27) / (Abc_NtkNodeNum(pNtk) + Abc_NtkCiNum(pNtk));
00722     nWordsMin = ABC_MIN( nWords1, nWords2 );
00723 
00724     // set parameters for fraiging
00725     Fraig_ParamsSetDefault( &Params );
00726     Params.nPatsRand  = nWordsMin * 32;    // the number of words of random simulation info
00727     Params.nPatsDyna  = nWordsMin * 32;    // the number of words of dynamic simulation info
00728     Params.nBTLimit   = 1000;              // the max number of backtracks to perform
00729     Params.fFuncRed   =    1;              // performs only one level hashing
00730     Params.fFeedBack  =    1;              // enables solver feedback
00731     Params.fDist1Pats =    1;              // enables distance-1 patterns
00732     Params.fDoSparse  =    1;              // performs equiv tests for sparse functions 
00733     Params.fChoicing  =    1;              // enables recording structural choices
00734     Params.fTryProve  =    0;              // tries to solve the final miter
00735     Params.fVerbose   =    0;              // the verbosiness flag
00736 
00737     // perform partitioned computation of structural choices
00738     pFraig = Abc_NtkFraigPartitioned( vStore, &Params );
00739     Abc_NtkFraigStoreClean();
00740 //PRT( "Total choicing time", clock() - clk );
00741     return pFraig;
00742 }

int Abc_NtkFraigStore ( Abc_Ntk_t pNtkAdd  ) 

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

Synopsis [Interfaces the network with the FRAIG package.]

Description []

SideEffects []

SeeAlso []

Definition at line 651 of file abcFraig.c.

00652 {
00653     Vec_Ptr_t * vStore;
00654     Abc_Ntk_t * pNtk;
00655     // create the network to be stored
00656     pNtk = Abc_NtkStrash( pNtkAdd, 0, 0, 0 );
00657     if ( pNtk == NULL )
00658     {
00659         printf( "Abc_NtkFraigStore: Initial strashing has failed.\n" );
00660         return 0;
00661     }
00662     // get the network currently stored
00663     vStore = Abc_FrameReadStore();
00664     if ( Vec_PtrSize(vStore) > 0 )
00665     {
00666         // check that the networks have the same PIs
00667         // reorder PIs of pNtk2 according to pNtk1
00668         if ( !Abc_NtkCompareSignals( pNtk, Vec_PtrEntry(vStore, 0), 1, 1 ) )
00669         {
00670             printf( "Trying to store the network with different primary inputs.\n" );
00671             printf( "The previously stored networks are deleted and this one is added.\n" );
00672             Abc_NtkFraigStoreClean();
00673         }
00674     }
00675     Vec_PtrPush( vStore, pNtk );
00676 //    printf( "The number of AIG nodes added to storage = %5d.\n", Abc_NtkNodeNum(pNtk) );
00677     return 1;
00678 }

void Abc_NtkFraigStoreClean (  ) 

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

Synopsis [Interfaces the network with the FRAIG package.]

Description []

SideEffects []

SeeAlso []

Definition at line 755 of file abcFraig.c.

00756 {
00757     Vec_Ptr_t * vStore;
00758     Abc_Ntk_t * pNtk;
00759     int i;
00760     vStore = Abc_FrameReadStore();
00761     Vec_PtrForEachEntry( vStore, pNtk, i )
00762         Abc_NtkDelete( pNtk );
00763     Vec_PtrClear( vStore );
00764 }

Abc_Ntk_t* Abc_NtkFraigTrust ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Interfaces the network with the FRAIG package.]

Description []

SideEffects []

SeeAlso []

Definition at line 482 of file abcFraig.c.

00483 {
00484     Abc_Ntk_t * pNtkNew;
00485 
00486     if ( !Abc_NtkIsSopLogic(pNtk) )
00487     {
00488         printf( "Abc_NtkFraigTrust: Trust mode works for netlists and logic SOP networks.\n" );
00489         return NULL;
00490     }
00491 
00492     if ( !Abc_NtkFraigTrustCheck(pNtk) )
00493     {
00494         printf( "Abc_NtkFraigTrust: The network does not look like an AIG with choice nodes.\n" );
00495         return NULL;
00496     }
00497     
00498     // perform strashing
00499     pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG );
00500     Abc_NtkFraigTrustOne( pNtk, pNtkNew );
00501     Abc_NtkFinalize( pNtk, pNtkNew );
00502     Abc_NtkReassignIds( pNtkNew );
00503 
00504     // print a warning about choice nodes
00505     printf( "Warning: The resulting AIG contains %d choice nodes.\n", Abc_NtkGetChoiceNum( pNtkNew ) );
00506 
00507     // make sure that everything is okay
00508     if ( !Abc_NtkCheck( pNtkNew ) )
00509     {
00510         printf( "Abc_NtkFraigTrust: The network check has failed.\n" );
00511         Abc_NtkDelete( pNtkNew );
00512         return NULL;
00513     }
00514     return pNtkNew;
00515 }

Abc_Ntk_t* Abc_NtkFrames ( Abc_Ntk_t pNtk,
int  nFrames,
int  fInitial 
)

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

Synopsis [Derives the timeframes of the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 720 of file abcMiter.c.

00721 {
00722     char Buffer[1000];
00723     ProgressBar * pProgress;
00724     Abc_Ntk_t * pNtkFrames;
00725     Abc_Obj_t * pLatch, * pLatchOut;
00726     int i, Counter;
00727     assert( nFrames > 0 );
00728     assert( Abc_NtkIsStrash(pNtk) );
00729     assert( Abc_NtkIsDfsOrdered(pNtk) );
00730     assert( Abc_NtkHasOnlyLatchBoxes(pNtk) );
00731     // start the new network
00732     pNtkFrames = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
00733     sprintf( Buffer, "%s_%d_frames", pNtk->pName, nFrames );
00734     pNtkFrames->pName = Extra_UtilStrsav(Buffer);
00735     // map the constant nodes
00736     Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkFrames);
00737     // create new latches (or their initial values) and remember them in the new latches
00738     if ( !fInitial )
00739     {
00740         Abc_NtkForEachLatch( pNtk, pLatch, i )
00741             Abc_NtkDupBox( pNtkFrames, pLatch, 1 );
00742     }
00743     else
00744     {
00745         Counter = 0;
00746         Abc_NtkForEachLatch( pNtk, pLatch, i )
00747         {
00748             pLatchOut = Abc_ObjFanout0(pLatch);
00749             if ( Abc_LatchIsInitNone(pLatch) || Abc_LatchIsInitDc(pLatch) ) // don't-care initial value - create a new PI
00750             {
00751                 pLatchOut->pCopy = Abc_NtkCreatePi(pNtkFrames);
00752                 Abc_ObjAssignName( pLatchOut->pCopy, Abc_ObjName(pLatchOut), NULL );
00753                 Counter++;
00754             }
00755             else
00756                 pLatchOut->pCopy = Abc_ObjNotCond( Abc_AigConst1(pNtkFrames), Abc_LatchIsInit0(pLatch) );
00757         }
00758         if ( Counter )
00759             printf( "Warning: %d uninitialized latches are replaced by free PI variables.\n", Counter );
00760     }
00761     
00762     // create the timeframes
00763     pProgress = Extra_ProgressBarStart( stdout, nFrames );
00764     for ( i = 0; i < nFrames; i++ )
00765     {
00766         Extra_ProgressBarUpdate( pProgress, i, NULL );
00767         Abc_NtkAddFrame( pNtkFrames, pNtk, i );
00768     }
00769     Extra_ProgressBarStop( pProgress );
00770     
00771     // connect the new latches to the outputs of the last frame
00772     if ( !fInitial )
00773     {
00774         // we cannot use pLatch->pCopy here because pLatch->pCopy is used for temporary storage of strashed values
00775         Abc_NtkForEachLatch( pNtk, pLatch, i )
00776             Abc_ObjAddFanin( Abc_ObjFanin0(pLatch)->pCopy, Abc_ObjFanout0(pLatch)->pCopy );
00777     }
00778 
00779     // remove dangling nodes
00780     Abc_AigCleanup( pNtkFrames->pManFunc );
00781     // reorder the latches
00782     Abc_NtkOrderCisCos( pNtkFrames );
00783     // make sure that everything is okay
00784     if ( !Abc_NtkCheck( pNtkFrames ) )
00785     {
00786         printf( "Abc_NtkFrames: The network check has failed.\n" );
00787         Abc_NtkDelete( pNtkFrames );
00788         return NULL;
00789     }
00790     return pNtkFrames;
00791 }

DdManager* Abc_NtkFreeGlobalBdds ( Abc_Ntk_t pNtk,
int  fFreeMan 
)

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

Synopsis [Frees the global BDDs of the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 459 of file abcNtbdd.c.

00460 { 
00461     return Abc_NtkAttrFree( pNtk, VEC_ATTR_GLOBAL_BDD, fFreeMan ); 
00462 }

void Abc_NtkFreeMvVars ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Stops the Mv-Var manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 62 of file abcBlifMv.c.

00063 { 
00064     void * pUserMan;
00065     pUserMan = Abc_NtkAttrFree( pNtk, VEC_ATTR_GLOBAL_BDD, 0 ); 
00066     Extra_MmFlexStop( pUserMan );
00067 }

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.

00267 {
00268     Abc_Obj_t * pNode;
00269     int i, nNodes = 0;
00270     assert( Abc_NtkIsAigLogic(pNtk) );
00271     Abc_NtkForEachNode( pNtk, pNode, i )
00272     {
00273         assert( pNode->pData );
00274         if ( Abc_ObjFaninNum(pNode) < 2 )
00275             continue;
00276 //printf( "%d ", Hop_DagSize( pNode->pData ) );
00277         nNodes += pNode->pData? Hop_DagSize( pNode->pData ) : 0;
00278     }
00279     return nNodes;
00280 }

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.

00241 {
00242     Abc_Obj_t * pNode;
00243     int i, nNodes = 0;
00244     assert( Abc_NtkIsBddLogic(pNtk) );
00245     Abc_NtkForEachNode( pNtk, pNode, i )
00246     {
00247         assert( pNode->pData );
00248         if ( Abc_ObjFaninNum(pNode) < 2 )
00249             continue;
00250         nNodes += pNode->pData? -1 + Cudd_DagSize( pNode->pData ) : 0;
00251     }
00252     return nNodes;
00253 }

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 404 of file abcUtil.c.

00405 {
00406     Abc_Obj_t * pNode;
00407     int i, Counter;
00408     if ( !Abc_NtkIsStrash(pNtk) )
00409         return 0;
00410     Counter = 0;
00411     Abc_NtkForEachNode( pNtk, pNode, i )
00412         Counter += Abc_AigNodeIsChoice( pNode );
00413     return Counter;
00414 }

float* Abc_NtkGetCiArrivalFloats ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Sets the CI node levels according to the arrival info.]

Description []

SideEffects []

SeeAlso []

Definition at line 521 of file abcTiming.c.

00522 {
00523     float * p;
00524     Abc_Obj_t * pNode;
00525     int i;
00526     p = ALLOC( float, Abc_NtkCiNum(pNtk) );
00527     memset( p, 0, sizeof(float) * Abc_NtkCiNum(pNtk) );
00528     if ( pNtk->pManTime == NULL )
00529         return p;
00530     // set the PI arrival times
00531     Abc_NtkForEachPi( pNtk, pNode, i )
00532         p[i] = Abc_NodeArrival(pNode)->Worst;
00533     return p;
00534 }

Abc_Time_t* Abc_NtkGetCiArrivalTimes ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Sets the CI node levels according to the arrival info.]

Description []

SideEffects []

SeeAlso []

Definition at line 494 of file abcTiming.c.

00495 {
00496     Abc_Time_t * p;
00497     Abc_Obj_t * pNode;
00498     int i;
00499     p = ALLOC( Abc_Time_t, Abc_NtkCiNum(pNtk) );
00500     memset( p, 0, sizeof(Abc_Time_t) * Abc_NtkCiNum(pNtk) );
00501     if ( pNtk->pManTime == NULL )
00502         return p;
00503     // set the PI arrival times
00504     Abc_NtkForEachPi( pNtk, pNode, i )
00505         p[i] = *Abc_NodeArrival(pNode);
00506     return p;
00507 }

Vec_Int_t* Abc_NtkGetCiIds ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Returns the array of CI IDs.]

Description []

SideEffects []

SeeAlso []

Definition at line 1315 of file abcUtil.c.

01316 {
01317     Vec_Int_t * vCiIds;
01318     Abc_Obj_t * pObj;
01319     int i;
01320     vCiIds = Vec_IntAlloc( Abc_NtkCiNum(pNtk) );
01321     Abc_NtkForEachCi( pNtk, pObj, i )
01322         Vec_IntPush( vCiIds, pObj->Id );
01323     return vCiIds;
01324 }

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.

00294 {
00295     Abc_Obj_t * pNode;
00296     DdNode * bCover, * zCover, * bFunc;
00297     DdManager * dd = pNtk->pManFunc;
00298     int i, nClauses = 0;
00299     assert( Abc_NtkIsBddLogic(pNtk) );
00300     Abc_NtkForEachNode( pNtk, pNode, i )
00301     {
00302         assert( pNode->pData );
00303         bFunc = pNode->pData;
00304 
00305         bCover = Cudd_zddIsop( dd, bFunc, bFunc, &zCover );  
00306         Cudd_Ref( bCover );
00307         Cudd_Ref( zCover );
00308         nClauses += Abc_CountZddCubes( dd, zCover );
00309         Cudd_RecursiveDeref( dd, bCover );
00310         Cudd_RecursiveDerefZdd( dd, zCover );
00311 
00312         bCover = Cudd_zddIsop( dd, Cudd_Not(bFunc), Cudd_Not(bFunc), &zCover );  
00313         Cudd_Ref( bCover );
00314         Cudd_Ref( zCover );
00315         nClauses += Abc_CountZddCubes( dd, zCover );
00316         Cudd_RecursiveDeref( dd, bCover );
00317         Cudd_RecursiveDerefZdd( dd, zCover );
00318     }
00319     return nClauses;
00320 }

int Abc_NtkGetCubeNum ( Abc_Ntk_t pNtk  ) 

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 134 of file abcUtil.c.

00135 {
00136     Abc_Obj_t * pNode;
00137     int i, nCubes = 0;
00138     assert( Abc_NtkHasSop(pNtk) );
00139     Abc_NtkForEachNode( pNtk, pNode, i )
00140     {
00141         if ( Abc_NodeIsConst(pNode) )
00142             continue;
00143         assert( pNode->pData );
00144         nCubes += Abc_SopGetCubeNum( pNode->pData );
00145     }
00146     return nCubes;
00147 }

int Abc_NtkGetCubePairNum ( Abc_Ntk_t pNtk  ) 

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 160 of file abcUtil.c.

00161 {
00162     Abc_Obj_t * pNode;
00163     int i, nCubes, nCubePairs = 0;
00164     assert( Abc_NtkHasSop(pNtk) );
00165     Abc_NtkForEachNode( pNtk, pNode, i )
00166     {
00167         if ( Abc_NodeIsConst(pNode) )
00168             continue;
00169         assert( pNode->pData );
00170         nCubes = Abc_SopGetCubeNum( pNode->pData );
00171         nCubePairs += nCubes * (nCubes - 1) / 2;
00172     }
00173     return nCubePairs;
00174 }

int Abc_NtkGetExorNum ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Counts the number of exors.]

Description []

SideEffects []

SeeAlso []

Definition at line 364 of file abcUtil.c.

00365 {
00366     Abc_Obj_t * pNode;
00367     int i, Counter = 0;
00368     Abc_NtkForEachNode( pNtk, pNode, i )
00369         Counter += pNode->fExor;
00370     return Counter;
00371 }

int Abc_NtkGetFaninMax ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Reads the maximum number of fanins.]

Description []

SideEffects []

SeeAlso []

Definition at line 427 of file abcUtil.c.

00428 {
00429     Abc_Obj_t * pNode;
00430     int i, nFaninsMax = 0;
00431     Abc_NtkForEachNode( pNtk, pNode, i )
00432     {
00433         if ( nFaninsMax < Abc_ObjFaninNum(pNode) )
00434             nFaninsMax = Abc_ObjFaninNum(pNode);
00435     }
00436     return nFaninsMax;
00437 }

int Abc_NtkGetLitFactNum ( Abc_Ntk_t pNtk  ) 

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 211 of file abcUtil.c.

00212 {
00213     Dec_Graph_t * pFactor;
00214     Abc_Obj_t * pNode;
00215     int nNodes, i;
00216     assert( Abc_NtkHasSop(pNtk) );
00217     nNodes = 0;
00218     Abc_NtkForEachNode( pNtk, pNode, i )
00219     {
00220         if ( Abc_NodeIsConst(pNode) )
00221             continue;
00222         pFactor = Dec_Factor( pNode->pData );
00223         nNodes += 1 + Dec_GraphNodeNum(pFactor);
00224         Dec_GraphFree( pFactor );
00225     }
00226     return nNodes;
00227 }

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 187 of file abcUtil.c.

00188 {
00189     Abc_Obj_t * pNode;
00190     int i, nLits = 0;
00191     assert( Abc_NtkHasSop(pNtk) );
00192     Abc_NtkForEachNode( pNtk, pNode, i )
00193     {
00194         assert( pNode->pData );
00195         nLits += Abc_SopGetLitNum( pNode->pData );
00196     }
00197     return nLits;
00198 }

double Abc_NtkGetMappedArea ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Computes the area of the mapped circuit.]

Description []

SideEffects []

SeeAlso []

Definition at line 333 of file abcUtil.c.

00334 {
00335     Abc_Obj_t * pNode;
00336     double TotalArea;
00337     int i;
00338     assert( Abc_NtkHasMapping(pNtk) );
00339     TotalArea = 0.0;
00340     Abc_NtkForEachNode( pNtk, pNode, i )
00341     {
00342 //        assert( pNode->pData );
00343         if ( pNode->pData == NULL )
00344         {
00345             printf( "Node without mapping is encountered.\n" );
00346             continue;
00347         }
00348         TotalArea += Mio_GateReadArea( pNode->pData );
00349     }
00350     return TotalArea;
00351 }

int Abc_NtkGetMuxNum ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Counts the number of exors.]

Description []

SideEffects []

SeeAlso []

Definition at line 384 of file abcUtil.c.

00385 {
00386     Abc_Obj_t * pNode;
00387     int i, Counter = 0;
00388     Abc_NtkForEachNode( pNtk, pNode, i )
00389         Counter += Abc_NodeIsMuxType(pNode);
00390     return Counter;
00391 }

int Abc_NtkGetTotalFanins ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Reads the total number of all fanins.]

Description []

SideEffects []

SeeAlso []

Definition at line 450 of file abcUtil.c.

00451 {
00452     Abc_Obj_t * pNode;
00453     int i, nFanins = 0;
00454     Abc_NtkForEachNode( pNtk, pNode, i )
00455         nFanins += Abc_ObjFaninNum(pNode);
00456     return nFanins;
00457 }

static void* Abc_NtkGlobalBdd ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 439 of file abc.h.

00439 { return (void *)Vec_PtrEntry(pNtk->vAttrs, VEC_ATTR_GLOBAL_BDD);             }

static DdNode** Abc_NtkGlobalBddArray ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 441 of file abc.h.

00441 { return (DdNode **)Vec_AttArray( (Vec_Att_t *)Abc_NtkGlobalBdd(pNtk) );                   }

static DdManager* Abc_NtkGlobalBddMan ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 440 of file abc.h.

00440 { return (DdManager *)Vec_AttMan( (Vec_Att_t *)Abc_NtkGlobalBdd(pNtk) );                   }

int Abc_NtkHaigStart ( Abc_Ntk_t pNtk  ) 

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

FileName [abcHaig.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Implements history AIG for combinational rewriting.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Start history AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file abcHaig.c.

00043 {
00044     Hop_Man_t * p;
00045     Abc_Obj_t * pObj, * pTemp;
00046     int i;
00047     assert( Abc_NtkIsStrash(pNtk) );
00048     // check if the package is already started
00049     if ( pNtk->pHaig )
00050     {
00051         Abc_NtkHaigStop( pNtk );
00052         assert( pNtk->pHaig == NULL );
00053         printf( "Warning: Previous history AIG was removed.\n" );
00054     }
00055     // make sure the data is clean
00056     Abc_NtkForEachObj( pNtk, pObj, i )
00057         assert( pObj->pEquiv == NULL );
00058     // start the HOP package
00059     p = Hop_ManStart();
00060     p->vObjs = Vec_PtrAlloc( 4096 );
00061     Vec_PtrPush( p->vObjs, Hop_ManConst1(p) );
00062     // map the constant node
00063     Abc_AigConst1(pNtk)->pEquiv = Hop_ManConst1(p);
00064     // map the CIs
00065     Abc_NtkForEachCi( pNtk, pObj, i )
00066         pObj->pEquiv = Hop_ObjCreatePi(p);
00067     // map the internal nodes
00068     Abc_NtkForEachNode( pNtk, pObj, i )
00069         pObj->pEquiv = Hop_And( p, Abc_ObjChild0Equiv(pObj), Abc_ObjChild1Equiv(pObj) );
00070     // map the choice nodes
00071     if ( Abc_NtkGetChoiceNum( pNtk ) )
00072     {
00073         // print warning about choice nodes
00074         printf( "Warning: The choice nodes in the original AIG are converted into HAIG.\n" );
00075         Abc_NtkForEachNode( pNtk, pObj, i )
00076         {
00077             if ( !Abc_AigNodeIsChoice( pObj ) )
00078                 continue;
00079             for ( pTemp = pObj->pData; pTemp; pTemp = pTemp->pData )
00080                 Hop_ObjCreateChoice( pObj->pEquiv, pTemp->pEquiv );
00081         }
00082     }
00083     // make sure everything is okay
00084     if ( !Hop_ManCheck(p) )
00085     {
00086         printf( "Abc_NtkHaigStart: Check for History AIG has failed.\n" );
00087         Hop_ManStop(p);
00088         return 0;
00089     }
00090     pNtk->pHaig = p;
00091     return 1;
00092 }

int Abc_NtkHaigStop ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Stops history AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 105 of file abcHaig.c.

00106 {
00107     Abc_Obj_t * pObj;
00108     int i;
00109     assert( Abc_NtkIsStrash(pNtk) );
00110     if ( pNtk->pHaig == NULL )
00111     {
00112         printf( "Warning: History AIG is not allocated.\n" );
00113         return 1;
00114     }
00115     Abc_NtkForEachObj( pNtk, pObj, i )
00116         pObj->pEquiv = NULL;
00117     Hop_ManStop( pNtk->pHaig );
00118     pNtk->pHaig = NULL;
00119     return 1;
00120 }

Abc_Ntk_t* Abc_NtkHaigUse ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Stops history AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 650 of file abcHaig.c.

00651 {
00652     Hop_Man_t * pMan, * pManTemp;
00653     Abc_Ntk_t * pNtkAig;
00654     Abc_Obj_t * pObj;
00655     int i;
00656 
00657     // check if HAIG is available
00658     assert( Abc_NtkIsStrash(pNtk) );
00659     if ( pNtk->pHaig == NULL )
00660     {
00661         printf( "Warning: History AIG is not available.\n" );
00662         return NULL;
00663     }
00664     // convert HOP package into AIG with choices
00665     // print HAIG stats
00666 //    Hop_ManPrintStats( pMan ); // USES DATA!!!
00667 
00668     // add the POs
00669     Abc_NtkForEachCo( pNtk, pObj, i )
00670         Hop_ObjCreatePo( pNtk->pHaig, Abc_ObjChild0Equiv(pObj) );
00671 
00672     // clean the old network
00673     Abc_NtkForEachObj( pNtk, pObj, i )
00674         pObj->pEquiv = NULL;
00675     pMan = pNtk->pHaig; 
00676     pNtk->pHaig = 0;
00677 
00678     // iteratively reconstruct the HOP manager to create choice nodes
00679     while ( Abc_NtkHaigResetReprs( pMan ) )
00680     {
00681         pMan = Abc_NtkHaigReconstruct( pManTemp = pMan );
00682         Hop_ManStop( pManTemp );
00683     }
00684 
00685     // traverse in the topological order and create new AIG
00686     pNtkAig = Abc_NtkHaigRecreateAig( pNtk, pMan );
00687     Hop_ManStop( pMan );
00688 
00689     // free HAIG
00690     return pNtkAig;
00691 }

static bool Abc_NtkHasAig ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 269 of file abc.h.

00269 { return pNtk->ntkFunc == ABC_FUNC_AIG;        }

static bool Abc_NtkHasBdd ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 268 of file abc.h.

00268 { return pNtk->ntkFunc == ABC_FUNC_BDD;        }

static bool Abc_NtkHasBlackbox ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 272 of file abc.h.

00272 { return pNtk->ntkFunc == ABC_FUNC_BLACKBOX;   }

static bool Abc_NtkHasBlifMv ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 271 of file abc.h.

00271 { return pNtk->ntkFunc == ABC_FUNC_BLIFMV;     }

static bool Abc_NtkHasMapping ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 270 of file abc.h.

00270 { return pNtk->ntkFunc == ABC_FUNC_MAP;        }

static bool Abc_NtkHasOnlyLatchBoxes ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 314 of file abc.h.

00314 { return Abc_NtkLatchNum(pNtk) == Abc_NtkBoxNum(pNtk); }

static bool Abc_NtkHasSop ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 267 of file abc.h.

00267 { return pNtk->ntkFunc == ABC_FUNC_SOP;        }

void Abc_NtkIncrementTravId ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Increments the current traversal ID of the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 67 of file abcUtil.c.

00068 {
00069     Abc_Obj_t * pObj;
00070     int i;
00071     if ( pNtk->nTravIds >= (1<<30)-1 )
00072     {
00073         pNtk->nTravIds = 0;
00074         Abc_NtkForEachObj( pNtk, pObj, i )
00075             pObj->TravId = 0;
00076     }
00077     pNtk->nTravIds++;
00078 }

Abc_Ntk_t* Abc_NtkInsertBlifMv ( Abc_Ntk_t pNtkBase,
Abc_Ntk_t pNtkLogic 
)

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

Synopsis [Inserts processed network into original base MV network.]

Description [The original network remembers the interface of combinational logic (PIs/POs/latches names and values). The processed network may be binary or multi-valued (currently, multi-value is not supported). The resulting network has the same interface as the original network while the internal logic is the same as that of the processed network.]

SideEffects []

SeeAlso []

Definition at line 719 of file abcBlifMv.c.

00720 {
00721     Abc_Ntk_t * pNtkSkel, * pNtkNew;
00722     Abc_Obj_t * pBox;
00723 
00724     assert( Abc_NtkIsNetlist(pNtkBase) );
00725     assert( Abc_NtkHasBlifMv(pNtkBase) );
00726     assert( Abc_NtkWhiteboxNum(pNtkBase) == 0 );
00727     assert( Abc_NtkBlackboxNum(pNtkBase) == 0 );
00728 
00729     assert( Abc_NtkIsNetlist(pNtkLogic) );
00730     assert( Abc_NtkHasBlifMv(pNtkLogic) );
00731     assert( Abc_NtkWhiteboxNum(pNtkLogic) == 0 );
00732     assert( Abc_NtkBlackboxNum(pNtkLogic) == 0 );
00733 
00734     // extract the skeleton of the old network
00735     pNtkSkel = Abc_NtkSkeletonBlifMv( pNtkBase );
00736 
00737     // set the implementation of the box to be the same as the processed network
00738     assert( Abc_NtkWhiteboxNum(pNtkSkel) == 1 );
00739     pBox = Abc_NtkBox( pNtkSkel, 0 );
00740     assert( Abc_ObjIsWhitebox(pBox) );
00741     assert( pBox->pData == NULL );
00742     assert( Abc_ObjFaninNum(pBox) == Abc_NtkPiNum(pNtkLogic) );
00743     assert( Abc_ObjFanoutNum(pBox) == Abc_NtkPoNum(pNtkLogic) );
00744     pBox->pData = pNtkLogic;
00745 
00746     // flatten the hierarchy to insert the processed network
00747     pNtkNew = Abc_NtkFlattenLogicHierarchy( pNtkSkel );
00748     pBox->pData = NULL;
00749     Abc_NtkDelete( pNtkSkel );
00750     return pNtkNew;    
00751 }

void Abc_NtkInsertLatchValues ( Abc_Ntk_t pNtk,
Vec_Int_t vValues 
)

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

Synopsis [Strashes one logic node using its SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 206 of file abcLatch.c.

00207 {
00208     Abc_Obj_t * pLatch;
00209     int i;
00210     Abc_NtkForEachLatch( pNtk, pLatch, i )
00211         pLatch->pData = (void *)(vValues? (Vec_IntEntry(vValues,i)? ABC_INIT_ONE : ABC_INIT_ZERO) : ABC_INIT_DC);
00212 }

Abc_Ntk_t* Abc_NtkInsertNewLogic ( Abc_Ntk_t pNtkH,
Abc_Ntk_t pNtkL 
)

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

Synopsis [Inserts blackboxes into the netlist.]

Description [The first arg is the netlist with blackboxes without logic hierarchy. The second arg is a non-hierarchical netlist derived from the above netlist after processing. This procedure create a new netlist, which is comparable to the original netlist with blackboxes, except that it contains logic nodes from the netlist after processing.]

SideEffects [This procedure silently assumes that blackboxes appear only in the top-level model. If they appear in other models as well, the name of the model and its number were appended to the names of blackbox inputs/outputs.]

SeeAlso []

Definition at line 339 of file abcHie.c.

00340 {
00341     Abc_Lib_t * pDesign;
00342     Abc_Ntk_t * pNtkNew;
00343     Abc_Obj_t * pObjH, * pObjL, * pNetH, * pNetL, * pTermH;
00344     int i, k;
00345 
00346     assert( Abc_NtkIsNetlist(pNtkH) );
00347     assert( Abc_NtkWhiteboxNum(pNtkH) == 0 );
00348     assert( Abc_NtkBlackboxNum(pNtkH) > 0 );
00349 
00350     assert( Abc_NtkIsNetlist(pNtkL) );
00351     assert( Abc_NtkWhiteboxNum(pNtkL) == 0 );
00352     assert( Abc_NtkBlackboxNum(pNtkL) == 0 );
00353 
00354     // prepare the logic network for copying
00355     Abc_NtkCleanCopy( pNtkL );
00356 
00357     // start the network
00358     pNtkNew = Abc_NtkAlloc( pNtkL->ntkType, pNtkL->ntkFunc, 1 );
00359     // duplicate the name and the spec
00360     pNtkNew->pName = Extra_UtilStrsav( pNtkH->pName );
00361     pNtkNew->pSpec = Extra_UtilStrsav( pNtkH->pSpec );
00362 
00363     // make sure every PI/PO has a PI/PO in the processed network
00364     Abc_NtkForEachPi( pNtkH, pObjH, i )
00365     {
00366         pNetH = Abc_ObjFanout0(pObjH);
00367         pNetL = Abc_NtkFindNet( pNtkL, Abc_ObjName(pNetH) );
00368         if ( pNetL == NULL || !Abc_ObjIsPi( Abc_ObjFanin0(pNetL) ) )
00369         {
00370             printf( "Error in Abc_NtkInsertNewLogic(): There is no PI corresponding to the PI %s.\n", Abc_ObjName(pNetH) );
00371             Abc_NtkDelete( pNtkNew );
00372             return NULL;
00373         }
00374         if ( pNetL->pCopy )
00375         {
00376             printf( "Error in Abc_NtkInsertNewLogic(): Primary input %s is repeated twice.\n", Abc_ObjName(pNetH) );
00377             Abc_NtkDelete( pNtkNew );
00378             return NULL;
00379         }
00380         // create the new net
00381         pNetL->pCopy = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pNetH) );
00382         Abc_NtkDupObj( pNtkNew, Abc_ObjFanin0(pNetL), 0 );
00383     }
00384 
00385     // make sure every BB has a PI/PO in the processed network
00386     Abc_NtkForEachBlackbox( pNtkH, pObjH, i )
00387     {
00388         // duplicate the box 
00389         Abc_NtkDupBox( pNtkNew, pObjH, 0 );
00390         pObjH->pCopy->pData = pObjH->pData;
00391         // create PIs
00392         Abc_ObjForEachFanout( pObjH, pTermH, k )
00393         {
00394             pNetH = Abc_ObjFanout0( pTermH );
00395             pNetL = Abc_NtkFindNet( pNtkL, Abc_ObjName(pNetH) );
00396             if ( pNetL == NULL || !Abc_ObjIsPi( Abc_ObjFanin0(pNetL) ) )
00397             {
00398                 printf( "Error in Abc_NtkInsertNewLogic(): There is no PI corresponding to the inpout %s of blackbox %s.\n", Abc_ObjName(pNetH), Abc_ObjName(pObjH) );
00399                 Abc_NtkDelete( pNtkNew );
00400                 return NULL;
00401             }
00402             if ( pNetL->pCopy )
00403             {
00404                 printf( "Error in Abc_NtkInsertNewLogic(): Box output %s is repeated twice.\n", Abc_ObjName(pNetH) );
00405                 Abc_NtkDelete( pNtkNew );
00406                 return NULL;
00407             }
00408             // create net and map the PI
00409             pNetL->pCopy = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pNetH) );
00410             Abc_ObjFanin0(pNetL)->pCopy = pTermH->pCopy;
00411         }
00412     }
00413 
00414     Abc_NtkForEachPo( pNtkH, pObjH, i )
00415     {
00416         pNetH = Abc_ObjFanin0(pObjH);
00417         pNetL = Abc_NtkFindNet( pNtkL, Abc_ObjName(pNetH) );
00418         if ( pNetL == NULL || !Abc_ObjIsPo( Abc_ObjFanout0(pNetL) ) )
00419         {
00420             printf( "Error in Abc_NtkInsertNewLogic(): There is no PO corresponding to the PO %s.\n", Abc_ObjName(pNetH) );
00421             Abc_NtkDelete( pNtkNew );
00422             return NULL;
00423         }
00424         if ( pNetL->pCopy )
00425             continue;
00426         // create the new net
00427         pNetL->pCopy = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pNetH) );
00428         Abc_NtkDupObj( pNtkNew, Abc_ObjFanout0(pNetL), 0 );
00429     }
00430     Abc_NtkForEachBlackbox( pNtkH, pObjH, i )
00431     {
00432         Abc_ObjForEachFanin( pObjH, pTermH, k )
00433         {
00434             char * pName;
00435             pNetH = Abc_ObjFanin0( pTermH );
00436             pName = Abc_ObjName(pNetH);
00437             pNetL = Abc_NtkFindNet( pNtkL, Abc_ObjName(pNetH) );
00438             if ( pNetL == NULL || !Abc_ObjIsPo( Abc_ObjFanout0(pNetL) ) )
00439             {
00440                 printf( "There is no PO corresponding to the input %s of blackbox %s.\n", Abc_ObjName(pNetH), Abc_ObjName(pObjH) );
00441                 Abc_NtkDelete( pNtkNew );
00442                 return NULL;
00443             }
00444             // create net and map the PO
00445             if ( pNetL->pCopy )
00446             {
00447                 if ( Abc_ObjFanout0(pNetL)->pCopy == NULL )
00448                     Abc_ObjFanout0(pNetL)->pCopy = pTermH->pCopy;
00449                 else
00450                     Abc_ObjAddFanin( pTermH->pCopy, pNetL->pCopy );
00451                 continue;
00452             }
00453             pNetL->pCopy = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pNetH) );
00454             Abc_ObjFanout0(pNetL)->pCopy = pTermH->pCopy;
00455         }
00456     }
00457 
00458     // duplicate other objects of the logic network
00459     Abc_NtkForEachObj( pNtkL, pObjL, i )
00460         if ( pObjL->pCopy == NULL && !Abc_ObjIsPo(pObjL) ) // skip POs feeding into PIs
00461             Abc_NtkDupObj( pNtkNew, pObjL, Abc_ObjIsNet(pObjL) );
00462 
00463     // connect objects
00464     Abc_NtkForEachObj( pNtkL, pObjL, i )
00465         Abc_ObjForEachFanin( pObjL, pNetL, k )
00466             if ( pObjL->pCopy )
00467                 Abc_ObjAddFanin( pObjL->pCopy, pNetL->pCopy );
00468 
00469     // transfer the design
00470     pDesign = pNtkH->pDesign;  pNtkH->pDesign = NULL;
00471     assert( Vec_PtrEntry( pDesign->vModules, 0 ) == pNtkH );
00472     Vec_PtrWriteEntry( pDesign->vModules, 0, pNtkNew );
00473     pNtkNew->pDesign = pDesign;
00474 
00475 //Abc_NtkPrintStats( stdout, pNtkH, 0 );
00476 //Abc_NtkPrintStats( stdout, pNtkNew, 0 );
00477 
00478     // check integrity
00479     if ( !Abc_NtkCheck( pNtkNew ) )
00480     {
00481         fprintf( stdout, "Abc_NtkInsertNewLogic(): Network check has failed.\n" );
00482         Abc_NtkDelete( pNtkNew );
00483         return NULL;
00484     }
00485     return pNtkNew;
00486 }

bool Abc_NtkIsAcyclic ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Detects combinational loops.]

Description [This procedure is based on the idea suggested by Donald Chai. As we traverse the network and visit the nodes, we need to distinquish three types of nodes: (1) those that are visited for the first time, (2) those that have been visited in this traversal but are currently not on the traversal path, (3) those that have been visited and are currently on the travesal path. When the node of type (3) is encountered, it means that there is a combinational loop. To mark the three types of nodes, two new values of the traversal IDs are used.]

SideEffects []

SeeAlso []

Definition at line 1116 of file abcDfs.c.

01117 {
01118     Abc_Obj_t * pNode;
01119     int fAcyclic, i;
01120     // set the traversal ID for this DFS ordering
01121     Abc_NtkIncrementTravId( pNtk );   
01122     Abc_NtkIncrementTravId( pNtk );   
01123     // pNode->TravId == pNet->nTravIds      means "pNode is on the path"
01124     // pNode->TravId == pNet->nTravIds - 1  means "pNode is visited but is not on the path"
01125     // pNode->TravId <  pNet->nTravIds - 1  means "pNode is not visited"
01126     // traverse the network to detect cycles
01127     fAcyclic = 1;
01128     Abc_NtkForEachCo( pNtk, pNode, i )
01129     {
01130         pNode = Abc_ObjFanin0Ntk(Abc_ObjFanin0(pNode));
01131         if ( Abc_NodeIsTravIdPrevious(pNode) )
01132             continue;
01133         // traverse the output logic cone
01134         if ( fAcyclic = Abc_NtkIsAcyclic_rec(pNode) )
01135             continue;
01136         // stop as soon as the first loop is detected
01137         fprintf( stdout, " CO \"%s\"\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
01138         break;
01139     }
01140     return fAcyclic;
01141 }

int Abc_NtkIsAcyclicHierarchy ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Returns 0 if the network hierachy contains a cycle.]

Description []

SideEffects []

SeeAlso []

Definition at line 804 of file abcCheck.c.

00805 {
00806     Abc_Ntk_t * pTemp;
00807     int i, RetValue;
00808     assert( Abc_NtkIsNetlist(pNtk) && pNtk->pDesign );
00809     // clear the modules
00810     Vec_PtrForEachEntry( pNtk->pDesign->vModules, pTemp, i )
00811         pTemp->fHieVisited = pTemp->fHiePath = 0;
00812     // traverse
00813     pNtk->fHiePath = 1;
00814     RetValue = Abc_NtkIsAcyclicHierarchy_rec( pNtk );
00815     pNtk->fHiePath = 0;
00816     // clear the modules
00817     Vec_PtrForEachEntry( pNtk->pDesign->vModules, pTemp, i )
00818         pTemp->fHieVisited = pTemp->fHiePath = 0;
00819     return RetValue;
00820 }

static bool Abc_NtkIsAigLogic ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 280 of file abc.h.

00280 { return pNtk->ntkFunc == ABC_FUNC_AIG && pNtk->ntkType == ABC_NTK_LOGIC  ;  }

static bool Abc_NtkIsAigNetlist ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 275 of file abc.h.

00275 { return pNtk->ntkFunc == ABC_FUNC_AIG && pNtk->ntkType == ABC_NTK_NETLIST;  }

static bool Abc_NtkIsBddLogic ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 279 of file abc.h.

00279 { return pNtk->ntkFunc == ABC_FUNC_BDD && pNtk->ntkType == ABC_NTK_LOGIC  ;  }

static bool Abc_NtkIsBlifMvNetlist ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 277 of file abc.h.

00277 { return pNtk->ntkFunc == ABC_FUNC_BLIFMV && pNtk->ntkType == ABC_NTK_NETLIST;  }

static bool Abc_NtkIsComb ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 313 of file abc.h.

00313 { return Abc_NtkLatchNum(pNtk) == 0;                   }

bool Abc_NtkIsDfsOrdered ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Returns 1 if the ordering of nodes is DFS.]

Description []

SideEffects []

SeeAlso []

Definition at line 630 of file abcDfs.c.

00631 {
00632     Abc_Obj_t * pNode, * pFanin;
00633     int i, k;
00634     // set the traversal ID
00635     Abc_NtkIncrementTravId( pNtk );
00636     // mark the CIs
00637     Abc_NtkForEachCi( pNtk, pNode, i )
00638         Abc_NodeSetTravIdCurrent( pNode );
00639     // go through the nodes
00640     Abc_NtkForEachNode( pNtk, pNode, i )
00641     {
00642         // check the fanins of the node
00643         Abc_ObjForEachFanin( pNode, pFanin, k )
00644             if ( !Abc_NodeIsTravIdCurrent(pFanin) )
00645                 return 0;
00646         // check the choices of the node
00647         if ( Abc_NtkIsStrash(pNtk) && Abc_AigNodeIsChoice(pNode) )
00648             for ( pFanin = pNode->pData; pFanin; pFanin = pFanin->pData )
00649                 if ( !Abc_NodeIsTravIdCurrent(pFanin) )
00650                     return 0;
00651         // mark the node as visited
00652         Abc_NodeSetTravIdCurrent( pNode );
00653     }
00654     return 1;
00655 }

static bool Abc_NtkIsLogic ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 264 of file abc.h.

00264 { return pNtk->ntkType == ABC_NTK_LOGIC;       }

static bool Abc_NtkIsMappedLogic ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 281 of file abc.h.

00281 { return pNtk->ntkFunc == ABC_FUNC_MAP && pNtk->ntkType == ABC_NTK_LOGIC  ;  }

static bool Abc_NtkIsMappedNetlist ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 276 of file abc.h.

00276 { return pNtk->ntkFunc == ABC_FUNC_MAP && pNtk->ntkType == ABC_NTK_NETLIST;  }

static bool Abc_NtkIsNetlist ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 263 of file abc.h.

00263 { return pNtk->ntkType == ABC_NTK_NETLIST;     }

static bool Abc_NtkIsSopLogic ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 278 of file abc.h.

00278 { return pNtk->ntkFunc == ABC_FUNC_SOP && pNtk->ntkType == ABC_NTK_LOGIC  ;  }

static bool Abc_NtkIsSopNetlist ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 274 of file abc.h.

00274 { return pNtk->ntkFunc == ABC_FUNC_SOP && pNtk->ntkType == ABC_NTK_NETLIST;  }

static bool Abc_NtkIsStrash ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 265 of file abc.h.

00265 { return pNtk->ntkType == ABC_NTK_STRASH;      }

int Abc_NtkIvyProve ( Abc_Ntk_t **  ppNtk,
void *  pPars 
)

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

Synopsis [Gives the current ABC network to AIG manager for processing.]

Description []

SideEffects []

SeeAlso []

Definition at line 489 of file abcIvy.c.

00490 {
00491     Prove_Params_t * pParams = pPars;
00492     Abc_Ntk_t * pNtk = *ppNtk, * pNtkTemp;
00493     Abc_Obj_t * pObj, * pFanin;
00494     Ivy_Man_t * pMan;
00495     int RetValue;
00496     assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
00497     // experiment with various parameters settings
00498 //    pParams->fUseBdds = 1;
00499 //    pParams->fBddReorder = 1;
00500 //    pParams->nTotalBacktrackLimit = 10000;
00501 
00502     // strash the network if it is not strashed already
00503     if ( !Abc_NtkIsStrash(pNtk) )
00504     {
00505         pNtk = Abc_NtkStrash( pNtkTemp = pNtk, 0, 1, 0 );
00506         Abc_NtkDelete( pNtkTemp );
00507     }
00508 
00509     // check the case when the 0000 simulation pattern detect the bug
00510     pObj = Abc_NtkPo(pNtk,0);
00511     pFanin = Abc_ObjFanin0(pObj);
00512     if ( Abc_ObjFanin0(pObj)->fPhase != (unsigned)Abc_ObjFaninC0(pObj) )
00513     {
00514         pNtk->pModel = ALLOC( int, Abc_NtkPiNum(pNtk) );
00515         memset( pNtk->pModel, 0, sizeof(int) * Abc_NtkPiNum(pNtk) );
00516         return 0;
00517     }
00518 
00519     // if SAT only, solve without iteration
00520     RetValue = Abc_NtkMiterSat( pNtk, 2*(sint64)pParams->nMiteringLimitStart, (sint64)0, 0, NULL, NULL );
00521     if ( RetValue >= 0 )
00522         return RetValue;
00523 
00524     // apply AIG rewriting
00525     if ( pParams->fUseRewriting && Abc_NtkNodeNum(pNtk) > 500 )
00526     {
00527         pParams->fUseRewriting = 0;
00528         pNtk = Abc_NtkBalance( pNtkTemp = pNtk, 0, 0, 0 );          
00529         Abc_NtkDelete( pNtkTemp );
00530         Abc_NtkRewrite( pNtk, 0, 0, 0, 0, 0 );
00531         pNtk = Abc_NtkBalance( pNtkTemp = pNtk, 0, 0, 0 );          
00532         Abc_NtkDelete( pNtkTemp );
00533         Abc_NtkRewrite( pNtk, 0, 0, 0, 0, 0 );
00534         Abc_NtkRefactor( pNtk, 10, 16, 0, 0, 0, 0 );
00535     }
00536 
00537     // convert ABC network into IVY network
00538     pMan = Abc_NtkIvyBefore( pNtk, 0, 0 );
00539 
00540     // solve the CEC problem
00541     RetValue = Ivy_FraigProve( &pMan, pParams );
00542     // convert IVY network into ABC network    
00543     pNtk = Abc_NtkIvyAfter( pNtkTemp = pNtk, pMan, 0, 0 );
00544     Abc_NtkDelete( pNtkTemp );
00545     // transfer model if given
00546     pNtk->pModel = pMan->pData; pMan->pData = NULL;
00547     Ivy_ManStop( pMan );
00548 
00549     // try to prove it using brute force SAT
00550     if ( RetValue < 0 && pParams->fUseBdds )
00551     {
00552         if ( pParams->fVerbose )
00553         {
00554             printf( "Attempting BDDs with node limit %d ...\n", pParams->nBddSizeLimit );
00555             fflush( stdout );
00556         }
00557         pNtk = Abc_NtkCollapse( pNtkTemp = pNtk, pParams->nBddSizeLimit, 0, pParams->fBddReorder, 0 );
00558         if ( pNtk )   
00559         {
00560             Abc_NtkDelete( pNtkTemp );
00561             RetValue = ( (Abc_NtkNodeNum(pNtk) == 1) && (Abc_ObjFanin0(Abc_NtkPo(pNtk,0))->pData == Cudd_ReadLogicZero(pNtk->pManFunc)) );
00562         }
00563         else 
00564             pNtk = pNtkTemp;
00565     }
00566 
00567     // return the result
00568     *ppNtk = pNtk;
00569     return RetValue;
00570 }

bool Abc_NtkLatchIsSelfFeed ( Abc_Obj_t pLatch  ) 

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

Synopsis [Checks if latches form self-loop.]

Description []

SideEffects []

SeeAlso []

Definition at line 65 of file abcLatch.c.

00066 {
00067     Abc_Obj_t * pFanin;
00068     assert( Abc_ObjIsLatch(pLatch) );
00069     pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pLatch));
00070     if ( !Abc_ObjIsBo(pFanin) || !Abc_ObjIsLatch(Abc_ObjFanin0(pFanin)) )
00071         return 0;
00072     return Abc_NtkLatchIsSelfFeed_rec( Abc_ObjFanin0(pFanin), pLatch );
00073 }

static int Abc_NtkLatchNum ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 310 of file abc.h.

00310 { return pNtk->nObjCounts[ABC_OBJ_LATCH];    }

int Abc_NtkLevel ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Computes the number of logic levels not counting PIs/POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 979 of file abcDfs.c.

00980 {
00981     Abc_Obj_t * pNode;
00982     int i, LevelsMax;
00983     // set the CI levels to zero
00984     Abc_NtkForEachCi( pNtk, pNode, i )
00985         pNode->Level = 0;
00986     // perform the traversal
00987     LevelsMax = 0;
00988     Abc_NtkIncrementTravId( pNtk );
00989     Abc_NtkForEachNode( pNtk, pNode, i )
00990     {
00991         Abc_NtkLevel_rec( pNode );
00992         if ( LevelsMax < (int)pNode->Level )
00993             LevelsMax = (int)pNode->Level;
00994     }
00995     return LevelsMax;
00996 }

int Abc_NtkLevelReverse ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Computes the number of logic levels not counting PIs/POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 1009 of file abcDfs.c.

01010 {
01011     Abc_Obj_t * pNode;
01012     int i, LevelsMax;
01013     // set the CO levels to zero
01014     Abc_NtkForEachCo( pNtk, pNode, i )
01015         pNode->Level = 0;
01016     // perform the traversal
01017     LevelsMax = 0;
01018     Abc_NtkIncrementTravId( pNtk );
01019     Abc_NtkForEachNode( pNtk, pNode, i )
01020     {
01021         Abc_NtkLevelReverse_rec( pNode );
01022         if ( LevelsMax < (int)pNode->Level )
01023             LevelsMax = (int)pNode->Level;
01024     }
01025     return LevelsMax;
01026 }

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 572 of file abcUtil.c.

00573 {
00574     Abc_Obj_t * pObj;
00575     int i;
00576     Abc_NtkForEachObj( pNtk, pObj, i )
00577         pObj->pCopy = Vec_PtrEntry( vCopies, i );
00578 }

bool 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 759 of file abcUtil.c.

00760 {
00761     Abc_Obj_t * pNode, * pDriver;
00762     int i;
00763     assert( Abc_NtkIsLogic(pNtk) );
00764     Abc_NtkIncrementTravId( pNtk );
00765     Abc_NtkForEachCo( pNtk, pNode, i ) 
00766     {
00767         // if the driver is complemented, this is an error
00768         pDriver = Abc_ObjFanin0(pNode);
00769         if ( Abc_ObjFaninC0(pNode) )
00770             return 0;
00771         // if the driver is a CI and has different name, this is an error
00772         if ( Abc_ObjIsCi(pDriver) && strcmp(Abc_ObjName(pDriver), Abc_ObjName(pNode)) )
00773             return 0;
00774         // if the driver is visited for the first time, remember the CO name
00775         if ( !Abc_NodeIsTravIdCurrent(pDriver) )
00776         {
00777             pDriver->pNext = (Abc_Obj_t *)Abc_ObjName(pNode);
00778             Abc_NodeSetTravIdCurrent(pDriver);
00779             continue;
00780         }
00781         // the driver has second CO - if they have different name, this is an error
00782         if ( strcmp((char *)pDriver->pNext, Abc_ObjName(pNode)) ) // diff names
00783             return 0;
00784     }
00785     return 1;
00786 }

void Abc_NtkLogicMakeDirectSops ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Removes complemented SOP covers.]

Description []

SideEffects []

SeeAlso []

Definition at line 154 of file abcFunc.c.

00155 {
00156     DdManager * dd;
00157     DdNode * bFunc;
00158     Vec_Str_t * vCube;
00159     Abc_Obj_t * pNode;
00160     int nFaninsMax, fFound, i;
00161 
00162     assert( Abc_NtkHasSop(pNtk) );
00163 
00164     // check if there are nodes with complemented SOPs
00165     fFound = 0;
00166     Abc_NtkForEachNode( pNtk, pNode, i )
00167         if ( Abc_SopIsComplement(pNode->pData) )
00168         {
00169             fFound = 1;
00170             break;
00171         }
00172     if ( !fFound )
00173         return;
00174 
00175     // start the BDD package
00176     nFaninsMax = Abc_NtkGetFaninMax( pNtk );
00177     if ( nFaninsMax == 0 )
00178         printf( "Warning: The network has only constant nodes.\n" );
00179     dd = Cudd_Init( nFaninsMax, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
00180 
00181     // change the cover of negated nodes
00182     vCube = Vec_StrAlloc( 100 );
00183     Abc_NtkForEachNode( pNtk, pNode, i )
00184         if ( Abc_SopIsComplement(pNode->pData) )
00185         {
00186             bFunc = Abc_ConvertSopToBdd( dd, pNode->pData );  Cudd_Ref( bFunc );
00187             pNode->pData = Abc_ConvertBddToSop( pNtk->pManFunc, dd, bFunc, bFunc, Abc_ObjFaninNum(pNode), 0, vCube, 1 );
00188             Cudd_RecursiveDeref( dd, bFunc );
00189             assert( !Abc_SopIsComplement(pNode->pData) );
00190         }
00191     Vec_StrFree( vCube );
00192     Extra_StopManager( dd );
00193 }

int Abc_NtkLogicMakeSimpleCos ( Abc_Ntk_t pNtk,
bool  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 804 of file abcUtil.c.

00805 {
00806     Abc_Obj_t * pNode, * pDriver;
00807     int i, nDupGates = 0;
00808     assert( Abc_NtkIsLogic(pNtk) );
00809     Abc_NtkIncrementTravId( pNtk );
00810     Abc_NtkForEachCo( pNtk, pNode, i ) 
00811     {
00812         // if the driver is complemented, this is an error
00813         pDriver = Abc_ObjFanin0(pNode);
00814         if ( Abc_ObjFaninC0(pNode) )
00815         {
00816             Abc_NtkFixCoDriverProblem( pDriver, pNode, fDuplicate );
00817             nDupGates++;
00818             continue;
00819         }
00820         // if the driver is a CI and has different name, this is an error
00821         if ( Abc_ObjIsCi(pDriver) && strcmp(Abc_ObjName(pDriver), Abc_ObjName(pNode)) )
00822         {
00823             Abc_NtkFixCoDriverProblem( pDriver, pNode, fDuplicate );
00824             nDupGates++;
00825             continue;
00826         }
00827         // if the driver is visited for the first time, remember the CO name
00828         if ( !Abc_NodeIsTravIdCurrent(pDriver) )
00829         {
00830             pDriver->pNext = (Abc_Obj_t *)Abc_ObjName(pNode);
00831             Abc_NodeSetTravIdCurrent(pDriver);
00832             continue;
00833         }
00834         // the driver has second CO - if they have different name, this is an error
00835         if ( strcmp((char *)pDriver->pNext, Abc_ObjName(pNode)) ) // diff names
00836         {
00837             Abc_NtkFixCoDriverProblem( pDriver, pNode, fDuplicate );
00838             nDupGates++;
00839             continue;
00840         }
00841     }
00842     assert( Abc_NtkLogicHasSimpleCos(pNtk) );
00843     return nDupGates;
00844 }

void Abc_NtkMakeComb ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Converts the network to combinational.]

Description []

SideEffects []

SeeAlso []

Definition at line 1096 of file abcNtk.c.

01097 {
01098     Abc_Obj_t * pObj;
01099     int i;
01100 
01101     if ( Abc_NtkIsComb(pNtk) )
01102         return;
01103 
01104     assert( !Abc_NtkIsNetlist(pNtk) );
01105     assert( Abc_NtkHasOnlyLatchBoxes(pNtk) );
01106 
01107     // detach the latches
01108 //    Abc_NtkForEachLatch( pNtk, pObj, i )
01109     Vec_PtrForEachEntryReverse( pNtk->vBoxes, pObj, i )
01110         Abc_NtkDeleteObj( pObj );
01111     assert( Abc_NtkLatchNum(pNtk) == 0 );
01112     assert( Abc_NtkBoxNum(pNtk) == 0 );
01113 
01114     // move CIs to become PIs
01115     Vec_PtrClear( pNtk->vPis );
01116     Abc_NtkForEachCi( pNtk, pObj, i )
01117     {
01118         if ( Abc_ObjIsBo(pObj) )
01119         {
01120             pObj->Type = ABC_OBJ_PI;
01121             pNtk->nObjCounts[ABC_OBJ_PI]++;
01122             pNtk->nObjCounts[ABC_OBJ_BO]--;
01123         }
01124         Vec_PtrPush( pNtk->vPis, pObj );
01125     }
01126     assert( Abc_NtkBoNum(pNtk) == 0 );
01127 
01128     // move COs to become POs
01129     Vec_PtrClear( pNtk->vPos );
01130     Abc_NtkForEachCo( pNtk, pObj, i )
01131     {
01132         if ( Abc_ObjIsBi(pObj) )
01133         {
01134             pObj->Type = ABC_OBJ_PO;
01135             pNtk->nObjCounts[ABC_OBJ_PO]++;
01136             pNtk->nObjCounts[ABC_OBJ_BI]--;
01137         }
01138         Vec_PtrPush( pNtk->vPos, pObj );
01139     }
01140     assert( Abc_NtkBiNum(pNtk) == 0 );
01141 
01142     if ( !Abc_NtkCheck( pNtk ) )
01143         fprintf( stdout, "Abc_NtkMakeComb(): Network check has failed.\n" );
01144 }

Vec_Ptr_t* Abc_NtkManCutReadCutLarge ( Abc_ManCut_t p  ) 

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

Synopsis [Returns the leaves of the cone.]

Description []

SideEffects []

SeeAlso []

Definition at line 632 of file abcReconv.c.

00633 {
00634     return p->vConeLeaves;
00635 }

Vec_Ptr_t* Abc_NtkManCutReadCutSmall ( Abc_ManCut_t p  ) 

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

Synopsis [Returns the leaves of the cone.]

Description []

SideEffects []

SeeAlso []

Definition at line 648 of file abcReconv.c.

00649 {
00650     return p->vNodeLeaves;
00651 }

Vec_Ptr_t* Abc_NtkManCutReadVisited ( Abc_ManCut_t p  ) 

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

Synopsis [Returns the leaves of the cone.]

Description []

SideEffects []

SeeAlso []

Definition at line 664 of file abcReconv.c.

00665 {
00666     return p->vVisited;
00667 }

Abc_ManCut_t* Abc_NtkManCutStart ( int  nNodeSizeMax,
int  nConeSizeMax,
int  nNodeFanStop,
int  nConeFanStop 
)

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

Synopsis [Starts the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 583 of file abcReconv.c.

00584 {
00585     Abc_ManCut_t * p;
00586     p = ALLOC( Abc_ManCut_t, 1 );
00587     memset( p, 0, sizeof(Abc_ManCut_t) );
00588     p->vNodeLeaves  = Vec_PtrAlloc( 100 );
00589     p->vConeLeaves  = Vec_PtrAlloc( 100 );
00590     p->vVisited     = Vec_PtrAlloc( 100 );
00591     p->vLevels      = Vec_VecAlloc( 100 );
00592     p->vNodesTfo    = Vec_PtrAlloc( 100 );
00593     p->nNodeSizeMax = nNodeSizeMax;
00594     p->nConeSizeMax = nConeSizeMax;
00595     p->nNodeFanStop = nNodeFanStop;
00596     p->nConeFanStop = nConeFanStop;
00597     return p;
00598 }

void Abc_NtkManCutStop ( Abc_ManCut_t p  ) 

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

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 611 of file abcReconv.c.

00612 {
00613     Vec_PtrFree( p->vNodeLeaves );
00614     Vec_PtrFree( p->vConeLeaves );
00615     Vec_PtrFree( p->vVisited    );
00616     Vec_VecFree( p->vLevels );
00617     Vec_PtrFree( p->vNodesTfo );
00618     free( p );
00619 }

int Abc_NtkMapToSop ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Unmaps the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 1013 of file abcFunc.c.

01014 {
01015     extern void * Abc_FrameReadLibGen();                    
01016     Abc_Obj_t * pNode;
01017     char * pSop;
01018     int i;
01019 
01020     assert( Abc_NtkHasMapping(pNtk) );
01021     // update the functionality manager
01022     assert( pNtk->pManFunc == Abc_FrameReadLibGen() );
01023     pNtk->pManFunc = Extra_MmFlexStart();
01024     pNtk->ntkFunc  = ABC_FUNC_SOP;
01025     // update the nodes
01026     Abc_NtkForEachNode( pNtk, pNode, i )
01027     {
01028         pSop = Mio_GateReadSop(pNode->pData);
01029         assert( Abc_SopGetVarNum(pSop) == Abc_ObjFaninNum(pNode) );
01030         pNode->pData = Abc_SopRegister( pNtk->pManFunc, pSop );
01031     }
01032     return 1;
01033 }

int Abc_NtkMinimumBase ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Makes nodes minimum base.]

Description [Returns the number of changed nodes.]

SideEffects []

SeeAlso []

Definition at line 44 of file abcMinBase.c.

00045 {
00046     Abc_Obj_t * pNode;
00047     int i, Counter;
00048     assert( Abc_NtkIsBddLogic(pNtk) );
00049     Counter = 0;
00050     Abc_NtkForEachNode( pNtk, pNode, i )
00051         Counter += Abc_NodeMinimumBase( pNode );
00052     return Counter;
00053 }

Abc_Ntk_t* Abc_NtkMiter ( Abc_Ntk_t pNtk1,
Abc_Ntk_t pNtk2,
int  fComb,
int  nPartSize 
)

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

Synopsis [Derives the miter of two networks.]

Description [Preprocesses the networks to make sure that they are strashed.]

SideEffects []

SeeAlso []

Definition at line 53 of file abcMiter.c.

00054 {
00055     Abc_Ntk_t * pTemp = NULL;
00056     int fRemove1, fRemove2;
00057     assert( Abc_NtkHasOnlyLatchBoxes(pNtk1) );
00058     assert( Abc_NtkHasOnlyLatchBoxes(pNtk2) );
00059     // check that the networks have the same PIs/POs/latches
00060     if ( !Abc_NtkCompareSignals( pNtk1, pNtk2, 0, fComb ) )
00061         return NULL;
00062     // make sure the circuits are strashed 
00063     fRemove1 = (!Abc_NtkIsStrash(pNtk1)) && (pNtk1 = Abc_NtkStrash(pNtk1, 0, 0, 0));
00064     fRemove2 = (!Abc_NtkIsStrash(pNtk2)) && (pNtk2 = Abc_NtkStrash(pNtk2, 0, 0, 0));
00065     if ( pNtk1 && pNtk2 )
00066         pTemp = Abc_NtkMiterInt( pNtk1, pNtk2, fComb, nPartSize );
00067     if ( fRemove1 )  Abc_NtkDelete( pNtk1 );
00068     if ( fRemove2 )  Abc_NtkDelete( pNtk2 );
00069     return pTemp;
00070 }

void Abc_NtkMiterAddCone ( Abc_Ntk_t pNtk,
Abc_Ntk_t pNtkMiter,
Abc_Obj_t pRoot 
)

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

Synopsis [Performs mitering for one network.]

Description []

SideEffects []

SeeAlso []

Definition at line 226 of file abcMiter.c.

00227 {
00228     Vec_Ptr_t * vNodes;
00229     Abc_Obj_t * pNode;
00230     int i;
00231     // map the constant nodes
00232     Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkMiter);
00233     // perform strashing
00234     vNodes = Abc_NtkDfsNodes( pNtk, &pRoot, 1 );
00235     Vec_PtrForEachEntry( vNodes, pNode, i )
00236         if ( Abc_AigNodeIsAnd(pNode) )
00237             pNode->pCopy = Abc_AigAnd( pNtkMiter->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
00238     Vec_PtrFree( vNodes );
00239 }

Abc_Ntk_t* Abc_NtkMiterAnd ( Abc_Ntk_t pNtk1,
Abc_Ntk_t pNtk2,
int  fOr,
int  fCompl2 
)

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

Synopsis [Derives the AND of two miters.]

Description [The network should have the same names of PIs.]

SideEffects []

SeeAlso []

Definition at line 340 of file abcMiter.c.

00341 {
00342     char Buffer[1000];
00343     Abc_Ntk_t * pNtkMiter;
00344     Abc_Obj_t * pOutput1, * pOutput2;
00345     Abc_Obj_t * pRoot1, * pRoot2, * pMiter;
00346 
00347     assert( Abc_NtkIsStrash(pNtk1) );
00348     assert( Abc_NtkIsStrash(pNtk2) );
00349     assert( 1 == Abc_NtkCoNum(pNtk1) );
00350     assert( 1 == Abc_NtkCoNum(pNtk2) );
00351     assert( 0 == Abc_NtkLatchNum(pNtk1) );
00352     assert( 0 == Abc_NtkLatchNum(pNtk2) );
00353     assert( Abc_NtkCiNum(pNtk1) == Abc_NtkCiNum(pNtk2) );
00354     assert( Abc_NtkHasOnlyLatchBoxes(pNtk1) );
00355     assert( Abc_NtkHasOnlyLatchBoxes(pNtk2) );
00356 
00357     // start the new network
00358     pNtkMiter = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
00359 //    sprintf( Buffer, "%s_%s_miter", pNtk1->pName, pNtk2->pName );
00360     sprintf( Buffer, "product" );
00361     pNtkMiter->pName = Extra_UtilStrsav(Buffer);
00362 
00363     // perform strashing
00364     Abc_NtkMiterPrepare( pNtk1, pNtk2, pNtkMiter, 1, -1 );
00365     Abc_NtkMiterAddOne( pNtk1, pNtkMiter );
00366     Abc_NtkMiterAddOne( pNtk2, pNtkMiter );
00367 //    Abc_NtkMiterFinalize( pNtk1, pNtk2, pNtkMiter, 1 );
00368     pRoot1 = Abc_NtkPo(pNtk1,0);
00369     pRoot2 = Abc_NtkPo(pNtk2,0);
00370     pOutput1 = Abc_ObjNotCond( Abc_ObjFanin0(pRoot1)->pCopy, Abc_ObjFaninC0(pRoot1) );
00371     pOutput2 = Abc_ObjNotCond( Abc_ObjFanin0(pRoot2)->pCopy, Abc_ObjFaninC0(pRoot2) ^ fCompl2 );
00372     
00373     // create the miter of the two outputs
00374     if ( fOr )
00375         pMiter = Abc_AigOr( pNtkMiter->pManFunc, pOutput1, pOutput2 );
00376     else
00377         pMiter = Abc_AigAnd( pNtkMiter->pManFunc, pOutput1, pOutput2 );
00378     Abc_ObjAddFanin( Abc_NtkPo(pNtkMiter,0), pMiter );
00379 
00380     // make sure that everything is okay
00381     if ( !Abc_NtkCheck( pNtkMiter ) )
00382     {
00383         printf( "Abc_NtkMiterAnd: The network check has failed.\n" );
00384         Abc_NtkDelete( pNtkMiter );
00385         return NULL;
00386     }
00387     return pNtkMiter;
00388 }

Abc_Ntk_t* Abc_NtkMiterCofactor ( Abc_Ntk_t pNtk,
Vec_Int_t vPiValues 
)

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

Synopsis [Derives the cofactor of the miter w.r.t. the set of vars.]

Description [The array of variable values contains -1/0/1 for each PI. -1 means this PI remains, 0/1 means this PI is set to 0/1.]

SideEffects []

SeeAlso []

Definition at line 403 of file abcMiter.c.

00404 {
00405     char Buffer[1000];
00406     Abc_Ntk_t * pNtkMiter;
00407     Abc_Obj_t * pRoot, * pOutput1;
00408     int Value, i;
00409 
00410     assert( Abc_NtkIsStrash(pNtk) );
00411     assert( 1 == Abc_NtkCoNum(pNtk) );
00412     assert( Abc_NtkHasOnlyLatchBoxes(pNtk) );
00413 
00414     // start the new network
00415     pNtkMiter = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
00416     sprintf( Buffer, "%s_miter", pNtk->pName );
00417     pNtkMiter->pName = Extra_UtilStrsav(Buffer);
00418 
00419     // get the root output
00420     pRoot = Abc_NtkCo( pNtk, 0 );
00421 
00422     // perform strashing
00423     Abc_NtkMiterPrepare( pNtk, pNtk, pNtkMiter, 1, -1 );
00424     // set the first cofactor
00425     Vec_IntForEachEntry( vPiValues, Value, i )
00426     {
00427         if ( Value == -1 )
00428             continue;
00429         if ( Value == 0 )
00430         {
00431             Abc_NtkCi(pNtk, i)->pCopy = Abc_ObjNot( Abc_AigConst1(pNtkMiter) );
00432             continue;
00433         }
00434         if ( Value == 1 )
00435         {
00436             Abc_NtkCi(pNtk, i)->pCopy = Abc_AigConst1(pNtkMiter);
00437             continue;
00438         }
00439         assert( 0 );
00440     }
00441     // add the first cofactor
00442     Abc_NtkMiterAddCone( pNtk, pNtkMiter, pRoot );
00443 
00444     // save the output
00445     pOutput1 = Abc_ObjNotCond( Abc_ObjFanin0(pRoot)->pCopy, Abc_ObjFaninC0(pRoot) );
00446 
00447     // create the miter of the two outputs
00448     Abc_ObjAddFanin( Abc_NtkPo(pNtkMiter,0), pOutput1 );
00449 
00450     // make sure that everything is okay
00451     if ( !Abc_NtkCheck( pNtkMiter ) )
00452     {
00453         printf( "Abc_NtkMiterCofactor: The network check has failed.\n" );
00454         Abc_NtkDelete( pNtkMiter );
00455         return NULL;
00456     }
00457     return pNtkMiter;
00458 }

Abc_Ntk_t* Abc_NtkMiterForCofactors ( Abc_Ntk_t pNtk,
int  Out,
int  In1,
int  In2 
)

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

Synopsis [Derives the miter of two cofactors of one output.]

Description []

SideEffects []

SeeAlso []

Definition at line 470 of file abcMiter.c.

00471 {
00472     char Buffer[1000];
00473     Abc_Ntk_t * pNtkMiter;
00474     Abc_Obj_t * pRoot, * pOutput1, * pOutput2, * pMiter;
00475 
00476     assert( Abc_NtkIsStrash(pNtk) );
00477     assert( Out < Abc_NtkCoNum(pNtk) );
00478     assert( In1 < Abc_NtkCiNum(pNtk) );
00479     assert( In2 < Abc_NtkCiNum(pNtk) );
00480     assert( Abc_NtkHasOnlyLatchBoxes(pNtk) );
00481 
00482     // start the new network
00483     pNtkMiter = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
00484     sprintf( Buffer, "%s_miter", Abc_ObjName(Abc_NtkCo(pNtk, Out)) );
00485     pNtkMiter->pName = Extra_UtilStrsav(Buffer);
00486 
00487     // get the root output
00488     pRoot = Abc_NtkCo( pNtk, Out );
00489 
00490     // perform strashing
00491     Abc_NtkMiterPrepare( pNtk, pNtk, pNtkMiter, 1, -1 );
00492     // set the first cofactor
00493     Abc_NtkCi(pNtk, In1)->pCopy = Abc_ObjNot( Abc_AigConst1(pNtkMiter) );
00494     if ( In2 >= 0 )
00495     Abc_NtkCi(pNtk, In2)->pCopy = Abc_AigConst1(pNtkMiter);
00496     // add the first cofactor
00497     Abc_NtkMiterAddCone( pNtk, pNtkMiter, pRoot );
00498 
00499     // save the output
00500     pOutput1 = Abc_ObjFanin0(pRoot)->pCopy;
00501 
00502     // set the second cofactor
00503     Abc_NtkCi(pNtk, In1)->pCopy = Abc_AigConst1(pNtkMiter);
00504     if ( In2 >= 0 )
00505     Abc_NtkCi(pNtk, In2)->pCopy = Abc_ObjNot( Abc_AigConst1(pNtkMiter) );
00506     // add the second cofactor
00507     Abc_NtkMiterAddCone( pNtk, pNtkMiter, pRoot );
00508 
00509     // save the output
00510     pOutput2 = Abc_ObjFanin0(pRoot)->pCopy;
00511 
00512     // create the miter of the two outputs
00513     pMiter = Abc_AigXor( pNtkMiter->pManFunc, pOutput1, pOutput2 );
00514     Abc_ObjAddFanin( Abc_NtkPo(pNtkMiter,0), pMiter );
00515 
00516     // make sure that everything is okay
00517     if ( !Abc_NtkCheck( pNtkMiter ) )
00518     {
00519         printf( "Abc_NtkMiter: The network check has failed.\n" );
00520         Abc_NtkDelete( pNtkMiter );
00521         return NULL;
00522     }
00523     return pNtkMiter;
00524 }

int Abc_NtkMiterIsConstant ( Abc_Ntk_t pMiter  ) 

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

Synopsis [Checks the status of the miter.]

Description [Return 0 if the miter is sat for at least one output. Return 1 if the miter is unsat for all its outputs. Returns -1 if the miter is undecided for some outputs.]

SideEffects []

SeeAlso []

Definition at line 635 of file abcMiter.c.

00636 {
00637     Abc_Obj_t * pNodePo, * pChild;
00638     int i;
00639     assert( Abc_NtkIsStrash(pMiter) );
00640     Abc_NtkForEachPo( pMiter, pNodePo, i )
00641     {
00642         pChild = Abc_ObjChild0( pNodePo );
00643         if ( Abc_AigNodeIsConst(pChild) )
00644         {
00645             assert( Abc_ObjRegular(pChild) == Abc_AigConst1(pMiter) );
00646             if ( !Abc_ObjIsComplement(pChild) )
00647             {
00648                 // if the miter is constant 1, return immediately
00649 //                printf( "MITER IS CONSTANT 1!\n" );
00650                 return 0;
00651             }
00652         }
00653         // if the miter is undecided (or satisfiable), return immediately
00654         else 
00655             return -1;
00656     }
00657     // return 1, meaning all outputs are constant zero
00658     return 1;
00659 }

int Abc_NtkMiterProve ( Abc_Ntk_t **  ppNtk,
void *  pPars 
)

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

Synopsis [Attempts to solve the miter using a number of tricks.]

Description [Returns -1 if timed out; 0 if SAT; 1 if UNSAT. Returns a simplified version of the original network (or a constant 0 network). In case the network is not a constant zero and a SAT assignment is found, pNtk->pModel contains a satisfying assignment.]

SideEffects []

SeeAlso []

Definition at line 54 of file abcProve.c.

00055 {
00056     Prove_Params_t * pParams = pPars;
00057     Abc_Ntk_t * pNtk, * pNtkTemp;
00058     int RetValue, nIter, nSatFails, Counter, clk, timeStart = clock();
00059     sint64 nSatConfs, nSatInspects, nInspectLimit;
00060 
00061     // get the starting network
00062     pNtk = *ppNtk;
00063     assert( Abc_NtkIsStrash(pNtk) );
00064     assert( Abc_NtkPoNum(pNtk) == 1 );
00065  
00066     if ( pParams->fVerbose )
00067     {
00068         printf( "RESOURCE LIMITS: Iterations = %d. Rewriting = %s. Fraiging = %s.\n",
00069             pParams->nItersMax, pParams->fUseRewriting? "yes":"no", pParams->fUseFraiging? "yes":"no" );
00070         printf( "Mitering = %d (%3.1f).  Rewriting = %d (%3.1f).  Fraiging = %d (%3.1f).\n", 
00071             pParams->nMiteringLimitStart,  pParams->nMiteringLimitMulti, 
00072             pParams->nRewritingLimitStart, pParams->nRewritingLimitMulti,
00073             pParams->nFraigingLimitStart,  pParams->nFraigingLimitMulti );
00074         printf( "Mitering last = %d.\n", 
00075             pParams->nMiteringLimitLast );
00076     }
00077 
00078     // if SAT only, solve without iteration
00079     if ( !pParams->fUseRewriting && !pParams->fUseFraiging )
00080     {
00081         clk = clock();
00082         RetValue = Abc_NtkMiterSat( pNtk, (sint64)pParams->nMiteringLimitLast, (sint64)0, 0, NULL, NULL );
00083         Abc_NtkMiterPrint( pNtk, "SAT solving", clk, pParams->fVerbose );
00084         *ppNtk = pNtk;
00085         return RetValue;
00086     }
00087 
00088     // check the current resource limits
00089     for ( nIter = 0; nIter < pParams->nItersMax; nIter++ )
00090     {
00091         if ( pParams->fVerbose )
00092         {
00093             printf( "ITERATION %2d : Confs = %6d. FraigBTL = %3d. \n", nIter+1, 
00094                  (int)(pParams->nMiteringLimitStart * pow(pParams->nMiteringLimitMulti,nIter)), 
00095                  (int)(pParams->nFraigingLimitStart * pow(pParams->nFraigingLimitMulti,nIter)) );
00096             fflush( stdout );
00097         }
00098 
00099         // try brute-force SAT
00100         clk = clock();
00101         nInspectLimit = pParams->nTotalInspectLimit? pParams->nTotalInspectLimit - pParams->nTotalInspectsMade : 0;
00102         RetValue = Abc_NtkMiterSat( pNtk, (sint64)(pParams->nMiteringLimitStart * pow(pParams->nMiteringLimitMulti,nIter)), (sint64)nInspectLimit, 0, &nSatConfs, &nSatInspects );
00103         Abc_NtkMiterPrint( pNtk, "SAT solving", clk, pParams->fVerbose );
00104         if ( RetValue >= 0 )
00105             break;
00106 
00107         // add to the number of backtracks and inspects
00108         pParams->nTotalBacktracksMade += nSatConfs;
00109         pParams->nTotalInspectsMade   += nSatInspects;
00110         // check if global resource limit is reached
00111         if ( (pParams->nTotalBacktrackLimit && pParams->nTotalBacktracksMade >= pParams->nTotalBacktrackLimit) ||
00112              (pParams->nTotalInspectLimit   && pParams->nTotalInspectsMade   >= pParams->nTotalInspectLimit) )
00113         {
00114             printf( "Reached global limit on conflicts/inspects. Quitting.\n" );
00115             *ppNtk = pNtk;
00116             return -1;
00117         }
00118 
00119         // try rewriting
00120         if ( pParams->fUseRewriting )
00121         {
00122             clk = clock();
00123             Counter = (int)(pParams->nRewritingLimitStart * pow(pParams->nRewritingLimitMulti,nIter));
00124 //            Counter = 1;
00125             while ( 1 )
00126             {
00127 /*
00128                 extern Abc_Ntk_t * Abc_NtkIvyResyn( Abc_Ntk_t * pNtk, int fUpdateLevel, int fVerbose );
00129                 pNtk = Abc_NtkIvyResyn( pNtkTemp = pNtk, 0, 0 );  Abc_NtkDelete( pNtkTemp );
00130                 if ( (RetValue = Abc_NtkMiterIsConstant(pNtk)) >= 0 )
00131                     break;
00132                 if ( --Counter == 0 )
00133                     break;
00134 */
00135 /*
00136                 Abc_NtkRewrite( pNtk, 0, 0, 0, 0, 0 );
00137                 if ( (RetValue = Abc_NtkMiterIsConstant(pNtk)) >= 0 )
00138                     break;
00139                 if ( --Counter == 0 )
00140                     break;
00141 */
00142                 Abc_NtkRewrite( pNtk, 0, 0, 0, 0, 0 );
00143                 if ( (RetValue = Abc_NtkMiterIsConstant(pNtk)) >= 0 )
00144                     break;
00145                 if ( --Counter == 0 )
00146                     break;
00147                 Abc_NtkRefactor( pNtk, 10, 16, 0, 0, 0, 0 );
00148                 if ( (RetValue = Abc_NtkMiterIsConstant(pNtk)) >= 0 )
00149                     break;
00150                 if ( --Counter == 0 )
00151                     break;
00152                 pNtk = Abc_NtkBalance( pNtkTemp = pNtk, 0, 0, 0 );  Abc_NtkDelete( pNtkTemp );
00153                 if ( (RetValue = Abc_NtkMiterIsConstant(pNtk)) >= 0 )
00154                     break;
00155                 if ( --Counter == 0 )
00156                     break;
00157             }
00158             Abc_NtkMiterPrint( pNtk, "Rewriting  ", clk, pParams->fVerbose );
00159         }
00160  
00161         if ( pParams->fUseFraiging )
00162         {
00163             // try FRAIGing
00164             clk = clock();
00165             nInspectLimit = pParams->nTotalInspectLimit? pParams->nTotalInspectLimit - pParams->nTotalInspectsMade : 0;
00166             pNtk = Abc_NtkMiterFraig( pNtkTemp = pNtk, (int)(pParams->nFraigingLimitStart * pow(pParams->nFraigingLimitMulti,nIter)), nInspectLimit, &RetValue, &nSatFails, &nSatConfs, &nSatInspects );  Abc_NtkDelete( pNtkTemp );
00167             Abc_NtkMiterPrint( pNtk, "FRAIGing   ", clk, pParams->fVerbose );
00168 //            printf( "NumFails = %d\n", nSatFails );
00169             if ( RetValue >= 0 )
00170                 break;
00171 
00172             // add to the number of backtracks and inspects
00173             pParams->nTotalBacktracksMade += nSatConfs;
00174             pParams->nTotalInspectsMade += nSatInspects;
00175             // check if global resource limit is reached
00176             if ( (pParams->nTotalBacktrackLimit && pParams->nTotalBacktracksMade >= pParams->nTotalBacktrackLimit) ||
00177                  (pParams->nTotalInspectLimit   && pParams->nTotalInspectsMade   >= pParams->nTotalInspectLimit) )
00178             {
00179                 printf( "Reached global limit on conflicts/inspects. Quitting.\n" );
00180                 *ppNtk = pNtk;
00181                 return -1;
00182             }
00183         }
00184 
00185     }    
00186 
00187     // try to prove it using brute force SAT
00188     if ( RetValue < 0 && pParams->fUseBdds )
00189     {
00190         if ( pParams->fVerbose )
00191         {
00192             printf( "Attempting BDDs with node limit %d ...\n", pParams->nBddSizeLimit );
00193             fflush( stdout );
00194         }
00195         clk = clock();
00196         pNtk = Abc_NtkCollapse( pNtkTemp = pNtk, pParams->nBddSizeLimit, 0, pParams->fBddReorder, 0 );
00197         if ( pNtk )   
00198         {
00199             Abc_NtkDelete( pNtkTemp );
00200             RetValue = ( (Abc_NtkNodeNum(pNtk) == 1) && (Abc_ObjFanin0(Abc_NtkPo(pNtk,0))->pData == Cudd_ReadLogicZero(pNtk->pManFunc)) );
00201         }
00202         else 
00203             pNtk = pNtkTemp;
00204         Abc_NtkMiterPrint( pNtk, "BDD building", clk, pParams->fVerbose );
00205     }
00206 
00207     if ( RetValue < 0 )
00208     {
00209         if ( pParams->fVerbose )
00210         {
00211             printf( "Attempting SAT with conflict limit %d ...\n", pParams->nMiteringLimitLast );
00212             fflush( stdout );
00213         }
00214         clk = clock();
00215         nInspectLimit = pParams->nTotalInspectLimit? pParams->nTotalInspectLimit - pParams->nTotalInspectsMade : 0;
00216         RetValue = Abc_NtkMiterSat( pNtk, (sint64)pParams->nMiteringLimitLast, (sint64)nInspectLimit, 0, NULL, NULL );
00217         Abc_NtkMiterPrint( pNtk, "SAT solving", clk, pParams->fVerbose );
00218     }
00219 
00220     // assign the model if it was proved by rewriting (const 1 miter)
00221     if ( RetValue == 0 && pNtk->pModel == NULL )
00222     {
00223         pNtk->pModel = ALLOC( int, Abc_NtkCiNum(pNtk) );
00224         memset( pNtk->pModel, 0, sizeof(int) * Abc_NtkCiNum(pNtk) );
00225     }
00226     *ppNtk = pNtk;
00227     return RetValue;
00228 }

Abc_Ntk_t* Abc_NtkMiterQuantify ( Abc_Ntk_t pNtk,
int  In,
int  fExist 
)

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

Synopsis [Derives the miter of two cofactors of one output.]

Description []

SideEffects []

SeeAlso []

Definition at line 538 of file abcMiter.c.

00539 {
00540     Abc_Ntk_t * pNtkMiter;
00541     Abc_Obj_t * pRoot, * pOutput1, * pOutput2, * pMiter;
00542 
00543     assert( Abc_NtkIsStrash(pNtk) );
00544     assert( 1 == Abc_NtkCoNum(pNtk) );
00545     assert( In < Abc_NtkCiNum(pNtk) );
00546     assert( Abc_NtkHasOnlyLatchBoxes(pNtk) );
00547 
00548     // start the new network
00549     pNtkMiter = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
00550     pNtkMiter->pName = Extra_UtilStrsav( Abc_ObjName(Abc_NtkCo(pNtk, 0)) );
00551 
00552     // get the root output
00553     pRoot = Abc_NtkCo( pNtk, 0 );
00554 
00555     // perform strashing
00556     Abc_NtkMiterPrepare( pNtk, pNtk, pNtkMiter, 1, -1 );
00557     // set the first cofactor
00558     Abc_NtkCi(pNtk, In)->pCopy = Abc_ObjNot( Abc_AigConst1(pNtkMiter) );
00559     // add the first cofactor
00560     Abc_NtkMiterAddCone( pNtk, pNtkMiter, pRoot );
00561     // save the output
00562 //    pOutput1 = Abc_ObjFanin0(pRoot)->pCopy;
00563     pOutput1 = Abc_ObjNotCond( Abc_ObjFanin0(pRoot)->pCopy, Abc_ObjFaninC0(pRoot) );
00564 
00565     // set the second cofactor
00566     Abc_NtkCi(pNtk, In)->pCopy = Abc_AigConst1(pNtkMiter);
00567     // add the second cofactor
00568     Abc_NtkMiterAddCone( pNtk, pNtkMiter, pRoot );
00569     // save the output
00570 //    pOutput2 = Abc_ObjFanin0(pRoot)->pCopy;
00571     pOutput2 = Abc_ObjNotCond( Abc_ObjFanin0(pRoot)->pCopy, Abc_ObjFaninC0(pRoot) );
00572 
00573     // create the miter of the two outputs
00574     if ( fExist ) 
00575         pMiter = Abc_AigOr( pNtkMiter->pManFunc, pOutput1, pOutput2 );
00576     else
00577         pMiter = Abc_AigAnd( pNtkMiter->pManFunc, pOutput1, pOutput2 );
00578     Abc_ObjAddFanin( Abc_NtkPo(pNtkMiter,0), pMiter );
00579 
00580     // make sure that everything is okay
00581     if ( !Abc_NtkCheck( pNtkMiter ) )
00582     {
00583         printf( "Abc_NtkMiter: The network check has failed.\n" );
00584         Abc_NtkDelete( pNtkMiter );
00585         return NULL;
00586     }
00587     return pNtkMiter;
00588 }

Abc_Ntk_t* Abc_NtkMiterQuantifyPis ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Quantifies all the PIs existentially from the only PO of the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 601 of file abcMiter.c.

00602 {
00603     Abc_Ntk_t * pNtkTemp;
00604     Abc_Obj_t * pObj;
00605     int i;
00606     assert( Abc_NtkHasOnlyLatchBoxes(pNtk) );
00607 
00608     Abc_NtkForEachPi( pNtk, pObj, i )
00609     {
00610         if ( Abc_ObjFanoutNum(pObj) == 0 )
00611             continue;
00612         pNtk = Abc_NtkMiterQuantify( pNtkTemp = pNtk, i, 1 );
00613         Abc_NtkDelete( pNtkTemp );
00614     }
00615 
00616     return pNtk;
00617 }

void Abc_NtkMiterReport ( Abc_Ntk_t pMiter  ) 

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

Synopsis [Reports the status of the miter.]

Description []

SideEffects []

SeeAlso []

Definition at line 672 of file abcMiter.c.

00673 {
00674     Abc_Obj_t * pChild, * pNode;
00675     int i;
00676     if ( Abc_NtkPoNum(pMiter) == 1 )
00677     {
00678         pChild = Abc_ObjChild0( Abc_NtkPo(pMiter,0) );
00679         if ( Abc_AigNodeIsConst(pChild) )
00680         {
00681             if ( Abc_ObjIsComplement(pChild) )
00682                 printf( "Unsatisfiable.\n" );
00683             else
00684                 printf( "Satisfiable. (Constant 1).\n" );
00685         }
00686         else
00687             printf( "Satisfiable.\n" );
00688     }
00689     else
00690     {
00691         Abc_NtkForEachPo( pMiter, pNode, i )
00692         {
00693             pChild = Abc_ObjChild0( Abc_NtkPo(pMiter,i) );
00694             printf( "Output #%2d : ", i );
00695             if ( Abc_AigNodeIsConst(pChild) )
00696             {
00697                 if ( Abc_ObjIsComplement(pChild) )
00698                     printf( "Unsatisfiable.\n" );
00699                 else
00700                     printf( "Satisfiable. (Constant 1).\n" );
00701             }
00702             else
00703                 printf( "Satisfiable.\n" );
00704         }
00705     }
00706 }

int Abc_NtkMiterSat ( Abc_Ntk_t pNtk,
sint64  nConfLimit,
sint64  nInsLimit,
int  fVerbose,
sint64 pNumConfs,
sint64 pNumInspects 
)

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

Synopsis [Attempts to solve the miter using an internal SAT sat_solver.]

Description [Returns -1 if timed out; 0 if SAT; 1 if UNSAT.]

SideEffects []

SeeAlso []

Definition at line 47 of file abcSat.c.

00048 {
00049     sat_solver * pSat;
00050     lbool   status;
00051     int RetValue, clk;
00052  
00053     if ( pNumConfs )
00054         *pNumConfs = 0;
00055     if ( pNumInspects )
00056         *pNumInspects = 0;
00057 
00058     assert( Abc_NtkLatchNum(pNtk) == 0 );
00059 
00060 //    if ( Abc_NtkPoNum(pNtk) > 1 )
00061 //        fprintf( stdout, "Warning: The miter has %d outputs. SAT will try to prove all of them.\n", Abc_NtkPoNum(pNtk) );
00062 
00063     // load clauses into the sat_solver
00064     clk = clock();
00065     pSat = Abc_NtkMiterSatCreate( pNtk, 0 );
00066     if ( pSat == NULL )
00067         return 1;
00068 //printf( "%d \n", pSat->clauses.size );
00069 //sat_solver_delete( pSat );
00070 //return 1;
00071 
00072 //    printf( "Created SAT problem with %d variable and %d clauses. ", sat_solver_nvars(pSat), sat_solver_nclauses(pSat) );
00073 //    PRT( "Time", clock() - clk );
00074 
00075     // simplify the problem
00076     clk = clock();
00077     status = sat_solver_simplify(pSat);
00078 //    printf( "Simplified the problem to %d variables and %d clauses. ", sat_solver_nvars(pSat), sat_solver_nclauses(pSat) );
00079 //    PRT( "Time", clock() - clk );
00080     if ( status == 0 )
00081     {
00082         sat_solver_delete( pSat );
00083 //        printf( "The problem is UNSATISFIABLE after simplification.\n" );
00084         return 1;
00085     }
00086 
00087     // solve the miter
00088     clk = clock();
00089     if ( fVerbose )
00090         pSat->verbosity = 1;
00091     status = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfLimit, (sint64)nInsLimit, (sint64)0, (sint64)0 );
00092     if ( status == l_Undef )
00093     {
00094 //        printf( "The problem timed out.\n" );
00095         RetValue = -1;
00096     }
00097     else if ( status == l_True )
00098     {
00099 //        printf( "The problem is SATISFIABLE.\n" );
00100         RetValue = 0;
00101     }
00102     else if ( status == l_False )
00103     {
00104 //        printf( "The problem is UNSATISFIABLE.\n" );
00105         RetValue = 1;
00106     }
00107     else
00108         assert( 0 );
00109 //    PRT( "SAT sat_solver time", clock() - clk );
00110 //    printf( "The number of conflicts = %d.\n", (int)pSat->sat_solver_stats.conflicts );
00111 
00112     // if the problem is SAT, get the counterexample
00113     if ( status == l_True )
00114     {
00115 //        Vec_Int_t * vCiIds = Abc_NtkGetCiIds( pNtk );
00116         Vec_Int_t * vCiIds = Abc_NtkGetCiSatVarNums( pNtk );
00117         pNtk->pModel = Sat_SolverGetModel( pSat, vCiIds->pArray, vCiIds->nSize );
00118         Vec_IntFree( vCiIds );
00119     }
00120     // free the sat_solver
00121     if ( fVerbose )
00122         Sat_SolverPrintStats( stdout, pSat );
00123 
00124     if ( pNumConfs )
00125         *pNumConfs = (int)pSat->stats.conflicts;
00126     if ( pNumInspects )
00127         *pNumInspects = (int)pSat->stats.inspects;
00128 
00129 sat_solver_store_write( pSat, "trace.cnf" );
00130 sat_solver_store_free( pSat );
00131 
00132     sat_solver_delete( pSat );
00133     return RetValue;
00134 }

void* Abc_NtkMiterSatCreate ( Abc_Ntk_t pNtk,
int  fAllPrimes 
)

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

Synopsis [Sets up the SAT sat_solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 614 of file abcSat.c.

00615 {
00616     sat_solver * pSat;
00617     Abc_Obj_t * pNode;
00618     int RetValue, i, clk = clock();
00619 
00620     assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsBddLogic(pNtk) );
00621     if ( Abc_NtkIsBddLogic(pNtk) )
00622         return Abc_NtkMiterSatCreateLogic(pNtk, fAllPrimes);
00623 
00624     nMuxes = 0;
00625     pSat = sat_solver_new();
00626 //sat_solver_store_alloc( pSat );
00627     RetValue = Abc_NtkMiterSatCreateInt( pSat, pNtk );
00628 sat_solver_store_mark_roots( pSat );
00629 
00630     Abc_NtkForEachObj( pNtk, pNode, i )
00631         pNode->fMarkA = 0;
00632 //    ASat_SolverWriteDimacs( pSat, "temp_sat.cnf", NULL, NULL, 1 );
00633     if ( RetValue == 0 )
00634     {
00635         sat_solver_delete(pSat);
00636         return NULL;
00637     }
00638 //    printf( "Ands = %6d.  Muxes = %6d (%5.2f %%).  ", Abc_NtkNodeNum(pNtk), nMuxes, 300.0*nMuxes/Abc_NtkNodeNum(pNtk) );
00639 //    PRT( "Creating sat_solver", clock() - clk );
00640     return pSat;
00641 }

static void* Abc_NtkMvVar ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 446 of file abc.h.

00446 { return Vec_PtrEntry(pNtk->vAttrs, VEC_ATTR_MVVAR);                          }

static void* Abc_NtkMvVarMan ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 447 of file abc.h.

00447 { return Abc_NtkMvVar(pNtk)? Vec_AttMan( (Vec_Att_t *)Abc_NtkMvVar(pNtk) ) : NULL;         }

static char* Abc_NtkName ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 284 of file abc.h.

00284 { return pNtk->pName;            }

static int Abc_NtkNetNum ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 308 of file abc.h.

00308 { return pNtk->nObjCounts[ABC_OBJ_NET];      }

static int Abc_NtkNodeNum ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 309 of file abc.h.

00309 { return pNtk->nObjCounts[ABC_OBJ_NODE];     }

Vec_Ptr_t* Abc_NtkNodeSupport ( Abc_Ntk_t pNtk,
Abc_Obj_t **  ppNodes,
int  nNodes 
)

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

Synopsis [Returns the set of CI nodes in the support of the given nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 733 of file abcDfs.c.

00734 {
00735     Vec_Ptr_t * vNodes;
00736     int i;
00737     // set the traversal ID
00738     Abc_NtkIncrementTravId( pNtk );
00739     // start the array of nodes
00740     vNodes = Vec_PtrAlloc( 100 );
00741     // go through the PO nodes and call for each of them
00742     for ( i = 0; i < nNodes; i++ )
00743         if ( Abc_ObjIsCo(ppNodes[i]) )
00744             Abc_NtkNodeSupport_rec( Abc_ObjFanin0(ppNodes[i]), vNodes );
00745         else
00746             Abc_NtkNodeSupport_rec( ppNodes[i], vNodes );
00747     return vNodes;
00748 }

static Abc_Obj_t* Abc_NtkObj ( Abc_Ntk_t pNtk,
int  i 
) [inline, static]

Definition at line 330 of file abc.h.

00330 { return (Abc_Obj_t *)Vec_PtrEntry( pNtk->vObjs, i );   }

static int Abc_NtkObjNum ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 298 of file abc.h.

00298 { return pNtk->nObjs;                        }

static int Abc_NtkObjNumMax ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 299 of file abc.h.

00299 { return Vec_PtrSize(pNtk->vObjs);           }

void Abc_NtkOrderCisCos ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Order CI/COs.]

Description []

SideEffects []

SeeAlso []

Definition at line 91 of file abcUtil.c.

00092 {
00093     Abc_Obj_t * pObj, * pTerm;
00094     int i, k;
00095     Vec_PtrClear( pNtk->vCis );
00096     Vec_PtrClear( pNtk->vCos );
00097     Abc_NtkForEachPi( pNtk, pObj, i )
00098         Vec_PtrPush( pNtk->vCis, pObj );
00099     Abc_NtkForEachPo( pNtk, pObj, i )
00100         Vec_PtrPush( pNtk->vCos, pObj );
00101     Abc_NtkForEachAssert( pNtk, pObj, i )
00102         Vec_PtrPush( pNtk->vCos, pObj );
00103     Abc_NtkForEachBox( pNtk, pObj, i )
00104     {
00105         if ( Abc_ObjIsLatch(pObj) )
00106             continue;
00107         Abc_ObjForEachFanin( pObj, pTerm, k )
00108             Vec_PtrPush( pNtk->vCos, pTerm );
00109         Abc_ObjForEachFanout( pObj, pTerm, k )
00110             Vec_PtrPush( pNtk->vCis, pTerm );
00111     }
00112     Abc_NtkForEachBox( pNtk, pObj, i )
00113     {
00114         if ( !Abc_ObjIsLatch(pObj) )
00115             continue;
00116         Abc_ObjForEachFanin( pObj, pTerm, k )
00117             Vec_PtrPush( pNtk->vCos, pTerm );
00118         Abc_ObjForEachFanout( pObj, pTerm, k )
00119             Vec_PtrPush( pNtk->vCis, pTerm );
00120     }
00121 }

void Abc_NtkOrderObjsByName ( Abc_Ntk_t pNtk,
int  fComb 
)

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

Synopsis [Orders PIs/POs/latches alphabetically.]

Description []

SideEffects []

SeeAlso []

Definition at line 311 of file abcNames.c.

00312 {
00313     Abc_Obj_t * pObj;
00314     int i;
00315     assert( Abc_NtkAssertNum(pNtk) == 0 );
00316     assert( Abc_NtkHasOnlyLatchBoxes(pNtk) );
00317     // temporarily store the names in the copy field
00318     Abc_NtkForEachPi( pNtk, pObj, i )
00319         pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
00320     Abc_NtkForEachPo( pNtk, pObj, i )
00321         pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
00322     Abc_NtkForEachBox( pNtk, pObj, i )
00323         pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(Abc_ObjFanout0(pObj));
00324     // order objects alphabetically
00325     qsort( (void *)Vec_PtrArray(pNtk->vPis), Vec_PtrSize(pNtk->vPis), sizeof(Abc_Obj_t *), 
00326         (int (*)(const void *, const void *)) Abc_NodeCompareNames );
00327     qsort( (void *)Vec_PtrArray(pNtk->vPos), Vec_PtrSize(pNtk->vPos), sizeof(Abc_Obj_t *), 
00328         (int (*)(const void *, const void *)) Abc_NodeCompareNames );
00329     // if the comparison if combinational (latches as PIs/POs), order them too
00330     if ( fComb )
00331         qsort( (void *)Vec_PtrArray(pNtk->vBoxes), Vec_PtrSize(pNtk->vBoxes), sizeof(Abc_Obj_t *), 
00332             (int (*)(const void *, const void *)) Abc_NodeCompareNames );
00333     // order CIs/COs first PIs/POs(Asserts) then latches
00334     Abc_NtkOrderCisCos( pNtk );
00335     // clean the copy fields
00336     Abc_NtkForEachPi( pNtk, pObj, i )
00337         pObj->pCopy = NULL;
00338     Abc_NtkForEachPo( pNtk, pObj, i )
00339         pObj->pCopy = NULL;
00340     Abc_NtkForEachBox( pNtk, pObj, i )
00341         pObj->pCopy = NULL;
00342 }

static Abc_Obj_t* Abc_NtkPi ( Abc_Ntk_t pNtk,
int  i 
) [inline, static]

Definition at line 331 of file abc.h.

00331 { return (Abc_Obj_t *)Vec_PtrEntry( pNtk->vPis, i );    }

static int Abc_NtkPiNum ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 300 of file abc.h.

00300 { return Vec_PtrSize(pNtk->vPis);            }

static Abc_Obj_t* Abc_NtkPo ( Abc_Ntk_t pNtk,
int  i 
) [inline, static]

Definition at line 332 of file abc.h.

00332 { return (Abc_Obj_t *)Vec_PtrEntry( pNtk->vPos, i );    }

static int Abc_NtkPoNum ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 301 of file abc.h.

00301 { return Vec_PtrSize(pNtk->vPos);            }

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 1080 of file abcUtil.c.

01082 {
01083     int fCheck = 1;
01084     FILE * pFile;
01085     Abc_Ntk_t * pNtk1, * pNtk2;
01086     int util_optind = 0;
01087 
01088     *pfDelete1 = 0;
01089     *pfDelete2 = 0;
01090     if ( argc == util_optind ) 
01091     { // use the spec
01092         if ( pNtk == NULL )
01093         {
01094             fprintf( pErr, "Empty current network.\n" );
01095             return 0;
01096         }
01097         if ( pNtk->pSpec == NULL )
01098         {
01099             fprintf( pErr, "The external spec is not given.\n" );
01100             return 0;
01101         }
01102         pFile = fopen( pNtk->pSpec, "r" );
01103         if ( pFile == NULL )
01104         {
01105             fprintf( pErr, "Cannot open the external spec file \"%s\".\n", pNtk->pSpec );
01106             return 0;
01107         }
01108         else
01109             fclose( pFile );
01110         pNtk1 = pNtk;
01111         pNtk2 = Io_Read( pNtk->pSpec, Io_ReadFileType(pNtk->pSpec), fCheck );
01112         if ( pNtk2 == NULL )
01113             return 0;
01114         *pfDelete2 = 1;
01115     }
01116     else if ( argc == util_optind + 1 ) 
01117     {
01118         if ( pNtk == NULL )
01119         {
01120             fprintf( pErr, "Empty current network.\n" );
01121             return 0;
01122         }
01123         pNtk1 = pNtk;
01124         pNtk2 = Io_Read( argv[util_optind], Io_ReadFileType(argv[util_optind]), fCheck );
01125         if ( pNtk2 == NULL )
01126             return 0;
01127         *pfDelete2 = 1;
01128     }
01129     else if ( argc == util_optind + 2 ) 
01130     {
01131         pNtk1 = Io_Read( argv[util_optind], Io_ReadFileType(argv[util_optind]), fCheck );
01132         if ( pNtk1 == NULL )
01133             return 0;
01134         pNtk2 = Io_Read( argv[util_optind+1], Io_ReadFileType(argv[util_optind+1]), fCheck );
01135         if ( pNtk2 == NULL )
01136         {
01137             Abc_NtkDelete( pNtk1 );
01138             return 0;
01139         }
01140         *pfDelete1 = 1;
01141         *pfDelete2 = 1;
01142     }
01143     else
01144     {
01145         fprintf( pErr, "Wrong number of arguments.\n" );
01146         return 0;
01147     }
01148     *ppNtk1 = pNtk1;
01149     *ppNtk2 = pNtk2;
01150     return 1;
01151 }

void Abc_NtkPrintFactor ( FILE *  pFile,
Abc_Ntk_t pNtk,
int  fUseRealNames 
)

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

Synopsis [Prints the factored form of one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 462 of file abcPrint.c.

00463 {
00464     Abc_Obj_t * pNode;
00465     int i;
00466     assert( Abc_NtkIsSopLogic(pNtk) );
00467     Abc_NtkForEachNode( pNtk, pNode, i )
00468         Abc_NodePrintFactor( pFile, pNode, fUseRealNames );
00469 }

void Abc_NtkPrintFanio ( FILE *  pFile,
Abc_Ntk_t pNtk 
)

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

Synopsis [Prints the distribution of fanins/fanouts in the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 343 of file abcPrint.c.

00344 {
00345     Abc_Obj_t * pNode;
00346     int i, k, nFanins, nFanouts;
00347     Vec_Int_t * vFanins, * vFanouts;
00348     int nOldSize, nNewSize;
00349 
00350     vFanins  = Vec_IntAlloc( 0 );
00351     vFanouts = Vec_IntAlloc( 0 );
00352     Vec_IntFill( vFanins,  100, 0 );
00353     Vec_IntFill( vFanouts, 100, 0 );
00354     Abc_NtkForEachNode( pNtk, pNode, i )
00355     {
00356         nFanins  = Abc_ObjFaninNum(pNode);
00357         if ( Abc_NtkIsNetlist(pNtk) )
00358             nFanouts = Abc_ObjFanoutNum( Abc_ObjFanout0(pNode) );
00359         else
00360             nFanouts = Abc_ObjFanoutNum(pNode);
00361 //            nFanouts = Abc_NodeMffcSize(pNode);
00362         if ( nFanins > vFanins->nSize || nFanouts > vFanouts->nSize )
00363         {
00364             nOldSize = vFanins->nSize;
00365             nNewSize = ABC_MAX(nFanins, nFanouts) + 10;
00366             Vec_IntGrow( vFanins,  nNewSize  );
00367             Vec_IntGrow( vFanouts, nNewSize );
00368             for ( k = nOldSize; k < nNewSize; k++ )
00369             {
00370                 Vec_IntPush( vFanins,  0  );
00371                 Vec_IntPush( vFanouts, 0 );
00372             }
00373         }
00374         vFanins->pArray[nFanins]++;
00375         vFanouts->pArray[nFanouts]++;
00376     }
00377     fprintf( pFile, "The distribution of fanins and fanouts in the network:\n" );
00378     fprintf( pFile, "  Number   Nodes with fanin  Nodes with fanout\n" );
00379     for ( k = 0; k < vFanins->nSize; k++ )
00380     {
00381         if ( vFanins->pArray[k] == 0 && vFanouts->pArray[k] == 0 )
00382             continue;
00383         fprintf( pFile, "%5d : ", k );
00384         if ( vFanins->pArray[k] == 0 )
00385             fprintf( pFile, "              " );
00386         else
00387             fprintf( pFile, "%12d  ", vFanins->pArray[k] );
00388         fprintf( pFile, "    " );
00389         if ( vFanouts->pArray[k] == 0 )
00390             fprintf( pFile, "              " );
00391         else
00392             fprintf( pFile, "%12d  ", vFanouts->pArray[k] );
00393         fprintf( pFile, "\n" );
00394     }
00395     Vec_IntFree( vFanins );
00396     Vec_IntFree( vFanouts );
00397 }

void Abc_NtkPrintIo ( FILE *  pFile,
Abc_Ntk_t pNtk 
)

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

Synopsis [Prints PIs/POs and LIs/LOs.]

Description []

SideEffects []

SeeAlso []

Definition at line 236 of file abcPrint.c.

00237 {
00238     Abc_Obj_t * pObj;
00239     int i;
00240 
00241     fprintf( pFile, "Primary inputs (%d): ", Abc_NtkPiNum(pNtk) );    
00242     Abc_NtkForEachPi( pNtk, pObj, i )
00243         fprintf( pFile, " %s", Abc_ObjName(pObj) );
00244 //        fprintf( pFile, " %s(%d)", Abc_ObjName(pObj), Abc_ObjFanoutNum(pObj) );
00245     fprintf( pFile, "\n" );   
00246 
00247     fprintf( pFile, "Primary outputs (%d):", Abc_NtkPoNum(pNtk) );    
00248     Abc_NtkForEachPo( pNtk, pObj, i )
00249         fprintf( pFile, " %s", Abc_ObjName(pObj) );
00250     fprintf( pFile, "\n" );    
00251 
00252     fprintf( pFile, "Latches (%d):  ", Abc_NtkLatchNum(pNtk) );  
00253     Abc_NtkForEachLatch( pNtk, pObj, i )
00254         fprintf( pFile, " %s(%s=%s)", Abc_ObjName(pObj), 
00255             Abc_ObjName(Abc_ObjFanout0(pObj)), Abc_ObjName(Abc_ObjFanin0(pObj)) );
00256     fprintf( pFile, "\n" );   
00257 }

void Abc_NtkPrintLatch ( FILE *  pFile,
Abc_Ntk_t pNtk 
)

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

Synopsis [Prints statistics about latches.]

Description []

SideEffects []

SeeAlso []

Definition at line 270 of file abcPrint.c.

00271 {
00272     Abc_Obj_t * pLatch, * pFanin;
00273     int i, Counter0, Counter1, Counter2;
00274     int InitNums[4], Init;
00275 
00276     assert( !Abc_NtkIsNetlist(pNtk) );
00277     if ( Abc_NtkLatchNum(pNtk) == 0 )
00278     {
00279         fprintf( pFile, "The network is combinational.\n" );
00280         return;
00281     }
00282 
00283     for ( i = 0; i < 4; i++ )    
00284         InitNums[i] = 0;
00285     Counter0 = Counter1 = Counter2 = 0;
00286     Abc_NtkForEachLatch( pNtk, pLatch, i )
00287     {
00288         Init = Abc_LatchInit( pLatch );
00289         assert( Init < 4 );
00290         InitNums[Init]++;
00291 
00292         pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pLatch));
00293         if ( Abc_NtkIsLogic(pNtk) )
00294         {
00295             if ( !Abc_NodeIsConst(pFanin) )
00296                 continue;
00297         }
00298         else if ( Abc_NtkIsStrash(pNtk) )
00299         {
00300             if ( !Abc_AigNodeIsConst(pFanin) )
00301                 continue;
00302         }
00303         else
00304             assert( 0 );
00305 
00306         // the latch input is a constant node
00307         Counter0++;
00308         if ( Abc_LatchIsInitDc(pLatch) )
00309         {
00310             Counter1++;
00311             continue;
00312         }
00313         // count the number of cases when the constant is equal to the initial value
00314         if ( Abc_NtkIsStrash(pNtk) )
00315         {
00316             if ( Abc_LatchIsInit1(pLatch) == !Abc_ObjFaninC0(pLatch) )
00317                 Counter2++;
00318         }
00319         else
00320         {
00321             if ( Abc_LatchIsInit1(pLatch) == Abc_NodeIsConst1(Abc_ObjFanin0(Abc_ObjFanin0(pLatch))) )
00322                 Counter2++;
00323         }
00324     }
00325     fprintf( pFile, "%-15s:  ", pNtk->pName );
00326     fprintf( pFile, "Latch = %6d. No = %4d. Zero = %4d. One = %4d. DC = %4d.\n", 
00327         Abc_NtkLatchNum(pNtk), InitNums[0], InitNums[1], InitNums[2], InitNums[3] );
00328     fprintf( pFile, "Const fanin = %3d. DC init = %3d. Matching init = %3d. ", Counter0, Counter1, Counter2 );
00329     fprintf( pFile, "Self-feed latches = %2d.\n", -1 ); //Abc_NtkCountSelfFeedLatches(pNtk) );
00330 }

void Abc_NtkPrintLevel ( FILE *  pFile,
Abc_Ntk_t pNtk,
int  fProfile,
int  fListNodes 
)

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

Synopsis [Prints the level stats of the PO node.]

Description []

SideEffects []

SeeAlso []

Definition at line 523 of file abcPrint.c.

00524 {
00525     Abc_Obj_t * pNode;
00526     int i, k, Length;
00527 
00528     if ( fListNodes )
00529     {
00530         int nLevels;
00531         nLevels = Abc_NtkLevel(pNtk);
00532         printf( "Nodes by level:\n" );
00533         for ( i = 0; i <= nLevels; i++ )
00534         {
00535             printf( "%2d : ", i );
00536             Abc_NtkForEachNode( pNtk, pNode, k )
00537                 if ( (int)pNode->Level == i )
00538                     printf( " %s", Abc_ObjName(pNode) );
00539             printf( "\n" );
00540         }
00541         return;
00542     }
00543 
00544     // print the delay profile
00545     if ( fProfile && Abc_NtkHasMapping(pNtk) )
00546     {
00547         int nIntervals = 12;
00548         float DelayMax, DelayCur, DelayDelta;
00549         int * pLevelCounts;
00550         int DelayInt, nOutsSum, nOutsTotal;
00551 
00552         // get the max delay and delta
00553         DelayMax   = Abc_NtkDelayTrace( pNtk );
00554         DelayDelta = DelayMax/nIntervals;
00555         // collect outputs by delay
00556         pLevelCounts = ALLOC( int, nIntervals );
00557         memset( pLevelCounts, 0, sizeof(int) * nIntervals );
00558         Abc_NtkForEachCo( pNtk, pNode, i )
00559         {
00560             DelayCur  = Abc_NodeReadArrival( Abc_ObjFanin0(pNode) )->Worst;
00561             DelayInt  = (int)(DelayCur / DelayDelta);
00562             if ( DelayInt >= nIntervals )
00563                 DelayInt = nIntervals - 1;
00564             pLevelCounts[DelayInt]++;
00565         }
00566 
00567         nOutsSum   = 0;
00568         nOutsTotal = Abc_NtkCoNum(pNtk);
00569         for ( i = 0; i < nIntervals; i++ )
00570         {
00571             nOutsSum += pLevelCounts[i];
00572             printf( "[%8.2f - %8.2f] :   COs = %4d.   %5.1f %%\n", 
00573                 DelayDelta * i, DelayDelta * (i+1), pLevelCounts[i], 100.0 * nOutsSum/nOutsTotal );
00574         }
00575         free( pLevelCounts );
00576         return;
00577     }
00578     else if ( fProfile )
00579     {
00580         int LevelMax, * pLevelCounts;
00581         int nOutsSum, nOutsTotal;
00582 
00583         if ( !Abc_NtkIsStrash(pNtk) )
00584             Abc_NtkLevel(pNtk);
00585 
00586         LevelMax = 0;
00587         Abc_NtkForEachCo( pNtk, pNode, i )
00588             if ( LevelMax < (int)Abc_ObjFanin0(pNode)->Level )
00589                 LevelMax = Abc_ObjFanin0(pNode)->Level;
00590         pLevelCounts = ALLOC( int, LevelMax + 1 );
00591         memset( pLevelCounts, 0, sizeof(int) * (LevelMax + 1) );
00592         Abc_NtkForEachCo( pNtk, pNode, i )
00593             pLevelCounts[Abc_ObjFanin0(pNode)->Level]++;
00594 
00595         nOutsSum   = 0;
00596         nOutsTotal = Abc_NtkCoNum(pNtk);
00597         for ( i = 0; i <= LevelMax; i++ )
00598             if ( pLevelCounts[i] )
00599             {
00600                 nOutsSum += pLevelCounts[i];
00601                 printf( "Level = %4d.  COs = %4d.   %5.1f %%\n", i, pLevelCounts[i], 100.0 * nOutsSum/nOutsTotal );
00602             }
00603         free( pLevelCounts );
00604         return;
00605     }
00606     assert( Abc_NtkIsStrash(pNtk) );
00607 
00608     // find the longest name
00609     Length = 0;
00610     Abc_NtkForEachCo( pNtk, pNode, i )
00611         if ( Length < (int)strlen(Abc_ObjName(pNode)) )
00612             Length = strlen(Abc_ObjName(pNode));
00613     if ( Length < 5 )
00614         Length = 5;
00615     // print stats for each output
00616     Abc_NtkForEachCo( pNtk, pNode, i )
00617     {
00618         fprintf( pFile, "CO %4d :  %*s    ", i, Length, Abc_ObjName(pNode) ); 
00619         Abc_NodePrintLevel( pFile, pNode );
00620     }
00621 }

void Abc_NtkPrintSkews ( FILE *  pFile,
Abc_Ntk_t pNtk,
int  fPrintAll 
)
void Abc_NtkPrintStats ( FILE *  pFile,
Abc_Ntk_t pNtk,
int  fFactored 
)

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

Synopsis [Print the vital stats of the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 54 of file abcPrint.c.

00055 {
00056     int Num;
00057 
00058 //    if ( Abc_NtkIsStrash(pNtk) )
00059 //        Abc_AigCountNext( pNtk->pManFunc );
00060 
00061     fprintf( pFile, "%-13s:",       pNtk->pName );
00062     if ( Abc_NtkAssertNum(pNtk) )
00063         fprintf( pFile, " i/o/a = %4d/%4d/%4d", Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk), Abc_NtkAssertNum(pNtk) );
00064     else
00065         fprintf( pFile, " i/o = %4d/%4d", Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk) );
00066     fprintf( pFile, "  lat = %4d", Abc_NtkLatchNum(pNtk) );
00067     if ( Abc_NtkIsNetlist(pNtk) )
00068     {
00069         fprintf( pFile, "  net = %5d", Abc_NtkNetNum(pNtk) );
00070         fprintf( pFile, "  nd = %5d",  Abc_NtkNodeNum(pNtk) );
00071         fprintf( pFile, "  wbox = %3d", Abc_NtkWhiteboxNum(pNtk) );
00072         fprintf( pFile, "  bbox = %3d", Abc_NtkBlackboxNum(pNtk) );
00073     }
00074     else if ( Abc_NtkIsStrash(pNtk) )
00075     {        
00076         fprintf( pFile, "  and = %5d", Abc_NtkNodeNum(pNtk) );
00077         if ( Num = Abc_NtkGetChoiceNum(pNtk) )
00078             fprintf( pFile, " (choice = %d)", Num );
00079         if ( Num = Abc_NtkGetExorNum(pNtk) )
00080             fprintf( pFile, " (exor = %d)", Num );
00081 //        if ( Num2 = Abc_NtkGetMuxNum(pNtk) )
00082 //            fprintf( pFile, " (mux = %d)", Num2-Num );
00083 //        if ( Num2 )
00084 //            fprintf( pFile, " (other = %d)", Abc_NtkNodeNum(pNtk)-3*Num2 );
00085     }
00086     else 
00087     {
00088         fprintf( pFile, "  nd = %5d", Abc_NtkNodeNum(pNtk) );
00089         fprintf( pFile, "  net = %5d", Abc_NtkGetTotalFanins(pNtk) );
00090     }
00091 
00092     if ( Abc_NtkIsStrash(pNtk) || Abc_NtkIsNetlist(pNtk) )
00093     {
00094     }
00095     else if ( Abc_NtkHasSop(pNtk) )   
00096     {
00097 
00098         fprintf( pFile, "  cube = %5d",  Abc_NtkGetCubeNum(pNtk) );
00099 //        fprintf( pFile, "  lit(sop) = %5d",  Abc_NtkGetLitNum(pNtk) );
00100         if ( fFactored )
00101             fprintf( pFile, "  lit(fac) = %5d",  Abc_NtkGetLitFactNum(pNtk) );
00102     }
00103     else if ( Abc_NtkHasAig(pNtk) )
00104         fprintf( pFile, "  aig  = %5d",  Abc_NtkGetAigNodeNum(pNtk) );
00105     else if ( Abc_NtkHasBdd(pNtk) )
00106         fprintf( pFile, "  bdd  = %5d",  Abc_NtkGetBddNodeNum(pNtk) );
00107     else if ( Abc_NtkHasMapping(pNtk) )
00108     {
00109         fprintf( pFile, "  area = %5.2f", Abc_NtkGetMappedArea(pNtk) );
00110         fprintf( pFile, "  delay = %5.2f", Abc_NtkDelayTrace(pNtk) );
00111     }
00112     else if ( !Abc_NtkHasBlackbox(pNtk) )
00113     {
00114         assert( 0 );
00115     }
00116 
00117     if ( Abc_NtkIsStrash(pNtk) )
00118         fprintf( pFile, "  lev = %3d", Abc_AigLevel(pNtk) );
00119     else 
00120         fprintf( pFile, "  lev = %3d", Abc_NtkLevel(pNtk) );
00121 
00122     fprintf( pFile, "\n" );
00123 
00124 //    Abc_NtkCrossCut( pNtk );
00125 
00126     // print the statistic into a file
00127 /*
00128     {
00129         FILE * pTable;
00130         pTable = fopen( "ibm/seq_stats.txt", "a+" );
00131 //        fprintf( pTable, "%s ",  pNtk->pName );
00132 //        fprintf( pTable, "%d ", Abc_NtkPiNum(pNtk) );
00133 //        fprintf( pTable, "%d ", Abc_NtkPoNum(pNtk) );
00134         fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
00135         fprintf( pTable, "%d ", Abc_NtkLatchNum(pNtk) );
00136         fprintf( pTable, "%d ", Abc_NtkLevel(pNtk) );
00137         fprintf( pTable, "\n" );
00138         fclose( pTable );
00139     }
00140 */
00141 
00142 /*
00143     // print the statistic into a file
00144     {
00145         FILE * pTable;
00146         pTable = fopen( "stats.txt", "a+" );
00147         fprintf( pTable, "%s ",  pNtk->pSpec );
00148         fprintf( pTable, "%.0f ", Abc_NtkGetMappedArea(pNtk) );
00149         fprintf( pTable, "%.2f ", Abc_NtkDelayTrace(pNtk) );
00150         fprintf( pTable, "\n" );
00151         fclose( pTable );
00152     }
00153 */
00154 
00155 /*
00156     // print the statistic into a file
00157     {
00158         FILE * pTable;
00159         pTable = fopen( "x/stats_new.txt", "a+" );
00160         fprintf( pTable, "%s ",  pNtk->pName );
00161 //        fprintf( pTable, "%d ", Abc_NtkPiNum(pNtk) );
00162 //        fprintf( pTable, "%d ", Abc_NtkPoNum(pNtk) );
00163 //        fprintf( pTable, "%d ", Abc_NtkLevel(pNtk) );
00164 //        fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
00165 //        fprintf( pTable, "%d ", Abc_NtkGetTotalFanins(pNtk) );
00166 //        fprintf( pTable, "%d ", Abc_NtkLatchNum(pNtk) );
00167 //        fprintf( pTable, "%.2f ", (float)(s_MappingMem)/(float)(1<<20) );
00168         fprintf( pTable, "%.2f", (float)(s_MappingTime)/(float)(CLOCKS_PER_SEC) );
00169 //        fprintf( pTable, "%.2f", (float)(s_ResynTime)/(float)(CLOCKS_PER_SEC) );
00170         fprintf( pTable, "\n" );
00171         fclose( pTable );
00172 
00173         s_ResynTime = 0;
00174     }
00175 */
00176 
00177 /*
00178     // print the statistic into a file
00179     {
00180         static int Counter = 0;
00181         extern int timeRetime;
00182         FILE * pTable;
00183         Counter++;
00184         pTable = fopen( "a/ret__stats.txt", "a+" );
00185         fprintf( pTable, "%s ", pNtk->pName );
00186         fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
00187         fprintf( pTable, "%d ", Abc_NtkLatchNum(pNtk) );
00188         fprintf( pTable, "%d ", Abc_NtkLevel(pNtk) );
00189         fprintf( pTable, "%.2f ", (float)(timeRetime)/(float)(CLOCKS_PER_SEC) );
00190         if ( Counter % 4 == 0 )
00191             fprintf( pTable, "\n" );
00192         fclose( pTable );
00193     }
00194 */
00195 
00196 /*
00197     // print the statistic into a file
00198     {
00199         static int Counter = 0;
00200         extern int timeRetime;
00201         FILE * pTable;
00202         Counter++;
00203         pTable = fopen( "d/stats.txt", "a+" );
00204         fprintf( pTable, "%s ", pNtk->pName );
00205 //        fprintf( pTable, "%d ", Abc_NtkPiNum(pNtk) );
00206 //        fprintf( pTable, "%d ", Abc_NtkPoNum(pNtk) );
00207 //        fprintf( pTable, "%d ", Abc_NtkLatchNum(pNtk) );
00208         fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
00209         fprintf( pTable, "%.2f ", (float)(timeRetime)/(float)(CLOCKS_PER_SEC) );
00210         fprintf( pTable, "\n" );
00211         fclose( pTable );
00212     }
00213 */
00214 
00215 /*
00216     s_TotalNodes += Abc_NtkNodeNum(pNtk);
00217     printf( "Total nodes = %6d   %6.2f Mb   Changes = %6d.\n", 
00218         s_TotalNodes, s_TotalNodes * 20.0 / (1<<20), s_TotalChanges );
00219 */
00220 
00221 //    if ( Abc_NtkHasSop(pNtk) )
00222 //        printf( "The total number of cube pairs = %d.\n", Abc_NtkGetCubePairNum(pNtk) );
00223 }

Abc_Time_t* Abc_NtkReadDefaultArrival ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Reads the arrival time of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file abcTiming.c.

00098 {
00099     assert( pNtk->pManTime );
00100     return &pNtk->pManTime->tArrDef;
00101 }

Abc_Time_t* Abc_NtkReadDefaultRequired ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Reads the arrival time of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 114 of file abcTiming.c.

00115 {
00116     assert( pNtk->pManTime );
00117     return &pNtk->pManTime->tReqDef;
00118 }

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 1337 of file abcUtil.c.

01338 {
01339     Vec_Ptr_t * vNodes;
01340     Vec_Ptr_t * vObjsNew;
01341     Abc_Obj_t * pNode, * pTemp, * pConst1;
01342     int i, k;
01343     assert( Abc_NtkIsStrash(pNtk) );
01344 //printf( "Total = %d. Current = %d.\n", Abc_NtkObjNumMax(pNtk), Abc_NtkObjNum(pNtk) );
01345     // start the array of objects with new IDs
01346     vObjsNew = Vec_PtrAlloc( pNtk->nObjs );
01347     // put constant node first
01348     pConst1 = Abc_AigConst1(pNtk);
01349     assert( pConst1->Id == 0 );
01350     Vec_PtrPush( vObjsNew, pConst1 );
01351     // put PI nodes next
01352     Abc_NtkForEachPi( pNtk, pNode, i )
01353     {
01354         pNode->Id = Vec_PtrSize( vObjsNew );
01355         Vec_PtrPush( vObjsNew, pNode );
01356     }
01357     // put PO nodes next
01358     Abc_NtkForEachPo( pNtk, pNode, i )
01359     {
01360         pNode->Id = Vec_PtrSize( vObjsNew );
01361         Vec_PtrPush( vObjsNew, pNode );
01362     }
01363     // put assert nodes next
01364     Abc_NtkForEachAssert( pNtk, pNode, i )
01365     {
01366         pNode->Id = Vec_PtrSize( vObjsNew );
01367         Vec_PtrPush( vObjsNew, pNode );
01368     }
01369     // put latches and their inputs/outputs next
01370     Abc_NtkForEachBox( pNtk, pNode, i )
01371     {
01372         pNode->Id = Vec_PtrSize( vObjsNew );
01373         Vec_PtrPush( vObjsNew, pNode );
01374         Abc_ObjForEachFanin( pNode, pTemp, k )
01375         {
01376             pTemp->Id = Vec_PtrSize( vObjsNew );
01377             Vec_PtrPush( vObjsNew, pTemp );
01378         }
01379         Abc_ObjForEachFanout( pNode, pTemp, k )
01380         {
01381             pTemp->Id = Vec_PtrSize( vObjsNew );
01382             Vec_PtrPush( vObjsNew, pTemp );
01383         }
01384     }
01385     // finally, internal nodes in the DFS order
01386     vNodes = Abc_AigDfs( pNtk, 1, 0 );
01387     Vec_PtrForEachEntry( vNodes, pNode, i )
01388     {
01389         if ( pNode == pConst1 )
01390             continue;
01391         pNode->Id = Vec_PtrSize( vObjsNew );
01392         Vec_PtrPush( vObjsNew, pNode );
01393     }
01394     Vec_PtrFree( vNodes );
01395     assert( Vec_PtrSize(vObjsNew) == pNtk->nObjs );
01396 
01397     // update the fanin/fanout arrays
01398     Abc_NtkForEachObj( pNtk, pNode, i )
01399     {
01400         Abc_ObjForEachFanin( pNode, pTemp, k )
01401             pNode->vFanins.pArray[k] = pTemp->Id;
01402         Abc_ObjForEachFanout( pNode, pTemp, k )
01403             pNode->vFanouts.pArray[k] = pTemp->Id;
01404     }
01405 
01406     // replace the array of objs
01407     Vec_PtrFree( pNtk->vObjs );
01408     pNtk->vObjs = vObjsNew;
01409 
01410     // rehash the AIG
01411     Abc_AigRehash( pNtk->pManFunc );
01412 
01413     // update the name manager!!!
01414 }

void Abc_NtkRecAdd ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Performs renoding as technology mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 506 of file abcRec.c.

00507 {
00508     extern Abc_Ntk_t * Abc_NtkIf( Abc_Ntk_t * pNtk, If_Par_t * pPars );
00509     extern int Abc_NtkRecAddCut( If_Man_t * pIfMan, If_Obj_t * pRoot, If_Cut_t * pCut );
00510 
00511     If_Par_t Pars, * pPars = &Pars;
00512     Abc_Ntk_t * pNtkNew;
00513     int clk = clock();
00514 
00515     if ( Abc_NtkGetChoiceNum( pNtk ) )
00516         printf( "Performing renoding with choices.\n" );
00517 
00518     // set defaults
00519     memset( pPars, 0, sizeof(If_Par_t) );
00520     // user-controlable paramters
00521     pPars->nLutSize    =  s_pMan->nVarsInit;
00522     pPars->nCutsMax    =  s_pMan->nCuts;
00523     pPars->nFlowIters  =  0;
00524     pPars->nAreaIters  =  0;
00525     pPars->DelayTarget = -1;
00526     pPars->fPreprocess =  0;
00527     pPars->fArea       =  1;
00528     pPars->fFancy      =  0;
00529     pPars->fExpRed     =  0; 
00530     pPars->fLatchPaths =  0;
00531     pPars->fSeqMap     =  0;
00532     pPars->fVerbose    =  0;
00533     // internal parameters
00534     pPars->fTruth      =  0;
00535     pPars->fUsePerm    =  0; 
00536     pPars->nLatches    =  0;
00537     pPars->pLutLib     =  NULL; // Abc_FrameReadLibLut();
00538     pPars->pTimesArr   =  NULL; 
00539     pPars->pTimesArr   =  NULL;   
00540     pPars->fUseBdds    =  0;
00541     pPars->fUseSops    =  0;
00542     pPars->fUseCnfs    =  0;
00543     pPars->fUseMv      =  0;
00544     pPars->pFuncCost   =  NULL;
00545     pPars->pFuncUser   =  Abc_NtkRecAddCut;
00546 
00547     // perform recording
00548     pNtkNew = Abc_NtkIf( pNtk, pPars );
00549     Abc_NtkDelete( pNtkNew );
00550 s_pMan->timeTotal += clock() - clk;
00551 
00552 //    if ( !Abc_NtkCheck( s_pMan->pNtk ) )
00553 //        printf( "Abc_NtkRecAdd: The network check has failed.\n" );
00554 }

void Abc_NtkRecFilter ( int  iVar,
int  iPlus 
)

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

Synopsis [Filters the current record.]

Description []

SideEffects []

SeeAlso []

Definition at line 424 of file abcRec.c.

00425 {
00426 }

int Abc_NtkRecIsRunning (  ) 

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

Synopsis [Starts the record for the given network.]

Description []

SideEffects []

SeeAlso []

Definition at line 95 of file abcRec.c.

00096 {
00097     return s_pMan != NULL;
00098 }

Vec_Int_t* Abc_NtkRecMemory (  ) 

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

Synopsis [Starts the record for the given network.]

Description []

SideEffects []

SeeAlso []

Definition at line 127 of file abcRec.c.

00128 {
00129     return s_pMan->vMemory;
00130 }

void Abc_NtkRecPs (  ) 

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

Synopsis [Print statistics about the current record.]

Description []

SideEffects []

SeeAlso []

Definition at line 346 of file abcRec.c.

00347 {
00348     int Counter, Counters[17] = {0};
00349     int CounterS, CountersS[17] = {0};
00350     Abc_ManRec_t * p = s_pMan;
00351     Abc_Ntk_t * pNtk = p->pNtk;
00352     Abc_Obj_t * pObj, * pEntry, * pTemp;
00353     int i;
00354 
00355     // set the max PI number
00356     Abc_NtkForEachPi( pNtk, pObj, i )
00357         Abc_ObjSetMax( pObj, i+1 );
00358     Abc_AigForEachAnd( pNtk, pObj, i )
00359         Abc_ObjSetMax( pObj, ABC_MAX( Abc_ObjGetMax(Abc_ObjFanin0(pObj)), Abc_ObjGetMax(Abc_ObjFanin1(pObj)) ) );
00360     // go through the table
00361     Counter = CounterS = 0;
00362     for ( i = 0; i < p->nBins; i++ )
00363     for ( pEntry = p->pBins[i]; pEntry; pEntry = pEntry->pCopy )
00364     {
00365         Counters[ Abc_ObjGetMax(pEntry) ]++;
00366         Counter++;
00367         for ( pTemp = pEntry; pTemp; pTemp = (Abc_Obj_t *)pTemp->pEquiv )
00368         {
00369             assert( Abc_ObjGetMax(pTemp) == Abc_ObjGetMax(pEntry) );
00370             CountersS[ Abc_ObjGetMax(pTemp) ]++;
00371             CounterS++;
00372         }
00373     }
00374 //    printf( "Functions = %d. Expected = %d.\n", Counter, p->nAddedFuncs );
00375 //    printf( "Subgraphs = %d. Expected = %d.\n", CounterS, p->nAdded );
00376     assert( Counter == p->nAddedFuncs );
00377     assert( CounterS == p->nAdded );
00378 
00379     // clean
00380     Abc_NtkForEachObj( pNtk, pObj, i )
00381     {
00382         Abc_ObjClearMax( pObj );
00383     }
00384 
00385     printf( "The record with %d AND nodes in %d subgraphs for %d functions with %d inputs:\n", 
00386         Abc_NtkNodeNum(pNtk), Abc_NtkPoNum(pNtk), p->nAddedFuncs, Abc_NtkPiNum(pNtk) );
00387     for ( i = 0; i <= 16; i++ )
00388     {
00389         if ( Counters[i] )
00390             printf( "Inputs = %2d.  Funcs = %8d.  Subgrs = %8d.  Ratio = %6.2f.\n", i, Counters[i], CountersS[i], 1.0*CountersS[i]/Counters[i] );
00391     }
00392 
00393     printf( "Subgraphs tried                             = %8d. (%6.2f %%)\n", p->nTried,        !p->nTried? 0 : 100.0*p->nTried/p->nTried );
00394     printf( "Subgraphs filtered by support size          = %8d. (%6.2f %%)\n", p->nFilterSize,   !p->nTried? 0 : 100.0*p->nFilterSize/p->nTried );
00395     printf( "Subgraphs filtered by structural redundancy = %8d. (%6.2f %%)\n", p->nFilterRedund, !p->nTried? 0 : 100.0*p->nFilterRedund/p->nTried );
00396     printf( "Subgraphs filtered by volume                = %8d. (%6.2f %%)\n", p->nFilterVolume, !p->nTried? 0 : 100.0*p->nFilterVolume/p->nTried );
00397     printf( "Subgraphs filtered by TT redundancy         = %8d. (%6.2f %%)\n", p->nFilterTruth,  !p->nTried? 0 : 100.0*p->nFilterTruth/p->nTried );
00398     printf( "Subgraphs filtered by error                 = %8d. (%6.2f %%)\n", p->nFilterError,  !p->nTried? 0 : 100.0*p->nFilterError/p->nTried );
00399     printf( "Subgraphs filtered by isomorphism           = %8d. (%6.2f %%)\n", p->nFilterSame,   !p->nTried? 0 : 100.0*p->nFilterSame/p->nTried );
00400     printf( "Subgraphs added                             = %8d. (%6.2f %%)\n", p->nAdded,        !p->nTried? 0 : 100.0*p->nAdded/p->nTried );
00401     printf( "Functions added                             = %8d. (%6.2f %%)\n", p->nAddedFuncs,   !p->nTried? 0 : 100.0*p->nAddedFuncs/p->nTried );
00402 
00403     p->timeOther = p->timeTotal - p->timeCollect - p->timeTruth - p->timeCanon;
00404     PRTP( "Collecting nodes ", p->timeCollect, p->timeTotal );
00405     PRTP( "Computing truth  ", p->timeTruth, p->timeTotal );
00406     PRTP( "Canonicizing     ", p->timeCanon, p->timeTotal );
00407     PRTP( "Other            ", p->timeOther, p->timeTotal );
00408     PRTP( "TOTAL            ", p->timeTotal, p->timeTotal );
00409     if ( p->nFunsFound )
00410     printf( "During rewriting found = %d and not found = %d functions.\n", p->nFunsFound, p->nFunsNotFound );
00411 }

void Abc_NtkRecStart ( Abc_Ntk_t pNtk,
int  nVars,
int  nCuts 
)

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

Synopsis [Starts the record for the given network.]

Description []

SideEffects []

SeeAlso []

Definition at line 143 of file abcRec.c.

00144 {
00145     Abc_ManRec_t * p;
00146     Abc_Obj_t * pObj, ** ppSpot;
00147     char Buffer[10];
00148     unsigned * pTruth;
00149     int i, RetValue;
00150     int clkTotal = clock(), clk;
00151 
00152     assert( s_pMan == NULL );
00153     if ( pNtk == NULL )
00154     {
00155         assert( nVars > 2 && nVars <= 16 );
00156         pNtk = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
00157         pNtk->pName = Extra_UtilStrsav( "record" );
00158     }
00159     else
00160     {
00161         if ( Abc_NtkGetChoiceNum(pNtk) > 0 )
00162         {
00163             printf( "The starting record should be a network without choice nodes.\n" );
00164             return;
00165         }
00166         if ( Abc_NtkPiNum(pNtk) > 16 )
00167         {
00168             printf( "The starting record should be a network with no more than %d primary inputs.\n", 16 );
00169             return;
00170         }
00171         if ( Abc_NtkPiNum(pNtk) > nVars )
00172             printf( "The starting record has %d inputs (warning only).\n", Abc_NtkPiNum(pNtk) );
00173         pNtk = Abc_NtkDup( pNtk );
00174     }
00175     // create the primary inputs
00176     for ( i = Abc_NtkPiNum(pNtk); i < nVars; i++ )
00177     {
00178         pObj = Abc_NtkCreatePi( pNtk );
00179         Buffer[0] = 'a' + i;
00180         Buffer[1] = 0;
00181         Abc_ObjAssignName( pObj, Buffer, NULL );
00182     }
00183     Abc_NtkCleanCopy( pNtk );
00184     Abc_NtkCleanEquiv( pNtk );
00185 
00186     // start the manager
00187     p = ALLOC( Abc_ManRec_t, 1 );
00188     memset( p, 0, sizeof(Abc_ManRec_t) );
00189     p->pNtk = pNtk;
00190     p->nVars = Abc_NtkPiNum(pNtk);
00191     p->nWords = Kit_TruthWordNum( p->nVars );
00192     p->nCuts = nCuts;
00193     p->nVarsInit = nVars;
00194 
00195     // create elementary truth tables
00196     p->vTtElems = Vec_PtrAlloc( 0 ); assert( p->vTtElems->pArray == NULL );
00197     p->vTtElems->nSize = p->nVars;
00198     p->vTtElems->nCap = p->nVars;
00199     p->vTtElems->pArray = (void *)Extra_TruthElementary( p->nVars );        
00200 
00201     // allocate room for node truth tables
00202     if ( Abc_NtkObjNum(pNtk) > (1<<14) )
00203         p->vTtNodes = Vec_PtrAllocSimInfo( 2 * Abc_NtkObjNum(pNtk), p->nWords );
00204     else
00205         p->vTtNodes = Vec_PtrAllocSimInfo( 1<<14, p->nWords );
00206 
00207     // create hash table
00208     p->nBins = 50011;
00209     p->pBins = ALLOC( Abc_Obj_t *, p->nBins );
00210     memset( p->pBins, 0, sizeof(Abc_Obj_t *) * p->nBins );
00211 
00212     // set elementary tables
00213     Kit_TruthFill( Vec_PtrEntry(p->vTtNodes, 0), p->nVars );
00214     Abc_NtkForEachPi( pNtk, pObj, i )
00215         Kit_TruthCopy( Vec_PtrEntry(p->vTtNodes, pObj->Id), Vec_PtrEntry(p->vTtElems, i), p->nVars );
00216 
00217     // compute the tables
00218 clk = clock();
00219     Abc_AigForEachAnd( pNtk, pObj, i )
00220     {
00221         RetValue = Abc_NtkRecComputeTruth( pObj, p->vTtNodes, p->nVars );
00222         assert( RetValue );
00223     }
00224 p->timeTruth += clock() - clk;
00225 
00226     // insert the PO nodes into the table
00227     Abc_NtkForEachPo( pNtk, pObj, i )
00228     {
00229         p->nTried++;
00230         p->nAdded++;
00231 
00232         pObj = Abc_ObjFanin0(pObj);
00233         pTruth = Vec_PtrEntry( p->vTtNodes, pObj->Id );
00234 
00235         if ( pTruth[0] == 1128481603 )
00236         {
00237             int x = 0;
00238         }
00239 
00240         // add the resulting truth table to the hash table 
00241         ppSpot = Abc_NtkRecTableLookup( p, pTruth, p->nVars );
00242         assert( pObj->pEquiv == NULL );
00243         assert( pObj->pCopy == NULL );
00244         if ( *ppSpot == NULL )
00245         {
00246             p->nAddedFuncs++;
00247             *ppSpot = pObj;
00248         }
00249         else
00250         {
00251             pObj->pEquiv = (*ppSpot)->pEquiv;
00252             (*ppSpot)->pEquiv = (Hop_Obj_t *)pObj;
00253             if ( !Abc_NtkRecAddCutCheckCycle_rec(*ppSpot, pObj) )
00254                 printf( "Loop!\n" );
00255         }
00256     }
00257 
00258     // temporaries
00259     p->pBytes = ALLOC( int, 4*p->nWords );
00260     p->pMints = ALLOC( int, 2*p->nVars );
00261     p->pTemp1 = ALLOC( unsigned, p->nWords );
00262     p->pTemp2 = ALLOC( unsigned, p->nWords );
00263     p->vNodes = Vec_PtrAlloc( 100 );
00264     p->vTtTemps = Vec_PtrAllocSimInfo( 64, p->nWords );
00265     p->vMemory = Vec_IntAlloc( Abc_TruthWordNum(p->nVars) * 1000 );
00266 
00267     // set the manager
00268     s_pMan = p;
00269 p->timeTotal += clock() - clkTotal;
00270 }

void Abc_NtkRecStop (  ) 

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

Synopsis [Returns the given record.]

Description []

SideEffects []

SeeAlso []

Definition at line 283 of file abcRec.c.

00284 {
00285     assert( s_pMan != NULL );
00286     if ( s_pMan->pNtk )
00287         Abc_NtkDelete( s_pMan->pNtk );
00288     Vec_PtrFree( s_pMan->vTtNodes );
00289     Vec_PtrFree( s_pMan->vTtElems );
00290     free( s_pMan->pBins );
00291 
00292     // temporaries
00293     free( s_pMan->pBytes );
00294     free( s_pMan->pMints );
00295     free( s_pMan->pTemp1 );
00296     free( s_pMan->pTemp2 );
00297     Vec_PtrFree( s_pMan->vNodes );
00298     Vec_PtrFree( s_pMan->vTtTemps );
00299     if ( s_pMan->vLabels )
00300         Vec_PtrFree( s_pMan->vLabels );
00301     if ( s_pMan->vCosts )
00302         Vec_StrFree( s_pMan->vCosts );
00303     Vec_IntFree( s_pMan->vMemory );
00304 
00305     free( s_pMan );
00306     s_pMan = NULL;
00307 }

int Abc_NtkRecStrashNode ( Abc_Ntk_t pNtkNew,
Abc_Obj_t pObj,
unsigned *  pTruth,
int  nVars 
)

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

Synopsis [Strashes the given node using its local function.]

Description [Assumes that the fanins are already strashed. Returns 0 if the function is not found in the table.]

SideEffects []

SeeAlso []

Definition at line 1041 of file abcRec.c.

01042 {
01043     char pCanonPerm[16];
01044     Abc_Ntk_t * pAig = s_pMan->pNtk;
01045     unsigned * pInOut = s_pMan->pTemp1;
01046     unsigned * pTemp = s_pMan->pTemp2;
01047     unsigned * pTruthRec;
01048     Abc_Obj_t * pCand, * pCandMin, * pLeaf, * pFanin, ** ppSpot;
01049     unsigned uCanonPhase;
01050     int i, nLeaves, CostMin, Cost, nOnes, fCompl;
01051 
01052     // check if the record works
01053     nLeaves = Abc_ObjFaninNum(pObj);
01054     assert( nLeaves >= 3 && nLeaves <= s_pMan->nVars );
01055     pFanin = Abc_ObjFanin0(pObj);
01056     assert( Abc_ObjRegular(pFanin->pCopy)->pNtk == pNtkNew );
01057     assert( s_pMan != NULL );
01058     assert( nVars == s_pMan->nVars );
01059 
01060     // copy the truth table
01061     Kit_TruthCopy( pInOut, pTruth, nVars );
01062 
01063     // set permutation
01064     for ( i = 0; i < nVars; i++ )
01065         pCanonPerm[i] = i;
01066 
01067     // canonicize the truth table
01068     uCanonPhase = Kit_TruthSemiCanonicize( pInOut, pTemp, nVars, pCanonPerm, (short *)s_pMan->pMints );
01069 
01070     // get hold of the curresponding class
01071     ppSpot = Abc_NtkRecTableLookup( s_pMan, pInOut, nVars );
01072     if ( *ppSpot == NULL )
01073     {
01074         s_pMan->nFunsNotFound++;        
01075 //        printf( "The class of a function with %d inputs is not found.\n", nLeaves );
01076         return 0;
01077     }
01078     s_pMan->nFunsFound++;        
01079 
01080     // make sure the truth table is the same
01081     pTruthRec = Vec_PtrEntry( s_pMan->vTtNodes, (*ppSpot)->Id );
01082     if ( !Kit_TruthIsEqualWithPhase( pTruthRec, pInOut, nVars ) )
01083     {
01084         assert( 0 );
01085         return 0;
01086     }
01087 
01088 
01089     // allocate storage for costs
01090     if ( s_pMan->vLabels && Vec_PtrSize(s_pMan->vLabels) < Abc_NtkObjNumMax(pAig) )
01091     {
01092         Vec_PtrFree( s_pMan->vLabels );
01093         s_pMan->vLabels = NULL;
01094     }
01095     if ( s_pMan->vLabels == NULL )
01096         s_pMan->vLabels = Vec_PtrStart( Abc_NtkObjNumMax(pAig) );
01097 
01098     // go through the variables in the new truth table
01099     Abc_NtkIncrementTravId( pAig );
01100     for ( i = 0; i < nLeaves; i++ )
01101     {
01102         // get hold of the corresponding fanin
01103         pFanin = Abc_ObjFanin( pObj, pCanonPerm[i] )->pCopy;
01104         pFanin = Abc_ObjNotCond( pFanin, (uCanonPhase & (1 << i)) );
01105         // label the PI of the AIG subgraphs with this fanin
01106         pLeaf = Abc_NtkPi( pAig, i );
01107         Vec_PtrWriteEntry( s_pMan->vLabels, pLeaf->Id, pFanin );
01108         Abc_NodeSetTravIdCurrent( pLeaf );
01109     }
01110 
01111     // go through the candidates - and recursively label them
01112     for ( pCand = *ppSpot; pCand; pCand = (Abc_Obj_t *)pCand->pEquiv )
01113         Abc_NtkRecStrashNodeLabel_rec( pNtkNew, pCand, 0, s_pMan->vLabels );
01114 
01115 
01116     // allocate storage for costs
01117     if ( s_pMan->vCosts && Vec_StrSize(s_pMan->vCosts) < Abc_NtkObjNumMax(pAig) )
01118     {
01119         Vec_StrFree( s_pMan->vCosts );
01120         s_pMan->vCosts = NULL;
01121     }
01122     if ( s_pMan->vCosts == NULL )
01123         s_pMan->vCosts = Vec_StrStart( Abc_NtkObjNumMax(pAig) );
01124 
01125     // find the best subgraph
01126     CostMin = ABC_INFINITY;
01127     pCandMin = NULL;
01128     for ( pCand = *ppSpot; pCand; pCand = (Abc_Obj_t *)pCand->pEquiv )
01129     {
01130         // label the leaves
01131         Abc_NtkIncrementTravId( pAig );
01132         // count the number of non-labeled nodes
01133         Cost = Abc_NtkRecStrashNodeCount_rec( pCand, s_pMan->vCosts, s_pMan->vLabels );
01134         if ( CostMin > Cost )
01135         {
01136 //            printf( "%d ", Cost );
01137             CostMin = Cost;
01138             pCandMin = pCand;
01139         }
01140     }
01141 //    printf( "\n" );
01142     assert( pCandMin != NULL );
01143     if ( pCandMin == NULL )
01144         return 0;
01145 
01146 
01147     // label the leaves
01148     Abc_NtkIncrementTravId( pAig );
01149     for ( i = 0; i < nLeaves; i++ )
01150         Abc_NodeSetTravIdCurrent( Abc_NtkPi(pAig, i) );
01151 
01152     // implement the subgraph
01153     pObj->pCopy = Abc_NtkRecStrashNodeLabel_rec( pNtkNew, pCandMin, 1, s_pMan->vLabels );
01154     assert( Abc_ObjRegular(pObj->pCopy)->pNtk == pNtkNew );
01155 
01156     // determine phase difference
01157     nOnes = Kit_TruthCountOnes(pTruth, nVars);
01158     fCompl = (nOnes > (1<< nVars)/2);
01159 //    assert( fCompl == ((uCanonPhase & (1 << nVars)) > 0) );
01160 
01161     nOnes = Kit_TruthCountOnes(pTruthRec, nVars);
01162     fCompl ^= (nOnes > (1<< nVars)/2);
01163     // complement
01164     pObj->pCopy = Abc_ObjNotCond( pObj->pCopy, fCompl );
01165     return 1;
01166 }

Abc_Ntk_t* Abc_NtkRecUse (  ) 

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

Synopsis [Returns the given record.]

Description []

SideEffects []

SeeAlso []

Definition at line 320 of file abcRec.c.

00321 {
00322     Abc_ManRec_t * p = s_pMan;
00323     Abc_Ntk_t * pNtk = p->pNtk;
00324     assert( p != NULL );
00325     Abc_NtkRecPs();
00326     p->pNtk = NULL;
00327     Abc_NtkRecStop();
00328     return pNtk;
00329 }

int Abc_NtkRecVarNum (  ) 

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

Synopsis [Starts the record for the given network.]

Description []

SideEffects []

SeeAlso []

Definition at line 111 of file abcRec.c.

00112 {
00113     return (s_pMan != NULL)? s_pMan->nVars : -1;
00114 }

int Abc_NtkRefactor ( Abc_Ntk_t pNtk,
int  nNodeSizeMax,
int  nConeSizeMax,
bool  fUpdateLevel,
bool  fUseZeros,
bool  fUseDcs,
bool  fVerbose 
)

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

Synopsis [Performs incremental resynthesis of the AIG.]

Description [Starting from each node, computes a reconvergence-driven cut, derives BDD of the cut function, constructs ISOP, factors the ISOP, and replaces the current implementation of the MFFC of the node by the new factored form, if the number of AIG nodes is reduced and the total number of levels of the AIG network is not increated. Returns the number of AIG nodes saved.]

SideEffects []

SeeAlso []

Definition at line 85 of file abcRefactor.c.

00086 {
00087     ProgressBar * pProgress;
00088     Abc_ManRef_t * pManRef;
00089     Abc_ManCut_t * pManCut;
00090     Dec_Graph_t * pFForm;
00091     Vec_Ptr_t * vFanins;
00092     Abc_Obj_t * pNode;
00093     int clk, clkStart = clock();
00094     int i, nNodes;
00095 
00096     assert( Abc_NtkIsStrash(pNtk) );
00097     // cleanup the AIG
00098     Abc_AigCleanup(pNtk->pManFunc);
00099     // start the managers
00100     pManCut = Abc_NtkManCutStart( nNodeSizeMax, nConeSizeMax, 2, 1000 );
00101     pManRef = Abc_NtkManRefStart( nNodeSizeMax, nConeSizeMax, fUseDcs, fVerbose );
00102     pManRef->vLeaves   = Abc_NtkManCutReadCutLarge( pManCut );
00103     // compute the reverse levels if level update is requested
00104     if ( fUpdateLevel )
00105         Abc_NtkStartReverseLevels( pNtk, 0 );
00106 
00107     // resynthesize each node once
00108     pManRef->nNodesBeg = Abc_NtkNodeNum(pNtk);
00109     nNodes = Abc_NtkObjNumMax(pNtk);
00110     pProgress = Extra_ProgressBarStart( stdout, nNodes );
00111     Abc_NtkForEachNode( pNtk, pNode, i )
00112     {
00113         Extra_ProgressBarUpdate( pProgress, i, NULL );
00114         // skip the constant node
00115 //        if ( Abc_NodeIsConst(pNode) )
00116 //            continue;
00117         // skip persistant nodes
00118         if ( Abc_NodeIsPersistant(pNode) )
00119             continue;
00120         // skip the nodes with many fanouts
00121         if ( Abc_ObjFanoutNum(pNode) > 1000 )
00122             continue;
00123         // stop if all nodes have been tried once
00124         if ( i >= nNodes )
00125             break;
00126         // compute a reconvergence-driven cut
00127 clk = clock();
00128         vFanins = Abc_NodeFindCut( pManCut, pNode, fUseDcs );
00129 pManRef->timeCut += clock() - clk;
00130         // evaluate this cut
00131 clk = clock();
00132         pFForm = Abc_NodeRefactor( pManRef, pNode, vFanins, fUpdateLevel, fUseZeros, fUseDcs, fVerbose );
00133 pManRef->timeRes += clock() - clk;
00134         if ( pFForm == NULL )
00135             continue;
00136         // acceptable replacement found, update the graph
00137 clk = clock();
00138         Dec_GraphUpdateNetwork( pNode, pFForm, fUpdateLevel, pManRef->nLastGain );
00139 pManRef->timeNtk += clock() - clk;
00140         Dec_GraphFree( pFForm );
00141 //    {
00142 //        extern int s_TotalChanges;
00143 //        s_TotalChanges++;
00144 //    }
00145     }
00146     Extra_ProgressBarStop( pProgress );
00147 pManRef->timeTotal = clock() - clkStart;
00148     pManRef->nNodesEnd = Abc_NtkNodeNum(pNtk);
00149 
00150     // print statistics of the manager
00151     if ( fVerbose )
00152         Abc_NtkManRefPrintStats( pManRef );
00153     // delete the managers
00154     Abc_NtkManCutStop( pManCut );
00155     Abc_NtkManRefStop( pManRef );
00156     // put the nodes into the DFS order and reassign their IDs
00157     Abc_NtkReassignIds( pNtk );
00158 //    Abc_AigCheckFaninOrder( pNtk->pManFunc );
00159     // fix the levels
00160     if ( fUpdateLevel )
00161         Abc_NtkStopReverseLevels( pNtk );
00162     else
00163         Abc_NtkLevel( pNtk );
00164     // check
00165     if ( !Abc_NtkCheck( pNtk ) )
00166     {
00167         printf( "Abc_NtkRefactor: The network check has failed.\n" );
00168         return 0;
00169     }
00170     return 1;
00171 }

int Abc_NtkRemoveDupFanins ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Makes nodes of the network fanin-dup-free.]

Description [Returns the number of pairs of duplicated fanins.]

SideEffects []

SeeAlso []

Definition at line 112 of file abcMinBase.c.

00113 {
00114     Abc_Obj_t * pNode;
00115     int i, Counter;
00116     assert( Abc_NtkIsBddLogic(pNtk) );
00117     Counter = 0;
00118     Abc_NtkForEachNode( pNtk, pNode, i )
00119         Counter += Abc_NodeRemoveDupFanins( pNode );
00120     return Counter;
00121 }

int Abc_NtkRemoveSelfFeedLatches ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Replaces self-feeding latches by latches with constant inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 111 of file abcLatch.c.

00112 {
00113     Abc_Obj_t * pLatch, * pConst1;
00114     int i, Counter;
00115     Counter = 0;
00116     Abc_NtkForEachLatch( pNtk, pLatch, i )
00117     {
00118         if ( Abc_NtkLatchIsSelfFeed( pLatch ) )
00119         {
00120             if ( Abc_NtkIsStrash(pNtk) )
00121                 pConst1 = Abc_AigConst1(pNtk);
00122             else
00123                 pConst1 = Abc_NtkCreateNodeConst1(pNtk);
00124             Abc_ObjPatchFanin( Abc_ObjFanin0(pLatch), Abc_ObjFanin0(Abc_ObjFanin0(pLatch)), pConst1 );
00125             Counter++;
00126         }
00127     }
00128     return Counter;
00129 }

int Abc_NtkRewrite ( Abc_Ntk_t pNtk,
int  fUpdateLevel,
int  fUseZeros,
int  fVerbose,
int  fVeryVerbose,
int  fPlaceEnable 
)

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

Synopsis [Performs incremental rewriting of the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 58 of file abcRewrite.c.

00059 {
00060     ProgressBar * pProgress;
00061     Cut_Man_t * pManCut;
00062     Rwr_Man_t * pManRwr;
00063     Abc_Obj_t * pNode;
00064     Vec_Ptr_t * vAddedCells = NULL, * vUpdatedNets = NULL;
00065     Dec_Graph_t * pGraph;
00066     int i, nNodes, nGain, fCompl;
00067     int clk, clkStart = clock();
00068 
00069     assert( Abc_NtkIsStrash(pNtk) );
00070     // cleanup the AIG
00071     Abc_AigCleanup(pNtk->pManFunc);
00072 /*
00073     {
00074         Vec_Vec_t * vParts;
00075         vParts = Abc_NtkPartitionSmart( pNtk, 50, 1 );
00076         Vec_VecFree( vParts );
00077     }
00078 */
00079 
00080     // start placement package
00081 //    if ( fPlaceEnable )
00082 //    {
00083 //        Abc_PlaceBegin( pNtk );
00084 //        vAddedCells = Abc_AigUpdateStart( pNtk->pManFunc, &vUpdatedNets );
00085 //    }
00086 
00087     // start the rewriting manager
00088     pManRwr = Rwr_ManStart( 0 );
00089     if ( pManRwr == NULL )
00090         return 0;
00091     // compute the reverse levels if level update is requested
00092     if ( fUpdateLevel )
00093         Abc_NtkStartReverseLevels( pNtk, 0 );
00094     // start the cut manager
00095 clk = clock();
00096     pManCut = Abc_NtkStartCutManForRewrite( pNtk );
00097 Rwr_ManAddTimeCuts( pManRwr, clock() - clk );
00098     pNtk->pManCut = pManCut;
00099 
00100     if ( fVeryVerbose )
00101         Rwr_ScoresClean( pManRwr );
00102 
00103     // resynthesize each node once
00104     pManRwr->nNodesBeg = Abc_NtkNodeNum(pNtk);
00105     nNodes = Abc_NtkObjNumMax(pNtk);
00106     pProgress = Extra_ProgressBarStart( stdout, nNodes );
00107     Abc_NtkForEachNode( pNtk, pNode, i )
00108     {
00109         Extra_ProgressBarUpdate( pProgress, i, NULL );
00110         // stop if all nodes have been tried once
00111         if ( i >= nNodes )
00112             break;
00113         // skip persistant nodes
00114         if ( Abc_NodeIsPersistant(pNode) )
00115             continue;
00116         // skip the nodes with many fanouts
00117         if ( Abc_ObjFanoutNum(pNode) > 1000 )
00118             continue;
00119 
00120         // for each cut, try to resynthesize it
00121         nGain = Rwr_NodeRewrite( pManRwr, pManCut, pNode, fUpdateLevel, fUseZeros, fPlaceEnable );
00122         if ( !(nGain > 0 || nGain == 0 && fUseZeros) )
00123             continue;
00124         // if we end up here, a rewriting step is accepted
00125 
00126         // get hold of the new subgraph to be added to the AIG
00127         pGraph = Rwr_ManReadDecs(pManRwr);
00128         fCompl = Rwr_ManReadCompl(pManRwr);
00129 
00130         // reset the array of the changed nodes
00131         if ( fPlaceEnable )
00132             Abc_AigUpdateReset( pNtk->pManFunc );
00133 
00134         // complement the FF if needed
00135         if ( fCompl ) Dec_GraphComplement( pGraph );
00136 clk = clock();
00137         Dec_GraphUpdateNetwork( pNode, pGraph, fUpdateLevel, nGain );
00138 Rwr_ManAddTimeUpdate( pManRwr, clock() - clk );
00139         if ( fCompl ) Dec_GraphComplement( pGraph );
00140 
00141         // use the array of changed nodes to update placement
00142 //        if ( fPlaceEnable )
00143 //            Abc_PlaceUpdate( vAddedCells, vUpdatedNets );
00144     }
00145     Extra_ProgressBarStop( pProgress );
00146 Rwr_ManAddTimeTotal( pManRwr, clock() - clkStart );
00147     // print stats
00148     pManRwr->nNodesEnd = Abc_NtkNodeNum(pNtk);
00149     if ( fVerbose )
00150         Rwr_ManPrintStats( pManRwr );
00151 //        Rwr_ManPrintStatsFile( pManRwr );
00152     if ( fVeryVerbose )
00153         Rwr_ScoresReport( pManRwr );
00154     // delete the managers
00155     Rwr_ManStop( pManRwr );
00156     Cut_ManStop( pManCut );
00157     pNtk->pManCut = NULL;
00158 
00159     // start placement package
00160 //    if ( fPlaceEnable )
00161 //    {
00162 //        Abc_PlaceEnd( pNtk );
00163 //        Abc_AigUpdateStop( pNtk->pManFunc );
00164 //    }
00165 
00166     // put the nodes into the DFS order and reassign their IDs
00167     {
00168 //        int clk = clock();
00169     Abc_NtkReassignIds( pNtk );
00170 //        PRT( "time", clock() - clk );
00171     }
00172 //    Abc_AigCheckFaninOrder( pNtk->pManFunc );
00173     // fix the levels
00174     if ( fUpdateLevel )
00175         Abc_NtkStopReverseLevels( pNtk );
00176     else
00177         Abc_NtkLevel( pNtk );
00178     // check
00179     if ( !Abc_NtkCheck( pNtk ) )
00180     {
00181         printf( "Abc_NtkRewrite: The network check has failed.\n" );
00182         return 0;
00183     }
00184     return 1;
00185 }

Vec_Ptr_t* Abc_NtkSaveCopy ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Saves copy field of the objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 550 of file abcUtil.c.

00551 {
00552     Vec_Ptr_t * vCopies;
00553     Abc_Obj_t * pObj;
00554     int i;
00555     vCopies = Vec_PtrStart( Abc_NtkObjNumMax(pNtk) );
00556     Abc_NtkForEachObj( pNtk, pObj, i )
00557         Vec_PtrWriteEntry( vCopies, i, pObj->pCopy );
00558     return vCopies;
00559 }

static void Abc_NtkSetBackup ( Abc_Ntk_t pNtk,
Abc_Ntk_t pNetBackup 
) [inline, static]

Definition at line 294 of file abc.h.

00294 { pNtk->pNetBackup = pNetBackup; }

void Abc_NtkSetMvVarValues ( Abc_Obj_t pObj,
int  nValues 
)

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

Synopsis [Duplicate the MV variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 80 of file abcBlifMv.c.

00081 {
00082     Extra_MmFlex_t * pFlex;
00083     struct temp 
00084     { 
00085         int nValues; 
00086         char ** pNames; 
00087     } * pVarStruct;
00088     assert( nValues > 1 );
00089     // skip binary signals
00090     if ( nValues == 2 )
00091         return;
00092     // skip already assigned signals
00093     if ( Abc_ObjMvVar(pObj) != NULL )
00094         return;
00095     // create the structure
00096     pFlex = Abc_NtkMvVarMan( pObj->pNtk );
00097     pVarStruct = (void *)Extra_MmFlexEntryFetch( pFlex, sizeof(struct temp) );
00098     pVarStruct->nValues = nValues;
00099     pVarStruct->pNames = NULL;
00100     Abc_ObjSetMvVar( pObj, pVarStruct );
00101 }

static void Abc_NtkSetName ( Abc_Ntk_t pNtk,
char *  pName 
) [inline, static]

Definition at line 292 of file abc.h.

00292 { pNtk->pName      = pName;      } 

void Abc_NtkSetNodeLevelsArrival ( Abc_Ntk_t pNtkOld  ) 

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

Synopsis [Sets the CI node levels according to the arrival info.]

Description []

SideEffects []

SeeAlso []

Definition at line 466 of file abcTiming.c.

00467 {
00468     Abc_Obj_t * pNodeOld, * pNodeNew;
00469     float tAndDelay;
00470     int i;
00471     if ( pNtkOld->pManTime == NULL )
00472         return;
00473     if ( Mio_LibraryReadNand2(Abc_FrameReadLibGen()) == NULL )
00474         return;
00475     tAndDelay = Mio_LibraryReadDelayNand2Max(Abc_FrameReadLibGen());
00476     Abc_NtkForEachPi( pNtkOld, pNodeOld, i )
00477     {
00478         pNodeNew = pNodeOld->pCopy;
00479         pNodeNew->Level = (int)(Abc_NodeArrival(pNodeOld)->Worst / tAndDelay);
00480     }
00481 }

static void Abc_NtkSetSpec ( Abc_Ntk_t pNtk,
char *  pName 
) [inline, static]

Definition at line 293 of file abc.h.

00293 { pNtk->pSpec      = pName;      } 

static void Abc_NtkSetStep ( Abc_Ntk_t pNtk,
int  iStep 
) [inline, static]

Definition at line 295 of file abc.h.

00295 { pNtk->iStep      = iStep;      }

void Abc_NtkShortNames ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Replaces names by short names.]

Description []

SideEffects []

SeeAlso []

Definition at line 453 of file abcNames.c.

00454 {
00455     Nm_ManFree( pNtk->pManName );
00456     pNtk->pManName = Nm_ManCreate( Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk) + Abc_NtkBoxNum(pNtk) );
00457     Abc_NtkAddDummyPiNames( pNtk );
00458     Abc_NtkAddDummyPoNames( pNtk );
00459     Abc_NtkAddDummyAssertNames( pNtk );
00460     Abc_NtkAddDummyBoxNames( pNtk );
00461 }

int Abc_NtkSizeOfGlobalBdds ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Returns the shared size of global BDDs of the COs.]

Description []

SideEffects []

SeeAlso []

Definition at line 475 of file abcNtbdd.c.

00476 {
00477     Vec_Ptr_t * vFuncsGlob;
00478     Abc_Obj_t * pObj;
00479     int RetValue, i;
00480     // complement the global functions
00481     vFuncsGlob = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
00482     Abc_NtkForEachCo( pNtk, pObj, i )
00483         Vec_PtrPush( vFuncsGlob, Abc_ObjGlobalBdd(pObj) );
00484     RetValue = Cudd_SharingSize( (DdNode **)Vec_PtrArray(vFuncsGlob), Vec_PtrSize(vFuncsGlob) );
00485     Vec_PtrFree( vFuncsGlob );
00486     return RetValue;
00487 }

int Abc_NtkSopToAig ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Converts the network from SOP to AIG representation.]

Description []

SideEffects []

SeeAlso []

Definition at line 551 of file abcFunc.c.

00552 {
00553     Abc_Obj_t * pNode;
00554     Hop_Man_t * pMan;
00555     int i;
00556 
00557     assert( Abc_NtkHasSop(pNtk) ); 
00558 
00559     // start the functionality manager
00560     pMan = Hop_ManStart();
00561 
00562     // convert each node from SOP to BDD
00563     Abc_NtkForEachNode( pNtk, pNode, i )
00564     {
00565         assert( pNode->pData );
00566         pNode->pData = Abc_ConvertSopToAig( pMan, pNode->pData );
00567         if ( pNode->pData == NULL )
00568         {
00569             printf( "Abc_NtkSopToAig: Error while converting SOP into AIG.\n" );
00570             return 0;
00571         }
00572     }
00573     Extra_MmFlexStop( pNtk->pManFunc );
00574     pNtk->pManFunc = pMan;
00575 
00576     // update the network type
00577     pNtk->ntkFunc = ABC_FUNC_AIG;
00578     return 1;
00579 }

int Abc_NtkSopToBdd ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Converts the network from SOP to BDD representation.]

Description []

SideEffects []

SeeAlso []

Definition at line 50 of file abcFunc.c.

00051 {
00052     Abc_Obj_t * pNode;
00053     DdManager * dd;
00054     int nFaninsMax, i;
00055  
00056     assert( Abc_NtkHasSop(pNtk) ); 
00057 
00058     // start the functionality manager
00059     nFaninsMax = Abc_NtkGetFaninMax( pNtk );
00060     if ( nFaninsMax == 0 )
00061         printf( "Warning: The network has only constant nodes.\n" );
00062 
00063     dd = Cudd_Init( nFaninsMax, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
00064 
00065     // convert each node from SOP to BDD
00066     Abc_NtkForEachNode( pNtk, pNode, i )
00067     {
00068         assert( pNode->pData );
00069         pNode->pData = Abc_ConvertSopToBdd( dd, pNode->pData );
00070         if ( pNode->pData == NULL )
00071         {
00072             printf( "Abc_NtkSopToBdd: Error while converting SOP into BDD.\n" );
00073             return 0;
00074         }
00075         Cudd_Ref( pNode->pData );
00076     }
00077 
00078     Extra_MmFlexStop( pNtk->pManFunc );
00079     pNtk->pManFunc = dd;
00080 
00081     // update the network type
00082     pNtk->ntkFunc = ABC_FUNC_BDD;
00083     return 1;
00084 }

static char* Abc_NtkSpec ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 285 of file abc.h.

00285 { return pNtk->pSpec;            }

Abc_Ntk_t* Abc_NtkStartFrom ( Abc_Ntk_t pNtk,
Abc_NtkType_t  Type,
Abc_NtkFunc_t  Func 
)

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

Synopsis [Starts a new network using existing network as a model.]

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file abcNtk.c.

00098 {
00099     Abc_Ntk_t * pNtkNew; 
00100     Abc_Obj_t * pObj;
00101     int fCopyNames, i;
00102     if ( pNtk == NULL )
00103         return NULL;
00104     // decide whether to copy the names
00105     fCopyNames = ( Type != ABC_NTK_NETLIST );
00106     // start the network
00107     pNtkNew = Abc_NtkAlloc( Type, Func, 1 );
00108     // duplicate the name and the spec
00109     pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
00110     pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
00111     // clean the node copy fields
00112     Abc_NtkCleanCopy( pNtk );
00113     // map the constant nodes
00114     if ( Abc_NtkIsStrash(pNtk) && Abc_NtkIsStrash(pNtkNew) )
00115         Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
00116     // clone CIs/CIs/boxes
00117     Abc_NtkForEachPi( pNtk, pObj, i )
00118         Abc_NtkDupObj( pNtkNew, pObj, fCopyNames );
00119     Abc_NtkForEachPo( pNtk, pObj, i )
00120         Abc_NtkDupObj( pNtkNew, pObj, fCopyNames );
00121     Abc_NtkForEachAssert( pNtk, pObj, i )
00122         Abc_NtkDupObj( pNtkNew, pObj, fCopyNames );
00123     Abc_NtkForEachBox( pNtk, pObj, i )
00124         Abc_NtkDupBox( pNtkNew, pObj, fCopyNames );
00125     // transfer the names
00126 //    Abc_NtkTrasferNames( pNtk, pNtkNew );
00127     Abc_ManTimeDup( pNtk, pNtkNew );
00128     // check that the CI/CO/latches are copied correctly
00129     assert( Abc_NtkCiNum(pNtk)    == Abc_NtkCiNum(pNtkNew) );
00130     assert( Abc_NtkCoNum(pNtk)    == Abc_NtkCoNum(pNtkNew) );
00131     assert( Abc_NtkLatchNum(pNtk) == Abc_NtkLatchNum(pNtkNew) );
00132     return pNtkNew;
00133 }

Abc_Ntk_t* Abc_NtkStartFromNoLatches ( Abc_Ntk_t pNtk,
Abc_NtkType_t  Type,
Abc_NtkFunc_t  Func 
)

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

Synopsis [Starts a new network using existing network as a model.]

Description []

SideEffects []

SeeAlso []

Definition at line 146 of file abcNtk.c.

00147 {
00148     Abc_Ntk_t * pNtkNew; 
00149     Abc_Obj_t * pObj;
00150     int i;
00151     if ( pNtk == NULL )
00152         return NULL;
00153     assert( Type != ABC_NTK_NETLIST );
00154     // start the network
00155     pNtkNew = Abc_NtkAlloc( Type, Func, 1 );
00156     // duplicate the name and the spec
00157     pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
00158     pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
00159     // clean the node copy fields
00160     Abc_NtkCleanCopy( pNtk );
00161     // map the constant nodes
00162     if ( Abc_NtkIsStrash(pNtk) && Abc_NtkIsStrash(pNtkNew) )
00163         Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
00164     // clone CIs/CIs/boxes
00165     Abc_NtkForEachPi( pNtk, pObj, i )
00166         Abc_NtkDupObj( pNtkNew, pObj, 1 );
00167     Abc_NtkForEachPo( pNtk, pObj, i )
00168         Abc_NtkDupObj( pNtkNew, pObj, 1 );
00169     Abc_NtkForEachAssert( pNtk, pObj, i )
00170         Abc_NtkDupObj( pNtkNew, pObj, 1 );
00171     Abc_NtkForEachBox( pNtk, pObj, i )
00172     {
00173         if ( Abc_ObjIsLatch(pObj) )
00174             continue;
00175         Abc_NtkDupBox(pNtkNew, pObj, 1);
00176     }
00177     // transfer the names
00178 //    Abc_NtkTrasferNamesNoLatches( pNtk, pNtkNew );
00179     Abc_ManTimeDup( pNtk, pNtkNew );
00180     // check that the CI/CO/latches are copied correctly
00181     assert( Abc_NtkPiNum(pNtk) == Abc_NtkPiNum(pNtkNew) );
00182     assert( Abc_NtkPoNum(pNtk) == Abc_NtkPoNum(pNtkNew) );
00183     return pNtkNew;
00184 }

void Abc_NtkStartMvVars ( Abc_Ntk_t pNtk  ) 

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

FileName [abcBlifMv.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Procedures to process BLIF-MV networks and AIGs.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Starts the Mv-Var manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file abcBlifMv.c.

00043 {
00044     Vec_Att_t * pAttMan;
00045     assert( Abc_NtkMvVar(pNtk) == NULL );
00046     pAttMan = Vec_AttAlloc( 0, Abc_NtkObjNumMax(pNtk) + 1, Extra_MmFlexStart(), Extra_MmFlexStop, NULL, NULL );
00047     Vec_PtrWriteEntry( pNtk->vAttrs, VEC_ATTR_MVVAR, pAttMan );
00048 //printf( "allocing attr\n" );
00049 }

Abc_Ntk_t* Abc_NtkStartRead ( char *  pName  ) 

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

Synopsis [Starts a new network using existing network as a model.]

Description []

SideEffects []

SeeAlso []

Definition at line 221 of file abcNtk.c.

00222 {
00223     Abc_Ntk_t * pNtkNew; 
00224     // allocate the empty network
00225     pNtkNew = Abc_NtkAlloc( ABC_NTK_NETLIST, ABC_FUNC_SOP, 1 );
00226     // set the specs
00227     pNtkNew->pName = Extra_FileNameGeneric(pName);
00228     pNtkNew->pSpec = Extra_UtilStrsav(pName);
00229     if ( pNtkNew->pName == NULL || strlen(pNtkNew->pName) == 0 )
00230     {
00231         FREE( pNtkNew->pName );
00232         pNtkNew->pName = Extra_UtilStrsav("unknown");
00233     }
00234     return pNtkNew;
00235 }

void Abc_NtkStartReverseLevels ( Abc_Ntk_t pNtk,
int  nMaxLevelIncrease 
)

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

Synopsis [Prepares for the computation of required levels.]

Description [This procedure should be called before the required times are used. It starts internal data structures, which records the level from the COs of the network nodes in reverse topologogical order.]

SideEffects []

SeeAlso []

Definition at line 746 of file abcTiming.c.

00747 {
00748     Vec_Ptr_t * vNodes;
00749     Abc_Obj_t * pObj;
00750     int i;
00751     // remember the maximum number of direct levels
00752     pNtk->LevelMax = Abc_NtkLevel(pNtk) + nMaxLevelIncrease;
00753     // start the reverse levels
00754     pNtk->vLevelsR = Vec_IntAlloc( 0 );
00755     Vec_IntFill( pNtk->vLevelsR, 1 + Abc_NtkObjNumMax(pNtk), 0 );
00756     // compute levels in reverse topological order
00757     vNodes = Abc_NtkDfsReverse( pNtk );
00758     Vec_PtrForEachEntry( vNodes, pObj, i )
00759         Abc_ObjSetReverseLevel( pObj, Abc_ObjReverseLevelNew(pObj) );
00760     Vec_PtrFree( vNodes );
00761 }

static int Abc_NtkStep ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 289 of file abc.h.

00289 { return pNtk->iStep;            }

void Abc_NtkStopReverseLevels ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Cleans the data structures used to compute required levels.]

Description []

SideEffects []

SeeAlso []

Definition at line 774 of file abcTiming.c.

00775 {
00776     assert( pNtk->vLevelsR );
00777     Vec_IntFree( pNtk->vLevelsR );
00778     pNtk->vLevelsR = NULL;
00779     pNtk->LevelMax = 0;
00780 
00781 }

Abc_Ntk_t* Abc_NtkStrash ( Abc_Ntk_t pNtk,
int  fAllNodes,
int  fCleanup,
int  fRecord 
)

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

Synopsis [Transforms logic network into structurally hashed AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 164 of file abcStrash.c.

00165 {
00166     Abc_Ntk_t * pNtkAig;
00167     int nNodes;
00168     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsStrash(pNtk) );
00169     // consider the special case when the network is already structurally hashed
00170     if ( Abc_NtkIsStrash(pNtk) )
00171         return Abc_NtkRestrash( pNtk, fCleanup );
00172     // convert the node representation in the logic network to the AIG form
00173     if ( !Abc_NtkToAig(pNtk) )
00174     {
00175         printf( "Converting to AIGs has failed.\n" );
00176         return NULL;
00177     }
00178     // perform strashing
00179 //    Abc_NtkCleanCopy( pNtk );
00180     pNtkAig = Abc_NtkStartFrom( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG );
00181     Abc_NtkStrashPerform( pNtk, pNtkAig, fAllNodes, fRecord );
00182     Abc_NtkFinalize( pNtk, pNtkAig );
00183     // print warning about self-feed latches
00184 //    if ( Abc_NtkCountSelfFeedLatches(pNtkAig) )
00185 //        printf( "Warning: The network has %d self-feeding latches.\n", Abc_NtkCountSelfFeedLatches(pNtkAig) );
00186     // perform cleanup if requested
00187     nNodes = fCleanup? Abc_AigCleanup(pNtkAig->pManFunc) : 0;
00188 //    if ( nNodes )
00189 //        printf( "Warning: AIG cleanup removed %d nodes (this is not a bug).\n", nNodes );
00190     // duplicate EXDC 
00191     if ( pNtk->pExdc )
00192         pNtkAig->pExdc = Abc_NtkDup( pNtk->pExdc );
00193     // make sure everything is okay
00194     if ( !Abc_NtkCheck( pNtkAig ) )
00195     {
00196         printf( "Abc_NtkStrash: The network check has failed.\n" );
00197         Abc_NtkDelete( pNtkAig );
00198         return NULL;
00199     }
00200     return pNtkAig;
00201 }

Abc_Ntk_t* Abc_NtkStrashBlifMv ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Strashes the BLIF-MV netlist.]

Description []

SideEffects []

SeeAlso []

Definition at line 359 of file abcBlifMv.c.

00360 {
00361     int fUsePositional = 0;
00362     Vec_Ptr_t * vNodes;
00363     Abc_Obj_t ** pBits;
00364     Abc_Obj_t ** pValues;
00365     Abc_Ntk_t * pNtkNew;
00366     Abc_Obj_t * pObj, * pTemp, * pBit, * pNet;
00367     int i, k, v, nValues, nValuesMax, nBits;
00368 
00369     assert( Abc_NtkIsNetlist(pNtk) );
00370     assert( Abc_NtkHasBlifMv(pNtk) );
00371     assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
00372     assert( Abc_NtkBlackboxNum(pNtk) == 0 );
00373 
00374     // get the largest number of values
00375     nValuesMax = 2;
00376     Abc_NtkForEachNet( pNtk, pObj, i )
00377     {
00378         nValues = Abc_ObjMvVarNum(pObj);
00379         if ( nValuesMax < nValues )
00380             nValuesMax = nValues;
00381     }
00382     nBits = Extra_Base2Log( nValuesMax );
00383     pBits = ALLOC( Abc_Obj_t *, nBits );
00384 
00385     // clean the node copy fields
00386     Abc_NtkCleanCopy( pNtk );
00387     // collect the nodes
00388     vNodes = Abc_NtkDfs( pNtk, 0 );
00389 
00390     // start the network
00391     pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
00392     // duplicate the name and the spec
00393     pNtkNew->pName = Extra_UtilStrsav( pNtk->pName );
00394 //    pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pName );
00395 
00396     // encode the CI nets
00397     Abc_NtkIncrementTravId( pNtk );
00398     if ( fUsePositional )
00399     {
00400         Abc_NtkForEachCi( pNtk, pObj, i )
00401         {
00402             pNet = Abc_ObjFanout0(pObj);
00403             nValues = Abc_ObjMvVarNum(pNet);
00404             pValues = ALLOC( Abc_Obj_t *, nValues );
00405             // create PIs for the values
00406             for ( v = 0; v < nValues; v++ )
00407             {
00408                 pValues[v] = Abc_NtkCreatePi( pNtkNew );
00409                 Abc_NtkConvertAssignName( pValues[v], pNet, v );
00410             }
00411             // save the values in the fanout net
00412             pNet->pCopy = (Abc_Obj_t *)pValues;
00413             // mark the net
00414             Abc_NodeSetTravIdCurrent( pNet );
00415         }
00416     }
00417     else
00418     {
00419         Abc_NtkForEachCi( pNtk, pObj, i )
00420         {
00421             pNet = Abc_ObjFanout0(pObj);
00422             nValues = Abc_ObjMvVarNum(pNet);
00423             pValues = ALLOC( Abc_Obj_t *, nValues );
00424             // create PIs for the encoding bits
00425             nBits = Extra_Base2Log( nValues );
00426             for ( k = 0; k < nBits; k++ )
00427             {
00428                 pBits[k] = Abc_NtkCreatePi( pNtkNew );
00429                 Abc_NtkConvertAssignName( pBits[k], pNet, k );
00430             }
00431             // encode the values
00432             for ( v = 0; v < nValues; v++ )
00433             {
00434                 pValues[v] = Abc_AigConst1(pNtkNew);
00435                 for ( k = 0; k < nBits; k++ )
00436                 {
00437                     pBit = Abc_ObjNotCond( pBits[k], (v&(1<<k)) == 0 );
00438                     pValues[v] = Abc_AigAnd( pNtkNew->pManFunc, pValues[v], pBit );
00439                 }
00440             }
00441             // save the values in the fanout net
00442             pNet->pCopy = (Abc_Obj_t *)pValues;
00443             // mark the net
00444             Abc_NodeSetTravIdCurrent( pNet );
00445         }
00446     }
00447 
00448     // process nodes in the topological order
00449     Vec_PtrForEachEntry( vNodes, pObj, i )
00450         if ( !Abc_NodeStrashBlifMv( pNtkNew, pObj ) )
00451         {
00452             Abc_NtkDelete( pNtkNew );
00453             return NULL;
00454         }
00455     Vec_PtrFree( vNodes );
00456 
00457     // encode the CO nets
00458     if ( fUsePositional )
00459     {
00460         Abc_NtkForEachCo( pNtk, pObj, i )
00461         {
00462             pNet = Abc_ObjFanin0(pObj);
00463             // skip marked nets
00464             if ( Abc_NodeIsTravIdCurrent(pNet) )
00465                 continue;
00466             Abc_NodeSetTravIdCurrent( pNet );
00467             nValues = Abc_ObjMvVarNum(pNet);
00468             pValues = (Abc_Obj_t **)pNet->pCopy;
00469             for ( v = 0; v < nValues; v++ )
00470             {
00471                 pTemp = Abc_NtkCreatePo( pNtkNew );
00472                 Abc_ObjAddFanin( pTemp, pValues[v] );
00473                 Abc_NtkConvertAssignName( pTemp, pNet, v );
00474             }
00475         }
00476     }
00477     else
00478     {
00479         Abc_NtkForEachCo( pNtk, pObj, i )
00480         {
00481             pNet = Abc_ObjFanin0(pObj);
00482             // skip marked nets
00483             if ( Abc_NodeIsTravIdCurrent(pNet) )
00484                 continue;
00485             Abc_NodeSetTravIdCurrent( pNet );
00486             nValues = Abc_ObjMvVarNum(pNet);
00487             pValues = (Abc_Obj_t **)pNet->pCopy;
00488             nBits = Extra_Base2Log( nValues );
00489             for ( k = 0; k < nBits; k++ )
00490             {
00491                 pBit = Abc_ObjNot( Abc_AigConst1(pNtkNew) );
00492                 for ( v = 0; v < nValues; v++ )
00493                     if ( v & (1<<k) )
00494                         pBit = Abc_AigOr( pNtkNew->pManFunc, pBit, pValues[v] );
00495                 pTemp = Abc_NtkCreatePo( pNtkNew );
00496                 Abc_ObjAddFanin( pTemp, pBit );
00497                 Abc_NtkConvertAssignName( pTemp, pNet, k );
00498             }
00499         }
00500     }
00501 
00502     // cleanup
00503     free( pBits );
00504     Abc_NtkForEachObj( pNtk, pObj, i )
00505         if ( pObj->pCopy )
00506             free( pObj->pCopy );
00507 
00508     // remove dangling nodes
00509     i = Abc_AigCleanup(pNtkNew->pManFunc);
00510 //    printf( "Cleanup removed %d nodes.\n", i );
00511 //    Abc_NtkReassignIds( pNtkNew );
00512 
00513     // check integrity
00514     if ( !Abc_NtkCheck( pNtkNew ) )
00515     {
00516         fprintf( stdout, "Abc_NtkStrashBlifMv(): Network check has failed.\n" );
00517         Abc_NtkDelete( pNtkNew );
00518         return NULL;
00519     }
00520     return pNtkNew;
00521 }

Vec_Ptr_t* Abc_NtkSupport ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Returns the set of CI nodes in the support of the given nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 702 of file abcDfs.c.

00703 {
00704     Vec_Ptr_t * vNodes;
00705     Abc_Obj_t * pNode;
00706     int i;
00707     // set the traversal ID
00708     Abc_NtkIncrementTravId( pNtk );
00709     // start the array of nodes
00710     vNodes = Vec_PtrAlloc( 100 );
00711     // go through the PO nodes and call for each of them
00712     Abc_NtkForEachCo( pNtk, pNode, i )
00713         Abc_NtkNodeSupport_rec( Abc_ObjFanin0(pNode), vNodes );
00714     // add unused CIs
00715     Abc_NtkForEachCi( pNtk, pNode, i )
00716         if ( !Abc_NodeIsTravIdCurrent( pNode ) )
00717             Vec_PtrPush( vNodes, pNode );
00718     assert( Vec_PtrSize(vNodes) == Abc_NtkCiNum(pNtk) );
00719     return vNodes;
00720 }

int Abc_NtkSweep ( Abc_Ntk_t pNtk,
int  fVerbose 
)

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

Synopsis [Tranditional sweep of the network.]

Description [Propagates constant and single-input node, removes dangling nodes.]

SideEffects []

SeeAlso []

Definition at line 536 of file abcSweep.c.

00537 {
00538     Vec_Ptr_t * vNodes;
00539     Abc_Obj_t * pNode, * pFanout, * pDriver;
00540     int i, nNodesOld;
00541     assert( Abc_NtkIsLogic(pNtk) ); 
00542     // convert network to BDD representation
00543     if ( !Abc_NtkToBdd(pNtk) )
00544     {
00545         fprintf( stdout, "Converting to BDD has failed.\n" );
00546         return 1;
00547     }
00548     // perform cleanup
00549     nNodesOld = Abc_NtkNodeNum(pNtk);
00550     Abc_NtkCleanup( pNtk, 0 );
00551     // prepare nodes for sweeping
00552     Abc_NtkRemoveDupFanins(pNtk);
00553     Abc_NtkMinimumBase(pNtk);
00554     // collect sweepable nodes
00555     vNodes = Vec_PtrAlloc( 100 );
00556     Abc_NtkForEachNode( pNtk, pNode, i )
00557         if ( Abc_ObjFaninNum(pNode) < 2 )
00558             Vec_PtrPush( vNodes, pNode );
00559     // sweep the nodes
00560     while ( Vec_PtrSize(vNodes) > 0 )
00561     {
00562         // get any sweepable node
00563         pNode = Vec_PtrPop(vNodes);
00564         if ( !Abc_ObjIsNode(pNode) )
00565             continue;
00566         // get any non-CO fanout of this node
00567         pFanout = Abc_NodeFindNonCoFanout(pNode);
00568         if ( pFanout == NULL )
00569             continue;
00570         assert( Abc_ObjIsNode(pFanout) );
00571         // transform the function of the fanout
00572         if ( Abc_ObjFaninNum(pNode) == 0 )
00573             Abc_NodeConstantInput( pFanout, pNode, Abc_NodeIsConst0(pNode) );
00574         else 
00575         {
00576             assert( Abc_ObjFaninNum(pNode) == 1 );
00577             pDriver = Abc_ObjFanin0(pNode);
00578             if ( Abc_NodeIsInv(pNode) )
00579                 Abc_NodeComplementInput( pFanout, pNode );
00580             Abc_ObjPatchFanin( pFanout, pNode, pDriver );
00581         }
00582         Abc_NodeRemoveDupFanins( pFanout );
00583         Abc_NodeMinimumBase( pFanout );
00584         // check if the fanout should be added
00585         if ( Abc_ObjFaninNum(pFanout) < 2 )
00586             Vec_PtrPush( vNodes, pFanout );
00587         // check if the node has other fanouts
00588         if ( Abc_ObjFanoutNum(pNode) > 0 )
00589             Vec_PtrPush( vNodes, pNode );
00590         else
00591             Abc_NtkDeleteObj_rec( pNode, 1 );
00592     }
00593     Vec_PtrFree( vNodes );
00594     // sweep a node into its CO fanout if all of this is true:
00595     // (a) this node is a single-input node
00596     // (b) the driver of the node has only one fanout (this node)
00597     // (c) the driver is a node
00598     Abc_NtkForEachCo( pNtk, pFanout, i )
00599     {
00600         pNode = Abc_ObjFanin0(pFanout);
00601         if ( Abc_ObjFaninNum(pNode) != 1 )
00602             continue;
00603         pDriver = Abc_ObjFanin0(pNode);
00604         if ( !(Abc_ObjFanoutNum(pDriver) == 1 && Abc_ObjIsNode(pDriver)) )
00605             continue;
00606         // trasform this CO
00607         if ( Abc_NodeIsInv(pNode) )
00608             pDriver->pData = Cudd_Not(pDriver->pData);
00609         Abc_ObjPatchFanin( pFanout, pNode, pDriver );
00610     }
00611     // perform cleanup
00612     Abc_NtkCleanup( pNtk, 0 );
00613     // report
00614     if ( fVerbose )
00615         printf( "Sweep removed %d nodes.\n", nNodesOld - Abc_NtkNodeNum(pNtk) );
00616     return nNodesOld - Abc_NtkNodeNum(pNtk);
00617 }

void Abc_NtkTimeInitialize ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Finalizes the timing manager after setting arr/req times.]

Description []

SideEffects []

SeeAlso []

Definition at line 231 of file abcTiming.c.

00232 {
00233     Abc_Obj_t * pObj;
00234     Abc_Time_t ** ppTimes, * pTime;
00235     int i;
00236     if ( pNtk->pManTime == NULL )
00237         return;
00238     Abc_ManTimeExpand( pNtk->pManTime, Abc_NtkObjNumMax(pNtk), 0 );
00239     // set the default timing
00240     ppTimes = (Abc_Time_t **)pNtk->pManTime->vArrs->pArray;
00241     Abc_NtkForEachPi( pNtk, pObj, i )
00242     {
00243         pTime = ppTimes[pObj->Id];
00244         if ( pTime->Worst != -ABC_INFINITY )
00245             continue;
00246         *pTime = pNtk->pManTime->tArrDef;
00247     }
00248     // set the default timing
00249     ppTimes = (Abc_Time_t **)pNtk->pManTime->vReqs->pArray;
00250     Abc_NtkForEachPo( pNtk, pObj, i )
00251     {
00252         pTime = ppTimes[pObj->Id];
00253         if ( pTime->Worst != -ABC_INFINITY )
00254             continue;
00255         *pTime = pNtk->pManTime->tReqDef;
00256     }
00257     // set the 0 arrival times for latch outputs and constant nodes
00258     ppTimes = (Abc_Time_t **)pNtk->pManTime->vArrs->pArray;
00259     Abc_NtkForEachLatchOutput( pNtk, pObj, i )
00260     {
00261         pTime = ppTimes[pObj->Id];
00262         pTime->Fall = pTime->Rise = pTime->Worst = 0.0;
00263     }
00264 }

void Abc_NtkTimeSetArrival ( Abc_Ntk_t pNtk,
int  ObjId,
float  Rise,
float  Fall 
)

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

Synopsis [Sets the arrival time for an object.]

Description []

SideEffects []

SeeAlso []

Definition at line 175 of file abcTiming.c.

00176 {
00177     Vec_Ptr_t * vTimes;
00178     Abc_Time_t * pTime;
00179     if ( pNtk->pManTime == NULL )
00180         pNtk->pManTime = Abc_ManTimeStart();
00181     if ( pNtk->pManTime->tArrDef.Rise == Rise && pNtk->pManTime->tArrDef.Fall == Fall )
00182         return;
00183     Abc_ManTimeExpand( pNtk->pManTime, ObjId + 1, 1 );
00184     // set the arrival time
00185     vTimes = pNtk->pManTime->vArrs;
00186     pTime = vTimes->pArray[ObjId];
00187     pTime->Rise  = Rise;
00188     pTime->Fall  = Rise;
00189     pTime->Worst = ABC_MAX( Rise, Fall );
00190 }

void Abc_NtkTimeSetDefaultArrival ( Abc_Ntk_t pNtk,
float  Rise,
float  Fall 
)

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

Synopsis [Sets the default arrival time for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 131 of file abcTiming.c.

00132 {
00133     if ( Rise == 0.0 && Fall == 0.0 )
00134         return;
00135     if ( pNtk->pManTime == NULL )
00136         pNtk->pManTime = Abc_ManTimeStart();
00137     pNtk->pManTime->tArrDef.Rise  = Rise;
00138     pNtk->pManTime->tArrDef.Fall  = Fall;
00139     pNtk->pManTime->tArrDef.Worst = ABC_MAX( Rise, Fall );
00140 }

void Abc_NtkTimeSetDefaultRequired ( Abc_Ntk_t pNtk,
float  Rise,
float  Fall 
)

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

Synopsis [Sets the default arrival time for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 153 of file abcTiming.c.

00154 {
00155     if ( Rise == 0.0 && Fall == 0.0 )
00156         return;
00157     if ( pNtk->pManTime == NULL )
00158         pNtk->pManTime = Abc_ManTimeStart();
00159     pNtk->pManTime->tReqDef.Rise  = Rise;
00160     pNtk->pManTime->tReqDef.Rise  = Fall;
00161     pNtk->pManTime->tReqDef.Worst = ABC_MAX( Rise, Fall );
00162 }

void Abc_NtkTimeSetRequired ( Abc_Ntk_t pNtk,
int  ObjId,
float  Rise,
float  Fall 
)

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

Synopsis [Sets the arrival time for an object.]

Description []

SideEffects []

SeeAlso []

Definition at line 203 of file abcTiming.c.

00204 {
00205     Vec_Ptr_t * vTimes;
00206     Abc_Time_t * pTime;
00207     if ( pNtk->pManTime == NULL )
00208         pNtk->pManTime = Abc_ManTimeStart();
00209     if ( pNtk->pManTime->tReqDef.Rise == Rise && pNtk->pManTime->tReqDef.Fall == Fall )
00210         return;
00211     Abc_ManTimeExpand( pNtk->pManTime, ObjId + 1, 1 );
00212     // set the required time
00213     vTimes = pNtk->pManTime->vReqs;
00214     pTime = vTimes->pArray[ObjId];
00215     pTime->Rise  = Rise;
00216     pTime->Fall  = Rise;
00217     pTime->Worst = ABC_MAX( Rise, Fall );
00218 }

int Abc_NtkToAig ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Convers logic network to the SOP form.]

Description []

SideEffects []

SeeAlso []

Definition at line 1127 of file abcFunc.c.

01128 {
01129     assert( !Abc_NtkIsStrash(pNtk) );
01130     if ( Abc_NtkHasAig(pNtk) )
01131         return 1;
01132     if ( Abc_NtkHasMapping(pNtk) )
01133     {
01134         Abc_NtkMapToSop(pNtk);
01135         return Abc_NtkSopToAig(pNtk);
01136     }
01137     if ( Abc_NtkHasBdd(pNtk) )
01138     {
01139         if ( !Abc_NtkBddToSop(pNtk,0) )
01140             return 0;
01141         return Abc_NtkSopToAig(pNtk);
01142     }
01143     if ( Abc_NtkHasSop(pNtk) )
01144         return Abc_NtkSopToAig(pNtk);
01145     assert( 0 );
01146     return 0;
01147 }

int Abc_NtkToBdd ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Convers logic network to the SOP form.]

Description []

SideEffects []

SeeAlso []

Definition at line 1098 of file abcFunc.c.

01099 {
01100     assert( !Abc_NtkIsStrash(pNtk) );
01101     if ( Abc_NtkHasBdd(pNtk) )
01102         return 1;
01103     if ( Abc_NtkHasMapping(pNtk) )
01104     {
01105         Abc_NtkMapToSop(pNtk);
01106         return Abc_NtkSopToBdd(pNtk);
01107     }
01108     if ( Abc_NtkHasSop(pNtk) )
01109         return Abc_NtkSopToBdd(pNtk);
01110     if ( Abc_NtkHasAig(pNtk) )
01111         return Abc_NtkAigToBdd(pNtk);
01112     assert( 0 );
01113     return 0;
01114 }

void* Abc_NtkToFraig ( Abc_Ntk_t pNtk,
void *  pParams,
int  fAllNodes,
int  fExdc 
)

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

Synopsis [Transforms the strashed network into FRAIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 100 of file abcFraig.c.

00101 {
00102     int fInternal = ((Fraig_Params_t *)pParams)->fInternal;
00103     Fraig_Man_t * pMan;
00104     ProgressBar * pProgress;
00105     Vec_Ptr_t * vNodes;
00106     Abc_Obj_t * pNode;
00107     int i;
00108 
00109     assert( Abc_NtkIsStrash(pNtk) );
00110 
00111     // create the FRAIG manager
00112     pMan = Fraig_ManCreate( pParams );
00113 
00114     // map the constant node
00115     Abc_NtkCleanCopy( pNtk );
00116     Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)Fraig_ManReadConst1(pMan);
00117     // create PIs and remember them in the old nodes
00118     Abc_NtkForEachCi( pNtk, pNode, i )
00119         pNode->pCopy = (Abc_Obj_t *)Fraig_ManReadIthVar(pMan, i);
00120  
00121     // perform strashing
00122     vNodes = Abc_AigDfs( pNtk, fAllNodes, 0 );
00123     if ( !fInternal )
00124         pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
00125     Vec_PtrForEachEntry( vNodes, pNode, i )
00126     {
00127         if ( Abc_ObjFaninNum(pNode) == 0 )
00128             continue;
00129         if ( !fInternal )
00130             Extra_ProgressBarUpdate( pProgress, i, NULL );
00131         pNode->pCopy = (Abc_Obj_t *)Fraig_NodeAnd( pMan, 
00132                 Fraig_NotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) ),
00133                 Fraig_NotCond( Abc_ObjFanin1(pNode)->pCopy, Abc_ObjFaninC1(pNode) ) );
00134     }
00135     if ( !fInternal )
00136         Extra_ProgressBarStop( pProgress );
00137     Vec_PtrFree( vNodes );
00138 
00139     // use EXDC to change the mapping of nodes into FRAIG nodes
00140     if ( fExdc )
00141         Abc_NtkFraigRemapUsingExdc( pMan, pNtk );
00142 
00143     // set the primary outputs
00144     Abc_NtkForEachCo( pNtk, pNode, i )
00145         Fraig_ManSetPo( pMan, (Fraig_Node_t *)Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) ) );
00146     return pMan;
00147 }

Abc_Ntk_t* Abc_NtkToLogic ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Transform the netlist into a logic network.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file abcNetlist.c.

00049 {
00050     Abc_Ntk_t * pNtkNew; 
00051     Abc_Obj_t * pObj, * pFanin;
00052     int i, k;
00053     // consider the case of the AIG
00054     if ( Abc_NtkIsStrash(pNtk) )
00055         return Abc_NtkAigToLogicSop( pNtk );
00056     assert( Abc_NtkIsNetlist(pNtk) );
00057     // consider simple case when there is hierarchy
00058 //    assert( pNtk->pDesign == NULL );
00059     assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
00060     assert( Abc_NtkBlackboxNum(pNtk) == 0 );
00061     // start the network
00062     pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, pNtk->ntkFunc );
00063     // duplicate the nodes 
00064     Abc_NtkForEachNode( pNtk, pObj, i )
00065         Abc_NtkDupObj(pNtkNew, pObj, 0);
00066     // reconnect the internal nodes in the new network
00067     Abc_NtkForEachNode( pNtk, pObj, i )
00068         Abc_ObjForEachFanin( pObj, pFanin, k )
00069             Abc_ObjAddFanin( pObj->pCopy, Abc_ObjFanin0(pFanin)->pCopy );
00070     // collect the CO nodes
00071     Abc_NtkFinalize( pNtk, pNtkNew );
00072     // fix the problem with CO pointing directly to CIs
00073     Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
00074     // duplicate EXDC 
00075     if ( pNtk->pExdc )
00076         pNtkNew->pExdc = Abc_NtkToLogic( pNtk->pExdc );
00077     if ( !Abc_NtkCheck( pNtkNew ) )
00078         fprintf( stdout, "Abc_NtkToLogic(): Network check has failed.\n" );
00079     return pNtkNew;
00080 }

Abc_Ntk_t* Abc_NtkToNetlist ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Transform the logic network into a netlist.]

Description []

SideEffects []

SeeAlso []

Definition at line 93 of file abcNetlist.c.

00094 {
00095     Abc_Ntk_t * pNtkNew, * pNtkTemp; 
00096     assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsStrash(pNtk) );
00097     if ( Abc_NtkIsStrash(pNtk) )
00098     {
00099         pNtkTemp = Abc_NtkAigToLogicSop(pNtk);
00100         pNtkNew = Abc_NtkLogicToNetlist( pNtkTemp );
00101         Abc_NtkDelete( pNtkTemp );
00102         return pNtkNew;
00103     }
00104     return Abc_NtkLogicToNetlist( pNtk );
00105 }

Abc_Ntk_t* Abc_NtkToNetlistBench ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Converts the AIG into the netlist.]

Description [This procedure does not copy the choices.]

SideEffects []

SeeAlso []

Definition at line 118 of file abcNetlist.c.

00119 {
00120     Abc_Ntk_t * pNtkNew, * pNtkTemp; 
00121     assert( Abc_NtkIsStrash(pNtk) );
00122     pNtkTemp = Abc_NtkAigToLogicSopBench( pNtk );
00123     pNtkNew = Abc_NtkLogicToNetlist( pNtkTemp );
00124     Abc_NtkDelete( pNtkTemp );
00125     return pNtkNew;
00126 }

Abc_Ntk_t* Abc_NtkTopmost ( Abc_Ntk_t pNtk,
int  nLevels 
)

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

Synopsis [Copies the topmost levels of the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 441 of file abcStrash.c.

00442 {
00443     Abc_Ntk_t * pNtkNew;
00444     Abc_Obj_t * pObjNew, * pPoNew;
00445     int LevelCut;
00446     assert( Abc_NtkIsStrash(pNtk) );
00447     assert( Abc_NtkCoNum(pNtk) == 1 );
00448     // get the cutoff level
00449     LevelCut = ABC_MAX( 0, Abc_AigLevel(pNtk) - nLevels );
00450     // start the network
00451     pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
00452     pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
00453     Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
00454     // create PIs below the cut and nodes above the cut
00455     Abc_NtkCleanCopy( pNtk );
00456     pObjNew = Abc_NtkTopmost_rec( pNtkNew, Abc_ObjFanin0(Abc_NtkPo(pNtk, 0)), LevelCut );
00457     pObjNew = Abc_ObjNotCond( pObjNew, Abc_ObjFaninC0(Abc_NtkPo(pNtk, 0)) );
00458     // add the PO node and name
00459     pPoNew = Abc_NtkCreatePo(pNtkNew);
00460     Abc_ObjAddFanin( pPoNew, pObjNew );
00461     Abc_NtkAddDummyPiNames( pNtkNew );
00462     Abc_ObjAssignName( pPoNew, Abc_ObjName(Abc_NtkPo(pNtk, 0)), NULL );
00463     // make sure everything is okay
00464     if ( !Abc_NtkCheck( pNtkNew ) )
00465     {
00466         printf( "Abc_NtkTopmost: The network check has failed.\n" );
00467         Abc_NtkDelete( pNtkNew );
00468         return NULL;
00469     }
00470     return pNtkNew;
00471 }

int Abc_NtkToSop ( Abc_Ntk_t pNtk,
int  fDirect 
)

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

Synopsis [Convers logic network to the SOP form.]

Description []

SideEffects []

SeeAlso []

Definition at line 1062 of file abcFunc.c.

01063 {
01064     assert( !Abc_NtkIsStrash(pNtk) );
01065     if ( Abc_NtkHasSop(pNtk) )
01066     {
01067         if ( !fDirect )
01068             return 1;
01069         if ( !Abc_NtkSopToBdd(pNtk) )
01070             return 0;
01071         return Abc_NtkBddToSop(pNtk, fDirect);
01072     }
01073     if ( Abc_NtkHasMapping(pNtk) )
01074         return Abc_NtkMapToSop(pNtk);
01075     if ( Abc_NtkHasBdd(pNtk) )
01076         return Abc_NtkBddToSop(pNtk, fDirect);
01077     if ( Abc_NtkHasAig(pNtk) )
01078     {
01079         if ( !Abc_NtkAigToBdd(pNtk) )
01080             return 0;
01081         return Abc_NtkBddToSop(pNtk, fDirect);
01082     }
01083     assert( 0 );
01084     return 0;
01085 }

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 1496 of file abcUtil.c.

01497 {
01498     Abc_Obj_t * pObj;
01499     int i;
01500     Abc_NtkForEachObj( pNtk, pObj, i )
01501         if ( !Abc_ObjIsNet(pObj) )
01502             pObj->pCopy = pObj->pCopy? Abc_ObjCopyCond(pObj->pCopy) : NULL;
01503 }

void Abc_NtkTrasferNames ( Abc_Ntk_t pNtk,
Abc_Ntk_t pNtkNew 
)

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

Synopsis [Tranfers names to the old network.]

Description [Assumes that the new nodes are attached using pObj->pCopy.]

SideEffects []

SeeAlso []

Definition at line 118 of file abcNames.c.

00119 {
00120     Abc_Obj_t * pObj;
00121     int i;
00122     assert( Abc_NtkPiNum(pNtk) == Abc_NtkPiNum(pNtkNew) );
00123     assert( Abc_NtkPoNum(pNtk) == Abc_NtkPoNum(pNtkNew) );
00124     assert( Abc_NtkBoxNum(pNtk) == Abc_NtkBoxNum(pNtkNew) );
00125     assert( Abc_NtkAssertNum(pNtk) == Abc_NtkAssertNum(pNtkNew) );
00126     assert( Nm_ManNumEntries(pNtk->pManName) > 0 );
00127     assert( Nm_ManNumEntries(pNtkNew->pManName) == 0 );
00128     // copy the CI/CO/box names
00129     Abc_NtkForEachCi( pNtk, pObj, i )
00130         Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanout0Ntk(pObj)), NULL );
00131     Abc_NtkForEachCo( pNtk, pObj, i ) 
00132         Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanin0Ntk(pObj)), NULL );
00133     Abc_NtkForEachBox( pNtk, pObj, i ) 
00134         Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
00135 }

void Abc_NtkTrasferNamesNoLatches ( Abc_Ntk_t pNtk,
Abc_Ntk_t pNtkNew 
)

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

Synopsis [Tranfers names to the old network.]

Description [Assumes that the new nodes are attached using pObj->pCopy.]

SideEffects []

SeeAlso []

Definition at line 148 of file abcNames.c.

00149 {
00150     Abc_Obj_t * pObj;
00151     int i;
00152     assert( Abc_NtkPiNum(pNtk) == Abc_NtkPiNum(pNtkNew) );
00153     assert( Abc_NtkPoNum(pNtk) == Abc_NtkPoNum(pNtkNew) );
00154     assert( Abc_NtkAssertNum(pNtk) == Abc_NtkAssertNum(pNtkNew) );
00155     assert( Nm_ManNumEntries(pNtk->pManName) > 0 );
00156     assert( Nm_ManNumEntries(pNtkNew->pManName) == 0 );
00157     // copy the CI/CO/box name and skip latches and theirs inputs/outputs
00158     Abc_NtkForEachCi( pNtk, pObj, i )
00159         if ( Abc_ObjFaninNum(pObj) == 0 || !Abc_ObjIsLatch(Abc_ObjFanin0(pObj)) )
00160             Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanout0Ntk(pObj)), NULL );
00161     Abc_NtkForEachCo( pNtk, pObj, i ) 
00162         if ( Abc_ObjFanoutNum(pObj) == 0 || !Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) )
00163             Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanin0Ntk(pObj)), NULL );
00164     Abc_NtkForEachBox( pNtk, pObj, i ) 
00165         if ( !Abc_ObjIsLatch(pObj) )
00166             Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
00167 }

static int Abc_NtkTravId ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 286 of file abc.h.

00286 { return pNtk->nTravIds;         }    

void Abc_NtkUpdate ( Abc_Obj_t pObj,
Abc_Obj_t pObjNew,
Vec_Vec_t vLevels 
)

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

Synopsis [Replaces the node and incrementally updates levels.]

Description []

SideEffects []

SeeAlso []

Definition at line 890 of file abcTiming.c.

00891 {
00892     // replace the old node by the new node
00893     pObjNew->Level = pObj->Level;
00894     Abc_ObjReplace( pObj, pObjNew );
00895     // update the level of the node
00896     Abc_NtkUpdateLevel( pObjNew, vLevels );
00897     Abc_ObjSetReverseLevel( pObjNew, 0 );
00898     Abc_NtkUpdateReverseLevel( pObjNew, vLevels );
00899 }

void Abc_NtkUpdateLevel ( Abc_Obj_t pObjNew,
Vec_Vec_t vLevels 
)

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

Synopsis [Incrementally updates level of the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 794 of file abcTiming.c.

00795 {
00796     Abc_Obj_t * pFanout, * pTemp;
00797     int LevelOld, Lev, k, m;
00798     // check if level has changed
00799     LevelOld = Abc_ObjLevel(pObjNew);
00800     if ( LevelOld == Abc_ObjLevelNew(pObjNew) )
00801         return;
00802     // start the data structure for level update
00803     // we cannot fail to visit a node when using this structure because the 
00804     // nodes are stored by their _old_ levels, which are assumed to be correct
00805     Vec_VecClear( vLevels );
00806     Vec_VecPush( vLevels, LevelOld, pObjNew );
00807     pObjNew->fMarkA = 1;
00808     // recursively update level
00809     Vec_VecForEachEntryStart( vLevels, pTemp, Lev, k, LevelOld )
00810     {
00811         pTemp->fMarkA = 0;
00812         assert( Abc_ObjLevel(pTemp) == Lev );
00813         Abc_ObjSetLevel( pTemp, Abc_ObjLevelNew(pTemp) );
00814         // if the level did not change, no need to check the fanout levels
00815         if ( Abc_ObjLevel(pTemp) == Lev )
00816             continue;
00817         // schedule fanout for level update
00818         Abc_ObjForEachFanout( pTemp, pFanout, m )
00819         {
00820             if ( !Abc_ObjIsCo(pFanout) && !pFanout->fMarkA )
00821             {
00822                 assert( Abc_ObjLevel(pFanout) >= Lev );
00823                 Vec_VecPush( vLevels, Abc_ObjLevel(pFanout), pFanout );
00824                 pFanout->fMarkA = 1;
00825             }
00826         }
00827     }
00828 }

void Abc_NtkUpdateReverseLevel ( Abc_Obj_t pObjNew,
Vec_Vec_t vLevels 
)

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

Synopsis [Incrementally updates level of the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 841 of file abcTiming.c.

00842 {
00843     Abc_Obj_t * pFanin, * pTemp;
00844     int LevelOld, LevFanin, Lev, k, m;
00845     // check if level has changed
00846     LevelOld = Abc_ObjReverseLevel(pObjNew);
00847     if ( LevelOld == Abc_ObjReverseLevelNew(pObjNew) )
00848         return;
00849     // start the data structure for level update
00850     // we cannot fail to visit a node when using this structure because the 
00851     // nodes are stored by their _old_ levels, which are assumed to be correct
00852     Vec_VecClear( vLevels );
00853     Vec_VecPush( vLevels, LevelOld, pObjNew );
00854     pObjNew->fMarkA = 1;
00855     // recursively update level
00856     Vec_VecForEachEntryStart( vLevels, pTemp, Lev, k, LevelOld )
00857     {
00858         pTemp->fMarkA = 0;
00859         LevelOld = Abc_ObjReverseLevel(pTemp); 
00860         assert( LevelOld == Lev );
00861         Abc_ObjSetReverseLevel( pTemp, Abc_ObjReverseLevelNew(pTemp) );
00862         // if the level did not change, no need to check the fanout levels
00863         if ( Abc_ObjReverseLevel(pTemp) == Lev )
00864             continue;
00865         // schedule fanins for level update
00866         Abc_ObjForEachFanin( pTemp, pFanin, m )
00867         {
00868             if ( !Abc_ObjIsCi(pFanin) && !pFanin->fMarkA )
00869             {
00870                 LevFanin = Abc_ObjReverseLevel( pFanin );
00871                 assert( LevFanin >= Lev );
00872                 Vec_VecPush( vLevels, LevFanin, pFanin );
00873                 pFanin->fMarkA = 1;
00874             }
00875         }
00876     }
00877 }

int* Abc_NtkVerifyGetCleanModel ( Abc_Ntk_t pNtk,
int  nFrames 
)

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

Synopsis [Returns a dummy pattern full of zeros.]

Description []

SideEffects []

SeeAlso []

Definition at line 632 of file abcVerify.c.

00633 {
00634     int * pModel = ALLOC( int, Abc_NtkCiNum(pNtk) * nFrames );
00635     memset( pModel, 0, sizeof(int) * Abc_NtkCiNum(pNtk) * nFrames );
00636     return pModel;
00637 }

int* Abc_NtkVerifySimulatePattern ( Abc_Ntk_t pNtk,
int *  pModel 
)

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

Synopsis [Returns the PO values under the given input pattern.]

Description []

SideEffects []

SeeAlso []

Definition at line 650 of file abcVerify.c.

00651 {
00652     Abc_Obj_t * pNode;
00653     int * pValues, Value0, Value1, i;
00654     int fStrashed = 0;
00655     if ( !Abc_NtkIsStrash(pNtk) )
00656     {
00657         pNtk = Abc_NtkStrash(pNtk, 0, 0, 0);
00658         fStrashed = 1;
00659     }
00660 /*
00661     printf( "Counter example: " );
00662     Abc_NtkForEachCi( pNtk, pNode, i )
00663         printf( " %d", pModel[i] );
00664     printf( "\n" );
00665 */
00666     // increment the trav ID
00667     Abc_NtkIncrementTravId( pNtk );
00668     // set the CI values
00669     Abc_AigConst1(pNtk)->pCopy = (void *)1;
00670     Abc_NtkForEachCi( pNtk, pNode, i )
00671         pNode->pCopy = (void *)pModel[i];
00672     // simulate in the topological order
00673     Abc_NtkForEachNode( pNtk, pNode, i )
00674     {
00675         Value0 = ((int)Abc_ObjFanin0(pNode)->pCopy) ^ Abc_ObjFaninC0(pNode);
00676         Value1 = ((int)Abc_ObjFanin1(pNode)->pCopy) ^ Abc_ObjFaninC1(pNode);
00677         pNode->pCopy = (void *)(Value0 & Value1);
00678     }
00679     // fill the output values
00680     pValues = ALLOC( int, Abc_NtkCoNum(pNtk) );
00681     Abc_NtkForEachCo( pNtk, pNode, i )
00682         pValues[i] = ((int)Abc_ObjFanin0(pNode)->pCopy) ^ Abc_ObjFaninC0(pNode);
00683     if ( fStrashed )
00684         Abc_NtkDelete( pNtk );
00685     return pValues;
00686 }

static int Abc_NtkWhiteboxNum ( Abc_Ntk_t pNtk  )  [inline, static]

Definition at line 311 of file abc.h.

00311 { return pNtk->nObjCounts[ABC_OBJ_WHITEBOX]; }

void Abc_ObjAddFanin ( Abc_Obj_t pObj,
Abc_Obj_t pFanin 
)

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

Synopsis [Creates fanout/fanin relationship between the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 81 of file abcFanio.c.

00082 {
00083     Abc_Obj_t * pFaninR = Abc_ObjRegular(pFanin);
00084     assert( !Abc_ObjIsComplement(pObj) );
00085     assert( pObj->pNtk == pFaninR->pNtk );
00086     assert( pObj->Id >= 0 && pFaninR->Id >= 0 );
00087     Vec_IntPushMem( pObj->pNtk->pMmStep, &pObj->vFanins,     pFaninR->Id );
00088     Vec_IntPushMem( pObj->pNtk->pMmStep, &pFaninR->vFanouts, pObj->Id    );
00089     if ( Abc_ObjIsComplement(pFanin) )
00090         Abc_ObjSetFaninC( pObj, Abc_ObjFaninNum(pObj)-1 );
00091     if ( Abc_ObjIsNet(pObj) && Abc_ObjFaninNum(pObj) > 1 )
00092     {
00093         int x = 0; 
00094     }
00095 //    printf( "Adding fanin of %s ", Abc_ObjName(pObj) );
00096 //    printf( "to be %s\n", Abc_ObjName(pFanin) );
00097 }

Abc_Obj_t* Abc_ObjAlloc ( Abc_Ntk_t pNtk,
Abc_ObjType_t  Type 
)

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

FileName [abcObj.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Object creation/duplication/deletion procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Creates a new object.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file abcObj.c.

00046 {
00047     Abc_Obj_t * pObj;
00048     if ( pNtk->pMmObj )
00049         pObj = (Abc_Obj_t *)Extra_MmFixedEntryFetch( pNtk->pMmObj );
00050     else
00051         pObj = (Abc_Obj_t *)ALLOC( Abc_Obj_t, 1 );
00052     memset( pObj, 0, sizeof(Abc_Obj_t) );
00053     pObj->pNtk = pNtk;
00054     pObj->Type = Type;
00055     pObj->Id   = -1;
00056     return pObj;
00057 }

char* Abc_ObjAssignName ( Abc_Obj_t pObj,
char *  pName,
char *  pSuffix 
)

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

Synopsis [Assigns the given name to the object.]

Description [The object should not have a name assigned. The same name may be used for several objects, which they share the same net in the original netlist. (For example, latch output and primary output may have the same name.) This procedure returns the pointer to the internally stored representation of the given name.]

SideEffects []

SeeAlso []

Definition at line 65 of file abcNames.c.

00066 {
00067     assert( pName != NULL );
00068     return Nm_ManStoreIdName( pObj->pNtk->pManName, pObj->Id, pObj->Type, pName, pSuffix );
00069 }

static void Abc_ObjBlackboxToWhitebox ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 378 of file abc.h.

static Abc_Obj_t* Abc_ObjChild ( Abc_Obj_t pObj,
int  i 
) [inline, static]

Definition at line 399 of file abc.h.

00399 { return Abc_ObjNotCond( Abc_ObjFanin(pObj,i), Abc_ObjFaninC(pObj,i) );}

static Abc_Obj_t* Abc_ObjChild0 ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 400 of file abc.h.

00400 { return Abc_ObjNotCond( Abc_ObjFanin0(pObj), Abc_ObjFaninC0(pObj) );  }

static Abc_Obj_t* Abc_ObjChild0Copy ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 403 of file abc.h.

00403 { return Abc_ObjNotCond( Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj) );    }

static Abc_Obj_t* Abc_ObjChild0Data ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 405 of file abc.h.

00405 { return Abc_ObjNotCond( (Abc_Obj_t *)Abc_ObjFanin0(pObj)->pData, Abc_ObjFaninC0(pObj) );    }

static Hop_Obj_t* Abc_ObjChild0Equiv ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 407 of file abc.h.

00407 { return Hop_NotCond( Abc_ObjFanin0(pObj)->pEquiv, Abc_ObjFaninC0(pObj) );      }

static Abc_Obj_t* Abc_ObjChild1 ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 401 of file abc.h.

00401 { return Abc_ObjNotCond( Abc_ObjFanin1(pObj), Abc_ObjFaninC1(pObj) );  }

static Abc_Obj_t* Abc_ObjChild1Copy ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 404 of file abc.h.

00404 { return Abc_ObjNotCond( Abc_ObjFanin1(pObj)->pCopy, Abc_ObjFaninC1(pObj) );    }

static Abc_Obj_t* Abc_ObjChild1Data ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 406 of file abc.h.

00406 { return Abc_ObjNotCond( (Abc_Obj_t *)Abc_ObjFanin1(pObj)->pData, Abc_ObjFaninC1(pObj) );    }

static Hop_Obj_t* Abc_ObjChild1Equiv ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 408 of file abc.h.

00408 { return Hop_NotCond( Abc_ObjFanin1(pObj)->pEquiv, Abc_ObjFaninC1(pObj) );      }

static Abc_Obj_t* Abc_ObjChildCopy ( Abc_Obj_t pObj,
int  i 
) [inline, static]

Definition at line 402 of file abc.h.

00402 { return Abc_ObjNotCond( Abc_ObjFanin(pObj,i)->pCopy, Abc_ObjFaninC(pObj,i) );  }

static Abc_Obj_t* Abc_ObjCopy ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 351 of file abc.h.

00351 { return pObj->pCopy;              }

static Abc_Obj_t* Abc_ObjCopyCond ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 355 of file abc.h.

00355 { return Abc_ObjRegular(pObj)->pCopy? Abc_ObjNotCond(Abc_ObjRegular(pObj)->pCopy, Abc_ObjIsComplement(pObj)) : NULL;  }

static void* Abc_ObjData ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 353 of file abc.h.

00353 { return pObj->pData;              }

void Abc_ObjDeleteFanin ( Abc_Obj_t pObj,
Abc_Obj_t pFanin 
)

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

Synopsis [Destroys fanout/fanin relationship between the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 111 of file abcFanio.c.

00112 {
00113     assert( !Abc_ObjIsComplement(pObj) );
00114     assert( !Abc_ObjIsComplement(pFanin) );
00115     assert( pObj->pNtk == pFanin->pNtk );
00116     assert( pObj->Id >= 0 && pFanin->Id >= 0 );
00117     if ( !Vec_IntRemove( &pObj->vFanins, pFanin->Id ) )
00118     {
00119         printf( "The obj %d is not found among the fanins of obj %d ...\n", pFanin->Id, pObj->Id );
00120         return;
00121     }
00122     if ( !Vec_IntRemove( &pFanin->vFanouts, pObj->Id ) )
00123     {
00124         printf( "The obj %d is not found among the fanouts of obj %d ...\n", pObj->Id, pFanin->Id );
00125         return;
00126     }
00127 }

static Hop_Obj_t* Abc_ObjEquiv ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 354 of file abc.h.

00354 { return pObj->pEquiv;             }

static Abc_Obj_t* Abc_ObjFanin ( Abc_Obj_t pObj,
int  i 
) [inline, static]

Definition at line 389 of file abc.h.

00389 { return (Abc_Obj_t *)pObj->pNtk->vObjs->pArray[ pObj->vFanins.pArray[i] ];   }

static Abc_Obj_t* Abc_ObjFanin0 ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 390 of file abc.h.

00390 { return (Abc_Obj_t *)pObj->pNtk->vObjs->pArray[ pObj->vFanins.pArray[0] ];   }

static Abc_Obj_t* Abc_ObjFanin0Ntk ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 392 of file abc.h.

00392 { return (Abc_NtkIsNetlist(pObj->pNtk)? Abc_ObjFanin0(pObj)  : pObj);  }

static Abc_Obj_t* Abc_ObjFanin1 ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 391 of file abc.h.

00391 { return (Abc_Obj_t *)pObj->pNtk->vObjs->pArray[ pObj->vFanins.pArray[1] ];   }

static bool Abc_ObjFaninC ( Abc_Obj_t pObj,
int  i 
) [inline, static]

Definition at line 396 of file abc.h.

00396 { assert( i >=0 && i < 2 ); return i? pObj->fCompl1 : pObj->fCompl0;   }

static bool Abc_ObjFaninC0 ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 394 of file abc.h.

00394 { return pObj->fCompl0;                                                }

static bool Abc_ObjFaninC1 ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 395 of file abc.h.

00395 { return pObj->fCompl1;                                                }

static int Abc_ObjFaninId ( Abc_Obj_t pObj,
int  i 
) [inline, static]

Definition at line 383 of file abc.h.

00383 { return pObj->vFanins.pArray[i]; }

static int Abc_ObjFaninId0 ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 384 of file abc.h.

00384 { return pObj->vFanins.pArray[0]; }

static int Abc_ObjFaninId1 ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 385 of file abc.h.

00385 { return pObj->vFanins.pArray[1]; }

static int Abc_ObjFaninNum ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 381 of file abc.h.

00381 { return pObj->vFanins.nSize;     }

static Vec_Int_t* Abc_ObjFaninVec ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 349 of file abc.h.

00349 { return &pObj->vFanins;           }

static Abc_Obj_t* Abc_ObjFanout ( Abc_Obj_t pObj,
int  i 
) [inline, static]

Definition at line 387 of file abc.h.

00387 { return (Abc_Obj_t *)pObj->pNtk->vObjs->pArray[ pObj->vFanouts.pArray[i] ];  }

static Abc_Obj_t* Abc_ObjFanout0 ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 388 of file abc.h.

00388 { return (Abc_Obj_t *)pObj->pNtk->vObjs->pArray[ pObj->vFanouts.pArray[0] ];  }

static Abc_Obj_t* Abc_ObjFanout0Ntk ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 393 of file abc.h.

00393 { return (Abc_NtkIsNetlist(pObj->pNtk)? Abc_ObjFanout0(pObj) : pObj);  }

static int Abc_ObjFanoutEdgeNum ( Abc_Obj_t pObj,
Abc_Obj_t pFanout 
) [inline, static]

Definition at line 386 of file abc.h.

00386 { assert( Abc_NtkHasAig(pObj->pNtk) );  if ( Abc_ObjFaninId0(pFanout) == pObj->Id ) return 0; if ( Abc_ObjFaninId1(pFanout) == pObj->Id ) return 1; assert( 0 ); return -1;  }

int Abc_ObjFanoutFaninNum ( Abc_Obj_t pFanout,
Abc_Obj_t pFanin 
)

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

Synopsis [Returns the index of the fanin in the fanin list of the fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 321 of file abcFanio.c.

00322 {
00323     Abc_Obj_t * pObj;
00324     int i;
00325     Abc_ObjForEachFanin( pFanout, pObj, i )
00326         if ( pObj == pFanin )
00327             return i;
00328     return -1;
00329 }

static int Abc_ObjFanoutNum ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 382 of file abc.h.

00382 { return pObj->vFanouts.nSize;    }

static Vec_Int_t* Abc_ObjFanoutVec ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 350 of file abc.h.

00350 { return &pObj->vFanouts;          }

static DdNode* Abc_ObjGlobalBdd ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 442 of file abc.h.

00442 { return (DdNode *)Vec_AttEntry( (Vec_Att_t *)Abc_NtkGlobalBdd(pObj->pNtk), pObj->Id );    }

static unsigned Abc_ObjId ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 346 of file abc.h.

00346 { return pObj->Id;                 }

Abc_Obj_t* Abc_ObjInsertBetween ( Abc_Obj_t pNodeIn,
Abc_Obj_t pNodeOut,
Abc_ObjType_t  Type 
)

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

Synopsis [Inserts one-input node of the type specified between the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 223 of file abcFanio.c.

00224 {
00225     Abc_Obj_t * pNodeNew;
00226     int iFanoutIndex, iFaninIndex;
00227     // find pNodeOut among the fanouts of pNodeIn
00228     if ( (iFanoutIndex = Vec_IntFind( &pNodeIn->vFanouts, pNodeOut->Id )) == -1 )
00229     {
00230         printf( "Node %s is not among", Abc_ObjName(pNodeOut) );
00231         printf( " the fanouts of node %s...\n", Abc_ObjName(pNodeIn) );
00232         return NULL;
00233     }
00234     // find pNodeIn among the fanins of pNodeOut
00235     if ( (iFaninIndex = Vec_IntFind( &pNodeOut->vFanins, pNodeIn->Id )) == -1 )
00236     {
00237         printf( "Node %s is not among", Abc_ObjName(pNodeIn) );
00238         printf( " the fanins of node %s...\n", Abc_ObjName(pNodeOut) );
00239         return NULL;
00240     }
00241     // create the new node
00242     pNodeNew = Abc_NtkCreateObj( pNodeIn->pNtk, Type );
00243     // add pNodeIn as fanin and pNodeOut as fanout
00244     Vec_IntPushMem( pNodeNew->pNtk->pMmStep, &pNodeNew->vFanins,  pNodeIn->Id  );
00245     Vec_IntPushMem( pNodeNew->pNtk->pMmStep, &pNodeNew->vFanouts, pNodeOut->Id );
00246     // update the fanout of pNodeIn
00247     Vec_IntWriteEntry( &pNodeIn->vFanouts, iFanoutIndex, pNodeNew->Id );
00248     // update the fanin of pNodeOut
00249     Vec_IntWriteEntry( &pNodeOut->vFanins, iFaninIndex, pNodeNew->Id );
00250     return pNodeNew;
00251 }

static bool Abc_ObjIsAssert ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 368 of file abc.h.

00368 { return pObj->Type == ABC_OBJ_ASSERT;  }

static bool Abc_ObjIsBi ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 366 of file abc.h.

00366 { return pObj->Type == ABC_OBJ_BI;      }

static bool Abc_ObjIsBlackbox ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 377 of file abc.h.

00377 { return pObj->Type == ABC_OBJ_BLACKBOX;}

static bool Abc_ObjIsBo ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 367 of file abc.h.

00367 { return pObj->Type == ABC_OBJ_BO;      }

static bool Abc_ObjIsBox ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 375 of file abc.h.

00375 { return pObj->Type == ABC_OBJ_LATCH || pObj->Type == ABC_OBJ_WHITEBOX || pObj->Type == ABC_OBJ_BLACKBOX; }

static bool Abc_ObjIsCi ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 369 of file abc.h.

00369 { return pObj->Type == ABC_OBJ_PI || pObj->Type == ABC_OBJ_BO; }

static bool Abc_ObjIsCo ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 370 of file abc.h.

00370 { return pObj->Type == ABC_OBJ_PO || pObj->Type == ABC_OBJ_BI || pObj->Type == ABC_OBJ_ASSERT; }

static bool Abc_ObjIsComplement ( Abc_Obj_t p  )  [inline, static]

Definition at line 339 of file abc.h.

00339 { return (bool)((unsigned long)p & (unsigned long)01);             }

static bool Abc_ObjIsLatch ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 374 of file abc.h.

00374 { return pObj->Type == ABC_OBJ_LATCH;   }

static bool Abc_ObjIsNet ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 372 of file abc.h.

00372 { return pObj->Type == ABC_OBJ_NET;     }

static bool Abc_ObjIsNode ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 373 of file abc.h.

00373 { return pObj->Type == ABC_OBJ_NODE;    }

static bool Abc_ObjIsPi ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 364 of file abc.h.

00364 { return pObj->Type == ABC_OBJ_PI;      }

static bool Abc_ObjIsPio ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 363 of file abc.h.

00363 { return pObj->Type == ABC_OBJ_PIO;     }

static bool Abc_ObjIsPo ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 365 of file abc.h.

00365 { return pObj->Type == ABC_OBJ_PO;      }

static bool Abc_ObjIsTerm ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 371 of file abc.h.

00371 { return Abc_ObjIsCi(pObj) || Abc_ObjIsCo(pObj); }

static bool Abc_ObjIsWhitebox ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 376 of file abc.h.

00376 { return pObj->Type == ABC_OBJ_WHITEBOX;}

static int Abc_ObjLevel ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 348 of file abc.h.

00348 { return pObj->Level;              }

int Abc_ObjLevelNew ( Abc_Obj_t pObj  ) 

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

Synopsis [Computes the level of the node using its fanin levels.]

Description []

SideEffects []

SeeAlso []

Definition at line 642 of file abcTiming.c.

00643 {
00644     Abc_Obj_t * pFanin;
00645     int i, Level = 0;
00646     Abc_ObjForEachFanin( pObj, pFanin, i )
00647         Level = ABC_MAX( Level, Abc_ObjLevel(pFanin) );
00648     return Level + 1;
00649 }

static void* Abc_ObjMvVar ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 448 of file abc.h.

00448 { return Abc_NtkMvVar(pObj->pNtk)? Vec_AttEntry( (Vec_Att_t *)Abc_NtkMvVar(pObj->pNtk), pObj->Id ) : NULL; }

static int Abc_ObjMvVarNum ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 449 of file abc.h.

00449 { return (Abc_NtkMvVar(pObj->pNtk) && Abc_ObjMvVar(pObj))? *((int*)Abc_ObjMvVar(pObj)) : 2;   }

char* Abc_ObjName ( Abc_Obj_t pObj  ) 

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

FileName [abcNames.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Procedures working with net and node names.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Returns the unique name for the object.]

Description [If the name previously did not exist, creates a new unique name but does not assign this name to the object. The temporary unique name is stored in a static buffer inside this procedure. It is important that the name is used before the function is called again!]

SideEffects []

SeeAlso []

Definition at line 45 of file abcNames.c.

00046 {
00047     return Nm_ManCreateUniqueName( pObj->pNtk->pManName, pObj->Id );
00048 }

char* Abc_ObjNameDummy ( char *  pPrefix,
int  Num,
int  nDigits 
)

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

Synopsis [Returns the dummy PI name.]

Description []

SideEffects []

SeeAlso []

Definition at line 100 of file abcNames.c.

00101 {
00102     static char Buffer[100];
00103     sprintf( Buffer, "%s%0*d", pPrefix, nDigits, Num );
00104     return Buffer;
00105 }

char* Abc_ObjNameSuffix ( Abc_Obj_t pObj,
char *  pSuffix 
)

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

Synopsis [Gets the long name of the node.]

Description [This name is the output net's name.]

SideEffects []

SeeAlso []

Definition at line 82 of file abcNames.c.

00083 {
00084     static char Buffer[500];
00085     sprintf( Buffer, "%s%s", Abc_ObjName(pObj), pSuffix );
00086     return Buffer;
00087 }

static Abc_Obj_t* Abc_ObjNot ( Abc_Obj_t p  )  [inline, static]

Definition at line 341 of file abc.h.

00341 { return (Abc_Obj_t *)((unsigned long)p ^  (unsigned long)01);     }

static Abc_Obj_t* Abc_ObjNotCond ( Abc_Obj_t p,
int  c 
) [inline, static]

Definition at line 342 of file abc.h.

00342 { return (Abc_Obj_t *)((unsigned long)p ^  (unsigned long)(c!=0)); }

static Abc_Ntk_t* Abc_ObjNtk ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 352 of file abc.h.

00352 { return pObj->pNtk;               }

void Abc_ObjPatchFanin ( Abc_Obj_t pObj,
Abc_Obj_t pFaninOld,
Abc_Obj_t pFaninNew 
)

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

Synopsis [Replaces a fanin of the node.]

Description [The node is pObj. An old fanin of this node (pFaninOld) has to be replaced by a new fanin (pFaninNew). Assumes that the node and the old fanin are not complemented. The new fanin can be complemented. In this case, the polarity of the new fanin will change, compared to the polarity of the old fanin.]

SideEffects []

SeeAlso []

Definition at line 172 of file abcFanio.c.

00173 {
00174     Abc_Obj_t * pFaninNewR = Abc_ObjRegular(pFaninNew);
00175     int iFanin;//, nLats;//, fCompl;
00176     assert( !Abc_ObjIsComplement(pObj) );
00177     assert( !Abc_ObjIsComplement(pFaninOld) );
00178     assert( pFaninOld != pFaninNewR );
00179 //    assert( pObj != pFaninOld );
00180 //    assert( pObj != pFaninNewR );
00181     assert( pObj->pNtk == pFaninOld->pNtk );
00182     assert( pObj->pNtk == pFaninNewR->pNtk );
00183     if ( (iFanin = Vec_IntFind( &pObj->vFanins, pFaninOld->Id )) == -1 )
00184     {
00185         printf( "Node %s is not among", Abc_ObjName(pFaninOld) );
00186         printf( " the fanins of node %s...\n", Abc_ObjName(pObj) );
00187         return;
00188     }
00189 
00190     // remember the attributes of the old fanin
00191 //    fCompl = Abc_ObjFaninC(pObj, iFanin);
00192     // replace the old fanin entry by the new fanin entry (removes attributes)
00193     Vec_IntWriteEntry( &pObj->vFanins, iFanin, pFaninNewR->Id );
00194     // set the attributes of the new fanin
00195 //    if ( fCompl ^ Abc_ObjIsComplement(pFaninNew) )
00196 //        Abc_ObjSetFaninC( pObj, iFanin );
00197     if ( Abc_ObjIsComplement(pFaninNew) )
00198         Abc_ObjXorFaninC( pObj, iFanin );
00199 
00200 //    if ( Abc_NtkIsSeq(pObj->pNtk) && (nLats = Seq_ObjFaninL(pObj, iFanin)) )
00201 //        Seq_ObjSetFaninL( pObj, iFanin, nLats );
00202     // update the fanout of the fanin
00203     if ( !Vec_IntRemove( &pFaninOld->vFanouts, pObj->Id ) )
00204     {
00205         printf( "Node %s is not among", Abc_ObjName(pObj) );
00206         printf( " the fanouts of its old fanin %s...\n", Abc_ObjName(pFaninOld) );
00207 //        return;
00208     }
00209     Vec_IntPushMem( pObj->pNtk->pMmStep, &pFaninNewR->vFanouts, pObj->Id );
00210 }

int Abc_ObjPointerCompare ( void **  pp1,
void **  pp2 
)

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

Synopsis [Compares the pointers.]

Description []

SideEffects []

SeeAlso []

Definition at line 1473 of file abcUtil.c.

01474 {
01475     if ( *pp1 < *pp2 )
01476         return -1;
01477     if ( *pp1 > *pp2 ) 
01478         return 1;
01479     return 0; 
01480 }

void Abc_ObjPrint ( FILE *  pFile,
Abc_Obj_t pObj 
)

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

Synopsis [Prints information about the object.]

Description []

SideEffects []

SeeAlso []

Definition at line 880 of file abcPrint.c.

00881 {
00882     Abc_Obj_t * pFanin;
00883     int i;
00884     fprintf( pFile, "Object %5d : ", pObj->Id );
00885     switch ( pObj->Type )
00886     {
00887         case ABC_OBJ_NONE: 
00888             fprintf( pFile, "NONE   " );  
00889             break;
00890         case ABC_OBJ_CONST1: 
00891             fprintf( pFile, "Const1 " );  
00892             break;
00893         case ABC_OBJ_PIO:    
00894             fprintf( pFile, "PIO    " );  
00895             break;
00896         case ABC_OBJ_PI:     
00897             fprintf( pFile, "PI     " );  
00898             break;
00899         case ABC_OBJ_PO:     
00900             fprintf( pFile, "PO     " );  
00901             break;
00902         case ABC_OBJ_BI:     
00903             fprintf( pFile, "BI     " );  
00904             break;
00905         case ABC_OBJ_BO:     
00906             fprintf( pFile, "BO     " );  
00907             break;
00908         case ABC_OBJ_ASSERT:     
00909             fprintf( pFile, "Assert " );  
00910             break;
00911         case ABC_OBJ_NET:  
00912             fprintf( pFile, "Net    " );  
00913             break;
00914         case ABC_OBJ_NODE: 
00915             fprintf( pFile, "Node   " );  
00916             break;
00917         case ABC_OBJ_LATCH:     
00918             fprintf( pFile, "Latch  " );  
00919             break;
00920         case ABC_OBJ_WHITEBOX: 
00921             fprintf( pFile, "Whitebox" );  
00922             break;
00923         case ABC_OBJ_BLACKBOX:     
00924             fprintf( pFile, "Blackbox" );  
00925             break;
00926         default:
00927             assert(0); 
00928             break;
00929     }
00930     // print the fanins
00931     fprintf( pFile, " Fanins ( " );
00932     Abc_ObjForEachFanin( pObj, pFanin, i )
00933         fprintf( pFile, "%d ", pFanin->Id );
00934     fprintf( pFile, ") " );
00935 /*
00936     fprintf( pFile, " Fanouts ( " );
00937     Abc_ObjForEachFanout( pObj, pFanin, i )
00938         fprintf( pFile, "%d(%c) ", pFanin->Id, Abc_NodeIsTravIdCurrent(pFanin)? '+' : '-' );
00939     fprintf( pFile, ") " );
00940 */
00941     // print the logic function
00942     if ( Abc_ObjIsNode(pObj) && Abc_NtkIsSopLogic(pObj->pNtk) )
00943         fprintf( pFile, " %s", pObj->pData );
00944     else
00945         fprintf( pFile, "\n" );
00946 }

void Abc_ObjRecycle ( Abc_Obj_t pObj  ) 

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

Synopsis [Recycles the object.]

Description []

SideEffects []

SeeAlso []

Definition at line 70 of file abcObj.c.

00071 {
00072     Abc_Ntk_t * pNtk = pObj->pNtk;
00073     int LargePiece = (4 << ABC_NUM_STEPS);
00074     // free large fanout arrays
00075     if ( pNtk->pMmStep && pObj->vFanouts.nCap * 4 > LargePiece )
00076         FREE( pObj->vFanouts.pArray );
00077     if ( pNtk->pMmStep == NULL )
00078     {
00079         FREE( pObj->vFanouts.pArray );
00080         FREE( pObj->vFanins.pArray );
00081     }
00082     // clean the memory to make deleted object distinct from the live one
00083     memset( pObj, 0, sizeof(Abc_Obj_t) );
00084     // recycle the object
00085     if ( pNtk->pMmObj )
00086         Extra_MmFixedEntryRecycle( pNtk->pMmObj, (char *)pObj );
00087     else
00088         free( pObj );
00089 }

static Abc_Obj_t* Abc_ObjRegular ( Abc_Obj_t p  )  [inline, static]

Definition at line 340 of file abc.h.

00340 { return (Abc_Obj_t *)((unsigned long)p & ~(unsigned long)01);     }

void Abc_ObjRemoveFanins ( Abc_Obj_t pObj  ) 

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

Synopsis [Destroys fanout/fanin relationship between the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 141 of file abcFanio.c.

00142 {
00143     Vec_Int_t * vFaninsOld;
00144     Abc_Obj_t * pFanin;
00145     int k;
00146     // remove old fanins
00147     vFaninsOld = &pObj->vFanins;
00148     for ( k = vFaninsOld->nSize - 1; k >= 0; k-- )
00149     {
00150         pFanin = Abc_NtkObj( pObj->pNtk, vFaninsOld->pArray[k] );
00151         Abc_ObjDeleteFanin( pObj, pFanin );
00152     }
00153     pObj->fCompl0 = 0;
00154     pObj->fCompl1 = 0;
00155     assert( vFaninsOld->nSize == 0 );
00156 }

void Abc_ObjReplace ( Abc_Obj_t pNodeOld,
Abc_Obj_t pNodeNew 
)

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

Synopsis [Replaces the node by a new node.]

Description []

SideEffects []

SeeAlso []

Definition at line 297 of file abcFanio.c.

00298 {
00299     assert( !Abc_ObjIsComplement(pNodeOld) );
00300     assert( !Abc_ObjIsComplement(pNodeNew) );
00301     assert( pNodeOld->pNtk == pNodeNew->pNtk );
00302     assert( pNodeOld != pNodeNew );
00303     assert( Abc_ObjFanoutNum(pNodeOld) > 0 );
00304     // transfer the fanouts to the old node
00305     Abc_ObjTransferFanout( pNodeOld, pNodeNew );
00306     // remove the old node
00307     Abc_NtkDeleteObj_rec( pNodeOld, 1 );
00308 }

int Abc_ObjRequiredLevel ( Abc_Obj_t pObj  ) 

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

Synopsis [Returns required level of the node.]

Description [Converts the reverse levels of the node into its required level as follows: ReqLevel(Node) = MaxLevels(Ntk) + 1 - LevelR(Node).]

SideEffects []

SeeAlso []

Definition at line 686 of file abcTiming.c.

00687 {
00688     Abc_Ntk_t * pNtk = pObj->pNtk;
00689     assert( pNtk->vLevelsR );
00690     return pNtk->LevelMax + 1 - Abc_ObjReverseLevel(pObj);
00691 }

int Abc_ObjReverseLevel ( Abc_Obj_t pObj  ) 

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

Synopsis [Returns the reverse level of the node.]

Description [The reverse level is the level of the node in reverse topological order, starting from the COs.]

SideEffects []

SeeAlso []

Definition at line 705 of file abcTiming.c.

00706 {
00707     Abc_Ntk_t * pNtk = pObj->pNtk;
00708     assert( pNtk->vLevelsR );
00709     Vec_IntFillExtra( pNtk->vLevelsR, pObj->Id + 1, 0 );
00710     return Vec_IntEntry(pNtk->vLevelsR, pObj->Id);
00711 }

int Abc_ObjReverseLevelNew ( Abc_Obj_t pObj  ) 

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

Synopsis [Computes the reverse level of the node using its fanout levels.]

Description []

SideEffects []

SeeAlso []

Definition at line 662 of file abcTiming.c.

00663 {
00664     Abc_Obj_t * pFanout;
00665     int i, LevelCur, Level = 0;
00666     Abc_ObjForEachFanout( pObj, pFanout, i )
00667     {
00668         LevelCur = Abc_ObjReverseLevel( pFanout );
00669         Level = ABC_MAX( Level, LevelCur );
00670     }
00671     return Level + 1;
00672 }

static void Abc_ObjSetCopy ( Abc_Obj_t pObj,
Abc_Obj_t pCopy 
) [inline, static]

Definition at line 359 of file abc.h.

00359 { pObj->pCopy =  pCopy;    } 

static void Abc_ObjSetData ( Abc_Obj_t pObj,
void *  pData 
) [inline, static]

Definition at line 360 of file abc.h.

00360 { pObj->pData =  pData;    } 

static void Abc_ObjSetFaninC ( Abc_Obj_t pObj,
int  i 
) [inline, static]

Definition at line 397 of file abc.h.

00397 { assert( i >=0 && i < 2 ); if ( i ) pObj->fCompl1 = 1; else pObj->fCompl0 = 1; }

static void Abc_ObjSetGlobalBdd ( Abc_Obj_t pObj,
DdNode bF 
) [inline, static]

Definition at line 443 of file abc.h.

00443 { Vec_AttWriteEntry( (Vec_Att_t *)Abc_NtkGlobalBdd(pObj->pNtk), pObj->Id, bF );   }

static void Abc_ObjSetLevel ( Abc_Obj_t pObj,
int  Level 
) [inline, static]

Definition at line 358 of file abc.h.

00358 { pObj->Level =  Level;    } 

static void Abc_ObjSetMvVar ( Abc_Obj_t pObj,
void *  pV 
) [inline, static]

Definition at line 450 of file abc.h.

00450 { Vec_AttWriteEntry( (Vec_Att_t *)Abc_NtkMvVar(pObj->pNtk), pObj->Id, pV );                }

void Abc_ObjSetReverseLevel ( Abc_Obj_t pObj,
int  LevelR 
)

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

Synopsis [Sets the reverse level of the node.]

Description [The reverse level is the level of the node in reverse topological order, starting from the COs.]

SideEffects []

SeeAlso []

Definition at line 725 of file abcTiming.c.

00726 {
00727     Abc_Ntk_t * pNtk = pObj->pNtk;
00728     assert( pNtk->vLevelsR );
00729     Vec_IntFillExtra( pNtk->vLevelsR, pObj->Id + 1, 0 );
00730     Vec_IntWriteEntry( pNtk->vLevelsR, pObj->Id, LevelR );
00731 }

void Abc_ObjTransferFanout ( Abc_Obj_t pNodeFrom,
Abc_Obj_t pNodeTo 
)

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

Synopsis [Transfers fanout from the old node to the new node.]

Description []

SideEffects []

SeeAlso []

Definition at line 264 of file abcFanio.c.

00265 {
00266     Vec_Ptr_t * vFanouts;
00267     int nFanoutsOld, i;
00268     assert( !Abc_ObjIsComplement(pNodeFrom) );
00269     assert( !Abc_ObjIsComplement(pNodeTo) );
00270     assert( !Abc_ObjIsPo(pNodeFrom) && !Abc_ObjIsPo(pNodeTo) );
00271     assert( pNodeFrom->pNtk == pNodeTo->pNtk );
00272     assert( pNodeFrom != pNodeTo );
00273     assert( Abc_ObjFanoutNum(pNodeFrom) > 0 );
00274     // get the fanouts of the old node
00275     nFanoutsOld = Abc_ObjFanoutNum(pNodeTo);
00276     vFanouts = Vec_PtrAlloc( nFanoutsOld );
00277     Abc_NodeCollectFanouts( pNodeFrom, vFanouts );
00278     // patch the fanin of each of them
00279     for ( i = 0; i < vFanouts->nSize; i++ )
00280         Abc_ObjPatchFanin( vFanouts->pArray[i], pNodeFrom, pNodeTo );
00281     assert( Abc_ObjFanoutNum(pNodeFrom) == 0 );
00282     assert( Abc_ObjFanoutNum(pNodeTo) == nFanoutsOld + vFanouts->nSize );
00283     Vec_PtrFree( vFanouts );
00284 }

static int Abc_ObjTravId ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 347 of file abc.h.

00347 { return pObj->TravId;             }

static unsigned Abc_ObjType ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 345 of file abc.h.

00345 { return pObj->Type;               }

static void Abc_ObjXorFaninC ( Abc_Obj_t pObj,
int  i 
) [inline, static]

Definition at line 398 of file abc.h.

00398 { assert( i >=0 && i < 2 ); if ( i ) pObj->fCompl1^= 1; else pObj->fCompl0^= 1; }

bool Abc_SopCheck ( char *  pSop,
int  nFanins 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 758 of file abcSop.c.

00759 {
00760     char * pCubes, * pCubesOld;
00761     int fFound0 = 0, fFound1 = 0;
00762 
00763     // check the logic function of the node
00764     for ( pCubes = pSop; *pCubes; pCubes++ )
00765     {
00766         // get the end of the next cube
00767         for ( pCubesOld = pCubes; *pCubes != ' '; pCubes++ );
00768         // compare the distance
00769         if ( pCubes - pCubesOld != nFanins )
00770         {
00771             fprintf( stdout, "Abc_SopCheck: SOP has a mismatch between its cover size (%d) and its fanin number (%d).\n",
00772                 pCubes - pCubesOld, nFanins );
00773             return 0;
00774         }
00775         // check the output values for this cube
00776         pCubes++;
00777         if ( *pCubes == '0' )
00778             fFound0 = 1;
00779         else if ( *pCubes == '1' )
00780             fFound1 = 1;
00781         else if ( *pCubes != 'x' && *pCubes != 'n' )
00782         {
00783             fprintf( stdout, "Abc_SopCheck: SOP has a strange character (%c) in the output part of its cube.\n", *pCubes );
00784             return 0;
00785         }
00786         // check the last symbol (new line)
00787         pCubes++;
00788         if ( *pCubes != '\n' )
00789         {
00790             fprintf( stdout, "Abc_SopCheck: SOP has a cube without new line in the end.\n" );
00791             return 0;
00792         }
00793     }
00794     if ( fFound0 && fFound1 )
00795     {
00796         fprintf( stdout, "Abc_SopCheck: SOP has cubes in both phases.\n" );
00797         return 0;
00798     }
00799     return 1;
00800 }

void Abc_SopComplement ( char *  pSop  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 560 of file abcSop.c.

00561 {
00562     char * pCur;
00563     for ( pCur = pSop; *pCur; pCur++ )
00564         if ( *pCur == '\n' )
00565         {
00566             if ( *(pCur - 1) == '0' )
00567                 *(pCur - 1) = '1';
00568             else if ( *(pCur - 1) == '1' )
00569                 *(pCur - 1) = '0';
00570             else if ( *(pCur - 1) == 'x' )
00571                 *(pCur - 1) = 'n';
00572             else if ( *(pCur - 1) == 'n' )
00573                 *(pCur - 1) = 'x';
00574             else
00575                 assert( 0 );
00576         }
00577 }

char* Abc_SopCreateAnd ( Extra_MmFlex_t pMan,
int  nVars,
int *  pfCompl 
)

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

Synopsis [Creates the multi-input AND cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 159 of file abcSop.c.

00160 {
00161     char * pSop;
00162     int i;
00163     pSop = Abc_SopStart( pMan, 1, nVars );
00164     for ( i = 0; i < nVars; i++ )
00165         pSop[i] = '1' - (pfCompl? pfCompl[i] : 0);
00166     pSop[nVars + 1] = '1';
00167     return pSop;
00168 }

char* Abc_SopCreateAnd2 ( Extra_MmFlex_t pMan,
int  fCompl0,
int  fCompl1 
)

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

Synopsis [Creates the AND2 cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 136 of file abcSop.c.

00137 {
00138     char Buffer[6];
00139     Buffer[0] = '1' - fCompl0;
00140     Buffer[1] = '1' - fCompl1;
00141     Buffer[2] = ' ';
00142     Buffer[3] = '1';
00143     Buffer[4] = '\n';
00144     Buffer[5] = 0;
00145     return Abc_SopRegister( pMan, Buffer );
00146 }

char* Abc_SopCreateBuf ( Extra_MmFlex_t pMan  ) 

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

Synopsis [Creates the buf cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 358 of file abcSop.c.

00359 {
00360     return Abc_SopRegister(pMan, "1 1\n");
00361 }

char* Abc_SopCreateConst0 ( Extra_MmFlex_t pMan  ) 

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

Synopsis [Creates the constant 1 cover with 0 variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 120 of file abcSop.c.

00121 {
00122     return Abc_SopRegister( pMan, " 0\n" );
00123 }

char* Abc_SopCreateConst1 ( Extra_MmFlex_t pMan  ) 

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

Synopsis [Creates the constant 1 cover with 0 variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 104 of file abcSop.c.

00105 {
00106     return Abc_SopRegister( pMan, " 1\n" );
00107 }

char* Abc_SopCreateFromIsop ( Extra_MmFlex_t pMan,
int  nVars,
Vec_Int_t vCover 
)

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

Synopsis [Creates the cover from the ISOP computed from TT.]

Description []

SideEffects []

SeeAlso []

Definition at line 413 of file abcSop.c.

00414 {
00415     char * pSop, * pCube;
00416     int i, k, Entry, Literal;
00417     assert( Vec_IntSize(vCover) > 0 );
00418     if ( Vec_IntSize(vCover) == 0 )
00419         return NULL;
00420     // start the cover
00421     pSop = Abc_SopStart( pMan, Vec_IntSize(vCover), nVars );
00422     // create cubes
00423     Vec_IntForEachEntry( vCover, Entry, i )
00424     {
00425         pCube = pSop + i * (nVars + 3);
00426         for ( k = 0; k < nVars; k++ )
00427         {
00428             Literal = 3 & (Entry >> (k << 1));
00429             if ( Literal == 1 )
00430                 pCube[k] = '0';
00431             else if ( Literal == 2 )
00432                 pCube[k] = '1';
00433             else if ( Literal != 0 )
00434                 assert( 0 );
00435         }
00436     }
00437     return pSop;
00438 }

char* Abc_SopCreateFromTruth ( Extra_MmFlex_t pMan,
int  nVars,
unsigned *  pTruth 
)

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

Synopsis [Creates the arbitrary cover from the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 374 of file abcSop.c.

00375 {
00376     char * pSop, * pCube;
00377     int nMints, Counter, i, k;
00378     // count the number of true minterms
00379     Counter = 0;
00380     nMints = (1 << nVars);
00381     for ( i = 0; i < nMints; i++ )
00382         Counter += ((pTruth[i>>5] & (1 << (i&31))) > 0);
00383     // SOP is not well-defined if the truth table is constant 0
00384     assert( Counter > 0 );
00385     if ( Counter == 0 )
00386         return NULL;
00387     // start the cover
00388     pSop = Abc_SopStart( pMan, Counter, nVars );
00389     // create true minterms
00390     Counter = 0;
00391     for ( i = 0; i < nMints; i++ )
00392         if ( (pTruth[i>>5] & (1 << (i&31))) > 0 )
00393         {
00394             pCube = pSop + Counter * (nVars + 3);
00395             for ( k = 0; k < nVars; k++ )
00396                 pCube[k] = '0' + ((i & (1 << k)) > 0);
00397             Counter++;
00398         }
00399     return pSop;
00400 }

char* Abc_SopCreateInv ( Extra_MmFlex_t pMan  ) 

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

Synopsis [Creates the inv cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 342 of file abcSop.c.

00343 {
00344     return Abc_SopRegister(pMan, "0 1\n");
00345 }

char* Abc_SopCreateMux ( Extra_MmFlex_t pMan  ) 

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

Synopsis [Creates the MUX cover.]

Description [The first input of MUX is the control. The second input is DATA1. The third input is DATA0.]

SideEffects []

SeeAlso []

Definition at line 326 of file abcSop.c.

00327 {
00328     return Abc_SopRegister(pMan, "11- 1\n0-1 1\n");
00329 }

char* Abc_SopCreateNand ( Extra_MmFlex_t pMan,
int  nVars 
)

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

Synopsis [Creates the multi-input NAND cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 181 of file abcSop.c.

00182 {
00183     char * pSop;
00184     int i;
00185     pSop = Abc_SopStart( pMan, 1, nVars );
00186     for ( i = 0; i < nVars; i++ )
00187         pSop[i] = '1';
00188     pSop[nVars + 1] = '0';
00189     return pSop;
00190 }

char* Abc_SopCreateNor ( Extra_MmFlex_t pMan,
int  nVars 
)

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

Synopsis [Creates the multi-input NOR cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 250 of file abcSop.c.

00251 {
00252     char * pSop;
00253     int i;
00254     pSop = Abc_SopStart( pMan, 1, nVars );
00255     for ( i = 0; i < nVars; i++ )
00256         pSop[i] = '0';
00257     return pSop;
00258 }

char* Abc_SopCreateNxor ( Extra_MmFlex_t pMan,
int  nVars 
)

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

Synopsis [Creates the multi-input XNOR cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 308 of file abcSop.c.

00309 {
00310     assert( nVars == 2 );
00311     return Abc_SopRegister(pMan, "11 1\n00 1\n");
00312 }

char* Abc_SopCreateOr ( Extra_MmFlex_t pMan,
int  nVars,
int *  pfCompl 
)

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

Synopsis [Creates the multi-input OR cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 203 of file abcSop.c.

00204 {
00205     char * pSop;
00206     int i;
00207     pSop = Abc_SopStart( pMan, 1, nVars );
00208     for ( i = 0; i < nVars; i++ )
00209         pSop[i] = '0' + (pfCompl? pfCompl[i] : 0);
00210     pSop[nVars + 1] = '0';
00211     return pSop;
00212 }

char* Abc_SopCreateOrMultiCube ( Extra_MmFlex_t pMan,
int  nVars,
int *  pfCompl 
)

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

Synopsis [Creates the multi-input OR cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 225 of file abcSop.c.

00226 {
00227     char * pSop, * pCube;
00228     int i;
00229     pSop = Abc_SopStart( pMan, nVars, nVars );
00230     i = 0;
00231     Abc_SopForEachCube( pSop, nVars, pCube )
00232     {
00233         pCube[i] = '1' - (pfCompl? pfCompl[i] : 0);
00234         i++;
00235     }
00236     return pSop;
00237 }

char* Abc_SopCreateXor ( Extra_MmFlex_t pMan,
int  nVars 
)

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

Synopsis [Creates the multi-input XOR cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 271 of file abcSop.c.

00272 {
00273     assert( nVars == 2 );
00274     return Abc_SopRegister(pMan, "01 1\n10 1\n");
00275 }

char* Abc_SopCreateXorSpecial ( Extra_MmFlex_t pMan,
int  nVars 
)

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

Synopsis [Creates the multi-input XOR cover (special case).]

Description []

SideEffects []

SeeAlso []

Definition at line 288 of file abcSop.c.

00289 {
00290     char * pSop;
00291     pSop = Abc_SopCreateAnd( pMan, nVars, NULL );
00292     pSop[nVars+1] = 'x';
00293     assert( pSop[nVars+2] == '\n' );
00294     return pSop;
00295 }

char* Abc_SopDecoderLog ( Extra_MmFlex_t pMan,
int  nValues 
)

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

Synopsis [Creates the decover node.]

Description [Produces MV-SOP for BLIF-MV representation.]

SideEffects []

SeeAlso []

Definition at line 1048 of file abcSop.c.

01049 {
01050     char * pResult;
01051     Vec_Str_t * vSop;
01052     int i, b, nBits = Extra_Base2Log(nValues);
01053     assert( nValues > 1 && nValues <= (1<<nBits) );
01054     vSop = Vec_StrAlloc( 100 );
01055     for ( i = 0; i < nValues; i++ )
01056     {
01057         for ( b = 0; b < nBits; b++ )
01058         {
01059             Vec_StrPrintNum( vSop, (int)((i & (1 << b)) > 0) );
01060             Vec_StrPush( vSop, ' ' );
01061         }
01062         Vec_StrPrintNum( vSop, i );
01063         Vec_StrPush( vSop, '\n' );
01064     }
01065     Vec_StrPush( vSop, 0 );
01066     pResult = Abc_SopRegister( pMan, Vec_StrArray(vSop) );
01067     Vec_StrFree( vSop );
01068     return pResult;
01069 }

char* Abc_SopDecoderPos ( Extra_MmFlex_t pMan,
int  nValues 
)

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

Synopsis [Creates the decoder node.]

Description [Produces MV-SOP for BLIF-MV representation.]

SideEffects []

SeeAlso []

Definition at line 1012 of file abcSop.c.

01013 {
01014     char * pResult;
01015     Vec_Str_t * vSop;
01016     int i, k;
01017     assert( nValues > 1 );
01018     vSop = Vec_StrAlloc( 100 );
01019     for ( i = 0; i < nValues; i++ )
01020     {
01021         for ( k = 0; k < nValues; k++ )
01022         {
01023             if ( k == i )
01024                 Vec_StrPrintStr( vSop, "1 " );
01025             else
01026                 Vec_StrPrintStr( vSop, "- " );
01027         }
01028         Vec_StrPrintNum( vSop, i );
01029         Vec_StrPush( vSop, '\n' );
01030     }
01031     Vec_StrPush( vSop, 0 );
01032     pResult = Abc_SopRegister( pMan, Vec_StrArray(vSop) );
01033     Vec_StrFree( vSop );
01034     return pResult;
01035 }

char* Abc_SopEncoderLog ( Extra_MmFlex_t pMan,
int  iBit,
int  nValues 
)

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

Synopsis [Creates one encoder node.]

Description [Produces MV-SOP for BLIF-MV representation.]

SideEffects []

SeeAlso []

Definition at line 968 of file abcSop.c.

00969 {
00970     char * pResult;
00971     Vec_Str_t * vSop;
00972     int v, Counter, fFirst = 1, nBits = Extra_Base2Log(nValues);
00973     assert( iBit < nBits );
00974     // count the number of literals
00975     Counter = 0;
00976     for ( v = 0; v < nValues; v++ )
00977         Counter += ( (v & (1 << iBit)) > 0 );
00978     // create the cover
00979     vSop = Vec_StrAlloc( 100 );
00980     Vec_StrPrintStr( vSop, "d0\n" );
00981     if ( Counter > 1 )
00982         Vec_StrPrintStr( vSop, "(" );
00983     for ( v = 0; v < nValues; v++ )
00984         if ( v & (1 << iBit) )
00985         {
00986             if ( fFirst )
00987                 fFirst = 0;
00988             else
00989                 Vec_StrPush( vSop, ',' );
00990             Vec_StrPrintNum( vSop, v );
00991         }
00992     if ( Counter > 1 )
00993         Vec_StrPrintStr( vSop, ")" );
00994     Vec_StrPrintStr( vSop, " 1\n" );
00995     Vec_StrPush( vSop, 0 );
00996     pResult = Abc_SopRegister( pMan, Vec_StrArray(vSop) );
00997     Vec_StrFree( vSop );
00998     return pResult;
00999 }

char* Abc_SopEncoderPos ( Extra_MmFlex_t pMan,
int  iValue,
int  nValues 
)

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

Synopsis [Creates one encoder node.]

Description [Produces MV-SOP for BLIF-MV representation.]

SideEffects []

SeeAlso []

Definition at line 949 of file abcSop.c.

00950 {
00951     char Buffer[32];
00952     assert( iValue < nValues );
00953     sprintf( Buffer, "d0\n%d 1\n", iValue );
00954     return Abc_SopRegister( pMan, Buffer );
00955 }

char* Abc_SopFromTruthBin ( char *  pTruth  ) 

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

Synopsis [Derives SOP from the truth table representation.]

Description [Truth table is expected to be in the hexadecimal notation.]

SideEffects []

SeeAlso []

Definition at line 814 of file abcSop.c.

00815 {
00816     char * pSopCover, * pCube;
00817     int nTruthSize, nVars, Digit, Length, Mint, i, b;
00818     Vec_Int_t * vMints;
00819 
00820     // get the number of variables
00821     nTruthSize = strlen(pTruth);
00822     nVars = Extra_Base2Log( nTruthSize );
00823     if ( nTruthSize != (1 << (nVars)) )
00824     {
00825         printf( "String %s does not look like a truth table of a %d-variable function.\n", pTruth, nVars );
00826         return NULL;
00827     }
00828 
00829     // collect the on-set minterms
00830     vMints = Vec_IntAlloc( 100 );
00831     for ( i = 0; i < nTruthSize; i++ )
00832     {
00833         if ( pTruth[i] >= '0' && pTruth[i] <= '1' )
00834             Digit = pTruth[i] - '0';
00835         else
00836         {
00837             printf( "String %s does not look like a binary representation of the truth table.\n", pTruth );
00838             return NULL;
00839         }
00840         if ( Digit == 1 )
00841             Vec_IntPush( vMints, nTruthSize - 1 - i );
00842     }
00843     if ( Vec_IntSize( vMints ) == 0 || Vec_IntSize( vMints ) == nTruthSize )
00844     {
00845         Vec_IntFree( vMints );
00846         printf( "Cannot create constant function.\n" );
00847         return NULL;
00848     }
00849 
00850     // create the SOP representation of the minterms
00851     Length = Vec_IntSize(vMints) * (nVars + 3);
00852     pSopCover = ALLOC( char, Length + 1 );
00853     pSopCover[Length] = 0;
00854     Vec_IntForEachEntry( vMints, Mint, i )
00855     {
00856         pCube = pSopCover + i * (nVars + 3);
00857         for ( b = 0; b < nVars; b++ )
00858             if ( Mint & (1 << (nVars-1-b)) )
00859 //            if ( Mint & (1 << b) )
00860                 pCube[b] = '1';
00861             else
00862                 pCube[b] = '0';
00863         pCube[nVars + 0] = ' ';
00864         pCube[nVars + 1] = '1';
00865         pCube[nVars + 2] = '\n';
00866     }
00867     Vec_IntFree( vMints );
00868     return pSopCover;
00869 }

char* Abc_SopFromTruthHex ( char *  pTruth  ) 

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

Synopsis [Derives SOP from the truth table representation.]

Description [Truth table is expected to be in the hexadecimal notation.]

SideEffects []

SeeAlso []

Definition at line 882 of file abcSop.c.

00883 {
00884     char * pSopCover, * pCube;
00885     int nTruthSize, nVars, Digit, Length, Mint, i, b;
00886     Vec_Int_t * vMints;
00887 
00888     // get the number of variables
00889     nTruthSize = strlen(pTruth);
00890     nVars = Extra_Base2Log( nTruthSize ) + 2;
00891     if ( nTruthSize != (1 << (nVars-2)) )
00892     {
00893         printf( "String %s does not look like a truth table of a %d-variable function.\n", pTruth, nVars );
00894         return NULL;
00895     }
00896 
00897     // collect the on-set minterms
00898     vMints = Vec_IntAlloc( 100 );
00899     for ( i = 0; i < nTruthSize; i++ )
00900     {
00901         if ( pTruth[i] >= '0' && pTruth[i] <= '9' )
00902             Digit = pTruth[i] - '0';
00903         else if ( pTruth[i] >= 'a' && pTruth[i] <= 'f' )
00904             Digit = 10 + pTruth[i] - 'a';
00905         else if ( pTruth[i] >= 'A' && pTruth[i] <= 'F' )
00906             Digit = 10 + pTruth[i] - 'A';
00907         else
00908         {
00909             printf( "String %s does not look like a hexadecimal representation of the truth table.\n", pTruth );
00910             return NULL;
00911         }
00912         for ( b = 0; b < 4; b++ )
00913             if ( Digit & (1 << b) )
00914                 Vec_IntPush( vMints, 4*(nTruthSize-1-i)+b );
00915     }
00916 
00917     // create the SOP representation of the minterms
00918     Length = Vec_IntSize(vMints) * (nVars + 3);
00919     pSopCover = ALLOC( char, Length + 1 );
00920     pSopCover[Length] = 0;
00921     Vec_IntForEachEntry( vMints, Mint, i )
00922     {
00923         pCube = pSopCover + i * (nVars + 3);
00924         for ( b = 0; b < nVars; b++ )
00925 //            if ( Mint & (1 << (nVars-1-b)) )
00926             if ( Mint & (1 << b) )
00927                 pCube[b] = '1';
00928             else
00929                 pCube[b] = '0';
00930         pCube[nVars + 0] = ' ';
00931         pCube[nVars + 1] = '1';
00932         pCube[nVars + 2] = '\n';
00933     }
00934     Vec_IntFree( vMints );
00935     return pSopCover;
00936 }

int Abc_SopGetCubeNum ( char *  pSop  ) 

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

Synopsis [Reads the number of cubes in the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 451 of file abcSop.c.

00452 {
00453     char * pCur;
00454     int nCubes = 0;
00455     if ( pSop == NULL )
00456         return 0;
00457     for ( pCur = pSop; *pCur; pCur++ )
00458         nCubes += (*pCur == '\n');
00459     return nCubes;
00460 }

int Abc_SopGetIthCareLit ( char *  pSop,
int  i 
)

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

Synopsis [Returns the i-th literal of the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 538 of file abcSop.c.

00539 {
00540     char * pCube;
00541     int nVars;
00542     nVars = Abc_SopGetVarNum( pSop );
00543     Abc_SopForEachCube( pSop, nVars, pCube )
00544         if ( pCube[i] != '-' )
00545             return pCube[i] - '0';
00546     return -1;
00547 }

int Abc_SopGetLitNum ( char *  pSop  ) 

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

Synopsis [Reads the number of SOP literals in the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 473 of file abcSop.c.

00474 {
00475     char * pCur;
00476     int nLits = 0;
00477     if ( pSop == NULL )
00478         return 0;
00479     for ( pCur = pSop; *pCur; pCur++ )
00480     {
00481         nLits  -= (*pCur == '\n');
00482         nLits  += (*pCur == '0' || *pCur == '1');
00483     }
00484     return nLits;
00485 }

int Abc_SopGetPhase ( char *  pSop  ) 

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

Synopsis [Reads the phase of the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 516 of file abcSop.c.

00517 {
00518     int nVars = Abc_SopGetVarNum( pSop );
00519     if ( pSop[nVars+1] == '0' || pSop[nVars+1] == 'n' )
00520         return 0;
00521     if ( pSop[nVars+1] == '1' || pSop[nVars+1] == 'x' )
00522         return 1;
00523     assert( 0 );
00524     return -1;
00525 }

int Abc_SopGetVarNum ( char *  pSop  ) 

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

Synopsis [Reads the number of variables in the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 498 of file abcSop.c.

00499 {
00500     char * pCur;
00501     for ( pCur = pSop; *pCur != '\n'; pCur++ );
00502     return pCur - pSop - 2;
00503 }

bool Abc_SopIsAndType ( char *  pSop  ) 

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

Synopsis [Checks if the cover is AND with possibly complemented inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 683 of file abcSop.c.

00684 {
00685     char * pCur;
00686     if ( Abc_SopGetCubeNum(pSop) != 1 )
00687         return 0;
00688     for ( pCur = pSop; *pCur != ' '; pCur++ )
00689         if ( *pCur == '-' )
00690             return 0;
00691     if ( pCur[1] != '1' )
00692         return 0;
00693     return 1;
00694 }

bool Abc_SopIsBuf ( char *  pSop  ) 

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

Synopsis [Checks if the cover is constant 1.]

Description []

SideEffects []

SeeAlso []

Definition at line 643 of file abcSop.c.

00644 {
00645     if ( pSop[4] != 0 )
00646         return 0;
00647     if ( (pSop[0] == '1' && pSop[2] == '1') || (pSop[0] == '0' && pSop[2] == '0') )
00648         return 1;
00649     return 0;
00650 }

bool Abc_SopIsComplement ( char *  pSop  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 590 of file abcSop.c.

00591 {
00592     char * pCur;
00593     for ( pCur = pSop; *pCur; pCur++ )
00594         if ( *pCur == '\n' )
00595             return (int)(*(pCur - 1) == '0' || *(pCur - 1) == 'n');
00596     assert( 0 );
00597     return 0;
00598 }

bool Abc_SopIsConst0 ( char *  pSop  ) 

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

Synopsis [Checks if the cover is constant 0.]

Description []

SideEffects []

SeeAlso []

Definition at line 611 of file abcSop.c.

00612 {
00613     return pSop[0] == ' ' && pSop[1] == '0';
00614 }

bool Abc_SopIsConst1 ( char *  pSop  ) 

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

Synopsis [Checks if the cover is constant 1.]

Description []

SideEffects []

SeeAlso []

Definition at line 627 of file abcSop.c.

00628 {
00629     return pSop[0] == ' ' && pSop[1] == '1';
00630 }

int Abc_SopIsExorType ( char *  pSop  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 737 of file abcSop.c.

00738 {
00739     char * pCur;
00740     for ( pCur = pSop; *pCur; pCur++ )
00741         if ( *pCur == '\n' )
00742             return (int)(*(pCur - 1) == 'x' || *(pCur - 1) == 'n');
00743     assert( 0 );
00744     return 0;
00745 }

bool Abc_SopIsInv ( char *  pSop  ) 

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

Synopsis [Checks if the cover is constant 1.]

Description []

SideEffects []

SeeAlso []

Definition at line 663 of file abcSop.c.

00664 {
00665     if ( pSop[4] != 0 )
00666         return 0;
00667     if ( (pSop[0] == '0' && pSop[2] == '1') || (pSop[0] == '1' && pSop[2] == '0') )
00668         return 1;
00669     return 0;
00670 }

bool Abc_SopIsOrType ( char *  pSop  ) 

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

Synopsis [Checks if the cover is OR with possibly complemented inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 707 of file abcSop.c.

00708 {
00709     char * pCube, * pCur;
00710     int nVars, nLits;
00711     nVars = Abc_SopGetVarNum( pSop );
00712     if ( nVars != Abc_SopGetCubeNum(pSop) )
00713         return 0;
00714     Abc_SopForEachCube( pSop, nVars, pCube )
00715     {
00716         // count the number of literals in the cube
00717         nLits = 0;
00718         for ( pCur = pCube; *pCur != ' '; pCur++ )
00719             nLits += ( *pCur != '-' );
00720         if ( nLits != 1 )
00721             return 0;
00722     }
00723     return 1;
00724 }

char* Abc_SopRegister ( Extra_MmFlex_t pMan,
char *  pName 
)

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

FileName [abcSop.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Implementation of a simple SOP representation of nodes.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Registers the cube string with the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 53 of file abcSop.c.

00054 {
00055     char * pRegName;
00056     if ( pName == NULL ) return NULL;
00057     pRegName = Extra_MmFlexEntryFetch( pMan, strlen(pName) + 1 );
00058     strcpy( pRegName, pName );
00059     return pRegName;
00060 }

char* Abc_SopStart ( Extra_MmFlex_t pMan,
int  nCubes,
int  nVars 
)

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

Synopsis [Creates the constant 1 cover with the given number of variables and cubes.]

Description []

SideEffects []

SeeAlso []

Definition at line 73 of file abcSop.c.

00074 {
00075     char * pSopCover, * pCube;
00076     int i, Length;
00077 
00078     Length = nCubes * (nVars + 3);
00079     pSopCover = Extra_MmFlexEntryFetch( pMan, Length + 1 );
00080     memset( pSopCover, '-', Length );
00081     pSopCover[Length] = 0;
00082 
00083     for ( i = 0; i < nCubes; i++ )
00084     {
00085         pCube = pSopCover + i * (nVars + 3);
00086         pCube[nVars + 0] = ' ';
00087         pCube[nVars + 1] = '1';
00088         pCube[nVars + 2] = '\n';
00089     }
00090     return pSopCover;
00091 }

static int Abc_TruthWordNum ( int  nVars  )  [inline, static]

Definition at line 244 of file abc.h.

00244 { return nVars <= 5 ? 1 : (1 << (nVars - 5));  }

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 857 of file abcUtil.c.

00858 {
00859     Abc_Obj_t * pNode1, * pNode2;
00860     int i;
00861     if ( Vec_PtrPushUnique(p, pNode) )
00862         return;
00863     // find the p of the node
00864     for ( i = p->nSize-1; i > 0; i-- )
00865     {
00866         pNode1 = p->pArray[i  ];
00867         pNode2 = p->pArray[i-1];
00868         if ( Abc_ObjRegular(pNode1)->Level <= Abc_ObjRegular(pNode2)->Level )
00869             break;
00870         p->pArray[i  ] = pNode2;
00871         p->pArray[i-1] = pNode1;
00872     }
00873 }


Generated on Tue Jan 5 12:18:29 2010 for abc70930 by  doxygen 1.6.1