ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
reoUnits.c
Go to the documentation of this file.
1
18
19#include "reo.h"
20
22
23
27
28static void reoUnitsAddToFreeUnitList( reo_man * p );
29
33
46{
47 reo_unit * pUnit;
48 // check there are stil units to extract
49 if ( p->pUnitFreeList == NULL )
50 reoUnitsAddToFreeUnitList( p );
51 // extract the next unit from the linked list
52 pUnit = p->pUnitFreeList;
53 p->pUnitFreeList = pUnit->Next;
54 p->nUnitsUsed++;
55 return pUnit;
56}
57
70{
71 pUnit->Next = p->pUnitFreeList;
72 p->pUnitFreeList = pUnit;
73 p->nUnitsUsed--;
74}
75
88{
89 reo_unit * pUnit;
90 reo_unit * pTail = NULL; // Suppress "might be used uninitialized"
91
92 if ( pPlane->pHead == NULL )
93 return;
94
95 // find the tail
96 for ( pUnit = pPlane->pHead; pUnit; pUnit = pUnit->Next )
97 pTail = pUnit;
98 pTail->Next = p->pUnitFreeList;
99 p->pUnitFreeList = pPlane->pHead;
100 memset( pPlane, 0, sizeof(reo_plane) );
101// pPlane->pHead = NULL;
102}
103
116{
117 int i;
118 for ( i = 0; i < p->nMemChunks; i++ )
119 ABC_FREE( p->pMemChunks[i] );
120// printf("\nThe number of chunks used is %d, each of them %d units\n", p->nMemChunks, REO_CHUNK_SIZE );
121 p->nMemChunks = 0;
122}
123
136{
137 if ( pPlane->pHead == NULL )
138 {
139 pPlane->pHead = pUnit;
140 pUnit->Next = NULL;
141 }
142 else
143 {
144 pUnit->Next = pPlane->pHead;
145 pPlane->pHead = pUnit;
146 }
147 pPlane->statsNodes++;
148}
149
150
162void reoUnitsAddToFreeUnitList( reo_man * p )
163{
164 int c;
165 // check that we still have chunks left
166 if ( p->nMemChunks == p->nMemChunksAlloc )
167 {
168 printf( "reoUnitsAddToFreeUnitList(): Memory manager ran out of memory!\n" );
169 fflush( stdout );
170 return;
171 }
172 // allocate the next chunk
173 assert( p->pUnitFreeList == NULL );
174 p->pUnitFreeList = ABC_ALLOC( reo_unit, REO_CHUNK_SIZE );
175 // split chunks into list-connected units
176 for ( c = 0; c < REO_CHUNK_SIZE-1; c++ )
177 (p->pUnitFreeList + c)->Next = p->pUnitFreeList + c + 1;
178 // set the last pointer to NULL
179 (p->pUnitFreeList + REO_CHUNK_SIZE-1)->Next = NULL;
180 // add the chunk to the array of chunks
181 p->pMemChunks[p->nMemChunks++] = p->pUnitFreeList;
182}
183
184
188
190
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Cube * p
Definition exorList.c:222
void reoUnitsRecycleUnitList(reo_man *p, reo_plane *pPlane)
Definition reoUnits.c:87
void reoUnitsStopDispenser(reo_man *p)
Definition reoUnits.c:115
void reoUnitsAddUnitToPlane(reo_plane *pPlane, reo_unit *pUnit)
Definition reoUnits.c:135
void reoUnitsRecycleUnit(reo_man *p, reo_unit *pUnit)
Definition reoUnits.c:69
reo_unit * reoUnitsGetNextUnit(reo_man *p)
FUNCTION DEFINITIONS ///.
Definition reoUnits.c:45
struct _reo_man reo_man
Definition reo.h:63
#define REO_CHUNK_SIZE
Definition reo.h:42
struct _reo_plane reo_plane
Definition reo.h:61
struct _reo_unit reo_unit
DATA STRUCTURES ///.
Definition reo.h:60
int statsNodes
Definition reo.h:83
reo_unit * pHead
Definition reo.h:90
reo_unit * Next
Definition reo.h:76
#define assert(ex)
Definition util_old.h:213
char * memset()