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

Go to the source code of this file.

Macros

#define MAP_TABLE_HASH(u1, u2, nSize)
 DECLARATIONS ///.
 

Functions

Map_HashTable_tMap_SuperTableCreate (Map_SuperLib_t *pLib)
 FUNCTION DEFINITIONS ///.
 
void Map_SuperTableFree (Map_HashTable_t *p)
 
int Map_SuperTableInsertC (Map_HashTable_t *p, unsigned uTruthC[], Map_Super_t *pGate)
 
int Map_SuperTableInsert (Map_HashTable_t *p, unsigned uTruth[], Map_Super_t *pGate, unsigned uPhase)
 
Map_Super_tMap_SuperTableLookupC (Map_SuperLib_t *p, unsigned uTruth[])
 
Map_Super_tMap_SuperTableLookup (Map_HashTable_t *p, unsigned uTruth[], unsigned *puPhase)
 
int Map_SuperTableCompareSupergates (Map_Super_t **ppS1, Map_Super_t **ppS2)
 
int Map_SuperTableCompareGatesInList (Map_Super_t **ppS1, Map_Super_t **ppS2)
 
void Map_SuperTableSortSupergates (Map_HashTable_t *p, int nSupersMax)
 
void Map_SuperTableSortSupergatesByDelay (Map_HashTable_t *p, int nSupersMax)
 

Macro Definition Documentation

◆ MAP_TABLE_HASH

#define MAP_TABLE_HASH ( u1,
u2,
nSize )
Value:
(((u1) + 2003 * (u2)) % nSize)

DECLARATIONS ///.

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

FileName [mapperTable.c]

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

Synopsis [Generic technology mapping engine.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 2.0. Started - June 1, 2004.]

Revision [

Id
mapperTable.c,v 1.6 2005/01/23 06:59:44 alanmi Exp

]

Definition at line 29 of file mapperTable.c.

Function Documentation

◆ Map_SuperTableCompareGatesInList()

int Map_SuperTableCompareGatesInList ( Map_Super_t ** ppS1,
Map_Super_t ** ppS2 )

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

Synopsis [Compares the supergates by the number of times they are used.]

Description []

SideEffects []

SeeAlso []

Definition at line 293 of file mapperTable.c.

294{
295// if ( (*ppS1)->tDelayMax.Rise > (*ppS2)->tDelayMax.Rise )
296 if ( (*ppS1)->Area > (*ppS2)->Area )
297 return -1;
298// if ( (*ppS1)->tDelayMax.Rise < (*ppS2)->tDelayMax.Rise )
299 if ( (*ppS1)->Area < (*ppS2)->Area )
300 return 1;
301 return 0;
302}
Here is the caller graph for this function:

◆ Map_SuperTableCompareSupergates()

int Map_SuperTableCompareSupergates ( Map_Super_t ** ppS1,
Map_Super_t ** ppS2 )

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

Synopsis [Compares the supergates by the number of times they are used.]

Description []

SideEffects []

SeeAlso []

Definition at line 273 of file mapperTable.c.

274{
275 if ( (*ppS1)->nUsed > (*ppS2)->nUsed )
276 return -1;
277 if ( (*ppS1)->nUsed < (*ppS2)->nUsed )
278 return 1;
279 return 0;
280}
Here is the caller graph for this function:

◆ Map_SuperTableCreate()

Map_HashTable_t * Map_SuperTableCreate ( Map_SuperLib_t * pLib)

FUNCTION DEFINITIONS ///.

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

Synopsis [Creates the hash table for supergates.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file mapperTable.c.

49{
51 // allocate the table
53 memset( p, 0, sizeof(Map_HashTable_t) );
54 p->mmMan = pLib->mmEntries;
55 // allocate and clean the bins
56 p->nBins = Abc_PrimeCudd(20000);
57 p->pBins = ABC_ALLOC( Map_HashEntry_t *, p->nBins );
58 memset( p->pBins, 0, sizeof(Map_HashEntry_t *) * p->nBins );
59 return p;
60}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
Cube * p
Definition exorList.c:222
struct Map_HashTableStruct_t_ Map_HashTable_t
Definition mapper.h:47
struct Map_HashEntryStruct_t_ Map_HashEntry_t
Definition mapper.h:48
Extra_MmFixed_t * mmEntries
Definition mapperInt.h:200
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Map_SuperTableFree()

void Map_SuperTableFree ( Map_HashTable_t * p)

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

Synopsis [Deallocates the supergate hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 74 of file mapperTable.c.

75{
76 ABC_FREE( p->pBins );
77 ABC_FREE( p );
78}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Map_SuperTableInsert()

int Map_SuperTableInsert ( Map_HashTable_t * p,
unsigned uTruth[],
Map_Super_t * pGate,
unsigned uPhase )

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

Synopsis [Inserts a new entry into the library.]

Description [This function inserts the new gate (pGate), which will be accessible through its unfolded function (uTruth).]

SideEffects []

SeeAlso []

Definition at line 137 of file mapperTable.c.

138{
139 Map_HashEntry_t * pEnt;
140 unsigned Key;
141 // resize the table
142 if ( p->nEntries >= 2 * p->nBins )
143 Map_SuperTableResize( p );
144 // check if this entry already exists
145 Key = MAP_TABLE_HASH( uTruth[0], uTruth[1], p->nBins );
146 for ( pEnt = p->pBins[Key]; pEnt; pEnt = pEnt->pNext )
147 if ( pEnt->uTruth[0] == uTruth[0] && pEnt->uTruth[1] == uTruth[1] )
148 return 1;
149 // add the new hash table entry to the table
150 pEnt = (Map_HashEntry_t *)Extra_MmFixedEntryFetch( p->mmMan );
151 memset( pEnt, 0, sizeof(Map_HashEntry_t) );
152 pEnt->uTruth[0] = uTruth[0];
153 pEnt->uTruth[1] = uTruth[1];
154 pEnt->pGates = pGate;
155 pEnt->uPhase = uPhase;
156 // add the hash table to the corresponding linked list in the table
157 pEnt->pNext = p->pBins[Key];
158 p->pBins[Key] = pEnt;
159 p->nEntries++;
160/*
161printf( "Adding gate: %10u ", Key );
162Map_LibraryPrintSupergate( pGate );
163Extra_PrintBinary( stdout, uTruth, 32 );
164printf( "\n" );
165*/
166 return 0;
167}
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
#define MAP_TABLE_HASH(u1, u2, nSize)
DECLARATIONS ///.
Definition mapperTable.c:29
Map_HashEntry_t * pNext
Definition mapperInt.h:325
Map_Super_t * pGates
Definition mapperInt.h:324
Here is the call graph for this function:

◆ Map_SuperTableInsertC()

int Map_SuperTableInsertC ( Map_HashTable_t * p,
unsigned uTruthC[],
Map_Super_t * pGate )

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

Synopsis [Inserts a new entry into the hash table.]

Description [This function inserts the new gate (pGate), which will be accessible through its canonical form (uTruthC).]

SideEffects []

SeeAlso []

Definition at line 92 of file mapperTable.c.

93{
94 Map_HashEntry_t * pEnt;
95 unsigned Key;
96 // resize the table
97 if ( p->nEntries >= 2 * p->nBins )
98 Map_SuperTableResize( p );
99 // check if another supergate with the same canonical form exists
100 Key = MAP_TABLE_HASH( uTruthC[0], uTruthC[1], p->nBins );
101 for ( pEnt = p->pBins[Key]; pEnt; pEnt = pEnt->pNext )
102 if ( pEnt->uTruth[0] == uTruthC[0] && pEnt->uTruth[1] == uTruthC[1] )
103 break;
104 // create a new entry if it does not exist
105 if ( pEnt == NULL )
106 {
107 // add the new entry to the table
108 pEnt = (Map_HashEntry_t *)Extra_MmFixedEntryFetch( p->mmMan );
109 memset( pEnt, 0, sizeof(Map_HashEntry_t) );
110 pEnt->uTruth[0] = uTruthC[0];
111 pEnt->uTruth[1] = uTruthC[1];
112 // add the hash table entry to the corresponding linked list in the table
113 pEnt->pNext = p->pBins[Key];
114 p->pBins[Key] = pEnt;
115 p->nEntries++;
116 }
117 // add the supergate to the entry
118 pGate->pNext = pEnt->pGates;
119 pEnt->pGates = pGate;
120 return 0;
121}
Map_Super_t * pNext
Definition mapperInt.h:299
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Map_SuperTableLookup()

Map_Super_t * Map_SuperTableLookup ( Map_HashTable_t * p,
unsigned uTruth[],
unsigned * puPhase )

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

Synopsis [Looks up an entry in the library.]

Description [This function looks up the function, given by its truth table, and return two things: (1) the linked list of supergates, which can implement the functions of this N-class; (2) the phase, which should be applied to the given function, in order to derive the canonical form of this N-class.]

SideEffects []

SeeAlso []

Definition at line 208 of file mapperTable.c.

209{
210 Map_HashEntry_t * pEnt;
211 unsigned Key;
212 Key = MAP_TABLE_HASH( uTruth[0], uTruth[1], p->nBins );
213 for ( pEnt = p->pBins[Key]; pEnt; pEnt = pEnt->pNext )
214 if ( pEnt->uTruth[0] == uTruth[0] && pEnt->uTruth[1] == uTruth[1] )
215 {
216 *puPhase = pEnt->uPhase;
217 return pEnt->pGates;
218 }
219 return NULL;
220}

◆ Map_SuperTableLookupC()

Map_Super_t * Map_SuperTableLookupC ( Map_SuperLib_t * p,
unsigned uTruth[] )

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

Synopsis [Looks up an entry in the library.]

Description [This function looks up the function, given by its truth table, and return two things: (1) the linked list of supergates, which can implement the functions of this N-class; (2) the phase, which should be applied to the given function, in order to derive the canonical form of this N-class.]

SideEffects []

SeeAlso []

Definition at line 183 of file mapperTable.c.

184{
185 Map_HashEntry_t * pEnt;
186 unsigned Key;
187 Key = MAP_TABLE_HASH( uTruth[0], uTruth[1], p->tTableC->nBins );
188 for ( pEnt = p->tTableC->pBins[Key]; pEnt; pEnt = pEnt->pNext )
189 if ( pEnt->uTruth[0] == uTruth[0] && pEnt->uTruth[1] == uTruth[1] )
190 return pEnt->pGates;
191 return NULL;
192}

◆ Map_SuperTableSortSupergates()

void Map_SuperTableSortSupergates ( Map_HashTable_t * p,
int nSupersMax )

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

Synopsis [Sorts supergates by usefulness and prints out most useful.]

Description []

SideEffects []

SeeAlso []

Definition at line 315 of file mapperTable.c.

316{
317 Map_HashEntry_t * pEnt;
318 Map_Super_t ** ppSupers;
319 Map_Super_t * pSuper;
320 int nSupers, i;
321
322 // copy all the supergates into one array
323 ppSupers = ABC_ALLOC( Map_Super_t *, nSupersMax );
324 nSupers = 0;
325 for ( i = 0; i < p->nBins; i++ )
326 for ( pEnt = p->pBins[i]; pEnt; pEnt = pEnt->pNext )
327 for ( pSuper = pEnt->pGates; pSuper; pSuper = pSuper->pNext )
328 ppSupers[nSupers++] = pSuper;
329
330 // sort by usage
331 qsort( (void *)ppSupers, (size_t)nSupers, sizeof(Map_Super_t *),
332 (int (*)(const void *, const void *)) Map_SuperTableCompareSupergates );
333 assert( Map_SuperTableCompareSupergates( ppSupers, ppSupers + nSupers - 1 ) <= 0 );
334
335 // print out the "top ten"
336// for ( i = 0; i < nSupers; i++ )
337 for ( i = 0; i < 10; i++ )
338 {
339 if ( ppSupers[i]->nUsed == 0 )
340 break;
341 printf( "%5d : ", ppSupers[i]->nUsed );
342 printf( "%5d ", ppSupers[i]->Num );
343 printf( "A = %5.2f ", ppSupers[i]->Area );
344 printf( "D = %5.2f ", ppSupers[i]->tDelayMax.Rise );
345 printf( "%s", ppSupers[i]->pFormula );
346 printf( "\n" );
347 }
348 ABC_FREE( ppSupers );
349}
int Map_SuperTableCompareSupergates(Map_Super_t **ppS1, Map_Super_t **ppS2)
struct Map_SuperStruct_t_ Map_Super_t
Definition mapper.h:45
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Map_SuperTableSortSupergatesByDelay()

void Map_SuperTableSortSupergatesByDelay ( Map_HashTable_t * p,
int nSupersMax )

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

Synopsis [Sorts supergates by max delay for each truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 362 of file mapperTable.c.

363{
364 Map_HashEntry_t * pEnt;
365 Map_Super_t ** ppSupers;
366 Map_Super_t * pSuper;
367 int nSupers, i, k;
368
369 ppSupers = ABC_ALLOC( Map_Super_t *, nSupersMax );
370 for ( i = 0; i < p->nBins; i++ )
371 for ( pEnt = p->pBins[i]; pEnt; pEnt = pEnt->pNext )
372 {
373 // collect the gates in this entry
374 nSupers = 0;
375 for ( pSuper = pEnt->pGates; pSuper; pSuper = pSuper->pNext )
376 {
377 // skip supergates, whose root is the AND gate
378// if ( strcmp( Mio_GateReadName(pSuper->pRoot), "and" ) == 0 )
379// continue;
380 ppSupers[nSupers++] = pSuper;
381 }
382 pEnt->pGates = NULL;
383 if ( nSupers == 0 )
384 continue;
385 // sort the gates by delay
386 qsort( (void *)ppSupers, (size_t)nSupers, sizeof(Map_Super_t *),
387 (int (*)(const void *, const void *)) Map_SuperTableCompareGatesInList );
388 assert( Map_SuperTableCompareGatesInList( ppSupers, ppSupers + nSupers - 1 ) <= 0 );
389 // link them in the reverse order
390 for ( k = 0; k < nSupers; k++ )
391 {
392 ppSupers[k]->pNext = pEnt->pGates;
393 pEnt->pGates = ppSupers[k];
394 }
395 // save the number of supergates in the list
396 pEnt->pGates->nSupers = nSupers;
397 }
398 ABC_FREE( ppSupers );
399}
int Map_SuperTableCompareGatesInList(Map_Super_t **ppS1, Map_Super_t **ppS2)
Here is the call graph for this function:
Here is the caller graph for this function: