abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mapperLib.c File Reference
#include <unistd.h>
#include "mapperInt.h"
#include "map/super/super.h"

Go to the source code of this file.

Macros

#define _BSD_SOURCE
 

Functions

ABC_NAMESPACE_IMPL_START
Map_SuperLib_t
Map_SuperLibCreate (Mio_Library_t *pGenlib, Vec_Str_t *vStr, char *pFileName, char *pExcludeFile, int fAlgorithm, int fVerbose)
 DECLARATIONS ///. More...
 
void Map_SuperLibFree (Map_SuperLib_t *p)
 
int Map_SuperLibDeriveFromGenlib (Mio_Library_t *pLib, int fVerbose)
 
int Map_SuperLibDeriveFromGenlib2 (Mio_Library_t *pLib, int fVerbose)
 

Macro Definition Documentation

#define _BSD_SOURCE

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

FileName [mapperLib.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:
mapperLib.c,v 1.6 2005/01/23 06:59:44 alanmi Exp

]

Definition at line 18 of file mapperLib.c.

Function Documentation

ABC_NAMESPACE_IMPL_START Map_SuperLib_t* Map_SuperLibCreate ( Mio_Library_t pGenlib,
Vec_Str_t vStr,
char *  pFileName,
char *  pExcludeFile,
int  fAlgorithm,
int  fVerbose 
)

DECLARATIONS ///.

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

Synopsis [Reads in the supergate library and prepares it for use.]

Description [The supergates library comes in a .super file. This file contains descriptions of supergates along with some relevant information. This procedure reads the supergate file, canonicizes the supergates, and constructs an additional lookup table, which can be used to map truth tables of the cuts into the pair (phase, supergate). The phase indicates how the current truth table should be phase assigned to match the canonical form of the supergate. The resulting phase is the bitwise EXOR of the phase needed to canonicize the supergate and the phase needed to transform the truth table into its canonical form.]

SideEffects []

SeeAlso []

Definition at line 58 of file mapperLib.c.

59 {
60  Map_SuperLib_t * p;
61  abctime clk;
62 
63  // start the supergate library
64  p = ABC_ALLOC( Map_SuperLib_t, 1 );
65  memset( p, 0, sizeof(Map_SuperLib_t) );
66  p->pName = Abc_UtilStrsav(pFileName);
67  p->fVerbose = fVerbose;
68  p->mmSupers = Extra_MmFixedStart( sizeof(Map_Super_t) );
72 
73  // start the hash table
74  p->tTableC = Map_SuperTableCreate( p );
75  p->tTable = Map_SuperTableCreate( p );
76 
77  // read the supergate library from file
78 clk = Abc_Clock();
79  if ( vStr != NULL )
80  {
81  // read the supergate library from file
82  int Status = Map_LibraryReadFileTreeStr( p, pGenlib, vStr, pFileName );
83  if ( Status == 0 )
84  {
85  Map_SuperLibFree( p );
86  return NULL;
87  }
88  // prepare the info about the library
89  Status = Map_LibraryDeriveGateInfo( p, NULL );
90  if ( Status == 0 )
91  {
92  Map_SuperLibFree( p );
93  return NULL;
94  }
95  assert( p->nVarsMax > 0 );
96  }
97  else if ( fAlgorithm )
98  {
99  if ( !Map_LibraryReadTree( p, pGenlib, pFileName, pExcludeFile ) )
100  {
101  Map_SuperLibFree( p );
102  return NULL;
103  }
104  }
105  else
106  {
107  if ( pExcludeFile != 0 )
108  {
109  Map_SuperLibFree( p );
110  printf ("Error: Exclude file support not present for old format. Stop.\n");
111  return NULL;
112  }
113  if ( !Map_LibraryRead( p, pFileName ) )
114  {
115  Map_SuperLibFree( p );
116  return NULL;
117  }
118  }
119  assert( p->nVarsMax > 0 );
120 
121  // report the stats
122  if ( fVerbose )
123  {
124  printf( "Loaded %d unique %d-input supergates from \"%s\". ",
125  p->nSupersReal, p->nVarsMax, pFileName );
126  ABC_PRT( "Time", Abc_Clock() - clk );
127  }
128 
129  // assign the interver parameters
136 
137  // assign the interver supergate
139  memset( p->pSuperInv, 0, sizeof(Map_Super_t) );
140  p->pSuperInv->Num = -1;
141  p->pSuperInv->nGates = 1;
142  p->pSuperInv->nFanins = 1;
143  p->pSuperInv->nFanLimit = 10;
144  p->pSuperInv->pFanins[0] = p->ppSupers[0];
145  p->pSuperInv->pRoot = p->pGateInv;
146  p->pSuperInv->Area = p->AreaInv;
147  p->pSuperInv->tDelayMax = p->tDelayInv;
149  p->pSuperInv->tDelaysR[0].Fall = p->tDelayInv.Rise;
150  p->pSuperInv->tDelaysF[0].Rise = p->tDelayInv.Fall;
152  return p;
153 }
char * memset()
#define MAP_NO_VAR
Definition: mapperInt.h:53
float Mio_LibraryReadAreaBuf(Mio_Library_t *pLib)
Definition: mioApi.c:61
int Map_LibraryDeriveGateInfo(Map_SuperLib_t *pLib, st__table *tExcludeGate)
Definition: mapperTree.c:586
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned nFanins
Definition: mapperInt.h:280
Map_Super_t * pSuperInv
Definition: mapperInt.h:192
Extra_MmFlex_t * Extra_MmFlexStart()
Map_Time_t tDelaysF[6]
Definition: mapperInt.h:291
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
float Mio_LibraryReadAreaInv(Mio_Library_t *pLib)
Definition: mioApi.c:60
float Mio_LibraryReadDelayInvFall(Mio_Library_t *pLib)
Definition: mioApi.c:54
static abctime Abc_Clock()
Definition: abc_global.h:279
Map_Super_t ** ppSupers
Definition: mapperInt.h:179
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
Map_Time_t tDelayMax
Definition: mapperInt.h:292
int Map_LibraryReadTree(Map_SuperLib_t *pLib, Mio_Library_t *pGenlib, char *pFileName, char *pExcludeFile)
Definition: mapperTree.c:525
unsigned uTruths[6][2]
Definition: mapperInt.h:184
Mio_Gate_t * pRoot
Definition: mapperInt.h:288
Mio_Library_t * pGenlib
Definition: mapperInt.h:169
Map_HashTable_t * Map_SuperTableCreate(Map_SuperLib_t *pLib)
FUNCTION DEFINITIONS ///.
Definition: mapperTable.c:48
Extra_MmFixed_t * Extra_MmFixedStart(int nEntrySize)
unsigned nFanLimit
Definition: mapperInt.h:282
int Map_LibraryRead(Map_SuperLib_t *p, char *pFileName)
FUNCTION DEFINITIONS ///.
Definition: mapperSuper.c:50
Extra_MmFixed_t * mmSupers
Definition: mapperInt.h:195
void Map_SuperLibFree(Map_SuperLib_t *p)
Definition: mapperLib.c:167
Map_Super_t * pFanins[6]
Definition: mapperInt.h:287
Map_HashTable_t * tTable
Definition: mapperInt.h:181
Mio_Gate_t * pGateInv
Definition: mapperInt.h:188
float Mio_LibraryReadDelayInvRise(Mio_Library_t *pLib)
Definition: mioApi.c:53
Extra_MmFixed_t * mmEntries
Definition: mapperInt.h:196
#define ABC_PRT(a, t)
Definition: abc_global.h:220
#define assert(ex)
Definition: util_old.h:213
Map_Time_t tDelaysR[6]
Definition: mapperInt.h:290
int Map_LibraryReadFileTreeStr(Map_SuperLib_t *pLib, Mio_Library_t *pGenlib, Vec_Str_t *vStr, char *pFileName)
Definition: mapperTree.c:391
Map_HashTable_t * tTableC
Definition: mapperInt.h:180
ABC_INT64_T abctime
Definition: abc_global.h:278
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
Mio_Gate_t * Mio_LibraryReadInv(Mio_Library_t *pLib)
Definition: mioApi.c:48
Extra_MmFlex_t * mmForms
Definition: mapperInt.h:197
void Map_MappingSetupTruthTables(unsigned uTruths[][2])
Definition: mapperUtils.c:335
#define MAP_MAX(a, b)
Definition: mapperInt.h:57
Map_Time_t tDelayInv
Definition: mapperInt.h:189
int Map_SuperLibDeriveFromGenlib ( Mio_Library_t pLib,
int  fVerbose 
)

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

Synopsis [Derives the library from the genlib library.]

Description []

SideEffects []

SeeAlso []

Definition at line 199 of file mapperLib.c.

200 {
201  Map_SuperLib_t * pLibSuper;
202  Vec_Str_t * vStr;
203  char * pFileName;
204  if ( pLib == NULL )
205  return 0;
206 
207  // compute supergates
208  vStr = Super_PrecomputeStr( pLib, 5, 1, 100000000, 10000000, 10000000, 100, 1, 0 );
209  if ( vStr == NULL )
210  return 0;
211 
212  // create supergate library
213  pFileName = Extra_FileNameGenericAppend( Mio_LibraryReadName(pLib), ".super" );
214  pLibSuper = Map_SuperLibCreate( pLib, vStr, pFileName, NULL, 1, 0 );
215  Vec_StrFree( vStr );
216 
217  // replace the library
219  Abc_FrameSetLibSuper( pLibSuper );
220  return 1;
221 }
ABC_DLL void Abc_FrameSetLibSuper(void *pLib)
Definition: mainFrame.c:84
char * Mio_LibraryReadName(Mio_Library_t *pLib)
DECLARATIONS ///.
Definition: mioApi.c:43
ABC_NAMESPACE_IMPL_START Map_SuperLib_t * Map_SuperLibCreate(Mio_Library_t *pGenlib, Vec_Str_t *vStr, char *pFileName, char *pExcludeFile, int fAlgorithm, int fVerbose)
DECLARATIONS ///.
Definition: mapperLib.c:58
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
Vec_Str_t * Super_PrecomputeStr(Mio_Library_t *pLibGen, int nVarsMax, int nLevels, int nGatesMax, float tDelayMax, float tAreaMax, int TimeLimit, int fSkipInv, int fVerbose)
Definition: superGate.c:172
void Map_SuperLibFree(Map_SuperLib_t *p)
Definition: mapperLib.c:167
ABC_DLL void * Abc_FrameReadLibSuper()
Definition: mainFrame.c:58
char * Extra_FileNameGenericAppend(char *pBase, char *pSuffix)
int Map_SuperLibDeriveFromGenlib2 ( Mio_Library_t pLib,
int  fVerbose 
)

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

Synopsis [Derives the library from the genlib library.]

Description []

SideEffects []

SeeAlso []

Definition at line 234 of file mapperLib.c.

235 {
237  char * pFileName;
238  if ( pLib == NULL )
239  return 0;
240  // compute supergates
241  pFileName = Extra_FileNameGenericAppend(Mio_LibraryReadName(pLib), ".super");
242  Super_Precompute( pLib, 5, 1, 100000000, 10000000, 10000000, 100, 1, 0, pFileName );
243  // assuming that it terminated successfully
244  if ( Cmd_CommandExecute( pAbc, pFileName ) )
245  {
246  fprintf( stdout, "Cannot execute command \"read_super %s\".\n", pFileName );
247  return 0;
248  }
249  return 1;
250 }
int Cmd_CommandExecute(void *pAbc, char *pCommandLine)
void Super_Precompute(Mio_Library_t *pLibGen, int nVarsMax, int nLevels, int nGatesMax, float tDelayMax, float tAreaMax, int TimeLimit, int fSkipInv, int fVerbose, char *pFileName)
FUNCTION DEFINITIONS ///.
Definition: superGate.c:140
char * Mio_LibraryReadName(Mio_Library_t *pLib)
DECLARATIONS ///.
Definition: mioApi.c:43
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
void * Abc_FrameGetGlobalFrame()
Definition: mainFrame.c:593
char * Extra_FileNameGenericAppend(char *pBase, char *pSuffix)
void Map_SuperLibFree ( Map_SuperLib_t p)

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

Synopsis [Deallocates the supergate library.]

Description []

SideEffects []

SeeAlso []

Definition at line 167 of file mapperLib.c.

168 {
169  if ( p == NULL ) return;
170  if ( p->pGenlib )
171  {
172  if ( p->pGenlib != Abc_FrameReadLibGen() )
174  p->pGenlib = NULL;
175  }
176  if ( p->tTableC )
178  if ( p->tTable )
183  ABC_FREE( p->ppSupers );
184  ABC_FREE( p->pName );
185  ABC_FREE( p );
186 }
ABC_DLL void * Abc_FrameReadLibGen()
Definition: mainFrame.c:56
void Mio_LibraryDelete(Mio_Library_t *pLib)
DECLARATIONS ///.
Definition: mioUtils.c:48
void Extra_MmFixedStop(Extra_MmFixed_t *p)
Map_Super_t ** ppSupers
Definition: mapperInt.h:179
Mio_Library_t * pGenlib
Definition: mapperInt.h:169
Extra_MmFixed_t * mmSupers
Definition: mapperInt.h:195
Map_HashTable_t * tTable
Definition: mapperInt.h:181
Extra_MmFixed_t * mmEntries
Definition: mapperInt.h:196
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Map_SuperTableFree(Map_HashTable_t *p)
Definition: mapperTable.c:74
Map_HashTable_t * tTableC
Definition: mapperInt.h:180
Extra_MmFlex_t * mmForms
Definition: mapperInt.h:197
void Extra_MmFlexStop(Extra_MmFlex_t *p)