abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hop.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "misc/vec/vec.h"

Go to the source code of this file.

Data Structures

struct  Hop_Obj_t_
 
struct  Hop_Man_t_
 

Macros

#define Hop_ManForEachPi(p, pObj, i)   Vec_PtrForEachEntry( Hop_Obj_t *, p->vPis, pObj, i )
 ITERATORS ///. More...
 
#define Hop_ManForEachPo(p, pObj, i)   Vec_PtrForEachEntry( Hop_Obj_t *, p->vPos, pObj, i )
 
#define Hop_ManForEachNode(p, pObj, i)
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Hop_Man_t_ 
Hop_Man_t
 INCLUDES ///. More...
 
typedef struct Hop_Obj_t_ Hop_Obj_t
 
typedef int Hop_Edge_t
 

Enumerations

enum  Hop_Type_t {
  AIG_NONE, AIG_CONST1, AIG_PI, AIG_PO,
  AIG_AND, AIG_EXOR, AIG_VOID
}
 

Functions

void Hop_ManAddMemory (Hop_Man_t *p)
 MACRO DEFINITIONS ///. More...
 
static int Hop_BitWordNum (int nBits)
 
static int Hop_TruthWordNum (int nVars)
 
static int Hop_InfoHasBit (unsigned *p, int i)
 
static void Hop_InfoSetBit (unsigned *p, int i)
 
static void Hop_InfoXorBit (unsigned *p, int i)
 
static int Hop_Base2Log (unsigned n)
 
static int Hop_Base10Log (unsigned n)
 
static Hop_Obj_tHop_Regular (Hop_Obj_t *p)
 
static Hop_Obj_tHop_Not (Hop_Obj_t *p)
 
static Hop_Obj_tHop_NotCond (Hop_Obj_t *p, int c)
 
static int Hop_IsComplement (Hop_Obj_t *p)
 
static Hop_Obj_tHop_ManConst0 (Hop_Man_t *p)
 
static Hop_Obj_tHop_ManConst1 (Hop_Man_t *p)
 
static Hop_Obj_tHop_ManGhost (Hop_Man_t *p)
 
static Hop_Obj_tHop_ManPi (Hop_Man_t *p, int i)
 
static Hop_Obj_tHop_ManPo (Hop_Man_t *p, int i)
 
static Hop_Obj_tHop_ManObj (Hop_Man_t *p, int i)
 
static Hop_Edge_t Hop_EdgeCreate (int Id, int fCompl)
 
static int Hop_EdgeId (Hop_Edge_t Edge)
 
static int Hop_EdgeIsComplement (Hop_Edge_t Edge)
 
static Hop_Edge_t Hop_EdgeRegular (Hop_Edge_t Edge)
 
static Hop_Edge_t Hop_EdgeNot (Hop_Edge_t Edge)
 
static Hop_Edge_t Hop_EdgeNotCond (Hop_Edge_t Edge, int fCond)
 
static int Hop_ManPiNum (Hop_Man_t *p)
 
static int Hop_ManPoNum (Hop_Man_t *p)
 
static int Hop_ManAndNum (Hop_Man_t *p)
 
static int Hop_ManExorNum (Hop_Man_t *p)
 
static int Hop_ManNodeNum (Hop_Man_t *p)
 
static int Hop_ManGetCost (Hop_Man_t *p)
 
static int Hop_ManObjNum (Hop_Man_t *p)
 
static Hop_Type_t Hop_ObjType (Hop_Obj_t *pObj)
 
static int Hop_ObjIsNone (Hop_Obj_t *pObj)
 
static int Hop_ObjIsConst1 (Hop_Obj_t *pObj)
 
static int Hop_ObjIsPi (Hop_Obj_t *pObj)
 
static int Hop_ObjIsPo (Hop_Obj_t *pObj)
 
static int Hop_ObjIsAnd (Hop_Obj_t *pObj)
 
static int Hop_ObjIsExor (Hop_Obj_t *pObj)
 
static int Hop_ObjIsNode (Hop_Obj_t *pObj)
 
static int Hop_ObjIsTerm (Hop_Obj_t *pObj)
 
static int Hop_ObjIsHash (Hop_Obj_t *pObj)
 
static int Hop_ObjIsMarkA (Hop_Obj_t *pObj)
 
static void Hop_ObjSetMarkA (Hop_Obj_t *pObj)
 
static void Hop_ObjClearMarkA (Hop_Obj_t *pObj)
 
static void Hop_ObjSetTravId (Hop_Obj_t *pObj, int TravId)
 
static void Hop_ObjSetTravIdCurrent (Hop_Man_t *p, Hop_Obj_t *pObj)
 
static void Hop_ObjSetTravIdPrevious (Hop_Man_t *p, Hop_Obj_t *pObj)
 
static int Hop_ObjIsTravIdCurrent (Hop_Man_t *p, Hop_Obj_t *pObj)
 
static int Hop_ObjIsTravIdPrevious (Hop_Man_t *p, Hop_Obj_t *pObj)
 
static int Hop_ObjTravId (Hop_Obj_t *pObj)
 
static int Hop_ObjPhase (Hop_Obj_t *pObj)
 
static int Hop_ObjRefs (Hop_Obj_t *pObj)
 
static void Hop_ObjRef (Hop_Obj_t *pObj)
 
static void Hop_ObjDeref (Hop_Obj_t *pObj)
 
static void Hop_ObjClearRef (Hop_Obj_t *pObj)
 
static int Hop_ObjFaninC0 (Hop_Obj_t *pObj)
 
static int Hop_ObjFaninC1 (Hop_Obj_t *pObj)
 
static Hop_Obj_tHop_ObjFanin0 (Hop_Obj_t *pObj)
 
static Hop_Obj_tHop_ObjFanin1 (Hop_Obj_t *pObj)
 
static Hop_Obj_tHop_ObjChild0 (Hop_Obj_t *pObj)
 
static Hop_Obj_tHop_ObjChild1 (Hop_Obj_t *pObj)
 
static Hop_Obj_tHop_ObjChild0Copy (Hop_Obj_t *pObj)
 
static Hop_Obj_tHop_ObjChild1Copy (Hop_Obj_t *pObj)
 
static int Hop_ObjChild0CopyI (Hop_Obj_t *pObj)
 
static int Hop_ObjChild1CopyI (Hop_Obj_t *pObj)
 
static int Hop_ObjLevel (Hop_Obj_t *pObj)
 
static int Hop_ObjLevelNew (Hop_Obj_t *pObj)
 
static int Hop_ObjPhaseCompl (Hop_Obj_t *pObj)
 
static void Hop_ObjClean (Hop_Obj_t *pObj)
 
static int Hop_ObjWhatFanin (Hop_Obj_t *pObj, Hop_Obj_t *pFanin)
 
static int Hop_ObjFanoutC (Hop_Obj_t *pObj, Hop_Obj_t *pFanout)
 
static Hop_Obj_tHop_ObjCreateGhost (Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1, Hop_Type_t Type)
 
static Hop_Obj_tHop_ManFetchMemory (Hop_Man_t *p)
 
static void Hop_ManRecycleMemory (Hop_Man_t *p, Hop_Obj_t *pEntry)
 
Hop_Man_tHop_ManBalance (Hop_Man_t *p, int fUpdateLevel)
 FUNCTION DECLARATIONS ///. More...
 
Hop_Obj_tHop_NodeBalanceBuildSuper (Hop_Man_t *p, Vec_Ptr_t *vSuper, Hop_Type_t Type, int fUpdateLevel)
 
int Hop_ManCheck (Hop_Man_t *p)
 DECLARATIONS ///. More...
 
Vec_Ptr_tHop_ManDfs (Hop_Man_t *p)
 
Vec_Ptr_tHop_ManDfsNode (Hop_Man_t *p, Hop_Obj_t *pNode)
 
int Hop_ManCountLevels (Hop_Man_t *p)
 
void Hop_ManCreateRefs (Hop_Man_t *p)
 
int Hop_DagSize (Hop_Obj_t *pObj)
 
int Hop_ObjFanoutCount (Hop_Obj_t *pObj, Hop_Obj_t *pPivot)
 
void Hop_ConeUnmark_rec (Hop_Obj_t *pObj)
 
Hop_Obj_tHop_Transfer (Hop_Man_t *pSour, Hop_Man_t *pDest, Hop_Obj_t *pObj, int nVars)
 
Hop_Obj_tHop_Compose (Hop_Man_t *p, Hop_Obj_t *pRoot, Hop_Obj_t *pFunc, int iVar)
 
Hop_Obj_tHop_Complement (Hop_Man_t *p, Hop_Obj_t *pRoot, int iVar)
 
Hop_Obj_tHop_Remap (Hop_Man_t *p, Hop_Obj_t *pRoot, unsigned uSupp, int nVars)
 
Hop_Obj_tHop_Permute (Hop_Man_t *p, Hop_Obj_t *pRoot, int nRootVars, int *pPermute)
 
Hop_Man_tHop_ManStart ()
 DECLARATIONS ///. More...
 
Hop_Man_tHop_ManDup (Hop_Man_t *p)
 
void Hop_ManStop (Hop_Man_t *p)
 
int Hop_ManCleanup (Hop_Man_t *p)
 
void Hop_ManPrintStats (Hop_Man_t *p)
 
void Hop_ManStartMemory (Hop_Man_t *p)
 FUNCTION DEFINITIONS ///. More...
 
void Hop_ManStopMemory (Hop_Man_t *p)
 
Hop_Obj_tHop_ObjCreatePi (Hop_Man_t *p)
 DECLARATIONS ///. More...
 
Hop_Obj_tHop_ObjCreatePo (Hop_Man_t *p, Hop_Obj_t *pDriver)
 
Hop_Obj_tHop_ObjCreate (Hop_Man_t *p, Hop_Obj_t *pGhost)
 
void Hop_ObjConnect (Hop_Man_t *p, Hop_Obj_t *pObj, Hop_Obj_t *pFan0, Hop_Obj_t *pFan1)
 
void Hop_ObjDisconnect (Hop_Man_t *p, Hop_Obj_t *pObj)
 
void Hop_ObjDelete (Hop_Man_t *p, Hop_Obj_t *pObj)
 
void Hop_ObjDelete_rec (Hop_Man_t *p, Hop_Obj_t *pObj)
 
Hop_Obj_tHop_ObjRepr (Hop_Obj_t *pObj)
 
void Hop_ObjCreateChoice (Hop_Obj_t *pOld, Hop_Obj_t *pNew)
 
Hop_Obj_tHop_IthVar (Hop_Man_t *p, int i)
 FUNCTION DEFINITIONS ///. More...
 
Hop_Obj_tHop_Oper (Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1, Hop_Type_t Type)
 
Hop_Obj_tHop_And (Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
 
Hop_Obj_tHop_Or (Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
 
Hop_Obj_tHop_Exor (Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
 
Hop_Obj_tHop_Mux (Hop_Man_t *p, Hop_Obj_t *pC, Hop_Obj_t *p1, Hop_Obj_t *p0)
 
Hop_Obj_tHop_Maj (Hop_Man_t *p, Hop_Obj_t *pA, Hop_Obj_t *pB, Hop_Obj_t *pC)
 
Hop_Obj_tHop_Miter (Hop_Man_t *p, Vec_Ptr_t *vPairs)
 
Hop_Obj_tHop_CreateAnd (Hop_Man_t *p, int nVars)
 
Hop_Obj_tHop_CreateOr (Hop_Man_t *p, int nVars)
 
Hop_Obj_tHop_CreateExor (Hop_Man_t *p, int nVars)
 
Hop_Obj_tHop_TableLookup (Hop_Man_t *p, Hop_Obj_t *pGhost)
 FUNCTION DEFINITIONS ///. More...
 
void Hop_TableInsert (Hop_Man_t *p, Hop_Obj_t *pObj)
 
void Hop_TableDelete (Hop_Man_t *p, Hop_Obj_t *pObj)
 
int Hop_TableCountEntries (Hop_Man_t *p)
 
void Hop_TableProfile (Hop_Man_t *p)
 
unsigned * Hop_ManConvertAigToTruth (Hop_Man_t *p, Hop_Obj_t *pRoot, int nVars, Vec_Int_t *vTruth, int fMsbFirst)
 
word Hop_ManComputeTruth6 (Hop_Man_t *p, Hop_Obj_t *pObj, int nVars)
 
void Hop_ManIncrementTravId (Hop_Man_t *p)
 DECLARATIONS ///. More...
 
void Hop_ManCleanData (Hop_Man_t *p)
 
void Hop_ObjCleanData_rec (Hop_Obj_t *pObj)
 
void Hop_ObjCollectMulti (Hop_Obj_t *pFunc, Vec_Ptr_t *vSuper)
 
int Hop_ObjIsMuxType (Hop_Obj_t *pObj)
 
int Hop_ObjRecognizeExor (Hop_Obj_t *pObj, Hop_Obj_t **ppFan0, Hop_Obj_t **ppFan1)
 
Hop_Obj_tHop_ObjRecognizeMux (Hop_Obj_t *pObj, Hop_Obj_t **ppObjT, Hop_Obj_t **ppObjE)
 
void Hop_ObjPrintEqn (FILE *pFile, Hop_Obj_t *pObj, Vec_Vec_t *vLevels, int Level)
 
void Hop_ObjPrintVerilog (FILE *pFile, Hop_Obj_t *pObj, Vec_Vec_t *vLevels, int Level)
 
void Hop_ObjPrintVerbose (Hop_Obj_t *pObj, int fHaig)
 
void Hop_ManPrintVerbose (Hop_Man_t *p, int fHaig)
 
void Hop_ManDumpBlif (Hop_Man_t *p, char *pFileName)
 

Macro Definition Documentation

#define Hop_ManForEachNode (   p,
  pObj,
 
)
Value:
for ( i = 0; i < p->nTableSize; i++ ) \
if ( ((pObj) = p->pTable[i]) == NULL ) {} else
static Llb_Mgr_t * p
Definition: llb3Image.c:950

Definition at line 265 of file hop.h.

#define Hop_ManForEachPi (   p,
  pObj,
 
)    Vec_PtrForEachEntry( Hop_Obj_t *, p->vPis, pObj, i )

ITERATORS ///.

Definition at line 259 of file hop.h.

#define Hop_ManForEachPo (   p,
  pObj,
 
)    Vec_PtrForEachEntry( Hop_Obj_t *, p->vPos, pObj, i )

Definition at line 262 of file hop.h.

Typedef Documentation

typedef int Hop_Edge_t

Definition at line 51 of file hop.h.

typedef typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t

INCLUDES ///.

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

FileName [hop.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Minimalistic And-Inverter Graph package.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - May 11, 2006.]

Revision [

Id:
hop.h,v 1.00 2006/05/11 00:00:00 alanmi Exp

]PARAMETERS ///BASIC TYPES ///

Definition at line 49 of file hop.h.

typedef struct Hop_Obj_t_ Hop_Obj_t

Definition at line 50 of file hop.h.

Enumeration Type Documentation

enum Hop_Type_t
Enumerator
AIG_NONE 
AIG_CONST1 
AIG_PI 
AIG_PO 
AIG_AND 
AIG_EXOR 
AIG_VOID 

Definition at line 54 of file hop.h.

54  {
55  AIG_NONE, // 0: non-existent object
56  AIG_CONST1, // 1: constant 1
57  AIG_PI, // 2: primary input
58  AIG_PO, // 3: primary output
59  AIG_AND, // 4: AND node
60  AIG_EXOR, // 5: EXOR node
61  AIG_VOID // 6: unused object
62 } Hop_Type_t;
Definition: hop.h:60
Hop_Type_t
Definition: hop.h:54
Definition: hop.h:57
Definition: hop.h:58
Definition: hop.h:56
Definition: hop.h:59
Definition: hop.h:61
Definition: hop.h:55

Function Documentation

Hop_Obj_t* Hop_And ( Hop_Man_t p,
Hop_Obj_t p0,
Hop_Obj_t p1 
)

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

Synopsis [Performs canonicization step.]

Description [The argument nodes can be complemented.]

SideEffects []

SeeAlso []

Definition at line 104 of file hopOper.c.

105 {
106  Hop_Obj_t * pGhost, * pResult;
107 // Hop_Obj_t * pFan0, * pFan1;
108  // check trivial cases
109  if ( p0 == p1 )
110  return p0;
111  if ( p0 == Hop_Not(p1) )
112  return Hop_Not(p->pConst1);
113  if ( Hop_Regular(p0) == p->pConst1 )
114  return p0 == p->pConst1 ? p1 : Hop_Not(p->pConst1);
115  if ( Hop_Regular(p1) == p->pConst1 )
116  return p1 == p->pConst1 ? p0 : Hop_Not(p->pConst1);
117  // check if it can be an EXOR gate
118 // if ( Hop_ObjIsExorType( p0, p1, &pFan0, &pFan1 ) )
119 // return Hop_Exor( p, pFan0, pFan1 );
120  // check the table
121  pGhost = Hop_ObjCreateGhost( p, p0, p1, AIG_AND );
122  if ( (pResult = Hop_TableLookup( p, pGhost )) )
123  return pResult;
124  return Hop_ObjCreate( p, pGhost );
125 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Hop_Obj_t * Hop_ObjCreate(Hop_Man_t *p, Hop_Obj_t *pGhost)
Definition: hopObj.c:97
static Hop_Obj_t * Hop_Not(Hop_Obj_t *p)
Definition: hop.h:127
Definition: hop.h:65
Definition: hop.h:59
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
static Hop_Obj_t * Hop_ObjCreateGhost(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1, Hop_Type_t Type)
Definition: hop.h:208
Hop_Obj_t * Hop_TableLookup(Hop_Man_t *p, Hop_Obj_t *pGhost)
FUNCTION DEFINITIONS ///.
Definition: hopTable.c:71
static int Hop_Base10Log ( unsigned  n)
inlinestatic

Definition at line 124 of file hop.h.

124 { int r; if ( n < 2 ) return n; for ( r = 0, n--; n; n /= 10, r++ ) {}; return r; }
static int Hop_Base2Log ( unsigned  n)
inlinestatic

Definition at line 123 of file hop.h.

123 { int r; if ( n < 2 ) return n; for ( r = 0, n--; n; n >>= 1, r++ ) {}; return r; }
static int Hop_BitWordNum ( int  nBits)
inlinestatic

Definition at line 118 of file hop.h.

118 { return (nBits>>5) + ((nBits&31) > 0); }
Hop_Obj_t* Hop_Complement ( Hop_Man_t p,
Hop_Obj_t pRoot,
int  iVar 
)

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

Synopsis [Complements the AIG (pRoot) with the function (pFunc) using PI var (iVar).]

Description []

SideEffects []

SeeAlso []

Definition at line 469 of file hopDfs.c.

470 {
471  // quit if the PI variable is not defined
472  if ( iVar >= Hop_ManPiNum(p) )
473  {
474  printf( "Hop_Complement(): The PI variable %d is not defined.\n", iVar );
475  return NULL;
476  }
477  // recursively perform composition
478  Hop_Complement_rec( p, Hop_Regular(pRoot), Hop_ManPi(p, iVar) );
479  // clear the markings
481  return Hop_NotCond( (Hop_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
482 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Hop_Complement_rec(Hop_Man_t *p, Hop_Obj_t *pObj, Hop_Obj_t *pVar)
Definition: hopDfs.c:441
Definition: hop.h:65
static Hop_Obj_t * Hop_ManPi(Hop_Man_t *p, int i)
Definition: hop.h:134
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
void Hop_ConeUnmark_rec(Hop_Obj_t *pObj)
Definition: hopDfs.c:257
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Definition: hop.h:128
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
static int Hop_ManPiNum(Hop_Man_t *p)
Definition: hop.h:145
Hop_Obj_t* Hop_Compose ( Hop_Man_t p,
Hop_Obj_t pRoot,
Hop_Obj_t pFunc,
int  iVar 
)

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

Synopsis [Composes the AIG (pRoot) with the function (pFunc) using PI var (iVar).]

Description []

SideEffects []

SeeAlso []

Definition at line 415 of file hopDfs.c.

416 {
417  // quit if the PI variable is not defined
418  if ( iVar >= Hop_ManPiNum(p) )
419  {
420  printf( "Hop_Compose(): The PI variable %d is not defined.\n", iVar );
421  return NULL;
422  }
423  // recursively perform composition
424  Hop_Compose_rec( p, Hop_Regular(pRoot), pFunc, Hop_ManPi(p, iVar) );
425  // clear the markings
427  return Hop_NotCond( (Hop_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
428 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:65
static Hop_Obj_t * Hop_ManPi(Hop_Man_t *p, int i)
Definition: hop.h:134
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
void Hop_ConeUnmark_rec(Hop_Obj_t *pObj)
Definition: hopDfs.c:257
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Definition: hop.h:128
void Hop_Compose_rec(Hop_Man_t *p, Hop_Obj_t *pObj, Hop_Obj_t *pFunc, Hop_Obj_t *pVar)
Definition: hopDfs.c:387
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
static int Hop_ManPiNum(Hop_Man_t *p)
Definition: hop.h:145
void Hop_ConeUnmark_rec ( Hop_Obj_t pObj)

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

Synopsis [Counts the number of AIG nodes rooted at this cone.]

Description []

SideEffects []

SeeAlso []

Definition at line 257 of file hopDfs.c.

258 {
259  assert( !Hop_IsComplement(pObj) );
260  if ( !Hop_ObjIsNode(pObj) || !Hop_ObjIsMarkA(pObj) )
261  return;
264  assert( Hop_ObjIsMarkA(pObj) ); // loop detection
265  Hop_ObjClearMarkA( pObj );
266 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static int Hop_ObjIsMarkA(Hop_Obj_t *pObj)
Definition: hop.h:164
static int Hop_ObjIsNode(Hop_Obj_t *pObj)
Definition: hop.h:160
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static void Hop_ObjClearMarkA(Hop_Obj_t *pObj)
Definition: hop.h:166
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
void Hop_ConeUnmark_rec(Hop_Obj_t *pObj)
Definition: hopDfs.c:257
#define assert(ex)
Definition: util_old.h:213
Hop_Obj_t* Hop_CreateAnd ( Hop_Man_t p,
int  nVars 
)

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

Synopsis [Creates AND function with nVars inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 320 of file hopOper.c.

321 {
322  Hop_Obj_t * pFunc;
323  int i;
324  pFunc = Hop_ManConst1( p );
325  for ( i = 0; i < nVars; i++ )
326  pFunc = Hop_And( p, pFunc, Hop_IthVar(p, i) );
327  return pFunc;
328 }
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Definition: hop.h:132
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:65
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: hopOper.c:63
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:104
Hop_Obj_t* Hop_CreateExor ( Hop_Man_t p,
int  nVars 
)

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

Synopsis [Creates AND function with nVars inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 362 of file hopOper.c.

363 {
364  Hop_Obj_t * pFunc;
365  int i;
366  pFunc = Hop_ManConst0( p );
367  for ( i = 0; i < nVars; i++ )
368  pFunc = Hop_Exor( p, pFunc, Hop_IthVar(p, i) );
369  return pFunc;
370 }
Hop_Obj_t * Hop_Exor(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:138
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:65
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: hopOper.c:63
static Hop_Obj_t * Hop_ManConst0(Hop_Man_t *p)
Definition: hop.h:131
Hop_Obj_t* Hop_CreateOr ( Hop_Man_t p,
int  nVars 
)

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

Synopsis [Creates AND function with nVars inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 341 of file hopOper.c.

342 {
343  Hop_Obj_t * pFunc;
344  int i;
345  pFunc = Hop_ManConst0( p );
346  for ( i = 0; i < nVars; i++ )
347  pFunc = Hop_Or( p, pFunc, Hop_IthVar(p, i) );
348  return pFunc;
349 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Hop_Obj_t * Hop_Or(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:171
Definition: hop.h:65
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: hopOper.c:63
static Hop_Obj_t * Hop_ManConst0(Hop_Man_t *p)
Definition: hop.h:131
int Hop_DagSize ( Hop_Obj_t pObj)

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

Synopsis [Counts the number of AIG nodes rooted at this cone.]

Description []

SideEffects []

SeeAlso []

Definition at line 279 of file hopDfs.c.

280 {
281  int Counter;
282  Counter = Hop_ConeCountAndMark_rec( Hop_Regular(pObj) );
284  return Counter;
285 }
static int Counter
void Hop_ConeUnmark_rec(Hop_Obj_t *pObj)
Definition: hopDfs.c:257
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
int Hop_ConeCountAndMark_rec(Hop_Obj_t *pObj)
Definition: hopDfs.c:233
static Hop_Edge_t Hop_EdgeCreate ( int  Id,
int  fCompl 
)
inlinestatic

Definition at line 138 of file hop.h.

138 { return (Id << 1) | fCompl; }
static int Hop_EdgeId ( Hop_Edge_t  Edge)
inlinestatic

Definition at line 139 of file hop.h.

139 { return Edge >> 1; }
static int Hop_EdgeIsComplement ( Hop_Edge_t  Edge)
inlinestatic

Definition at line 140 of file hop.h.

140 { return Edge & 1; }
static Hop_Edge_t Hop_EdgeNot ( Hop_Edge_t  Edge)
inlinestatic

Definition at line 142 of file hop.h.

142 { return Edge ^ 1; }
static Hop_Edge_t Hop_EdgeNotCond ( Hop_Edge_t  Edge,
int  fCond 
)
inlinestatic

Definition at line 143 of file hop.h.

143 { return Edge ^ fCond; }
static Hop_Edge_t Hop_EdgeRegular ( Hop_Edge_t  Edge)
inlinestatic

Definition at line 141 of file hop.h.

141 { return (Edge >> 1) << 1; }
Hop_Obj_t* Hop_Exor ( Hop_Man_t p,
Hop_Obj_t p0,
Hop_Obj_t p1 
)

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

Synopsis [Performs canonicization step.]

Description [The argument nodes can be complemented.]

SideEffects []

SeeAlso []

Definition at line 138 of file hopOper.c.

139 {
140 /*
141  Hop_Obj_t * pGhost, * pResult;
142  // check trivial cases
143  if ( p0 == p1 )
144  return Hop_Not(p->pConst1);
145  if ( p0 == Hop_Not(p1) )
146  return p->pConst1;
147  if ( Hop_Regular(p0) == p->pConst1 )
148  return Hop_NotCond( p1, p0 == p->pConst1 );
149  if ( Hop_Regular(p1) == p->pConst1 )
150  return Hop_NotCond( p0, p1 == p->pConst1 );
151  // check the table
152  pGhost = Hop_ObjCreateGhost( p, p0, p1, AIG_EXOR );
153  if ( pResult = Hop_TableLookup( p, pGhost ) )
154  return pResult;
155  return Hop_ObjCreate( p, pGhost );
156 */
157  return Hop_Or( p, Hop_And(p, p0, Hop_Not(p1)), Hop_And(p, Hop_Not(p0), p1) );
158 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Hop_Obj_t * Hop_Or(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:171
static Hop_Obj_t * Hop_Not(Hop_Obj_t *p)
Definition: hop.h:127
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:104
static int Hop_InfoHasBit ( unsigned *  p,
int  i 
)
inlinestatic

Definition at line 120 of file hop.h.

120 { return (p[(i)>>5] & (1<<((i) & 31))) > 0; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Hop_InfoSetBit ( unsigned *  p,
int  i 
)
inlinestatic

Definition at line 121 of file hop.h.

121 { p[(i)>>5] |= (1<<((i) & 31)); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Hop_InfoXorBit ( unsigned *  p,
int  i 
)
inlinestatic

Definition at line 122 of file hop.h.

122 { p[(i)>>5] ^= (1<<((i) & 31)); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Hop_IsComplement ( Hop_Obj_t p)
inlinestatic

Definition at line 129 of file hop.h.

129 { return (int)((ABC_PTRUINT_T)(p) & 01); }
Hop_Obj_t* Hop_IthVar ( Hop_Man_t p,
int  i 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Returns i-th elementary variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 63 of file hopOper.c.

64 {
65  int v;
66  for ( v = Hop_ManPiNum(p); v <= i; v++ )
67  Hop_ObjCreatePi( p );
68  assert( i < Vec_PtrSize(p->vPis) );
69  return Hop_ManPi( p, i );
70 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static Hop_Obj_t * Hop_ManPi(Hop_Man_t *p, int i)
Definition: hop.h:134
#define assert(ex)
Definition: util_old.h:213
Hop_Obj_t * Hop_ObjCreatePi(Hop_Man_t *p)
DECLARATIONS ///.
Definition: hopObj.c:45
static int Hop_ManPiNum(Hop_Man_t *p)
Definition: hop.h:145
Hop_Obj_t* Hop_Maj ( Hop_Man_t p,
Hop_Obj_t pA,
Hop_Obj_t pB,
Hop_Obj_t pC 
)

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

Synopsis [Implements ITE operation.]

Description []

SideEffects []

SeeAlso []

Definition at line 242 of file hopOper.c.

243 {
244  return Hop_Or( p, Hop_Or(p, Hop_And(p, pA, pB), Hop_And(p, pA, pC)), Hop_And(p, pB, pC) );
245 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Hop_Obj_t * Hop_Or(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:171
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:104
void Hop_ManAddMemory ( Hop_Man_t p)

MACRO DEFINITIONS ///.

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

Synopsis [Allocates additional memory for the nodes.]

Description [Allocates IVY_PAGE_SIZE nodes. Aligns memory by 32 bytes. Records the pointer to the AIG manager in the -1 entry.]

SideEffects []

SeeAlso []

Definition at line 89 of file hopMem.c.

90 {
91  char * pMemory;
92  int i, nBytes;
93  assert( sizeof(Hop_Obj_t) <= 64 );
94  assert( p->pListFree == NULL );
95 // assert( (Hop_ManObjNum(p) & IVY_PAGE_MASK) == 0 );
96  // allocate new memory page
97  nBytes = sizeof(Hop_Obj_t) * (1<<IVY_PAGE_SIZE) + 64;
98  pMemory = ABC_ALLOC( char, nBytes );
99  Vec_PtrPush( p->vChunks, pMemory );
100  // align memory at the 32-byte boundary
101  pMemory = pMemory + 64 - (((int)(ABC_PTRUINT_T)pMemory) & 63);
102  // remember the manager in the first entry
103  Vec_PtrPush( p->vPages, pMemory );
104  // break the memory down into nodes
105  p->pListFree = (Hop_Obj_t *)pMemory;
106  for ( i = 1; i <= IVY_PAGE_MASK; i++ )
107  {
108  *((char **)pMemory) = pMemory + sizeof(Hop_Obj_t);
109  pMemory += sizeof(Hop_Obj_t);
110  }
111  *((char **)pMemory) = NULL;
112 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Definition: hop.h:65
for(p=first;p->value< newval;p=p->next)
#define IVY_PAGE_MASK
Definition: hopMem.c:32
#define assert(ex)
Definition: util_old.h:213
#define IVY_PAGE_SIZE
DECLARATIONS ///.
Definition: hopMem.c:31
struct Hop_Obj_t_ Hop_Obj_t
Definition: hop.h:50
static int Hop_ManAndNum ( Hop_Man_t p)
inlinestatic

Definition at line 147 of file hop.h.

147 { return p->nObjs[AIG_AND]; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:59
Hop_Man_t* Hop_ManBalance ( Hop_Man_t p,
int  fUpdateLevel 
)

FUNCTION DECLARATIONS ///.

FUNCTION DECLARATIONS ///.

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

Synopsis [Performs algebraic balancing of the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 51 of file hopBalance.c.

52 {
53  Hop_Man_t * pNew;
54  Hop_Obj_t * pObj, * pObjNew;
55  Vec_Vec_t * vStore;
56  int i;
57  // create the new manager
58  pNew = Hop_ManStart();
59  pNew->fRefCount = 0;
60  // map the PI nodes
63  Hop_ManForEachPi( p, pObj, i )
64  pObj->pData = Hop_ObjCreatePi(pNew);
65  // balance the AIG
66  vStore = Vec_VecAlloc( 50 );
67  Hop_ManForEachPo( p, pObj, i )
68  {
69  pObjNew = Hop_NodeBalance_rec( pNew, Hop_ObjFanin0(pObj), vStore, 0, fUpdateLevel );
70  Hop_ObjCreatePo( pNew, Hop_NotCond( pObjNew, Hop_ObjFaninC0(pObj) ) );
71  }
72  Vec_VecFree( vStore );
73  // remove dangling nodes
74 // Hop_ManCreateRefs( pNew );
75 // if ( i = Hop_ManCleanup( pNew ) )
76 // printf( "Cleanup after balancing removed %d dangling nodes.\n", i );
77  // check the resulting AIG
78  if ( !Hop_ManCheck(pNew) )
79  printf( "Hop_ManBalance(): The check has failed.\n" );
80  return pNew;
81 }
int Hop_ManCheck(Hop_Man_t *p)
DECLARATIONS ///.
Definition: hopCheck.c:45
static Vec_Vec_t * Vec_VecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecVec.h:145
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Definition: hop.h:132
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static ABC_NAMESPACE_IMPL_START Hop_Obj_t * Hop_NodeBalance_rec(Hop_Man_t *pNew, Hop_Obj_t *pObj, Vec_Vec_t *vStore, int Level, int fUpdateLevel)
DECLARATIONS ///.
Definition: hopBalance.c:94
#define Hop_ManForEachPi(p, pObj, i)
ITERATORS ///.
Definition: hop.h:259
#define Hop_ManForEachPo(p, pObj, i)
Definition: hop.h:262
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
Definition: hop.h:65
Hop_Man_t * Hop_ManStart()
DECLARATIONS ///.
Definition: hopMan.c:45
void * pData
Definition: hop.h:68
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static int Hop_ObjFaninC0(Hop_Obj_t *pObj)
Definition: hop.h:180
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Definition: hop.h:128
void Hop_ManCleanData(Hop_Man_t *p)
Definition: hopUtil.c:63
Hop_Obj_t * Hop_ObjCreatePo(Hop_Man_t *p, Hop_Obj_t *pDriver)
Definition: hopObj.c:67
Hop_Obj_t * Hop_ObjCreatePi(Hop_Man_t *p)
DECLARATIONS ///.
Definition: hopObj.c:45
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition: hop.h:49
int Hop_ManCheck ( Hop_Man_t p)

DECLARATIONS ///.

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

FileName [hopCheck.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Minimalistic And-Inverter Graph package.]

Synopsis [AIG checking procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - May 11, 2006.]

Revision [

Id:
hopCheck.c,v 1.00 2006/05/11 00:00:00 alanmi Exp

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

Synopsis [Checks the consistency of the AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file hopCheck.c.

46 {
47  Hop_Obj_t * pObj, * pObj2;
48  int i;
49  // check primary inputs
50  Hop_ManForEachPi( p, pObj, i )
51  {
52  if ( Hop_ObjFanin0(pObj) || Hop_ObjFanin1(pObj) )
53  {
54  printf( "Hop_ManCheck: The PI node \"%p\" has fanins.\n", pObj );
55  return 0;
56  }
57  }
58  // check primary outputs
59  Hop_ManForEachPo( p, pObj, i )
60  {
61  if ( !Hop_ObjFanin0(pObj) )
62  {
63  printf( "Hop_ManCheck: The PO node \"%p\" has NULL fanin.\n", pObj );
64  return 0;
65  }
66  if ( Hop_ObjFanin1(pObj) )
67  {
68  printf( "Hop_ManCheck: The PO node \"%p\" has second fanin.\n", pObj );
69  return 0;
70  }
71  }
72  // check internal nodes
73  Hop_ManForEachNode( p, pObj, i )
74  {
75  if ( !Hop_ObjFanin0(pObj) || !Hop_ObjFanin1(pObj) )
76  {
77  printf( "Hop_ManCheck: The AIG has internal node \"%p\" with a NULL fanin.\n", pObj );
78  return 0;
79  }
80  if ( Hop_ObjFanin0(pObj)->Id >= Hop_ObjFanin1(pObj)->Id )
81  {
82  printf( "Hop_ManCheck: The AIG has node \"%p\" with a wrong ordering of fanins.\n", pObj );
83  return 0;
84  }
85  pObj2 = Hop_TableLookup( p, pObj );
86  if ( pObj2 != pObj )
87  {
88  printf( "Hop_ManCheck: Node \"%p\" is not in the structural hashing table.\n", pObj );
89  return 0;
90  }
91  }
92  // count the total number of nodes
94  {
95  printf( "Hop_ManCheck: The number of created nodes is wrong.\n" );
96  return 0;
97  }
98  // count the number of nodes in the table
100  {
101  printf( "Hop_ManCheck: The number of nodes in the structural hashing table is wrong.\n" );
102  return 0;
103  }
104 // if ( !Hop_ManIsAcyclic(p) )
105 // return 0;
106  return 1;
107 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Hop_ManForEachNode(p, pObj, i)
Definition: hop.h:265
#define Hop_ManForEachPi(p, pObj, i)
ITERATORS ///.
Definition: hop.h:259
#define Hop_ManForEachPo(p, pObj, i)
Definition: hop.h:262
static int Hop_ManPoNum(Hop_Man_t *p)
Definition: hop.h:146
static int Hop_ManObjNum(Hop_Man_t *p)
Definition: hop.h:151
Definition: hop.h:65
static int Hop_ManAndNum(Hop_Man_t *p)
Definition: hop.h:147
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static int Hop_ManExorNum(Hop_Man_t *p)
Definition: hop.h:148
int Hop_TableCountEntries(Hop_Man_t *p)
Definition: hopTable.c:145
Hop_Obj_t * Hop_TableLookup(Hop_Man_t *p, Hop_Obj_t *pGhost)
FUNCTION DEFINITIONS ///.
Definition: hopTable.c:71
static int Hop_ManPiNum(Hop_Man_t *p)
Definition: hop.h:145
void Hop_ManCleanData ( Hop_Man_t p)

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

Synopsis [Cleans the data pointers for the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 63 of file hopUtil.c.

64 {
65  Hop_Obj_t * pObj;
66  int i;
67  p->nTravIds = 1;
68  Hop_ManConst1(p)->pData = NULL;
69  Hop_ManForEachPi( p, pObj, i )
70  pObj->pData = NULL;
71  Hop_ManForEachPo( p, pObj, i )
72  pObj->pData = NULL;
73  Hop_ManForEachNode( p, pObj, i )
74  pObj->pData = NULL;
75 }
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Definition: hop.h:132
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Hop_ManForEachNode(p, pObj, i)
Definition: hop.h:265
#define Hop_ManForEachPi(p, pObj, i)
ITERATORS ///.
Definition: hop.h:259
#define Hop_ManForEachPo(p, pObj, i)
Definition: hop.h:262
Definition: hop.h:65
void * pData
Definition: hop.h:68
int Hop_ManCleanup ( Hop_Man_t p)

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

Synopsis [Returns the number of dangling nodes removed.]

Description []

SideEffects []

SeeAlso []

Definition at line 120 of file hopMan.c.

121 {
122  Vec_Ptr_t * vObjs;
123  Hop_Obj_t * pNode;
124  int i, nNodesOld;
125  assert( p->fRefCount );
126  nNodesOld = Hop_ManNodeNum(p);
127  // collect roots of dangling nodes
128  vObjs = Vec_PtrAlloc( 100 );
129  Hop_ManForEachNode( p, pNode, i )
130  if ( Hop_ObjRefs(pNode) == 0 )
131  Vec_PtrPush( vObjs, pNode );
132  // recursively remove dangling nodes
133  Vec_PtrForEachEntry( Hop_Obj_t *, vObjs, pNode, i )
134  Hop_ObjDelete_rec( p, pNode );
135  Vec_PtrFree( vObjs );
136  return nNodesOld - Hop_ManNodeNum(p);
137 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Hop_ObjRefs(Hop_Obj_t *pObj)
Definition: hop.h:176
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Hop_ManForEachNode(p, pObj, i)
Definition: hop.h:265
void Hop_ObjDelete_rec(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopObj.c:214
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
Definition: hop.h:65
if(last==0)
Definition: sparse_int.h:34
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static int Hop_ManNodeNum(Hop_Man_t *p)
Definition: hop.h:149
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
word Hop_ManComputeTruth6 ( Hop_Man_t p,
Hop_Obj_t pObj,
int  nVars 
)

Definition at line 256 of file hopTruth.c.

257 {
258  word Truth;
259  int i;
260  if ( Hop_ObjIsConst1( Hop_Regular(pObj) ) )
261  return Hop_IsComplement(pObj) ? 0 : ~(word)0;
262  for ( i = 0; i < nVars; i++ )
263  Hop_ManPi( p, i )->iData = i;
264  Truth = Hop_ManComputeTruth6_rec( p, Hop_Regular(pObj) );
265  return Hop_IsComplement(pObj) ? ~Truth : Truth;
266 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static word Truth[8]
Definition: hopTruth.c:233
int iData
Definition: hop.h:69
static Hop_Obj_t * Hop_ManPi(Hop_Man_t *p, int i)
Definition: hop.h:134
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static int Hop_ObjIsConst1(Hop_Obj_t *pObj)
Definition: hop.h:155
word Hop_ManComputeTruth6_rec(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopTruth.c:244
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
static Hop_Obj_t* Hop_ManConst0 ( Hop_Man_t p)
inlinestatic

Definition at line 131 of file hop.h.

131 { return Hop_Not(p->pConst1); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Hop_Obj_t * Hop_Not(Hop_Obj_t *p)
Definition: hop.h:127
static Hop_Obj_t* Hop_ManConst1 ( Hop_Man_t p)
inlinestatic

Definition at line 132 of file hop.h.

132 { return p->pConst1; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned* Hop_ManConvertAigToTruth ( 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 143 of file hopTruth.c.

144 {
145  static unsigned uTruths[8][8] = { // elementary truth tables
146  { 0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA },
147  { 0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC },
148  { 0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0 },
149  { 0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00 },
150  { 0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000 },
151  { 0x00000000,0xFFFFFFFF,0x00000000,0xFFFFFFFF,0x00000000,0xFFFFFFFF,0x00000000,0xFFFFFFFF },
152  { 0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFF,0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFF },
153  { 0x00000000,0x00000000,0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF }
154  };
155  Hop_Obj_t * pObj;
156  unsigned * pTruth, * pTruth2;
157  int i, nWords, nNodes;
158  Vec_Ptr_t * vTtElems;
159 
160  // if the number of variables is more than 8, allocate truth tables
161  if ( nVars > 8 )
162  vTtElems = Vec_PtrAllocTruthTables( nVars );
163  else
164  vTtElems = NULL;
165 
166  // clear the data fields and set marks
167  nNodes = Hop_ManConvertAigToTruth_rec1( Hop_Regular(pRoot) );
168  // prepare memory
169  nWords = Hop_TruthWordNum( nVars );
170  Vec_IntClear( vTruth );
171  Vec_IntGrow( vTruth, nWords * (nNodes+1) );
172  pTruth = Vec_IntFetch( vTruth, nWords );
173  // check the case of a constant
174  if ( Hop_ObjIsConst1( Hop_Regular(pRoot) ) )
175  {
176  assert( nNodes == 0 );
177  if ( Hop_IsComplement(pRoot) )
178  Hop_ManTruthClear( pTruth, nVars );
179  else
180  Hop_ManTruthFill( pTruth, nVars );
181  return pTruth;
182  }
183  // set elementary truth tables at the leaves
184  assert( nVars <= Hop_ManPiNum(p) );
185 // assert( Hop_ManPiNum(p) <= 8 );
186  if ( fMsbFirst )
187  {
188 // Hop_ManForEachPi( p, pObj, i )
189  for ( i = 0; i < nVars; i++ )
190  {
191  pObj = Hop_ManPi( p, i );
192  if ( vTtElems )
193  pObj->pData = Vec_PtrEntry(vTtElems, nVars-1-i);
194  else
195  pObj->pData = (void *)uTruths[nVars-1-i];
196  }
197  }
198  else
199  {
200 // Hop_ManForEachPi( p, pObj, i )
201  for ( i = 0; i < nVars; i++ )
202  {
203  pObj = Hop_ManPi( p, i );
204  if ( vTtElems )
205  pObj->pData = Vec_PtrEntry(vTtElems, i);
206  else
207  pObj->pData = (void *)uTruths[i];
208  }
209  }
210  // clear the marks and compute the truth table
211  pTruth2 = Hop_ManConvertAigToTruth_rec2( Hop_Regular(pRoot), vTruth, nWords );
212  // copy the result
213  Hop_ManTruthCopy( pTruth, pTruth2, nVars );
214  if ( Hop_IsComplement(pRoot) )
215  Hop_ManTruthNot( pTruth, pTruth, nVars );
216  if ( vTtElems )
217  Vec_PtrFree( vTtElems );
218  return pTruth;
219 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned * Hop_ManConvertAigToTruth_rec2(Hop_Obj_t *pObj, Vec_Int_t *vTruth, int nWords)
Definition: hopTruth.c:97
static unsigned * Vec_IntFetch(Vec_Int_t *p, int nWords)
Definition: vecInt.h:853
int nWords
Definition: abcNpn.c:127
Definition: hop.h:65
static Vec_Ptr_t * Vec_PtrAllocTruthTables(int nVars)
Definition: vecPtr.h:1065
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
static Hop_Obj_t * Hop_ManPi(Hop_Man_t *p, int i)
Definition: hop.h:134
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
void * pData
Definition: hop.h:68
static int Hop_ObjIsConst1(Hop_Obj_t *pObj)
Definition: hop.h:155
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static void Hop_ManTruthClear(unsigned *pOut, int nVars)
Definition: hopTruth.c:38
static int Hop_TruthWordNum(int nVars)
Definition: hop.h:119
static void Hop_ManTruthFill(unsigned *pOut, int nVars)
Definition: hopTruth.c:44
static void Hop_ManTruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: hopTruth.c:32
#define assert(ex)
Definition: util_old.h:213
static void Hop_ManTruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: hopTruth.c:50
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static int Hop_ManPiNum(Hop_Man_t *p)
Definition: hop.h:145
int Hop_ManConvertAigToTruth_rec1(Hop_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition: hopTruth.c:73
int Hop_ManCountLevels ( Hop_Man_t p)

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

Synopsis [Computes the max number of levels in the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 116 of file hopDfs.c.

117 {
118  Vec_Ptr_t * vNodes;
119  Hop_Obj_t * pObj;
120  int i, LevelsMax, Level0, Level1;
121  // initialize the levels
122  Hop_ManConst1(p)->pData = NULL;
123  Hop_ManForEachPi( p, pObj, i )
124  pObj->pData = NULL;
125  // compute levels in a DFS order
126  vNodes = Hop_ManDfs( p );
127  Vec_PtrForEachEntry( Hop_Obj_t *, vNodes, pObj, i )
128  {
129  Level0 = (int)(ABC_PTRUINT_T)Hop_ObjFanin0(pObj)->pData;
130  Level1 = (int)(ABC_PTRUINT_T)Hop_ObjFanin1(pObj)->pData;
131  pObj->pData = (void *)(ABC_PTRUINT_T)(1 + Hop_ObjIsExor(pObj) + Abc_MaxInt(Level0, Level1));
132  }
133  Vec_PtrFree( vNodes );
134  // get levels of the POs
135  LevelsMax = 0;
136  Hop_ManForEachPo( p, pObj, i )
137  LevelsMax = Abc_MaxInt( LevelsMax, (int)(ABC_PTRUINT_T)Hop_ObjFanin0(pObj)->pData );
138  return LevelsMax;
139 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Definition: hop.h:132
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Ptr_t * Hop_ManDfs(Hop_Man_t *p)
Definition: hopDfs.c:68
#define Hop_ManForEachPi(p, pObj, i)
ITERATORS ///.
Definition: hop.h:259
#define Hop_ManForEachPo(p, pObj, i)
Definition: hop.h:262
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
Definition: hop.h:65
void * pData
Definition: hop.h:68
static int Hop_ObjIsExor(Hop_Obj_t *pObj)
Definition: hop.h:159
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Hop_ManCreateRefs ( Hop_Man_t p)

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

Synopsis [Creates correct reference counters at each node.]

Description []

SideEffects []

SeeAlso []

Definition at line 152 of file hopDfs.c.

153 {
154  Hop_Obj_t * pObj;
155  int i;
156  if ( p->fRefCount )
157  return;
158  p->fRefCount = 1;
159  // clear refs
161  Hop_ManForEachPi( p, pObj, i )
162  Hop_ObjClearRef( pObj );
163  Hop_ManForEachNode( p, pObj, i )
164  Hop_ObjClearRef( pObj );
165  Hop_ManForEachPo( p, pObj, i )
166  Hop_ObjClearRef( pObj );
167  // set refs
168  Hop_ManForEachNode( p, pObj, i )
169  {
170  Hop_ObjRef( Hop_ObjFanin0(pObj) );
171  Hop_ObjRef( Hop_ObjFanin1(pObj) );
172  }
173  Hop_ManForEachPo( p, pObj, i )
174  Hop_ObjRef( Hop_ObjFanin0(pObj) );
175 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Definition: hop.h:132
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Hop_ManForEachNode(p, pObj, i)
Definition: hop.h:265
#define Hop_ManForEachPi(p, pObj, i)
ITERATORS ///.
Definition: hop.h:259
#define Hop_ManForEachPo(p, pObj, i)
Definition: hop.h:262
Definition: hop.h:65
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static void Hop_ObjClearRef(Hop_Obj_t *pObj)
Definition: hop.h:179
static void Hop_ObjRef(Hop_Obj_t *pObj)
Definition: hop.h:177
Vec_Ptr_t* Hop_ManDfs ( Hop_Man_t p)

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

Synopsis [Collects internal nodes in the DFS order.]

Description []

SideEffects []

SeeAlso []

Definition at line 68 of file hopDfs.c.

69 {
70  Vec_Ptr_t * vNodes;
71  Hop_Obj_t * pObj;
72  int i;
73  vNodes = Vec_PtrAlloc( Hop_ManNodeNum(p) );
74  Hop_ManForEachNode( p, pObj, i )
75  Hop_ManDfs_rec( pObj, vNodes );
76  Hop_ManForEachNode( p, pObj, i )
77  Hop_ObjClearMarkA(pObj);
78  return vNodes;
79 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Hop_ManForEachNode(p, pObj, i)
Definition: hop.h:265
Definition: hop.h:65
ABC_NAMESPACE_IMPL_START void Hop_ManDfs_rec(Hop_Obj_t *pObj, Vec_Ptr_t *vNodes)
DECLARATIONS ///.
Definition: hopDfs.c:45
static void Hop_ObjClearMarkA(Hop_Obj_t *pObj)
Definition: hop.h:166
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static int Hop_ManNodeNum(Hop_Man_t *p)
Definition: hop.h:149
Vec_Ptr_t* Hop_ManDfsNode ( Hop_Man_t p,
Hop_Obj_t pNode 
)

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

Synopsis [Collects internal nodes in the DFS order.]

Description []

SideEffects []

SeeAlso []

Definition at line 92 of file hopDfs.c.

93 {
94  Vec_Ptr_t * vNodes;
95  Hop_Obj_t * pObj;
96  int i;
97  assert( !Hop_IsComplement(pNode) );
98  vNodes = Vec_PtrAlloc( 16 );
99  Hop_ManDfs_rec( pNode, vNodes );
100  Vec_PtrForEachEntry( Hop_Obj_t *, vNodes, pObj, i )
101  Hop_ObjClearMarkA(pObj);
102  return vNodes;
103 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Definition: hop.h:65
ABC_NAMESPACE_IMPL_START void Hop_ManDfs_rec(Hop_Obj_t *pObj, Vec_Ptr_t *vNodes)
DECLARATIONS ///.
Definition: hopDfs.c:45
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static void Hop_ObjClearMarkA(Hop_Obj_t *pObj)
Definition: hop.h:166
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
void Hop_ManDumpBlif ( Hop_Man_t p,
char *  pFileName 
)

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

Synopsis [Writes the AIG into the BLIF file.]

Description []

SideEffects []

SeeAlso []

Definition at line 509 of file hopUtil.c.

510 {
511  FILE * pFile;
512  Vec_Ptr_t * vNodes;
513  Hop_Obj_t * pObj, * pConst1 = NULL;
514  int i, nDigits, Counter = 0;
515  if ( Hop_ManPoNum(p) == 0 )
516  {
517  printf( "Hop_ManDumpBlif(): AIG manager does not have POs.\n" );
518  return;
519  }
520  // collect nodes in the DFS order
521  vNodes = Hop_ManDfs( p );
522  // assign IDs to objects
523  Hop_ManConst1(p)->pData = (void *)(ABC_PTRUINT_T)Counter++;
524  Hop_ManForEachPi( p, pObj, i )
525  pObj->pData = (void *)(ABC_PTRUINT_T)Counter++;
526  Hop_ManForEachPo( p, pObj, i )
527  pObj->pData = (void *)(ABC_PTRUINT_T)Counter++;
528  Vec_PtrForEachEntry( Hop_Obj_t *, vNodes, pObj, i )
529  pObj->pData = (void *)(ABC_PTRUINT_T)Counter++;
530  nDigits = Hop_Base10Log( Counter );
531  // write the file
532  pFile = fopen( pFileName, "w" );
533  fprintf( pFile, "# BLIF file written by procedure Hop_ManDumpBlif() in ABC\n" );
534  fprintf( pFile, "# http://www.eecs.berkeley.edu/~alanmi/abc/\n" );
535  fprintf( pFile, ".model test\n" );
536  // write PIs
537  fprintf( pFile, ".inputs" );
538  Hop_ManForEachPi( p, pObj, i )
539  fprintf( pFile, " n%0*d", nDigits, (int)(ABC_PTRUINT_T)pObj->pData );
540  fprintf( pFile, "\n" );
541  // write POs
542  fprintf( pFile, ".outputs" );
543  Hop_ManForEachPo( p, pObj, i )
544  fprintf( pFile, " n%0*d", nDigits, (int)(ABC_PTRUINT_T)pObj->pData );
545  fprintf( pFile, "\n" );
546  // write nodes
547  Vec_PtrForEachEntry( Hop_Obj_t *, vNodes, pObj, i )
548  {
549  fprintf( pFile, ".names n%0*d n%0*d n%0*d\n",
550  nDigits, (int)(ABC_PTRUINT_T)Hop_ObjFanin0(pObj)->pData,
551  nDigits, (int)(ABC_PTRUINT_T)Hop_ObjFanin1(pObj)->pData,
552  nDigits, (int)(ABC_PTRUINT_T)pObj->pData );
553  fprintf( pFile, "%d%d 1\n", !Hop_ObjFaninC0(pObj), !Hop_ObjFaninC1(pObj) );
554  }
555  // write POs
556  Hop_ManForEachPo( p, pObj, i )
557  {
558  fprintf( pFile, ".names n%0*d n%0*d\n",
559  nDigits, (int)(ABC_PTRUINT_T)Hop_ObjFanin0(pObj)->pData,
560  nDigits, (int)(ABC_PTRUINT_T)pObj->pData );
561  fprintf( pFile, "%d 1\n", !Hop_ObjFaninC0(pObj) );
562  if ( Hop_ObjIsConst1(Hop_ObjFanin0(pObj)) )
563  pConst1 = Hop_ManConst1(p);
564  }
565  if ( pConst1 )
566  fprintf( pFile, ".names n%0*d\n 1\n", nDigits, (int)(ABC_PTRUINT_T)pConst1->pData );
567  fprintf( pFile, ".end\n\n" );
568  fclose( pFile );
569  Vec_PtrFree( vNodes );
570 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Vec_Ptr_t * Hop_ManDfs(Hop_Man_t *p)
Definition: hopDfs.c:68
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Definition: hop.h:132
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Hop_ManForEachPi(p, pObj, i)
ITERATORS ///.
Definition: hop.h:259
#define Hop_ManForEachPo(p, pObj, i)
Definition: hop.h:262
static int Hop_ManPoNum(Hop_Man_t *p)
Definition: hop.h:146
static int Hop_ObjFaninC1(Hop_Obj_t *pObj)
Definition: hop.h:181
Definition: hop.h:65
static int Hop_Base10Log(unsigned n)
Definition: hop.h:124
static int Counter
void * pData
Definition: hop.h:68
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static int Hop_ObjIsConst1(Hop_Obj_t *pObj)
Definition: hop.h:155
static int Hop_ObjFaninC0(Hop_Obj_t *pObj)
Definition: hop.h:180
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Hop_Man_t* Hop_ManDup ( Hop_Man_t p)
static int Hop_ManExorNum ( Hop_Man_t p)
inlinestatic

Definition at line 148 of file hop.h.

148 { return p->nObjs[AIG_EXOR]; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:60
static Hop_Obj_t* Hop_ManFetchMemory ( Hop_Man_t p)
inlinestatic

Definition at line 230 of file hop.h.

231 {
232  Hop_Obj_t * pTemp;
233  if ( p->pListFree == NULL )
234  Hop_ManAddMemory( p );
235  pTemp = p->pListFree;
236  p->pListFree = *((Hop_Obj_t **)pTemp);
237  memset( pTemp, 0, sizeof(Hop_Obj_t) );
238  if ( p->vObjs )
239  {
240  assert( p->nCreated == Vec_PtrSize(p->vObjs) );
241  Vec_PtrPush( p->vObjs, pTemp );
242  }
243  pTemp->Id = p->nCreated++;
244  return pTemp;
245 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Id
Definition: hop.h:80
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: hop.h:65
#define assert(ex)
Definition: util_old.h:213
void Hop_ManAddMemory(Hop_Man_t *p)
MACRO DEFINITIONS ///.
Definition: hopMem.c:89
static int Hop_ManGetCost ( Hop_Man_t p)
inlinestatic

Definition at line 150 of file hop.h.

150 { return p->nObjs[AIG_AND]+3*p->nObjs[AIG_EXOR]; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:60
Definition: hop.h:59
static Hop_Obj_t* Hop_ManGhost ( Hop_Man_t p)
inlinestatic

Definition at line 133 of file hop.h.

133 { return &p->Ghost; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Hop_ManIncrementTravId ( Hop_Man_t p)

DECLARATIONS ///.

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

FileName [hopUtil.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [And-Inverter Graph package.]

Synopsis [Various procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - May 11, 2006.]

Revision [

Id:
hopUtil.c,v 1.00 2006/05/11 00:00:00 alanmi Exp

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file hopUtil.c.

46 {
47  if ( p->nTravIds >= (1<<30)-1 )
49  p->nTravIds++;
50 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Hop_ManCleanData(Hop_Man_t *p)
Definition: hopUtil.c:63
static int Hop_ManNodeNum ( Hop_Man_t p)
inlinestatic

Definition at line 149 of file hop.h.

149 { return p->nObjs[AIG_AND]+p->nObjs[AIG_EXOR];}
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:60
Definition: hop.h:59
static Hop_Obj_t* Hop_ManObj ( Hop_Man_t p,
int  i 
)
inlinestatic

Definition at line 136 of file hop.h.

136 { return p->vObjs ? (Hop_Obj_t *)Vec_PtrEntry(p->vObjs, i) : NULL; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:65
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Hop_ManObjNum ( Hop_Man_t p)
inlinestatic

Definition at line 151 of file hop.h.

151 { return p->nCreated - p->nDeleted; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Hop_Obj_t* Hop_ManPi ( Hop_Man_t p,
int  i 
)
inlinestatic

Definition at line 134 of file hop.h.

134 { return (Hop_Obj_t *)Vec_PtrEntry(p->vPis, i); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:65
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Hop_ManPiNum ( Hop_Man_t p)
inlinestatic

Definition at line 145 of file hop.h.

145 { return p->nObjs[AIG_PI]; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:57
static Hop_Obj_t* Hop_ManPo ( Hop_Man_t p,
int  i 
)
inlinestatic

Definition at line 135 of file hop.h.

135 { return (Hop_Obj_t *)Vec_PtrEntry(p->vPos, i); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:65
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Hop_ManPoNum ( Hop_Man_t p)
inlinestatic

Definition at line 146 of file hop.h.

146 { return p->nObjs[AIG_PO]; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:58
void Hop_ManPrintStats ( Hop_Man_t p)

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

Synopsis [Stops the AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 150 of file hopMan.c.

151 {
152  printf( "PI/PO = %d/%d. ", Hop_ManPiNum(p), Hop_ManPoNum(p) );
153  printf( "A = %7d. ", Hop_ManAndNum(p) );
154  printf( "X = %5d. ", Hop_ManExorNum(p) );
155  printf( "Cre = %7d. ", p->nCreated );
156  printf( "Del = %7d. ", p->nDeleted );
157  printf( "Lev = %3d. ", Hop_ManCountLevels(p) );
158  printf( "\n" );
159 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Hop_ManCountLevels(Hop_Man_t *p)
Definition: hopDfs.c:116
static int Hop_ManPoNum(Hop_Man_t *p)
Definition: hop.h:146
static int Hop_ManAndNum(Hop_Man_t *p)
Definition: hop.h:147
static int Hop_ManExorNum(Hop_Man_t *p)
Definition: hop.h:148
static int Hop_ManPiNum(Hop_Man_t *p)
Definition: hop.h:145
void Hop_ManPrintVerbose ( Hop_Man_t p,
int  fHaig 
)

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

Synopsis [Prints node in HAIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 482 of file hopUtil.c.

483 {
484  Vec_Ptr_t * vNodes;
485  Hop_Obj_t * pObj;
486  int i;
487  printf( "PIs: " );
488  Hop_ManForEachPi( p, pObj, i )
489  printf( " %p", pObj );
490  printf( "\n" );
491  vNodes = Hop_ManDfs( p );
492  Vec_PtrForEachEntry( Hop_Obj_t *, vNodes, pObj, i )
493  Hop_ObjPrintVerbose( pObj, fHaig ), printf( "\n" );
494  printf( "\n" );
495  Vec_PtrFree( vNodes );
496 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Vec_Ptr_t * Hop_ManDfs(Hop_Man_t *p)
Definition: hopDfs.c:68
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Hop_ManForEachPi(p, pObj, i)
ITERATORS ///.
Definition: hop.h:259
void Hop_ObjPrintVerbose(Hop_Obj_t *pObj, int fHaig)
Definition: hopUtil.c:456
Definition: hop.h:65
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static void Hop_ManRecycleMemory ( Hop_Man_t p,
Hop_Obj_t pEntry 
)
inlinestatic

Definition at line 246 of file hop.h.

247 {
248  pEntry->Type = AIG_NONE; // distinquishes dead node from live node
249  *((Hop_Obj_t **)pEntry) = p->pListFree;
250  p->pListFree = pEntry;
251 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned int Type
Definition: hop.h:75
Definition: hop.h:65
Definition: hop.h:55
Hop_Man_t* Hop_ManStart ( )

DECLARATIONS ///.

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

FileName [hopMan.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Minimalistic And-Inverter Graph package.]

Synopsis [AIG manager.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - May 11, 2006.]

Revision [

Id:
hopMan.c,v 1.00 2006/05/11 00:00:00 alanmi Exp

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

Synopsis [Starts the AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file hopMan.c.

46 {
47  Hop_Man_t * p;
48  // start the manager
49  p = ABC_ALLOC( Hop_Man_t, 1 );
50  memset( p, 0, sizeof(Hop_Man_t) );
51  // perform initializations
52  p->nTravIds = 1;
53  p->fRefCount = 1;
54  p->fCatchExor = 0;
55  // allocate arrays for nodes
56  p->vPis = Vec_PtrAlloc( 100 );
57  p->vPos = Vec_PtrAlloc( 100 );
58  // prepare the internal memory manager
59  Hop_ManStartMemory( p );
60  // create the constant node
61  p->pConst1 = Hop_ManFetchMemory( p );
62  p->pConst1->Type = AIG_CONST1;
63  p->pConst1->fPhase = 1;
64  p->nCreated = 1;
65  // start the table
66 // p->nTableSize = 107;
67  p->nTableSize = 10007;
68  p->pTable = ABC_ALLOC( Hop_Obj_t *, p->nTableSize );
69  memset( p->pTable, 0, sizeof(Hop_Obj_t *) * p->nTableSize );
70  return p;
71 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Hop_ManStartMemory(Hop_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: hopMem.c:49
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Definition: hop.h:65
static Hop_Obj_t * Hop_ManFetchMemory(Hop_Man_t *p)
Definition: hop.h:230
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Definition: hop.h:56
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition: hop.h:49
void Hop_ManStartMemory ( Hop_Man_t p)

FUNCTION DEFINITIONS ///.

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

Synopsis [Starts the internal memory manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 49 of file hopMem.c.

50 {
51  p->vChunks = Vec_PtrAlloc( 128 );
52  p->vPages = Vec_PtrAlloc( 128 );
53 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
void Hop_ManStop ( Hop_Man_t p)

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

Synopsis [Stops the AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 84 of file hopMan.c.

85 {
86  Hop_Obj_t * pObj;
87  int i;
88  // make sure the nodes have clean marks
89  pObj = Hop_ManConst1(p);
90  assert( !pObj->fMarkA && !pObj->fMarkB );
91  Hop_ManForEachPi( p, pObj, i )
92  assert( !pObj->fMarkA && !pObj->fMarkB );
93  Hop_ManForEachPo( p, pObj, i )
94  assert( !pObj->fMarkA && !pObj->fMarkB );
95  Hop_ManForEachNode( p, pObj, i )
96  assert( !pObj->fMarkA && !pObj->fMarkB );
97  // print time
98  if ( p->time1 ) { ABC_PRT( "time1", p->time1 ); }
99  if ( p->time2 ) { ABC_PRT( "time2", p->time2 ); }
100 // Hop_TableProfile( p );
101  if ( p->vChunks ) Hop_ManStopMemory( p );
102  if ( p->vPis ) Vec_PtrFree( p->vPis );
103  if ( p->vPos ) Vec_PtrFree( p->vPos );
104  if ( p->vObjs ) Vec_PtrFree( p->vObjs );
105  ABC_FREE( p->pTable );
106  ABC_FREE( p );
107 }
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Definition: hop.h:132
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Hop_ManForEachNode(p, pObj, i)
Definition: hop.h:265
#define Hop_ManForEachPi(p, pObj, i)
ITERATORS ///.
Definition: hop.h:259
#define Hop_ManForEachPo(p, pObj, i)
Definition: hop.h:262
Definition: hop.h:65
unsigned int fMarkA
Definition: hop.h:77
if(last==0)
Definition: sparse_int.h:34
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_PRT(a, t)
Definition: abc_global.h:220
#define assert(ex)
Definition: util_old.h:213
unsigned int fMarkB
Definition: hop.h:78
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Hop_ManStopMemory(Hop_Man_t *p)
Definition: hopMem.c:66
void Hop_ManStopMemory ( Hop_Man_t p)

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

Synopsis [Stops the internal memory manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 66 of file hopMem.c.

67 {
68  void * pMemory;
69  int i;
70  Vec_PtrForEachEntry( void *, p->vChunks, pMemory, i )
71  ABC_FREE( pMemory );
72  Vec_PtrFree( p->vChunks );
73  Vec_PtrFree( p->vPages );
74  p->pListFree = NULL;
75 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Hop_Obj_t* Hop_Miter ( Hop_Man_t p,
Vec_Ptr_t vPairs 
)

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

Synopsis [Implements the miter.]

Description []

SideEffects []

SeeAlso []

Definition at line 297 of file hopOper.c.

298 {
299  int i;
300  assert( vPairs->nSize > 0 );
301  assert( vPairs->nSize % 2 == 0 );
302  // go through the cubes of the node's SOP
303  for ( i = 0; i < vPairs->nSize; i += 2 )
304  vPairs->pArray[i/2] = Hop_Not( Hop_Exor( p, (Hop_Obj_t *)vPairs->pArray[i], (Hop_Obj_t *)vPairs->pArray[i+1] ) );
305  vPairs->nSize = vPairs->nSize/2;
306  return Hop_Not( Hop_Multi_rec( p, (Hop_Obj_t **)vPairs->pArray, vPairs->nSize, AIG_AND ) );
307 }
Hop_Obj_t * Hop_Exor(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:138
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Hop_Obj_t * Hop_Multi_rec(Hop_Man_t *p, Hop_Obj_t **ppObjs, int nObjs, Hop_Type_t Type)
Definition: hopOper.c:258
static Hop_Obj_t * Hop_Not(Hop_Obj_t *p)
Definition: hop.h:127
Definition: hop.h:65
Definition: hop.h:59
#define assert(ex)
Definition: util_old.h:213
Hop_Obj_t* Hop_Mux ( Hop_Man_t p,
Hop_Obj_t pC,
Hop_Obj_t p1,
Hop_Obj_t p0 
)

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

Synopsis [Implements ITE operation.]

Description []

SideEffects []

SeeAlso []

Definition at line 187 of file hopOper.c.

188 {
189 /*
190  Hop_Obj_t * pTempA1, * pTempA2, * pTempB1, * pTempB2, * pTemp;
191  int Count0, Count1;
192  // consider trivial cases
193  if ( p0 == Hop_Not(p1) )
194  return Hop_Exor( p, pC, p0 );
195  // other cases can be added
196  // implement the first MUX (F = C * x1 + C' * x0)
197 
198  // check for constants here!!!
199 
200  pTempA1 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, pC, p1, AIG_AND) );
201  pTempA2 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pC), p0, AIG_AND) );
202  if ( pTempA1 && pTempA2 )
203  {
204  pTemp = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pTempA1), Hop_Not(pTempA2), AIG_AND) );
205  if ( pTemp ) return Hop_Not(pTemp);
206  }
207  Count0 = (pTempA1 != NULL) + (pTempA2 != NULL);
208  // implement the second MUX (F' = C * x1' + C' * x0')
209  pTempB1 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, pC, Hop_Not(p1), AIG_AND) );
210  pTempB2 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pC), Hop_Not(p0), AIG_AND) );
211  if ( pTempB1 && pTempB2 )
212  {
213  pTemp = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pTempB1), Hop_Not(pTempB2), AIG_AND) );
214  if ( pTemp ) return pTemp;
215  }
216  Count1 = (pTempB1 != NULL) + (pTempB2 != NULL);
217  // compare and decide which one to implement
218  if ( Count0 >= Count1 )
219  {
220  pTempA1 = pTempA1? pTempA1 : Hop_And(p, pC, p1);
221  pTempA2 = pTempA2? pTempA2 : Hop_And(p, Hop_Not(pC), p0);
222  return Hop_Or( p, pTempA1, pTempA2 );
223  }
224  pTempB1 = pTempB1? pTempB1 : Hop_And(p, pC, Hop_Not(p1));
225  pTempB2 = pTempB2? pTempB2 : Hop_And(p, Hop_Not(pC), Hop_Not(p0));
226  return Hop_Not( Hop_Or( p, pTempB1, pTempB2 ) );
227 */
228  return Hop_Or( p, Hop_And(p, pC, p1), Hop_And(p, Hop_Not(pC), p0) );
229 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Hop_Obj_t * Hop_Or(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:171
static Hop_Obj_t * Hop_Not(Hop_Obj_t *p)
Definition: hop.h:127
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:104
Hop_Obj_t* Hop_NodeBalanceBuildSuper ( Hop_Man_t p,
Vec_Ptr_t vSuper,
Hop_Type_t  Type,
int  fUpdateLevel 
)

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

Synopsis [Builds implication supergate.]

Description []

SideEffects []

SeeAlso []

Definition at line 243 of file hopBalance.c.

244 {
245  Hop_Obj_t * pObj1, * pObj2;
246  int LeftBound;
247  assert( vSuper->nSize > 1 );
248  // sort the new nodes by level in the decreasing order
249  Vec_PtrSort( vSuper, (int (*)(void))Hop_NodeCompareLevelsDecrease );
250  // balance the nodes
251  while ( vSuper->nSize > 1 )
252  {
253  // find the left bound on the node to be paired
254  LeftBound = (!fUpdateLevel)? 0 : Hop_NodeBalanceFindLeft( vSuper );
255  // find the node that can be shared (if no such node, randomize choice)
256  Hop_NodeBalancePermute( p, vSuper, LeftBound, Type == AIG_EXOR );
257  // pull out the last two nodes
258  pObj1 = (Hop_Obj_t *)Vec_PtrPop(vSuper);
259  pObj2 = (Hop_Obj_t *)Vec_PtrPop(vSuper);
260  Hop_NodeBalancePushUniqueOrderByLevel( vSuper, Hop_Oper(p, pObj1, pObj2, Type) );
261  }
262  return (Hop_Obj_t *)Vec_PtrEntry(vSuper, 0);
263 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Hop_NodeBalancePermute(Hop_Man_t *p, Vec_Ptr_t *vSuper, int LeftBound, int fExor)
Definition: hopBalance.c:318
static int Hop_NodeBalanceFindLeft(Vec_Ptr_t *vSuper)
Definition: hopBalance.c:280
Definition: hop.h:60
static void Vec_PtrSort(Vec_Ptr_t *p, int(*Vec_PtrSortCompare)()) ___unused
Definition: vecPtr.h:851
static void * Vec_PtrPop(Vec_Ptr_t *p)
Definition: vecPtr.h:677
Definition: hop.h:65
Hop_Obj_t * Hop_Oper(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1, Hop_Type_t Type)
Definition: hopOper.c:83
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define assert(ex)
Definition: util_old.h:213
int Hop_NodeCompareLevelsDecrease(Hop_Obj_t **pp1, Hop_Obj_t **pp2)
Definition: hopBalance.c:217
static void Hop_NodeBalancePushUniqueOrderByLevel(Vec_Ptr_t *vStore, Hop_Obj_t *pObj)
Definition: hopBalance.c:376
static Hop_Obj_t* Hop_Not ( Hop_Obj_t p)
inlinestatic

Definition at line 127 of file hop.h.

127 { return (Hop_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); }
Definition: hop.h:65
static Hop_Obj_t* Hop_NotCond ( Hop_Obj_t p,
int  c 
)
inlinestatic

Definition at line 128 of file hop.h.

128 { return (Hop_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); }
Definition: hop.h:65
static Hop_Obj_t* Hop_ObjChild0 ( Hop_Obj_t pObj)
inlinestatic

Definition at line 184 of file hop.h.

184 { return pObj->pFanin0; }
Hop_Obj_t * pFanin0
Definition: hop.h:73
static Hop_Obj_t* Hop_ObjChild0Copy ( Hop_Obj_t pObj)
inlinestatic

Definition at line 186 of file hop.h.

186 { assert( !Hop_IsComplement(pObj) ); return Hop_ObjFanin0(pObj)? Hop_NotCond((Hop_Obj_t *)Hop_ObjFanin0(pObj)->pData, Hop_ObjFaninC0(pObj)) : NULL; }
Definition: hop.h:65
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static int Hop_ObjFaninC0(Hop_Obj_t *pObj)
Definition: hop.h:180
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Definition: hop.h:128
#define assert(ex)
Definition: util_old.h:213
static int Hop_ObjChild0CopyI ( Hop_Obj_t pObj)
inlinestatic

Definition at line 188 of file hop.h.

188 { assert( !Hop_IsComplement(pObj) ); return Hop_ObjFanin0(pObj)? Abc_LitNotCond(Hop_ObjFanin0(pObj)->iData, Hop_ObjFaninC0(pObj)) : -1; }
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static int Hop_ObjFaninC0(Hop_Obj_t *pObj)
Definition: hop.h:180
#define assert(ex)
Definition: util_old.h:213
static Hop_Obj_t* Hop_ObjChild1 ( Hop_Obj_t pObj)
inlinestatic

Definition at line 185 of file hop.h.

185 { return pObj->pFanin1; }
Hop_Obj_t * pFanin1
Definition: hop.h:74
static Hop_Obj_t* Hop_ObjChild1Copy ( Hop_Obj_t pObj)
inlinestatic

Definition at line 187 of file hop.h.

187 { assert( !Hop_IsComplement(pObj) ); return Hop_ObjFanin1(pObj)? Hop_NotCond((Hop_Obj_t *)Hop_ObjFanin1(pObj)->pData, Hop_ObjFaninC1(pObj)) : NULL; }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static int Hop_ObjFaninC1(Hop_Obj_t *pObj)
Definition: hop.h:181
Definition: hop.h:65
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Definition: hop.h:128
#define assert(ex)
Definition: util_old.h:213
static int Hop_ObjChild1CopyI ( Hop_Obj_t pObj)
inlinestatic

Definition at line 189 of file hop.h.

189 { assert( !Hop_IsComplement(pObj) ); return Hop_ObjFanin1(pObj)? Abc_LitNotCond(Hop_ObjFanin1(pObj)->iData, Hop_ObjFaninC1(pObj)) : -1; }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static int Hop_ObjFaninC1(Hop_Obj_t *pObj)
Definition: hop.h:181
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
#define assert(ex)
Definition: util_old.h:213
static void Hop_ObjClean ( Hop_Obj_t pObj)
inlinestatic

Definition at line 193 of file hop.h.

193 { memset( pObj, 0, sizeof(Hop_Obj_t) ); }
char * memset()
Definition: hop.h:65
void Hop_ObjCleanData_rec ( Hop_Obj_t pObj)

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

Synopsis [Recursively cleans the data pointers in the cone of the node.]

Description [Applicable to small AIGs only because no caching is performed.]

SideEffects []

SeeAlso []

Definition at line 88 of file hopUtil.c.

89 {
90  assert( !Hop_IsComplement(pObj) );
91  assert( !Hop_ObjIsPo(pObj) );
92  if ( Hop_ObjIsAnd(pObj) )
93  {
96  }
97  pObj->pData = NULL;
98 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static int Hop_ObjIsAnd(Hop_Obj_t *pObj)
Definition: hop.h:158
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static int Hop_ObjIsPo(Hop_Obj_t *pObj)
Definition: hop.h:157
void * pData
Definition: hop.h:68
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
#define assert(ex)
Definition: util_old.h:213
void Hop_ObjCleanData_rec(Hop_Obj_t *pObj)
Definition: hopUtil.c:88
static void Hop_ObjClearMarkA ( Hop_Obj_t pObj)
inlinestatic

Definition at line 166 of file hop.h.

166 { pObj->fMarkA = 0; }
unsigned int fMarkA
Definition: hop.h:77
static void Hop_ObjClearRef ( Hop_Obj_t pObj)
inlinestatic

Definition at line 179 of file hop.h.

179 { pObj->nRefs = 0; }
unsigned int nRefs
Definition: hop.h:79
void Hop_ObjCollectMulti ( Hop_Obj_t pRoot,
Vec_Ptr_t vSuper 
)

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

Synopsis [Detects multi-input gate rooted at this node.]

Description []

SideEffects []

SeeAlso []

Definition at line 133 of file hopUtil.c.

134 {
135  assert( !Hop_IsComplement(pRoot) );
136  Vec_PtrClear( vSuper );
137  Hop_ObjCollectMulti_rec( pRoot, pRoot, vSuper );
138 }
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
void Hop_ObjCollectMulti_rec(Hop_Obj_t *pRoot, Hop_Obj_t *pObj, Vec_Ptr_t *vSuper)
Definition: hopUtil.c:111
void Hop_ObjConnect ( Hop_Man_t p,
Hop_Obj_t pObj,
Hop_Obj_t pFan0,
Hop_Obj_t pFan1 
)

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

Synopsis [Connect the object to the fanin.]

Description []

SideEffects []

SeeAlso []

Definition at line 125 of file hopObj.c.

126 {
127  assert( !Hop_IsComplement(pObj) );
128  assert( Hop_ObjIsNode(pObj) );
129  // add the first fanin
130  pObj->pFanin0 = pFan0;
131  pObj->pFanin1 = pFan1;
132  // increment references of the fanins and add their fanouts
133  if ( p->fRefCount )
134  {
135  if ( pFan0 != NULL )
136  Hop_ObjRef( Hop_ObjFanin0(pObj) );
137  if ( pFan1 != NULL )
138  Hop_ObjRef( Hop_ObjFanin1(pObj) );
139  }
140  else
141  pObj->nRefs = Hop_ObjLevelNew( pObj );
142  // set the phase
143  pObj->fPhase = Hop_ObjPhaseCompl(pFan0) & Hop_ObjPhaseCompl(pFan1);
144  // add the node to the structural hash table
145  Hop_TableInsert( p, pObj );
146 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Hop_TableInsert(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopTable.c:100
static int Hop_ObjIsNode(Hop_Obj_t *pObj)
Definition: hop.h:160
Hop_Obj_t * pFanin1
Definition: hop.h:74
unsigned int nRefs
Definition: hop.h:79
unsigned int fPhase
Definition: hop.h:76
static int Hop_ObjPhaseCompl(Hop_Obj_t *pObj)
Definition: hop.h:192
Hop_Obj_t * pFanin0
Definition: hop.h:73
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static void Hop_ObjRef(Hop_Obj_t *pObj)
Definition: hop.h:177
#define assert(ex)
Definition: util_old.h:213
static int Hop_ObjLevelNew(Hop_Obj_t *pObj)
Definition: hop.h:191
Hop_Obj_t* Hop_ObjCreate ( Hop_Man_t p,
Hop_Obj_t pGhost 
)

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

Synopsis [Create the new node assuming it does not exist.]

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file hopObj.c.

98 {
99  Hop_Obj_t * pObj;
100  assert( !Hop_IsComplement(pGhost) );
101  assert( Hop_ObjIsNode(pGhost) );
102  assert( pGhost == &p->Ghost );
103  // get memory for the new object
104  pObj = Hop_ManFetchMemory( p );
105  pObj->Type = pGhost->Type;
106  // add connections
107  Hop_ObjConnect( p, pObj, pGhost->pFanin0, pGhost->pFanin1 );
108  // update node counters of the manager
109  p->nObjs[Hop_ObjType(pObj)]++;
110  assert( pObj->pData == NULL );
111  return pObj;
112 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Hop_ObjIsNode(Hop_Obj_t *pObj)
Definition: hop.h:160
static Hop_Type_t Hop_ObjType(Hop_Obj_t *pObj)
Definition: hop.h:153
Hop_Obj_t * pFanin1
Definition: hop.h:74
unsigned int Type
Definition: hop.h:75
Definition: hop.h:65
void Hop_ObjConnect(Hop_Man_t *p, Hop_Obj_t *pObj, Hop_Obj_t *pFan0, Hop_Obj_t *pFan1)
Definition: hopObj.c:125
Hop_Obj_t * pFanin0
Definition: hop.h:73
static Hop_Obj_t * Hop_ManFetchMemory(Hop_Man_t *p)
Definition: hop.h:230
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
void * pData
Definition: hop.h:68
#define assert(ex)
Definition: util_old.h:213
void Hop_ObjCreateChoice ( Hop_Obj_t pOld,
Hop_Obj_t pNew 
)

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

Synopsis [Sets an equivalence relation between the nodes.]

Description [Makes the representative of pNew point to the representaive of pOld.]

SideEffects []

SeeAlso []

Definition at line 260 of file hopObj.c.

261 {
262  Hop_Obj_t * pOldRepr;
263  Hop_Obj_t * pNewRepr;
264  assert( pOld != NULL && pNew != NULL );
265  pOldRepr = Hop_ObjRepr(pOld);
266  pNewRepr = Hop_ObjRepr(pNew);
267  if ( pNewRepr != pOldRepr )
268  pNewRepr->pData = pOldRepr;
269 }
Definition: hop.h:65
Hop_Obj_t * Hop_ObjRepr(Hop_Obj_t *pObj)
Definition: hopObj.c:241
void * pData
Definition: hop.h:68
#define assert(ex)
Definition: util_old.h:213
static Hop_Obj_t* Hop_ObjCreateGhost ( Hop_Man_t p,
Hop_Obj_t p0,
Hop_Obj_t p1,
Hop_Type_t  Type 
)
inlinestatic

Definition at line 208 of file hop.h.

209 {
210  Hop_Obj_t * pGhost;
211  assert( Type != AIG_AND || !Hop_ObjIsConst1(Hop_Regular(p0)) );
212  assert( p1 == NULL || !Hop_ObjIsConst1(Hop_Regular(p1)) );
213  assert( Type == AIG_PI || Hop_Regular(p0) != Hop_Regular(p1) );
214  pGhost = Hop_ManGhost(p);
215  pGhost->Type = Type;
216  if ( Hop_Regular(p0)->Id < Hop_Regular(p1)->Id )
217  {
218  pGhost->pFanin0 = p0;
219  pGhost->pFanin1 = p1;
220  }
221  else
222  {
223  pGhost->pFanin0 = p1;
224  pGhost->pFanin1 = p0;
225  }
226  return pGhost;
227 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Hop_Obj_t * Hop_ManGhost(Hop_Man_t *p)
Definition: hop.h:133
Hop_Obj_t * pFanin1
Definition: hop.h:74
unsigned int Type
Definition: hop.h:75
Definition: hop.h:65
Definition: hop.h:57
Hop_Obj_t * pFanin0
Definition: hop.h:73
static int Hop_ObjIsConst1(Hop_Obj_t *pObj)
Definition: hop.h:155
Definition: hop.h:59
#define assert(ex)
Definition: util_old.h:213
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
Hop_Obj_t* Hop_ObjCreatePi ( Hop_Man_t p)

DECLARATIONS ///.

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

FileName [hopObj.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Minimalistic And-Inverter Graph package.]

Synopsis [Adding/removing objects.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - May 11, 2006.]

Revision [

Id:
hopObj.c,v 1.00 2006/05/11 00:00:00 alanmi Exp

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

Synopsis [Creates primary input.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file hopObj.c.

46 {
47  Hop_Obj_t * pObj;
48  pObj = Hop_ManFetchMemory( p );
49  pObj->Type = AIG_PI;
50  pObj->PioNum = Vec_PtrSize( p->vPis );
51  Vec_PtrPush( p->vPis, pObj );
52  p->nObjs[AIG_PI]++;
53  return pObj;
54 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
unsigned int Type
Definition: hop.h:75
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: hop.h:65
Definition: hop.h:57
int PioNum
Definition: hop.h:72
static Hop_Obj_t * Hop_ManFetchMemory(Hop_Man_t *p)
Definition: hop.h:230
Hop_Obj_t* Hop_ObjCreatePo ( Hop_Man_t p,
Hop_Obj_t pDriver 
)

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

Synopsis [Creates primary output with the given driver.]

Description []

SideEffects []

SeeAlso []

Definition at line 67 of file hopObj.c.

68 {
69  Hop_Obj_t * pObj;
70  pObj = Hop_ManFetchMemory( p );
71  pObj->Type = AIG_PO;
72  Vec_PtrPush( p->vPos, pObj );
73  // add connections
74  pObj->pFanin0 = pDriver;
75  if ( p->fRefCount )
76  Hop_ObjRef( Hop_Regular(pDriver) );
77  else
78  pObj->nRefs = Hop_ObjLevel( Hop_Regular(pDriver) );
79  // set the phase
80  pObj->fPhase = Hop_ObjPhaseCompl(pDriver);
81  // update node counters of the manager
82  p->nObjs[AIG_PO]++;
83  return pObj;
84 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
unsigned int Type
Definition: hop.h:75
unsigned int nRefs
Definition: hop.h:79
Definition: hop.h:65
unsigned int fPhase
Definition: hop.h:76
static int Hop_ObjPhaseCompl(Hop_Obj_t *pObj)
Definition: hop.h:192
Hop_Obj_t * pFanin0
Definition: hop.h:73
static Hop_Obj_t * Hop_ManFetchMemory(Hop_Man_t *p)
Definition: hop.h:230
Definition: hop.h:58
static int Hop_ObjLevel(Hop_Obj_t *pObj)
Definition: hop.h:190
static void Hop_ObjRef(Hop_Obj_t *pObj)
Definition: hop.h:177
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
void Hop_ObjDelete ( Hop_Man_t p,
Hop_Obj_t pObj 
)

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

Synopsis [Deletes the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 186 of file hopObj.c.

187 {
188  assert( !Hop_IsComplement(pObj) );
189  assert( !Hop_ObjIsTerm(pObj) );
190  assert( Hop_ObjRefs(pObj) == 0 );
191  // update node counters of the manager
192  p->nObjs[pObj->Type]--;
193  p->nDeleted++;
194  // remove connections
195  Hop_ObjDisconnect( p, pObj );
196  // remove PIs/POs from the arrays
197  if ( Hop_ObjIsPi(pObj) )
198  Vec_PtrRemove( p->vPis, pObj );
199  // free the node
200  Hop_ManRecycleMemory( p, pObj );
201 }
static int Hop_ObjRefs(Hop_Obj_t *pObj)
Definition: hop.h:176
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Hop_ObjIsPi(Hop_Obj_t *pObj)
Definition: hop.h:156
unsigned int Type
Definition: hop.h:75
static void Vec_PtrRemove(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:714
static void Hop_ManRecycleMemory(Hop_Man_t *p, Hop_Obj_t *pEntry)
Definition: hop.h:246
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static int Hop_ObjIsTerm(Hop_Obj_t *pObj)
Definition: hop.h:161
void Hop_ObjDisconnect(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopObj.c:159
#define assert(ex)
Definition: util_old.h:213
void Hop_ObjDelete_rec ( Hop_Man_t p,
Hop_Obj_t pObj 
)

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

Synopsis [Deletes the MFFC of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 214 of file hopObj.c.

215 {
216  Hop_Obj_t * pFanin0, * pFanin1;
217  assert( !Hop_IsComplement(pObj) );
218  if ( Hop_ObjIsConst1(pObj) || Hop_ObjIsPi(pObj) )
219  return;
220  assert( Hop_ObjIsNode(pObj) );
221  pFanin0 = Hop_ObjFanin0(pObj);
222  pFanin1 = Hop_ObjFanin1(pObj);
223  Hop_ObjDelete( p, pObj );
224  if ( pFanin0 && !Hop_ObjIsNone(pFanin0) && Hop_ObjRefs(pFanin0) == 0 )
225  Hop_ObjDelete_rec( p, pFanin0 );
226  if ( pFanin1 && !Hop_ObjIsNone(pFanin1) && Hop_ObjRefs(pFanin1) == 0 )
227  Hop_ObjDelete_rec( p, pFanin1 );
228 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static int Hop_ObjRefs(Hop_Obj_t *pObj)
Definition: hop.h:176
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Hop_ObjIsPi(Hop_Obj_t *pObj)
Definition: hop.h:156
static int Hop_ObjIsNode(Hop_Obj_t *pObj)
Definition: hop.h:160
Definition: hop.h:65
static int Hop_ObjIsNone(Hop_Obj_t *pObj)
Definition: hop.h:154
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
void Hop_ObjDelete(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopObj.c:186
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static int Hop_ObjIsConst1(Hop_Obj_t *pObj)
Definition: hop.h:155
#define assert(ex)
Definition: util_old.h:213
void Hop_ObjDelete_rec(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopObj.c:214
static void Hop_ObjDeref ( Hop_Obj_t pObj)
inlinestatic

Definition at line 178 of file hop.h.

178 { assert( pObj->nRefs > 0 ); pObj->nRefs--; }
unsigned int nRefs
Definition: hop.h:79
#define assert(ex)
Definition: util_old.h:213
void Hop_ObjDisconnect ( Hop_Man_t p,
Hop_Obj_t pObj 
)

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

Synopsis [Connect the object to the fanin.]

Description []

SideEffects []

SeeAlso []

Definition at line 159 of file hopObj.c.

160 {
161  assert( !Hop_IsComplement(pObj) );
162  assert( Hop_ObjIsNode(pObj) );
163  // remove connections
164  if ( pObj->pFanin0 != NULL )
166  if ( pObj->pFanin1 != NULL )
168  // remove the node from the structural hash table
169  Hop_TableDelete( p, pObj );
170  // add the first fanin
171  pObj->pFanin0 = NULL;
172  pObj->pFanin1 = NULL;
173 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Hop_ObjIsNode(Hop_Obj_t *pObj)
Definition: hop.h:160
Hop_Obj_t * pFanin1
Definition: hop.h:74
Hop_Obj_t * pFanin0
Definition: hop.h:73
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static void Hop_ObjDeref(Hop_Obj_t *pObj)
Definition: hop.h:178
void Hop_TableDelete(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopTable.c:123
#define assert(ex)
Definition: util_old.h:213
static Hop_Obj_t* Hop_ObjFanin0 ( Hop_Obj_t pObj)
inlinestatic

Definition at line 182 of file hop.h.

182 { return Hop_Regular(pObj->pFanin0); }
Hop_Obj_t * pFanin0
Definition: hop.h:73
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
static Hop_Obj_t* Hop_ObjFanin1 ( Hop_Obj_t pObj)
inlinestatic

Definition at line 183 of file hop.h.

183 { return Hop_Regular(pObj->pFanin1); }
Hop_Obj_t * pFanin1
Definition: hop.h:74
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
static int Hop_ObjFaninC0 ( Hop_Obj_t pObj)
inlinestatic

Definition at line 180 of file hop.h.

180 { return Hop_IsComplement(pObj->pFanin0); }
Hop_Obj_t * pFanin0
Definition: hop.h:73
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static int Hop_ObjFaninC1 ( Hop_Obj_t pObj)
inlinestatic

Definition at line 181 of file hop.h.

181 { return Hop_IsComplement(pObj->pFanin1); }
Hop_Obj_t * pFanin1
Definition: hop.h:74
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static int Hop_ObjFanoutC ( Hop_Obj_t pObj,
Hop_Obj_t pFanout 
)
inlinestatic

Definition at line 200 of file hop.h.

201 {
202  if ( Hop_ObjFanin0(pFanout) == pObj ) return Hop_ObjFaninC0(pObj);
203  if ( Hop_ObjFanin1(pFanout) == pObj ) return Hop_ObjFaninC1(pObj);
204  assert(0); return -1;
205 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static int Hop_ObjFaninC1(Hop_Obj_t *pObj)
Definition: hop.h:181
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static int Hop_ObjFaninC0(Hop_Obj_t *pObj)
Definition: hop.h:180
#define assert(ex)
Definition: util_old.h:213
int Hop_ObjFanoutCount ( Hop_Obj_t pObj,
Hop_Obj_t pPivot 
)

Definition at line 310 of file hopDfs.c.

311 {
312  int Counter;
313  assert( !Hop_IsComplement(pPivot) );
314  Counter = Hop_ObjFanoutCount_rec( Hop_Regular(pObj), pPivot );
316  return Counter;
317 }
int Hop_ObjFanoutCount_rec(Hop_Obj_t *pObj, Hop_Obj_t *pPivot)
Definition: hopDfs.c:298
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static int Counter
void Hop_ConeUnmark_rec(Hop_Obj_t *pObj)
Definition: hopDfs.c:257
#define assert(ex)
Definition: util_old.h:213
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
static int Hop_ObjIsAnd ( Hop_Obj_t pObj)
inlinestatic

Definition at line 158 of file hop.h.

158 { return pObj->Type == AIG_AND; }
unsigned int Type
Definition: hop.h:75
Definition: hop.h:59
static int Hop_ObjIsConst1 ( Hop_Obj_t pObj)
inlinestatic

Definition at line 155 of file hop.h.

155 { assert(!Hop_IsComplement(pObj)); return pObj->Type == AIG_CONST1; }
unsigned int Type
Definition: hop.h:75
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
Definition: hop.h:56
#define assert(ex)
Definition: util_old.h:213
static int Hop_ObjIsExor ( Hop_Obj_t pObj)
inlinestatic

Definition at line 159 of file hop.h.

159 { return pObj->Type == AIG_EXOR; }
Definition: hop.h:60
unsigned int Type
Definition: hop.h:75
static int Hop_ObjIsHash ( Hop_Obj_t pObj)
inlinestatic

Definition at line 162 of file hop.h.

162 { return pObj->Type == AIG_AND || pObj->Type == AIG_EXOR; }
Definition: hop.h:60
unsigned int Type
Definition: hop.h:75
Definition: hop.h:59
static int Hop_ObjIsMarkA ( Hop_Obj_t pObj)
inlinestatic

Definition at line 164 of file hop.h.

164 { return pObj->fMarkA; }
unsigned int fMarkA
Definition: hop.h:77
int Hop_ObjIsMuxType ( Hop_Obj_t pNode)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 151 of file hopUtil.c.

152 {
153  Hop_Obj_t * pNode0, * pNode1;
154  // check that the node is regular
155  assert( !Hop_IsComplement(pNode) );
156  // if the node is not AND, this is not MUX
157  if ( !Hop_ObjIsAnd(pNode) )
158  return 0;
159  // if the children are not complemented, this is not MUX
160  if ( !Hop_ObjFaninC0(pNode) || !Hop_ObjFaninC1(pNode) )
161  return 0;
162  // get children
163  pNode0 = Hop_ObjFanin0(pNode);
164  pNode1 = Hop_ObjFanin1(pNode);
165  // if the children are not ANDs, this is not MUX
166  if ( !Hop_ObjIsAnd(pNode0) || !Hop_ObjIsAnd(pNode1) )
167  return 0;
168  // otherwise the node is MUX iff it has a pair of equal grandchildren
169  return (Hop_ObjFanin0(pNode0) == Hop_ObjFanin0(pNode1) && (Hop_ObjFaninC0(pNode0) ^ Hop_ObjFaninC0(pNode1))) ||
170  (Hop_ObjFanin0(pNode0) == Hop_ObjFanin1(pNode1) && (Hop_ObjFaninC0(pNode0) ^ Hop_ObjFaninC1(pNode1))) ||
171  (Hop_ObjFanin1(pNode0) == Hop_ObjFanin0(pNode1) && (Hop_ObjFaninC1(pNode0) ^ Hop_ObjFaninC0(pNode1))) ||
172  (Hop_ObjFanin1(pNode0) == Hop_ObjFanin1(pNode1) && (Hop_ObjFaninC1(pNode0) ^ Hop_ObjFaninC1(pNode1)));
173 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static int Hop_ObjFaninC1(Hop_Obj_t *pObj)
Definition: hop.h:181
static int Hop_ObjIsAnd(Hop_Obj_t *pObj)
Definition: hop.h:158
Definition: hop.h:65
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static int Hop_ObjFaninC0(Hop_Obj_t *pObj)
Definition: hop.h:180
#define assert(ex)
Definition: util_old.h:213
static int Hop_ObjIsNode ( Hop_Obj_t pObj)
inlinestatic

Definition at line 160 of file hop.h.

160 { return pObj->Type == AIG_AND || pObj->Type == AIG_EXOR; }
Definition: hop.h:60
unsigned int Type
Definition: hop.h:75
Definition: hop.h:59
static int Hop_ObjIsNone ( Hop_Obj_t pObj)
inlinestatic

Definition at line 154 of file hop.h.

154 { return pObj->Type == AIG_NONE; }
unsigned int Type
Definition: hop.h:75
Definition: hop.h:55
static int Hop_ObjIsPi ( Hop_Obj_t pObj)
inlinestatic

Definition at line 156 of file hop.h.

156 { return pObj->Type == AIG_PI; }
unsigned int Type
Definition: hop.h:75
Definition: hop.h:57
static int Hop_ObjIsPo ( Hop_Obj_t pObj)
inlinestatic

Definition at line 157 of file hop.h.

157 { return pObj->Type == AIG_PO; }
unsigned int Type
Definition: hop.h:75
Definition: hop.h:58
static int Hop_ObjIsTerm ( Hop_Obj_t pObj)
inlinestatic

Definition at line 161 of file hop.h.

161 { return pObj->Type == AIG_PI || pObj->Type == AIG_PO || pObj->Type == AIG_CONST1; }
unsigned int Type
Definition: hop.h:75
Definition: hop.h:57
Definition: hop.h:58
Definition: hop.h:56
static int Hop_ObjIsTravIdCurrent ( Hop_Man_t p,
Hop_Obj_t pObj 
)
inlinestatic

Definition at line 171 of file hop.h.

171 { return (int)((int)(ABC_PTRINT_T)pObj->pData == p->nTravIds); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void * pData
Definition: hop.h:68
static int Hop_ObjIsTravIdPrevious ( Hop_Man_t p,
Hop_Obj_t pObj 
)
inlinestatic

Definition at line 172 of file hop.h.

172 { return (int)((int)(ABC_PTRINT_T)pObj->pData == p->nTravIds - 1); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void * pData
Definition: hop.h:68
static int Hop_ObjLevel ( Hop_Obj_t pObj)
inlinestatic

Definition at line 190 of file hop.h.

190 { return pObj->nRefs; }
unsigned int nRefs
Definition: hop.h:79
static int Hop_ObjLevelNew ( Hop_Obj_t pObj)
inlinestatic

Definition at line 191 of file hop.h.

191 { return 1 + Hop_ObjIsExor(pObj) + Abc_MaxInt(Hop_ObjFanin0(pObj)->nRefs, Hop_ObjFanin1(pObj)->nRefs); }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Hop_ObjIsExor(Hop_Obj_t *pObj)
Definition: hop.h:159
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static int Hop_ObjPhase ( Hop_Obj_t pObj)
inlinestatic

Definition at line 175 of file hop.h.

175 { return pObj->fPhase; }
unsigned int fPhase
Definition: hop.h:76
static int Hop_ObjPhaseCompl ( Hop_Obj_t pObj)
inlinestatic

Definition at line 192 of file hop.h.

192 { return Hop_IsComplement(pObj)? !Hop_Regular(pObj)->fPhase : pObj->fPhase; }
unsigned int fPhase
Definition: hop.h:76
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
void Hop_ObjPrintEqn ( FILE *  pFile,
Hop_Obj_t pObj,
Vec_Vec_t vLevels,
int  Level 
)

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

Synopsis [Prints Eqn formula for the AIG rooted at this node.]

Description [The formula is in terms of PIs, which should have their names assigned in pObj->pData fields.]

SideEffects []

SeeAlso []

Definition at line 322 of file hopUtil.c.

323 {
324  Vec_Ptr_t * vSuper;
325  Hop_Obj_t * pFanin;
326  int fCompl, i;
327  // store the complemented attribute
328  fCompl = Hop_IsComplement(pObj);
329  pObj = Hop_Regular(pObj);
330  // constant case
331  if ( Hop_ObjIsConst1(pObj) )
332  {
333  fprintf( pFile, "%d", !fCompl );
334  return;
335  }
336  // PI case
337  if ( Hop_ObjIsPi(pObj) )
338  {
339  fprintf( pFile, "%s%s", fCompl? "!" : "", (char*)pObj->pData );
340  return;
341  }
342  // AND case
343  Vec_VecExpand( vLevels, Level );
344  vSuper = Vec_VecEntry(vLevels, Level);
345  Hop_ObjCollectMulti( pObj, vSuper );
346  fprintf( pFile, "%s", (Level==0? "" : "(") );
347  Vec_PtrForEachEntry( Hop_Obj_t *, vSuper, pFanin, i )
348  {
349  Hop_ObjPrintEqn( pFile, Hop_NotCond(pFanin, fCompl), vLevels, Level+1 );
350  if ( i < Vec_PtrSize(vSuper) - 1 )
351  fprintf( pFile, " %s ", fCompl? "+" : "*" );
352  }
353  fprintf( pFile, "%s", (Level==0? "" : ")") );
354  return;
355 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Hop_ObjIsPi(Hop_Obj_t *pObj)
Definition: hop.h:156
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: hop.h:65
void Hop_ObjPrintEqn(FILE *pFile, Hop_Obj_t *pObj, Vec_Vec_t *vLevels, int Level)
Definition: hopUtil.c:322
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
void * pData
Definition: hop.h:68
static int Hop_ObjIsConst1(Hop_Obj_t *pObj)
Definition: hop.h:155
static void Vec_VecExpand(Vec_Vec_t *p, int Level)
Definition: vecVec.h:190
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Definition: hop.h:128
static Vec_Ptr_t * Vec_VecEntry(Vec_Vec_t *p, int i)
Definition: vecVec.h:271
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
void Hop_ObjCollectMulti(Hop_Obj_t *pRoot, Vec_Ptr_t *vSuper)
Definition: hopUtil.c:133
void Hop_ObjPrintVerbose ( Hop_Obj_t pObj,
int  fHaig 
)

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

Synopsis [Prints node in HAIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 456 of file hopUtil.c.

457 {
458  assert( !Hop_IsComplement(pObj) );
459  printf( "Node %p : ", pObj );
460  if ( Hop_ObjIsConst1(pObj) )
461  printf( "constant 1" );
462  else if ( Hop_ObjIsPi(pObj) )
463  printf( "PI" );
464  else
465  printf( "AND( %p%s, %p%s )",
466  Hop_ObjFanin0(pObj), (Hop_ObjFaninC0(pObj)? "\'" : " "),
467  Hop_ObjFanin1(pObj), (Hop_ObjFaninC1(pObj)? "\'" : " ") );
468  printf( " (refs = %3d)", Hop_ObjRefs(pObj) );
469 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static int Hop_ObjRefs(Hop_Obj_t *pObj)
Definition: hop.h:176
static int Hop_ObjIsPi(Hop_Obj_t *pObj)
Definition: hop.h:156
static int Hop_ObjFaninC1(Hop_Obj_t *pObj)
Definition: hop.h:181
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static int Hop_ObjIsConst1(Hop_Obj_t *pObj)
Definition: hop.h:155
static int Hop_ObjFaninC0(Hop_Obj_t *pObj)
Definition: hop.h:180
#define assert(ex)
Definition: util_old.h:213
void Hop_ObjPrintVerilog ( FILE *  pFile,
Hop_Obj_t pObj,
Vec_Vec_t vLevels,
int  Level 
)

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

Synopsis [Prints Verilog formula for the AIG rooted at this node.]

Description [The formula is in terms of PIs, which should have their names assigned in pObj->pData fields.]

SideEffects []

SeeAlso []

Definition at line 369 of file hopUtil.c.

370 {
371  Vec_Ptr_t * vSuper;
372  Hop_Obj_t * pFanin, * pFanin0, * pFanin1, * pFaninC;
373  int fCompl, i;
374  // store the complemented attribute
375  fCompl = Hop_IsComplement(pObj);
376  pObj = Hop_Regular(pObj);
377  // constant case
378  if ( Hop_ObjIsConst1(pObj) )
379  {
380  fprintf( pFile, "1\'b%d", !fCompl );
381  return;
382  }
383  // PI case
384  if ( Hop_ObjIsPi(pObj) )
385  {
386  fprintf( pFile, "%s%s", fCompl? "~" : "", (char*)pObj->pData );
387  return;
388  }
389  // EXOR case
390  if ( Hop_ObjIsExor(pObj) )
391  {
392  Vec_VecExpand( vLevels, Level );
393  vSuper = Vec_VecEntry( vLevels, Level );
394  Hop_ObjCollectMulti( pObj, vSuper );
395  fprintf( pFile, "%s", (Level==0? "" : "(") );
396  Vec_PtrForEachEntry( Hop_Obj_t *, vSuper, pFanin, i )
397  {
398  Hop_ObjPrintVerilog( pFile, Hop_NotCond(pFanin, (fCompl && i==0)), vLevels, Level+1 );
399  if ( i < Vec_PtrSize(vSuper) - 1 )
400  fprintf( pFile, " ^ " );
401  }
402  fprintf( pFile, "%s", (Level==0? "" : ")") );
403  return;
404  }
405  // MUX case
406  if ( Hop_ObjIsMuxType(pObj) )
407  {
408  if ( Hop_ObjRecognizeExor( pObj, &pFanin0, &pFanin1 ) )
409  {
410  fprintf( pFile, "%s", (Level==0? "" : "(") );
411  Hop_ObjPrintVerilog( pFile, Hop_NotCond(pFanin0, fCompl), vLevels, Level+1 );
412  fprintf( pFile, " ^ " );
413  Hop_ObjPrintVerilog( pFile, pFanin1, vLevels, Level+1 );
414  fprintf( pFile, "%s", (Level==0? "" : ")") );
415  }
416  else
417  {
418  pFaninC = Hop_ObjRecognizeMux( pObj, &pFanin1, &pFanin0 );
419  fprintf( pFile, "%s", (Level==0? "" : "(") );
420  Hop_ObjPrintVerilog( pFile, pFaninC, vLevels, Level+1 );
421  fprintf( pFile, " ? " );
422  Hop_ObjPrintVerilog( pFile, Hop_NotCond(pFanin1, fCompl), vLevels, Level+1 );
423  fprintf( pFile, " : " );
424  Hop_ObjPrintVerilog( pFile, Hop_NotCond(pFanin0, fCompl), vLevels, Level+1 );
425  fprintf( pFile, "%s", (Level==0? "" : ")") );
426  }
427  return;
428  }
429  // AND case
430  Vec_VecExpand( vLevels, Level );
431  vSuper = Vec_VecEntry(vLevels, Level);
432  Hop_ObjCollectMulti( pObj, vSuper );
433  fprintf( pFile, "%s", (Level==0? "" : "(") );
434  Vec_PtrForEachEntry( Hop_Obj_t *, vSuper, pFanin, i )
435  {
436  Hop_ObjPrintVerilog( pFile, Hop_NotCond(pFanin, fCompl), vLevels, Level+1 );
437  if ( i < Vec_PtrSize(vSuper) - 1 )
438  fprintf( pFile, " %s ", fCompl? "|" : "&" );
439  }
440  fprintf( pFile, "%s", (Level==0? "" : ")") );
441  return;
442 }
int Hop_ObjRecognizeExor(Hop_Obj_t *pObj, Hop_Obj_t **ppFan0, Hop_Obj_t **ppFan1)
Definition: hopUtil.c:187
int Hop_ObjIsMuxType(Hop_Obj_t *pNode)
Definition: hopUtil.c:151
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Hop_ObjIsPi(Hop_Obj_t *pObj)
Definition: hop.h:156
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: hop.h:65
void Hop_ObjPrintVerilog(FILE *pFile, Hop_Obj_t *pObj, Vec_Vec_t *vLevels, int Level)
Definition: hopUtil.c:369
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
void * pData
Definition: hop.h:68
static int Hop_ObjIsExor(Hop_Obj_t *pObj)
Definition: hop.h:159
static int Hop_ObjIsConst1(Hop_Obj_t *pObj)
Definition: hop.h:155
Hop_Obj_t * Hop_ObjRecognizeMux(Hop_Obj_t *pNode, Hop_Obj_t **ppNodeT, Hop_Obj_t **ppNodeE)
Definition: hopUtil.c:231
static void Vec_VecExpand(Vec_Vec_t *p, int Level)
Definition: vecVec.h:190
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Definition: hop.h:128
static Vec_Ptr_t * Vec_VecEntry(Vec_Vec_t *p, int i)
Definition: vecVec.h:271
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
void Hop_ObjCollectMulti(Hop_Obj_t *pRoot, Vec_Ptr_t *vSuper)
Definition: hopUtil.c:133
int Hop_ObjRecognizeExor ( Hop_Obj_t pObj,
Hop_Obj_t **  ppFan0,
Hop_Obj_t **  ppFan1 
)

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

Synopsis [Recognizes what nodes are inputs of the EXOR.]

Description []

SideEffects []

SeeAlso []

Definition at line 187 of file hopUtil.c.

188 {
189  Hop_Obj_t * p0, * p1;
190  assert( !Hop_IsComplement(pObj) );
191  if ( !Hop_ObjIsNode(pObj) )
192  return 0;
193  if ( Hop_ObjIsExor(pObj) )
194  {
195  *ppFan0 = Hop_ObjChild0(pObj);
196  *ppFan1 = Hop_ObjChild1(pObj);
197  return 1;
198  }
199  assert( Hop_ObjIsAnd(pObj) );
200  p0 = Hop_ObjChild0(pObj);
201  p1 = Hop_ObjChild1(pObj);
202  if ( !Hop_IsComplement(p0) || !Hop_IsComplement(p1) )
203  return 0;
204  p0 = Hop_Regular(p0);
205  p1 = Hop_Regular(p1);
206  if ( !Hop_ObjIsAnd(p0) || !Hop_ObjIsAnd(p1) )
207  return 0;
208  if ( Hop_ObjFanin0(p0) != Hop_ObjFanin0(p1) || Hop_ObjFanin1(p0) != Hop_ObjFanin1(p1) )
209  return 0;
210  if ( Hop_ObjFaninC0(p0) == Hop_ObjFaninC0(p1) || Hop_ObjFaninC1(p0) == Hop_ObjFaninC1(p1) )
211  return 0;
212  *ppFan0 = Hop_ObjChild0(p0);
213  *ppFan1 = Hop_ObjChild1(p0);
214  return 1;
215 }
static Hop_Obj_t * Hop_ObjChild0(Hop_Obj_t *pObj)
Definition: hop.h:184
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static int Hop_ObjIsNode(Hop_Obj_t *pObj)
Definition: hop.h:160
static int Hop_ObjFaninC1(Hop_Obj_t *pObj)
Definition: hop.h:181
static int Hop_ObjIsAnd(Hop_Obj_t *pObj)
Definition: hop.h:158
Definition: hop.h:65
static Hop_Obj_t * Hop_ObjChild1(Hop_Obj_t *pObj)
Definition: hop.h:185
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static int Hop_ObjIsExor(Hop_Obj_t *pObj)
Definition: hop.h:159
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static int Hop_ObjFaninC0(Hop_Obj_t *pObj)
Definition: hop.h:180
#define assert(ex)
Definition: util_old.h:213
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
Hop_Obj_t* Hop_ObjRecognizeMux ( Hop_Obj_t pNode,
Hop_Obj_t **  ppNodeT,
Hop_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 231 of file hopUtil.c.

232 {
233  Hop_Obj_t * pNode0, * pNode1;
234  assert( !Hop_IsComplement(pNode) );
235  assert( Hop_ObjIsMuxType(pNode) );
236  // get children
237  pNode0 = Hop_ObjFanin0(pNode);
238  pNode1 = Hop_ObjFanin1(pNode);
239 
240  // find the control variable
241  if ( Hop_ObjFanin1(pNode0) == Hop_ObjFanin1(pNode1) && (Hop_ObjFaninC1(pNode0) ^ Hop_ObjFaninC1(pNode1)) )
242  {
243 // if ( Fraig_IsComplement(pNode1->p2) )
244  if ( Hop_ObjFaninC1(pNode0) )
245  { // pNode2->p2 is positive phase of C
246  *ppNodeT = Hop_Not(Hop_ObjChild0(pNode1));//pNode2->p1);
247  *ppNodeE = Hop_Not(Hop_ObjChild0(pNode0));//pNode1->p1);
248  return Hop_ObjChild1(pNode1);//pNode2->p2;
249  }
250  else
251  { // pNode1->p2 is positive phase of C
252  *ppNodeT = Hop_Not(Hop_ObjChild0(pNode0));//pNode1->p1);
253  *ppNodeE = Hop_Not(Hop_ObjChild0(pNode1));//pNode2->p1);
254  return Hop_ObjChild1(pNode0);//pNode1->p2;
255  }
256  }
257  else if ( Hop_ObjFanin0(pNode0) == Hop_ObjFanin0(pNode1) && (Hop_ObjFaninC0(pNode0) ^ Hop_ObjFaninC0(pNode1)) )
258  {
259 // if ( Fraig_IsComplement(pNode1->p1) )
260  if ( Hop_ObjFaninC0(pNode0) )
261  { // pNode2->p1 is positive phase of C
262  *ppNodeT = Hop_Not(Hop_ObjChild1(pNode1));//pNode2->p2);
263  *ppNodeE = Hop_Not(Hop_ObjChild1(pNode0));//pNode1->p2);
264  return Hop_ObjChild0(pNode1);//pNode2->p1;
265  }
266  else
267  { // pNode1->p1 is positive phase of C
268  *ppNodeT = Hop_Not(Hop_ObjChild1(pNode0));//pNode1->p2);
269  *ppNodeE = Hop_Not(Hop_ObjChild1(pNode1));//pNode2->p2);
270  return Hop_ObjChild0(pNode0);//pNode1->p1;
271  }
272  }
273  else if ( Hop_ObjFanin0(pNode0) == Hop_ObjFanin1(pNode1) && (Hop_ObjFaninC0(pNode0) ^ Hop_ObjFaninC1(pNode1)) )
274  {
275 // if ( Fraig_IsComplement(pNode1->p1) )
276  if ( Hop_ObjFaninC0(pNode0) )
277  { // pNode2->p2 is positive phase of C
278  *ppNodeT = Hop_Not(Hop_ObjChild0(pNode1));//pNode2->p1);
279  *ppNodeE = Hop_Not(Hop_ObjChild1(pNode0));//pNode1->p2);
280  return Hop_ObjChild1(pNode1);//pNode2->p2;
281  }
282  else
283  { // pNode1->p1 is positive phase of C
284  *ppNodeT = Hop_Not(Hop_ObjChild1(pNode0));//pNode1->p2);
285  *ppNodeE = Hop_Not(Hop_ObjChild0(pNode1));//pNode2->p1);
286  return Hop_ObjChild0(pNode0);//pNode1->p1;
287  }
288  }
289  else if ( Hop_ObjFanin1(pNode0) == Hop_ObjFanin0(pNode1) && (Hop_ObjFaninC1(pNode0) ^ Hop_ObjFaninC0(pNode1)) )
290  {
291 // if ( Fraig_IsComplement(pNode1->p2) )
292  if ( Hop_ObjFaninC1(pNode0) )
293  { // pNode2->p1 is positive phase of C
294  *ppNodeT = Hop_Not(Hop_ObjChild1(pNode1));//pNode2->p2);
295  *ppNodeE = Hop_Not(Hop_ObjChild0(pNode0));//pNode1->p1);
296  return Hop_ObjChild0(pNode1);//pNode2->p1;
297  }
298  else
299  { // pNode1->p2 is positive phase of C
300  *ppNodeT = Hop_Not(Hop_ObjChild0(pNode0));//pNode1->p1);
301  *ppNodeE = Hop_Not(Hop_ObjChild1(pNode1));//pNode2->p2);
302  return Hop_ObjChild1(pNode0);//pNode1->p2;
303  }
304  }
305  assert( 0 ); // this is not MUX
306  return NULL;
307 }
static Hop_Obj_t * Hop_ObjChild0(Hop_Obj_t *pObj)
Definition: hop.h:184
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
int Hop_ObjIsMuxType(Hop_Obj_t *pNode)
Definition: hopUtil.c:151
static int Hop_ObjFaninC1(Hop_Obj_t *pObj)
Definition: hop.h:181
static Hop_Obj_t * Hop_Not(Hop_Obj_t *p)
Definition: hop.h:127
Definition: hop.h:65
static Hop_Obj_t * Hop_ObjChild1(Hop_Obj_t *pObj)
Definition: hop.h:185
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static int Hop_ObjFaninC0(Hop_Obj_t *pObj)
Definition: hop.h:180
#define assert(ex)
Definition: util_old.h:213
static void Hop_ObjRef ( Hop_Obj_t pObj)
inlinestatic

Definition at line 177 of file hop.h.

177 { pObj->nRefs++; }
unsigned int nRefs
Definition: hop.h:79
static int Hop_ObjRefs ( Hop_Obj_t pObj)
inlinestatic

Definition at line 176 of file hop.h.

176 { return pObj->nRefs; }
unsigned int nRefs
Definition: hop.h:79
Hop_Obj_t* Hop_ObjRepr ( Hop_Obj_t pObj)

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

Synopsis [Returns the representative of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 241 of file hopObj.c.

242 {
243  assert( !Hop_IsComplement(pObj) );
244  if ( pObj->pData == NULL || pObj->pData == pObj )
245  return pObj;
246  return Hop_ObjRepr( (Hop_Obj_t *)pObj->pData );
247 }
Definition: hop.h:65
Hop_Obj_t * Hop_ObjRepr(Hop_Obj_t *pObj)
Definition: hopObj.c:241
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
void * pData
Definition: hop.h:68
#define assert(ex)
Definition: util_old.h:213
static void Hop_ObjSetMarkA ( Hop_Obj_t pObj)
inlinestatic

Definition at line 165 of file hop.h.

165 { pObj->fMarkA = 1; }
unsigned int fMarkA
Definition: hop.h:77
static void Hop_ObjSetTravId ( Hop_Obj_t pObj,
int  TravId 
)
inlinestatic

Definition at line 168 of file hop.h.

168 { pObj->pData = (void *)(ABC_PTRINT_T)TravId; }
void * pData
Definition: hop.h:68
static void Hop_ObjSetTravIdCurrent ( Hop_Man_t p,
Hop_Obj_t pObj 
)
inlinestatic

Definition at line 169 of file hop.h.

169 { pObj->pData = (void *)(ABC_PTRINT_T)p->nTravIds; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void * pData
Definition: hop.h:68
static void Hop_ObjSetTravIdPrevious ( Hop_Man_t p,
Hop_Obj_t pObj 
)
inlinestatic

Definition at line 170 of file hop.h.

170 { pObj->pData = (void *)(ABC_PTRINT_T)(p->nTravIds - 1); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void * pData
Definition: hop.h:68
static int Hop_ObjTravId ( Hop_Obj_t pObj)
inlinestatic

Definition at line 174 of file hop.h.

174 { return (int)(ABC_PTRINT_T)pObj->pData; }
void * pData
Definition: hop.h:68
static Hop_Type_t Hop_ObjType ( Hop_Obj_t pObj)
inlinestatic

Definition at line 153 of file hop.h.

153 { return (Hop_Type_t)pObj->Type; }
unsigned int Type
Definition: hop.h:75
Hop_Type_t
Definition: hop.h:54
static int Hop_ObjWhatFanin ( Hop_Obj_t pObj,
Hop_Obj_t pFanin 
)
inlinestatic

Definition at line 194 of file hop.h.

195 {
196  if ( Hop_ObjFanin0(pObj) == pFanin ) return 0;
197  if ( Hop_ObjFanin1(pObj) == pFanin ) return 1;
198  assert(0); return -1;
199 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
#define assert(ex)
Definition: util_old.h:213
Hop_Obj_t* Hop_Oper ( Hop_Man_t p,
Hop_Obj_t p0,
Hop_Obj_t p1,
Hop_Type_t  Type 
)

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

Synopsis [Perform one operation.]

Description [The argument nodes can be complemented.]

SideEffects []

SeeAlso []

Definition at line 83 of file hopOper.c.

84 {
85  if ( Type == AIG_AND )
86  return Hop_And( p, p0, p1 );
87  if ( Type == AIG_EXOR )
88  return Hop_Exor( p, p0, p1 );
89  assert( 0 );
90  return NULL;
91 }
Hop_Obj_t * Hop_Exor(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:138
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:60
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:104
Definition: hop.h:59
#define assert(ex)
Definition: util_old.h:213
Hop_Obj_t* Hop_Or ( Hop_Man_t p,
Hop_Obj_t p0,
Hop_Obj_t p1 
)

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

Synopsis [Implements Boolean OR.]

Description []

SideEffects []

SeeAlso []

Definition at line 171 of file hopOper.c.

172 {
173  return Hop_Not( Hop_And( p, Hop_Not(p0), Hop_Not(p1) ) );
174 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Hop_Obj_t * Hop_Not(Hop_Obj_t *p)
Definition: hop.h:127
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:104
Hop_Obj_t* Hop_Permute ( Hop_Man_t p,
Hop_Obj_t pRoot,
int  nRootVars,
int *  pPermute 
)

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

Synopsis [Permute the AIG according to the given permutation.]

Description []

SideEffects []

SeeAlso []

Definition at line 563 of file hopDfs.c.

564 {
565  Hop_Obj_t * pObj;
566  int i;
567  // return if constant
568  if ( Hop_ObjIsConst1( Hop_Regular(pRoot) ) )
569  return pRoot;
570  // create mapping
571  Hop_ManForEachPi( p, pObj, i )
572  {
573  if ( i == nRootVars )
574  break;
575  assert( pPermute[i] >= 0 && pPermute[i] < Hop_ManPiNum(p) );
576  pObj->pData = Hop_IthVar( p, pPermute[i] );
577  }
578  // recursively perform composition
579  Hop_Remap_rec( p, Hop_Regular(pRoot) );
580  // clear the markings
582  return Hop_NotCond( (Hop_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
583 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Hop_ManForEachPi(p, pObj, i)
ITERATORS ///.
Definition: hop.h:259
void Hop_Remap_rec(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopDfs.c:495
Definition: hop.h:65
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
void * pData
Definition: hop.h:68
static int Hop_ObjIsConst1(Hop_Obj_t *pObj)
Definition: hop.h:155
void Hop_ConeUnmark_rec(Hop_Obj_t *pObj)
Definition: hopDfs.c:257
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Definition: hop.h:128
#define assert(ex)
Definition: util_old.h:213
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: hopOper.c:63
static int Hop_ManPiNum(Hop_Man_t *p)
Definition: hop.h:145
static Hop_Obj_t* Hop_Regular ( Hop_Obj_t p)
inlinestatic

Definition at line 126 of file hop.h.

126 { return (Hop_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); }
Definition: hop.h:65
Hop_Obj_t* Hop_Remap ( Hop_Man_t p,
Hop_Obj_t pRoot,
unsigned  uSupp,
int  nVars 
)

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

Synopsis [Remaps the AIG (pRoot) to have the given support (uSupp).]

Description []

SideEffects []

SeeAlso []

Definition at line 518 of file hopDfs.c.

519 {
520  Hop_Obj_t * pObj;
521  int i, k;
522  // quit if the PI variable is not defined
523  if ( nVars > Hop_ManPiNum(p) )
524  {
525  printf( "Hop_Remap(): The number of variables (%d) is more than the manager size (%d).\n", nVars, Hop_ManPiNum(p) );
526  return NULL;
527  }
528  // return if constant
529  if ( Hop_ObjIsConst1( Hop_Regular(pRoot) ) )
530  return pRoot;
531  if ( uSupp == 0 )
532  return Hop_NotCond( Hop_ManConst0(p), Hop_ObjPhaseCompl(pRoot) );
533  // set the PI mapping
534  k = 0;
535  Hop_ManForEachPi( p, pObj, i )
536  {
537  if ( i == nVars )
538  break;
539  if ( uSupp & (1 << i) )
540  pObj->pData = Hop_IthVar(p, k++);
541  else
542  pObj->pData = Hop_ManConst0(p);
543  }
544  assert( k > 0 && k < nVars );
545  // recursively perform composition
546  Hop_Remap_rec( p, Hop_Regular(pRoot) );
547  // clear the markings
549  return Hop_NotCond( (Hop_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
550 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Hop_ManForEachPi(p, pObj, i)
ITERATORS ///.
Definition: hop.h:259
void Hop_Remap_rec(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopDfs.c:495
Definition: hop.h:65
static int Hop_ObjPhaseCompl(Hop_Obj_t *pObj)
Definition: hop.h:192
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
void * pData
Definition: hop.h:68
static int Hop_ObjIsConst1(Hop_Obj_t *pObj)
Definition: hop.h:155
void Hop_ConeUnmark_rec(Hop_Obj_t *pObj)
Definition: hopDfs.c:257
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Definition: hop.h:128
#define assert(ex)
Definition: util_old.h:213
static Hop_Obj_t * Hop_ManConst0(Hop_Man_t *p)
Definition: hop.h:131
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: hopOper.c:63
static int Hop_ManPiNum(Hop_Man_t *p)
Definition: hop.h:145
int Hop_TableCountEntries ( Hop_Man_t p)

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

Synopsis [Count the number of nodes in the table.]

Description []

SideEffects []

SeeAlso []

Definition at line 145 of file hopTable.c.

146 {
147  Hop_Obj_t * pEntry;
148  int i, Counter = 0;
149  for ( i = 0; i < p->nTableSize; i++ )
150  for ( pEntry = p->pTable[i]; pEntry; pEntry = pEntry->pNext )
151  Counter++;
152  return Counter;
153 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:65
static int Counter
Hop_Obj_t * pNext
Definition: hop.h:71
void Hop_TableDelete ( Hop_Man_t p,
Hop_Obj_t pObj 
)

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

Synopsis [Deletes the node from the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 123 of file hopTable.c.

124 {
125  Hop_Obj_t ** ppPlace;
126  assert( !Hop_IsComplement(pObj) );
127  ppPlace = Hop_TableFind( p, pObj );
128  assert( *ppPlace == pObj ); // node should be in the table
129  // remove the node
130  *ppPlace = pObj->pNext;
131  pObj->pNext = NULL;
132 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:65
static Hop_Obj_t ** Hop_TableFind(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopTable.c:42
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
Hop_Obj_t * pNext
Definition: hop.h:71
#define assert(ex)
Definition: util_old.h:213
void Hop_TableInsert ( Hop_Man_t p,
Hop_Obj_t pObj 
)

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

Synopsis [Adds the new node to the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 100 of file hopTable.c.

101 {
102  Hop_Obj_t ** ppPlace;
103  assert( !Hop_IsComplement(pObj) );
104  assert( Hop_TableLookup(p, pObj) == NULL );
105  if ( (pObj->Id & 0xFF) == 0 && 2 * p->nTableSize < Hop_ManNodeNum(p) )
106  Hop_TableResize( p );
107  ppPlace = Hop_TableFind( p, pObj );
108  assert( *ppPlace == NULL );
109  *ppPlace = pObj;
110 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Id
Definition: hop.h:80
static void Hop_TableResize(Hop_Man_t *p)
Definition: hopTable.c:166
Definition: hop.h:65
Hop_Obj_t * Hop_TableLookup(Hop_Man_t *p, Hop_Obj_t *pGhost)
FUNCTION DEFINITIONS ///.
Definition: hopTable.c:71
static Hop_Obj_t ** Hop_TableFind(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopTable.c:42
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
#define assert(ex)
Definition: util_old.h:213
static int Hop_ManNodeNum(Hop_Man_t *p)
Definition: hop.h:149
Hop_Obj_t* Hop_TableLookup ( Hop_Man_t p,
Hop_Obj_t pGhost 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Checks if a node with the given attributes is in the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 71 of file hopTable.c.

72 {
73  Hop_Obj_t * pEntry;
74  assert( !Hop_IsComplement(pGhost) );
75  assert( Hop_ObjChild0(pGhost) && Hop_ObjChild1(pGhost) );
76  assert( Hop_ObjFanin0(pGhost)->Id < Hop_ObjFanin1(pGhost)->Id );
77  if ( p->fRefCount && (!Hop_ObjRefs(Hop_ObjFanin0(pGhost)) || !Hop_ObjRefs(Hop_ObjFanin1(pGhost))) )
78  return NULL;
79  for ( pEntry = p->pTable[Hop_Hash(pGhost, p->nTableSize)]; pEntry; pEntry = pEntry->pNext )
80  {
81  if ( Hop_ObjChild0(pEntry) == Hop_ObjChild0(pGhost) &&
82  Hop_ObjChild1(pEntry) == Hop_ObjChild1(pGhost) &&
83  Hop_ObjType(pEntry) == Hop_ObjType(pGhost) )
84  return pEntry;
85  }
86  return NULL;
87 }
static Hop_Obj_t * Hop_ObjChild0(Hop_Obj_t *pObj)
Definition: hop.h:184
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static int Hop_ObjRefs(Hop_Obj_t *pObj)
Definition: hop.h:176
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Hop_Type_t Hop_ObjType(Hop_Obj_t *pObj)
Definition: hop.h:153
Definition: hop.h:65
static ABC_NAMESPACE_IMPL_START unsigned long Hop_Hash(Hop_Obj_t *pObj, int TableSize)
DECLARATIONS ///.
Definition: hopTable.c:31
static Hop_Obj_t * Hop_ObjChild1(Hop_Obj_t *pObj)
Definition: hop.h:185
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
Hop_Obj_t * pNext
Definition: hop.h:71
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
#define assert(ex)
Definition: util_old.h:213
void Hop_TableProfile ( Hop_Man_t p)

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

Synopsis [Profiles the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 212 of file hopTable.c.

213 {
214  Hop_Obj_t * pEntry;
215  int i, Counter;
216  for ( i = 0; i < p->nTableSize; i++ )
217  {
218  Counter = 0;
219  for ( pEntry = p->pTable[i]; pEntry; pEntry = pEntry->pNext )
220  Counter++;
221  if ( Counter )
222  printf( "%d ", Counter );
223  }
224 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:65
static int Counter
Hop_Obj_t * pNext
Definition: hop.h:71
Hop_Obj_t* Hop_Transfer ( Hop_Man_t pSour,
Hop_Man_t pDest,
Hop_Obj_t pRoot,
int  nVars 
)

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

Synopsis [Transfers the AIG from one manager into another.]

Description []

SideEffects []

SeeAlso []

Definition at line 353 of file hopDfs.c.

354 {
355  Hop_Obj_t * pObj;
356  int i;
357  // solve simple cases
358  if ( pSour == pDest )
359  return pRoot;
360  if ( Hop_ObjIsConst1( Hop_Regular(pRoot) ) )
361  return Hop_NotCond( Hop_ManConst1(pDest), Hop_IsComplement(pRoot) );
362  // set the PI mapping
363  Hop_ManForEachPi( pSour, pObj, i )
364  {
365  if ( i == nVars )
366  break;
367  pObj->pData = Hop_IthVar(pDest, i);
368  }
369  // transfer and set markings
370  Hop_Transfer_rec( pDest, Hop_Regular(pRoot) );
371  // clear the markings
373  return Hop_NotCond( (Hop_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
374 }
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Definition: hop.h:132
#define Hop_ManForEachPi(p, pObj, i)
ITERATORS ///.
Definition: hop.h:259
Definition: hop.h:65
void Hop_Transfer_rec(Hop_Man_t *pDest, Hop_Obj_t *pObj)
Definition: hopDfs.c:330
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
void * pData
Definition: hop.h:68
static int Hop_ObjIsConst1(Hop_Obj_t *pObj)
Definition: hop.h:155
void Hop_ConeUnmark_rec(Hop_Obj_t *pObj)
Definition: hopDfs.c:257
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Definition: hop.h:128
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: hopOper.c:63
static int Hop_TruthWordNum ( int  nVars)
inlinestatic

Definition at line 119 of file hop.h.

119 { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }