ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
fxuHeapS.c File Reference
#include "fxuInt.h"
Include dependency graph for fxuHeapS.c:

Go to the source code of this file.

Macros

#define FXU_HEAP_SINGLE_WEIGHT(pSingle)
 DECLARATIONS ///.
 
#define FXU_HEAP_SINGLE_CURRENT(p, pSingle)
 
#define FXU_HEAP_SINGLE_PARENT_EXISTS(p, pSingle)
 
#define FXU_HEAP_SINGLE_CHILD1_EXISTS(p, pSingle)
 
#define FXU_HEAP_SINGLE_CHILD2_EXISTS(p, pSingle)
 
#define FXU_HEAP_SINGLE_PARENT(p, pSingle)
 
#define FXU_HEAP_SINGLE_CHILD1(p, pSingle)
 
#define FXU_HEAP_SINGLE_CHILD2(p, pSingle)
 
#define FXU_HEAP_SINGLE_ASSERT(p, pSingle)
 

Functions

Fxu_HeapSingleFxu_HeapSingleStart ()
 FUNCTION DEFINITIONS ///.
 
void Fxu_HeapSingleStop (Fxu_HeapSingle *p)
 
void Fxu_HeapSinglePrint (FILE *pFile, Fxu_HeapSingle *p)
 
void Fxu_HeapSingleCheck (Fxu_HeapSingle *p)
 
void Fxu_HeapSingleCheckOne (Fxu_HeapSingle *p, Fxu_Single *pSingle)
 
void Fxu_HeapSingleInsert (Fxu_HeapSingle *p, Fxu_Single *pSingle)
 
void Fxu_HeapSingleUpdate (Fxu_HeapSingle *p, Fxu_Single *pSingle)
 
void Fxu_HeapSingleDelete (Fxu_HeapSingle *p, Fxu_Single *pSingle)
 
Fxu_SingleFxu_HeapSingleReadMax (Fxu_HeapSingle *p)
 
Fxu_SingleFxu_HeapSingleGetMax (Fxu_HeapSingle *p)
 
int Fxu_HeapSingleReadMaxWeight (Fxu_HeapSingle *p)
 

Macro Definition Documentation

◆ FXU_HEAP_SINGLE_ASSERT

#define FXU_HEAP_SINGLE_ASSERT ( p,
pSingle )
Value:
assert( (pSingle)->HNum >= 1 && (pSingle)->HNum <= p->nItemsAlloc )
#define assert(ex)
Definition util_old.h:213

Definition at line 36 of file fxuHeapS.c.

◆ FXU_HEAP_SINGLE_CHILD1

#define FXU_HEAP_SINGLE_CHILD1 ( p,
pSingle )
Value:
((p)->pTree[(pSingle)->HNum << 1])
Cube * p
Definition exorList.c:222

Definition at line 34 of file fxuHeapS.c.

◆ FXU_HEAP_SINGLE_CHILD1_EXISTS

#define FXU_HEAP_SINGLE_CHILD1_EXISTS ( p,
pSingle )
Value:
(((pSingle)->HNum << 1) <= p->nItems)

Definition at line 31 of file fxuHeapS.c.

◆ FXU_HEAP_SINGLE_CHILD2

#define FXU_HEAP_SINGLE_CHILD2 ( p,
pSingle )
Value:
((p)->pTree[((pSingle)->HNum << 1)+1])

Definition at line 35 of file fxuHeapS.c.

◆ FXU_HEAP_SINGLE_CHILD2_EXISTS

#define FXU_HEAP_SINGLE_CHILD2_EXISTS ( p,
pSingle )
Value:
((((pSingle)->HNum << 1)+1) <= p->nItems)

Definition at line 32 of file fxuHeapS.c.

◆ FXU_HEAP_SINGLE_CURRENT

#define FXU_HEAP_SINGLE_CURRENT ( p,
pSingle )
Value:
((p)->pTree[(pSingle)->HNum])

Definition at line 29 of file fxuHeapS.c.

◆ FXU_HEAP_SINGLE_PARENT

#define FXU_HEAP_SINGLE_PARENT ( p,
pSingle )
Value:
((p)->pTree[(pSingle)->HNum >> 1])

Definition at line 33 of file fxuHeapS.c.

◆ FXU_HEAP_SINGLE_PARENT_EXISTS

#define FXU_HEAP_SINGLE_PARENT_EXISTS ( p,
pSingle )
Value:
((pSingle)->HNum > 1)

Definition at line 30 of file fxuHeapS.c.

◆ FXU_HEAP_SINGLE_WEIGHT

#define FXU_HEAP_SINGLE_WEIGHT ( pSingle)
Value:
((pSingle)->Weight)

DECLARATIONS ///.

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

FileName [fxuHeapS.c]

PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]

Synopsis [The priority queue for variables.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - February 1, 2003.]

Revision [

Id
fxuHeapS.c,v 1.0 2003/02/01 00:00:00 alanmi Exp

]

Definition at line 28 of file fxuHeapS.c.

Function Documentation

◆ Fxu_HeapSingleCheck()

void Fxu_HeapSingleCheck ( Fxu_HeapSingle * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 155 of file fxuHeapS.c.

156{
157 Fxu_Single * pSingle;
158 Fxu_HeapSingleForEachItem( p, pSingle )
159 {
160 assert( pSingle->HNum == p->i );
161 Fxu_HeapSingleCheckOne( p, pSingle );
162 }
163}
void Fxu_HeapSingleCheckOne(Fxu_HeapSingle *p, Fxu_Single *pSingle)
Definition fxuHeapS.c:176
struct FxuSingle Fxu_Single
Definition fxuInt.h:73
#define Fxu_HeapSingleForEachItem(Heap, Single)
Definition fxuInt.h:379
int HNum
Definition fxuInt.h:270
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fxu_HeapSingleCheckOne()

void Fxu_HeapSingleCheckOne ( Fxu_HeapSingle * p,
Fxu_Single * pSingle )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 176 of file fxuHeapS.c.

177{
178 int Weight1, Weight2;
179 if ( FXU_HEAP_SINGLE_CHILD1_EXISTS(p,pSingle) )
180 {
181 Weight1 = FXU_HEAP_SINGLE_WEIGHT(pSingle);
182 Weight2 = FXU_HEAP_SINGLE_WEIGHT( FXU_HEAP_SINGLE_CHILD1(p,pSingle) );
183 assert( Weight1 >= Weight2 );
184 }
185 if ( FXU_HEAP_SINGLE_CHILD2_EXISTS(p,pSingle) )
186 {
187 Weight1 = FXU_HEAP_SINGLE_WEIGHT(pSingle);
188 Weight2 = FXU_HEAP_SINGLE_WEIGHT( FXU_HEAP_SINGLE_CHILD2(p,pSingle) );
189 assert( Weight1 >= Weight2 );
190 }
191}
#define FXU_HEAP_SINGLE_CHILD2_EXISTS(p, pSingle)
Definition fxuHeapS.c:32
#define FXU_HEAP_SINGLE_WEIGHT(pSingle)
DECLARATIONS ///.
Definition fxuHeapS.c:28
#define FXU_HEAP_SINGLE_CHILD1(p, pSingle)
Definition fxuHeapS.c:34
#define FXU_HEAP_SINGLE_CHILD2(p, pSingle)
Definition fxuHeapS.c:35
#define FXU_HEAP_SINGLE_CHILD1_EXISTS(p, pSingle)
Definition fxuHeapS.c:31
Here is the caller graph for this function:

◆ Fxu_HeapSingleDelete()

void Fxu_HeapSingleDelete ( Fxu_HeapSingle * p,
Fxu_Single * pSingle )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 251 of file fxuHeapS.c.

252{
253 int Place = pSingle->HNum;
254 FXU_HEAP_SINGLE_ASSERT(p,pSingle);
255 // put the last entry to the deleted place
256 // decrement the number of entries
257 p->pTree[Place] = p->pTree[p->nItems--];
258 p->pTree[Place]->HNum = Place;
259 // move the top entry down if necessary
260 Fxu_HeapSingleUpdate( p, p->pTree[Place] );
261 pSingle->HNum = 0;
262}
void Fxu_HeapSingleUpdate(Fxu_HeapSingle *p, Fxu_Single *pSingle)
Definition fxuHeapS.c:226
#define FXU_HEAP_SINGLE_ASSERT(p, pSingle)
Definition fxuHeapS.c:36
Here is the call graph for this function:

◆ Fxu_HeapSingleGetMax()

Fxu_Single * Fxu_HeapSingleGetMax ( Fxu_HeapSingle * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 293 of file fxuHeapS.c.

294{
295 Fxu_Single * pSingle;
296 if ( p->nItems == 0 )
297 return NULL;
298 // prepare the return value
299 pSingle = p->pTree[1];
300 pSingle->HNum = 0;
301 // put the last entry on top
302 // decrement the number of entries
303 p->pTree[1] = p->pTree[p->nItems--];
304 p->pTree[1]->HNum = 1;
305 // move the top entry down if necessary
306 Fxu_HeapSingleMoveDn( p, p->pTree[1] );
307 return pSingle;
308}
Here is the caller graph for this function:

◆ Fxu_HeapSingleInsert()

void Fxu_HeapSingleInsert ( Fxu_HeapSingle * p,
Fxu_Single * pSingle )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 204 of file fxuHeapS.c.

205{
206 if ( p->nItems == p->nItemsAlloc )
207 Fxu_HeapSingleResize( p );
208 // put the last entry to the last place and move up
209 p->pTree[++p->nItems] = pSingle;
210 pSingle->HNum = p->nItems;
211 // move the last entry up if necessary
212 Fxu_HeapSingleMoveUp( p, pSingle );
213}
Here is the caller graph for this function:

◆ Fxu_HeapSinglePrint()

void Fxu_HeapSinglePrint ( FILE * pFile,
Fxu_HeapSingle * p )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 120 of file fxuHeapS.c.

121{
122 Fxu_Single * pSingle;
123 int Counter = 1;
124 int Degree = 1;
125
127 fprintf( pFile, "The contents of the heap:\n" );
128 fprintf( pFile, "Level %d: ", Degree );
129 Fxu_HeapSingleForEachItem( p, pSingle )
130 {
131 assert( Counter == p->pTree[Counter]->HNum );
132 fprintf( pFile, "%2d=%3d ", Counter, FXU_HEAP_SINGLE_WEIGHT(p->pTree[Counter]) );
133 if ( ++Counter == (1 << Degree) )
134 {
135 fprintf( pFile, "\n" );
136 Degree++;
137 fprintf( pFile, "Level %d: ", Degree );
138 }
139 }
140 fprintf( pFile, "\n" );
141 fprintf( pFile, "End of the heap printout.\n" );
142}
void Fxu_HeapSingleCheck(Fxu_HeapSingle *p)
Definition fxuHeapS.c:155
Here is the call graph for this function:

◆ Fxu_HeapSingleReadMax()

Fxu_Single * Fxu_HeapSingleReadMax ( Fxu_HeapSingle * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 275 of file fxuHeapS.c.

276{
277 if ( p->nItems == 0 )
278 return NULL;
279 return p->pTree[1];
280}
Here is the caller graph for this function:

◆ Fxu_HeapSingleReadMaxWeight()

int Fxu_HeapSingleReadMaxWeight ( Fxu_HeapSingle * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 321 of file fxuHeapS.c.

322{
323 if ( p->nItems == 0 )
324 return -1;
325 return FXU_HEAP_SINGLE_WEIGHT(p->pTree[1]);
326}
Here is the caller graph for this function:

◆ Fxu_HeapSingleStart()

Fxu_HeapSingle * Fxu_HeapSingleStart ( )

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 58 of file fxuHeapS.c.

59{
62 memset( p, 0, sizeof(Fxu_HeapSingle) );
63 p->nItems = 0;
64 p->nItemsAlloc = 2000;
65 p->pTree = ABC_ALLOC( Fxu_Single *, p->nItemsAlloc + 10 );
66 p->pTree[0] = NULL;
67 return p;
68}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
struct FxuHeapSingle Fxu_HeapSingle
Definition fxuInt.h:85
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fxu_HeapSingleStop()

void Fxu_HeapSingleStop ( Fxu_HeapSingle * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 99 of file fxuHeapS.c.

100{
101 int i;
102 i = 0;
103 ABC_FREE( p->pTree );
104 i = 1;
105 ABC_FREE( p );
106}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Fxu_HeapSingleUpdate()

void Fxu_HeapSingleUpdate ( Fxu_HeapSingle * p,
Fxu_Single * pSingle )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 226 of file fxuHeapS.c.

227{
228 FXU_HEAP_SINGLE_ASSERT(p,pSingle);
229 if ( FXU_HEAP_SINGLE_PARENT_EXISTS(p,pSingle) &&
231 Fxu_HeapSingleMoveUp( p, pSingle );
232 else if ( FXU_HEAP_SINGLE_CHILD1_EXISTS(p,pSingle) &&
234 Fxu_HeapSingleMoveDn( p, pSingle );
235 else if ( FXU_HEAP_SINGLE_CHILD2_EXISTS(p,pSingle) &&
237 Fxu_HeapSingleMoveDn( p, pSingle );
238}
#define FXU_HEAP_SINGLE_PARENT(p, pSingle)
Definition fxuHeapS.c:33
#define FXU_HEAP_SINGLE_PARENT_EXISTS(p, pSingle)
Definition fxuHeapS.c:30
Here is the caller graph for this function: