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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Aig_ManOrderStart (Aig_Man_t *p)
 DECLARATIONS ///. More...
 
void Aig_ManOrderStop (Aig_Man_t *p)
 
void Aig_ObjOrderInsert (Aig_Man_t *p, int ObjId)
 
void Aig_ObjOrderRemove (Aig_Man_t *p, int ObjId)
 
void Aig_ObjOrderAdvance (Aig_Man_t *p)
 

Function Documentation

ABC_NAMESPACE_IMPL_START void Aig_ManOrderStart ( Aig_Man_t p)

DECLARATIONS ///.

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

FileName [aigOrder.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [AIG package.]

Synopsis [Dynamically updated topological order.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - April 28, 2007.]

Revision [

Id:
aigOrder.c,v 1.00 2007/04/28 00:00:00 alanmi Exp

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

Synopsis [Initializes the order datastructure.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file aigOrder.c.

46 {
47  Aig_Obj_t * pObj;
48  int i;
49  assert( Aig_ManBufNum(p) == 0 );
50  // allocate order datastructure
51  assert( p->pOrderData == NULL );
52  p->nOrderAlloc = 2 * Aig_ManObjNumMax(p);
53  if ( p->nOrderAlloc < (1<<12) )
54  p->nOrderAlloc = (1<<12);
55  p->pOrderData = ABC_ALLOC( unsigned, 2 * p->nOrderAlloc );
56  memset( p->pOrderData, 0xFF, sizeof(unsigned) * 2 * p->nOrderAlloc );
57  // add the constant node
58  p->pOrderData[0] = p->pOrderData[1] = 0;
59  p->iPrev = p->iNext = 0;
60  // add the internal nodes
61  Aig_ManForEachNode( p, pObj, i )
62  Aig_ObjOrderInsert( p, pObj->Id );
63 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Aig_ManBufNum(Aig_Man_t *p)
Definition: aig.h:253
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
Definition: aig.h:69
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
#define assert(ex)
Definition: util_old.h:213
void Aig_ObjOrderInsert(Aig_Man_t *p, int ObjId)
Definition: aigOrder.c:95
void Aig_ManOrderStop ( Aig_Man_t p)

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

Synopsis [Deletes the order datastructure.]

Description []

SideEffects []

SeeAlso []

Definition at line 76 of file aigOrder.c.

77 {
78  assert( p->pOrderData );
79  ABC_FREE( p->pOrderData );
80  p->nOrderAlloc = 0;
81  p->iPrev = p->iNext = 0;
82 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
void Aig_ObjOrderAdvance ( Aig_Man_t p)

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

Synopsis [Advances the order forward.]

Description []

SideEffects []

SeeAlso []

Definition at line 162 of file aigOrder.c.

163 {
164  assert( p->pOrderData );
165  assert( p->pOrderData[2*p->iPrev+1] == (unsigned)p->iNext );
166  p->iPrev = p->iNext;
167  p->nAndPrev++;
168 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define assert(ex)
Definition: util_old.h:213
void Aig_ObjOrderInsert ( Aig_Man_t p,
int  ObjId 
)

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

Synopsis [Inserts an entry before iNext.]

Description []

SideEffects []

SeeAlso []

Definition at line 95 of file aigOrder.c.

96 {
97  int iPrev;
98  assert( ObjId != 0 );
99  assert( Aig_ObjIsNode( Aig_ManObj(p, ObjId) ) );
100  if ( ObjId >= p->nOrderAlloc )
101  {
102  int nOrderAlloc = 2 * ObjId;
103  p->pOrderData = ABC_REALLOC( unsigned, p->pOrderData, 2 * nOrderAlloc );
104  memset( p->pOrderData + 2 * p->nOrderAlloc, 0xFF, sizeof(unsigned) * 2 * (nOrderAlloc - p->nOrderAlloc) );
105  p->nOrderAlloc = nOrderAlloc;
106  }
107  assert( p->pOrderData[2*ObjId] == 0xFFFFFFFF ); // prev
108  assert( p->pOrderData[2*ObjId+1] == 0xFFFFFFFF ); // next
109  iPrev = p->pOrderData[2*p->iNext];
110  assert( p->pOrderData[2*iPrev+1] == (unsigned)p->iNext );
111  p->pOrderData[2*ObjId] = iPrev;
112  p->pOrderData[2*iPrev+1] = ObjId;
113  p->pOrderData[2*p->iNext] = ObjId;
114  p->pOrderData[2*ObjId+1] = p->iNext;
115  p->nAndTotal++;
116 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
static Aig_Obj_t * Aig_ManObj(Aig_Man_t *p, int i)
Definition: aig.h:270
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
#define assert(ex)
Definition: util_old.h:213
void Aig_ObjOrderRemove ( Aig_Man_t p,
int  ObjId 
)

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

Synopsis [Removes the entry.]

Description [If iPrev is removed, it slides backward. If iNext is removed, it slides forward.]

SideEffects []

SeeAlso []

Definition at line 130 of file aigOrder.c.

131 {
132  int iPrev, iNext;
133  assert( ObjId != 0 );
134  assert( Aig_ObjIsNode( Aig_ManObj(p, ObjId) ) );
135  iPrev = p->pOrderData[2*ObjId];
136  iNext = p->pOrderData[2*ObjId+1];
137  p->pOrderData[2*ObjId] = 0xFFFFFFFF;
138  p->pOrderData[2*ObjId+1] = 0xFFFFFFFF;
139  p->pOrderData[2*iNext] = iPrev;
140  p->pOrderData[2*iPrev+1] = iNext;
141  if ( p->iPrev == ObjId )
142  {
143  p->nAndPrev--;
144  p->iPrev = iPrev;
145  }
146  if ( p->iNext == ObjId )
147  p->iNext = iNext;
148  p->nAndTotal--;
149 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Aig_Obj_t * Aig_ManObj(Aig_Man_t *p, int i)
Definition: aig.h:270
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
#define assert(ex)
Definition: util_old.h:213