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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START Amap_Lib_tAmap_LibAlloc ()
 DECLARATIONS ///.
 
void Amap_LibFree (Amap_Lib_t *p)
 
int Amap_LibNumPinsMax (Amap_Lib_t *p)
 
void Amap_LibWritePin (FILE *pFile, Amap_Pin_t *pPin)
 
void Amap_LibWriteGate (FILE *pFile, Amap_Gat_t *pGate, int fPrintDsd)
 
void Amap_LibWrite (FILE *pFile, Amap_Lib_t *pLib, int fPrintDsd)
 
int Amap_LibCompareGatesByArea (Amap_Gat_t **pp1, Amap_Gat_t **pp2)
 
Vec_Ptr_tAmap_LibSortGatesByArea (Amap_Lib_t *pLib)
 
Amap_Gat_tAmap_LibFindGate (Amap_Lib_t *p, unsigned uTruth)
 
Vec_Ptr_tAmap_LibSelectGates (Amap_Lib_t *p, int fVerbose)
 
void Amap_LibPrintSelectedGates (Amap_Lib_t *p, int fAllGates)
 
Amap_Lib_tAmap_LibReadAndPrepare (char *pFileName, char *pBuffer, int fVerbose, int fVeryVerbose)
 

Function Documentation

◆ Amap_LibAlloc()

ABC_NAMESPACE_IMPL_START Amap_Lib_t * Amap_LibAlloc ( )

DECLARATIONS ///.

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

FileName [amapLib.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Technology mapper for standard cells.]

Synopsis [Standard-cell library.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
amapLib.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

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

Synopsis [Allocs a library.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file amapLib.c.

46{
47 Amap_Lib_t * p;
49 memset( p, 0, sizeof(Amap_Lib_t) );
50 p->vGates = Vec_PtrAlloc( 100 );
51 p->pMemGates = Aig_MmFlexStart();
52 p->pMemSet = Aig_MmFlexStart();
53 return p;
54}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
Aig_MmFlex_t * Aig_MmFlexStart()
Definition aigMem.c:305
typedefABC_NAMESPACE_HEADER_START struct Amap_Lib_t_ Amap_Lib_t
INCLUDES ///.
Definition amap.h:42
Cube * p
Definition exorList.c:222
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Amap_LibCompareGatesByArea()

int Amap_LibCompareGatesByArea ( Amap_Gat_t ** pp1,
Amap_Gat_t ** pp2 )

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

Synopsis [Compares two gates by area.]

Description []

SideEffects []

SeeAlso []

Definition at line 199 of file amapLib.c.

200{
201 double Diff = (*pp1)->dArea - (*pp2)->dArea;
202 if ( Diff < 0.0 )
203 return -1;
204 if ( Diff > 0.0 )
205 return 1;
206 return 0;
207}
Here is the caller graph for this function:

◆ Amap_LibFindGate()

Amap_Gat_t * Amap_LibFindGate ( Amap_Lib_t * p,
unsigned uTruth )

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

Synopsis [Finds min-area gate with the given function.]

Description []

SideEffects []

SeeAlso []

Definition at line 240 of file amapLib.c.

241{
242 Amap_Gat_t * pGate;
243 int i;
244 Vec_PtrForEachEntry( Amap_Gat_t *, p->vSorted, pGate, i )
245 {
246 if (( pGate == NULL ) || ( pGate->pFunc == NULL )) continue;
247 if ( pGate->nPins <= 5 && pGate->pFunc[0] == uTruth )
248 return pGate;
249 }
250 return NULL;
251}
struct Amap_Gat_t_ Amap_Gat_t
Definition amapInt.h:66
unsigned nPins
Definition amapInt.h:162
unsigned * pFunc
Definition amapInt.h:159
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the caller graph for this function:

◆ Amap_LibFree()

void Amap_LibFree ( Amap_Lib_t * p)

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

Synopsis [Deallocs a library.]

Description []

SideEffects []

SeeAlso []

Definition at line 67 of file amapLib.c.

68{
69 if ( p == NULL )
70 return;
71 if ( p->vSelect )
72 Vec_PtrFree( p->vSelect );
73 if ( p->vSorted )
74 Vec_PtrFree( p->vSorted );
75 if ( p->vGates )
76 Vec_PtrFree( p->vGates );
77 if ( p->vRules )
78 Vec_VecFree( (Vec_Vec_t *)p->vRules );
79 if ( p->vRulesX )
80 Vec_VecFree( (Vec_Vec_t *)p->vRulesX );
81 if ( p->vRules3 )
82 Vec_IntFree( p->vRules3 );
83 Aig_MmFlexStop( p->pMemGates, 0 );
84 Aig_MmFlexStop( p->pMemSet, 0 );
85 ABC_FREE( p->pRules );
86 ABC_FREE( p->pRulesX );
87 ABC_FREE( p->pNodes );
88 ABC_FREE( p->pName );
89 ABC_FREE( p );
90}
#define ABC_FREE(obj)
Definition abc_global.h:267
void Aig_MmFlexStop(Aig_MmFlex_t *p, int fVerbose)
Definition aigMem.c:337
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition vecVec.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Amap_LibNumPinsMax()

int Amap_LibNumPinsMax ( Amap_Lib_t * p)

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

Synopsis [Returns the largest gate size.]

Description []

SideEffects []

SeeAlso []

Definition at line 103 of file amapLib.c.

104{
105 Amap_Gat_t * pGate;
106 int i, Counter = 0;
107 Amap_LibForEachGate( p, pGate, i )
108 if ( Counter < (int)pGate->nPins )
109 Counter = pGate->nPins;
110 return Counter;
111}
#define Amap_LibForEachGate(pLib, pGate, i)
Definition amapInt.h:294
Here is the caller graph for this function:

◆ Amap_LibPrintSelectedGates()

void Amap_LibPrintSelectedGates ( Amap_Lib_t * p,
int fAllGates )

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

Synopsis [Selects gates useful for area-only mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 305 of file amapLib.c.

306{
307 Vec_Ptr_t * vArray;
308 Amap_Gat_t * pGate;
309 int i;
310 vArray = fAllGates? p->vGates : p->vSelect;
311 Vec_PtrForEachEntry( Amap_Gat_t *, vArray, pGate, i )
312 {
313 printf( "%3d :%12s %d %9.2f ", i, pGate->pName, pGate->nPins, pGate->dArea );
314 printf( "%4s=%40s ", pGate->pOutName, pGate->pForm );
315 printf( "DSD: " );
316 Kit_DsdPrintFromTruth( pGate->pFunc, pGate->nPins );
317 printf( "\n" );
318 }
319}
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition kitDsd.c:491
char * pForm
Definition amapInt.h:158
double dArea
Definition amapInt.h:157
char * pOutName
Definition amapInt.h:156
char * pName
Definition amapInt.h:155
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:

◆ Amap_LibReadAndPrepare()

Amap_Lib_t * Amap_LibReadAndPrepare ( char * pFileName,
char * pBuffer,
int fVerbose,
int fVeryVerbose )

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

Synopsis [Parses equations for the gates.]

Description []

SideEffects []

SeeAlso []

Definition at line 332 of file amapLib.c.

333{
334 Amap_Lib_t * p;
335 abctime clk = Abc_Clock();
336 if ( pBuffer == NULL )
337 p = Amap_LibReadFile( pFileName, fVerbose );
338 else
339 {
340 p = Amap_LibReadBuffer( pBuffer, fVerbose );
341 if ( p )
342 p->pName = Abc_UtilStrsav( pFileName );
343 }
344 if ( fVerbose )
345 printf( "Read %d gates from file \"%s\".\n", Vec_PtrSize(p->vGates), pFileName );
346 if ( p == NULL )
347 return NULL;
348 if ( !Amap_LibParseEquations( p, fVerbose ) )
349 {
350 Amap_LibFree( p );
351 return NULL;
352 }
353 p->vSorted = Amap_LibSortGatesByArea( p );
354 p->vSelect = Amap_LibSelectGates( p, fVerbose );
355 if ( fVerbose )
356 {
357 printf( "Selected %d functionally unique gates. ", Vec_PtrSize(p->vSelect) );
358 ABC_PRT( "Time", Abc_Clock() - clk );
359// Amap_LibPrintSelectedGates( p, 0 );
360 }
361 clk = Abc_Clock();
362 Amap_LibCreateRules( p, fVeryVerbose );
363 if ( fVerbose )
364 {
365 printf( "Created %d rules and %d matches. ", p->nNodes, p->nSets );
366 ABC_PRT( "Time", Abc_Clock() - clk );
367 }
368 return p;
369}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
void Amap_LibCreateRules(Amap_Lib_t *p, int fVeryVerbose)
Definition amapRule.c:426
Amap_Lib_t * Amap_LibReadFile(char *pFileName, int fVerbose)
Definition amapRead.c:485
int Amap_LibParseEquations(Amap_Lib_t *p, int fVerbose)
Definition amapParse.c:392
Amap_Lib_t * Amap_LibReadBuffer(char *pBuffer, int fVerbose)
Definition amapRead.c:458
Vec_Ptr_t * Amap_LibSortGatesByArea(Amap_Lib_t *pLib)
Definition amapLib.c:220
void Amap_LibFree(Amap_Lib_t *p)
Definition amapLib.c:67
Vec_Ptr_t * Amap_LibSelectGates(Amap_Lib_t *p, int fVerbose)
Definition amapLib.c:264
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Amap_LibSelectGates()

Vec_Ptr_t * Amap_LibSelectGates ( Amap_Lib_t * p,
int fVerbose )

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

Synopsis [Selects gates useful for area-only mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 264 of file amapLib.c.

265{
266 Vec_Ptr_t * vSelect;
267 Amap_Gat_t * pGate, * pGate2;
268 int i, k;//, clk = Abc_Clock();
269 p->pGate0 = Amap_LibFindGate( p, 0 );
270 p->pGate1 = Amap_LibFindGate( p, ~0 );
271 p->pGateBuf = Amap_LibFindGate( p, 0xAAAAAAAA );
272 p->pGateInv = Amap_LibFindGate( p, ~0xAAAAAAAA );
273 vSelect = Vec_PtrAlloc( 100 );
274 Vec_PtrForEachEntry( Amap_Gat_t *, p->vSorted, pGate, i )
275 {
276 if ( pGate->pFunc == NULL || pGate->pTwin != NULL )
277 continue;
278 Vec_PtrForEachEntryStop( Amap_Gat_t *, p->vSorted, pGate2, k, i )
279 {
280 if ( pGate2->pFunc == NULL || pGate2->pTwin != NULL )
281 continue;
282 if ( pGate2->nPins != pGate->nPins )
283 continue;
284 if ( !memcmp( pGate2->pFunc, pGate->pFunc, sizeof(unsigned) * Abc_TruthWordNum(pGate->nPins) ) )
285 break;
286 }
287 if ( k < i )
288 continue;
289 Vec_PtrPush( vSelect, pGate );
290 }
291 return vSelect;
292}
Amap_Gat_t * Amap_LibFindGate(Amap_Lib_t *p, unsigned uTruth)
Definition amapLib.c:240
Amap_Gat_t * pTwin
Definition amapInt.h:154
int memcmp()
#define Vec_PtrForEachEntryStop(Type, vVec, pEntry, i, Stop)
Definition vecPtr.h:59
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Amap_LibSortGatesByArea()

Vec_Ptr_t * Amap_LibSortGatesByArea ( Amap_Lib_t * pLib)

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

Synopsis [Compares gates by area.]

Description []

SideEffects []

SeeAlso []

Definition at line 220 of file amapLib.c.

221{
222 Vec_Ptr_t * vSorted;
223 vSorted = Vec_PtrDup( pLib->vGates );
224 qsort( (void *)Vec_PtrArray(vSorted), (size_t)Vec_PtrSize(vSorted), sizeof(void *),
225 (int (*)(const void *, const void *)) Amap_LibCompareGatesByArea );
226 return vSorted;
227}
int Amap_LibCompareGatesByArea(Amap_Gat_t **pp1, Amap_Gat_t **pp2)
Definition amapLib.c:199
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Amap_LibWrite()

void Amap_LibWrite ( FILE * pFile,
Amap_Lib_t * pLib,
int fPrintDsd )

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

Synopsis [Writes library.]

Description []

SideEffects []

SeeAlso []

Definition at line 179 of file amapLib.c.

180{
181 Amap_Gat_t * pGate;
182 int i;
183 fprintf( pFile, "# The genlib library \"%s\".\n", pLib->pName );
184 Amap_LibForEachGate( pLib, pGate, i )
185 Amap_LibWriteGate( pFile, pGate, fPrintDsd );
186}
void Amap_LibWriteGate(FILE *pFile, Amap_Gat_t *pGate, int fPrintDsd)
Definition amapLib.c:150
Here is the call graph for this function:

◆ Amap_LibWriteGate()

void Amap_LibWriteGate ( FILE * pFile,
Amap_Gat_t * pGate,
int fPrintDsd )

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

Synopsis [Writes one gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 150 of file amapLib.c.

151{
152 Amap_Pin_t * pPin;
153 fprintf( pFile, "GATE " );
154 fprintf( pFile, "%12s ", pGate->pName );
155 fprintf( pFile, "%10.2f ", pGate->dArea );
156 fprintf( pFile, "%s=%s;\n", pGate->pOutName, pGate->pForm );
157 if ( fPrintDsd )
158 {
159 if ( pGate->pFunc == NULL )
160 printf( "Truth table is not available.\n" );
161 else
162 Kit_DsdPrintFromTruth( pGate->pFunc, pGate->nPins );
163 }
164 Amap_GateForEachPin( pGate, pPin )
165 Amap_LibWritePin( pFile, pPin );
166}
#define Amap_GateForEachPin(pGate, pPin)
Definition amapInt.h:297
struct Amap_Pin_t_ Amap_Pin_t
BASIC TYPES ///.
Definition amapInt.h:65
void Amap_LibWritePin(FILE *pFile, Amap_Pin_t *pPin)
Definition amapLib.c:124
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Amap_LibWritePin()

void Amap_LibWritePin ( FILE * pFile,
Amap_Pin_t * pPin )

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

Synopsis [Writes one pin.]

Description []

SideEffects []

SeeAlso []

Definition at line 124 of file amapLib.c.

125{
126 char * pPhaseNames[10] = { "UNKNOWN", "INV", "NONINV" };
127 fprintf( pFile, " PIN " );
128 fprintf( pFile, "%9s ", pPin->pName );
129 fprintf( pFile, "%10s ", pPhaseNames[pPin->Phase] );
130 fprintf( pFile, "%6d ", (int)pPin->dLoadInput );
131 fprintf( pFile, "%6d ", (int)pPin->dLoadMax );
132 fprintf( pFile, "%6.2f ", pPin->dDelayBlockRise );
133 fprintf( pFile, "%6.2f ", pPin->dDelayFanoutRise );
134 fprintf( pFile, "%6.2f ", pPin->dDelayBlockFall );
135 fprintf( pFile, "%6.2f", pPin->dDelayFanoutFall );
136 fprintf( pFile, "\n" );
137}
double dLoadMax
Definition amapInt.h:144
double dDelayBlockRise
Definition amapInt.h:145
double dDelayFanoutFall
Definition amapInt.h:148
double dLoadInput
Definition amapInt.h:143
double dDelayBlockFall
Definition amapInt.h:147
char * pName
Definition amapInt.h:141
double dDelayFanoutRise
Definition amapInt.h:146
Here is the caller graph for this function: