ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
mapperLib.c
Go to the documentation of this file.
1
18//#define _BSD_SOURCE
19
20#ifndef WIN32
21#ifndef _DEFAULT_SOURCE
22#define _DEFAULT_SOURCE
23#endif
24#include <unistd.h>
25#endif
26
27#include "mapperInt.h"
28#include "map/super/super.h"
30
32
33
37
41
61Map_SuperLib_t * Map_SuperLibCreate( Mio_Library_t * pGenlib, Vec_Str_t * vStr, char * pFileName, char * pExcludeFile, int fAlgorithm, int fVerbose )
62{
64 abctime clk;
65
66 // start the supergate library
68 memset( p, 0, sizeof(Map_SuperLib_t) );
69 p->pName = Abc_UtilStrsav(pFileName);
70 p->fVerbose = fVerbose;
71 p->mmSupers = Extra_MmFixedStart( sizeof(Map_Super_t) );
72 p->mmEntries = Extra_MmFixedStart( sizeof(Map_HashEntry_t) );
73 p->mmForms = Extra_MmFlexStart();
75
76 // start the hash table
77 p->tTableC = Map_SuperTableCreate( p );
78 p->tTable = Map_SuperTableCreate( p );
79
80 // read the supergate library from file
81clk = Abc_Clock();
82 if ( vStr != NULL )
83 {
84 // read the supergate library from file
85 int Status = Map_LibraryReadFileTreeStr( p, pGenlib, vStr, pFileName );
86 if ( Status == 0 )
87 {
89 return NULL;
90 }
91 // prepare the info about the library
92 Status = Map_LibraryDeriveGateInfo( p, NULL );
93 if ( Status == 0 )
94 {
96 return NULL;
97 }
98 assert( p->nVarsMax > 0 );
99 }
100 else if ( fAlgorithm )
101 {
102 if ( !Map_LibraryReadTree( p, pGenlib, pFileName, pExcludeFile ) )
103 {
105 return NULL;
106 }
107 }
108 else
109 {
110 if ( pExcludeFile != 0 )
111 {
113 printf ("Error: Exclude file support not present for old format. Stop.\n");
114 return NULL;
115 }
116 if ( !Map_LibraryRead( p, pFileName ) )
117 {
119 return NULL;
120 }
121 }
122 assert( p->nVarsMax > 0 );
123
124 // report the stats
125 if ( fVerbose )
126 {
127 printf( "Loaded %d unique %d-input supergates from \"%s\". ",
128 p->nSupersReal, p->nVarsMax, pFileName );
129 ABC_PRT( "Time", Abc_Clock() - clk );
130 }
131
132 // assign the interver parameters
133 p->pGateInv = Mio_LibraryReadInv( p->pGenlib );
134 p->tDelayInv.Rise = Mio_LibraryReadDelayInvRise( p->pGenlib );
135 p->tDelayInv.Fall = Mio_LibraryReadDelayInvFall( p->pGenlib );
136 p->tDelayInv.Worst = MAP_MAX( p->tDelayInv.Rise, p->tDelayInv.Fall );
137 p->AreaInv = Mio_LibraryReadAreaInv( p->pGenlib );
138 p->AreaBuf = Mio_LibraryReadAreaBuf( p->pGenlib );
139
140 // assign the interver supergate
141 p->pSuperInv = (Map_Super_t *)Extra_MmFixedEntryFetch( p->mmSupers );
142 memset( p->pSuperInv, 0, sizeof(Map_Super_t) );
143 p->pSuperInv->Num = -1;
144 p->pSuperInv->nGates = 1;
145 p->pSuperInv->nFanins = 1;
146 p->pSuperInv->nFanLimit = 10;
147 p->pSuperInv->pFanins[0] = p->ppSupers[0];
148 p->pSuperInv->pRoot = p->pGateInv;
149 p->pSuperInv->Area = p->AreaInv;
150 p->pSuperInv->tDelayMax = p->tDelayInv;
151 p->pSuperInv->tDelaysR[0].Rise = MAP_NO_VAR;
152 p->pSuperInv->tDelaysR[0].Fall = p->tDelayInv.Rise;
153 p->pSuperInv->tDelaysF[0].Rise = p->tDelayInv.Fall;
154 p->pSuperInv->tDelaysF[0].Fall = MAP_NO_VAR;
155 return p;
156}
157
158
171{
172 if ( p == NULL ) return;
173 if ( p->pGenlib )
174 {
175 if ( p->pGenlib != Abc_FrameReadLibGen() )
176 Mio_LibraryDelete( p->pGenlib );
177 p->pGenlib = NULL;
178 }
179 if ( p->tTableC )
180 Map_SuperTableFree( p->tTableC );
181 if ( p->tTable )
182 Map_SuperTableFree( p->tTable );
183 Extra_MmFixedStop( p->mmSupers );
184 Extra_MmFixedStop( p->mmEntries );
185 Extra_MmFlexStop( p->mmForms );
186 ABC_FREE( p->ppSupers );
187 ABC_FREE( p->pName );
188 ABC_FREE( p );
189}
190
203{
204 Map_SuperLib_t * pLibSuper;
205 Vec_Str_t * vStr;
206 char * pFileName;
207 if ( pLib == NULL )
208 return 0;
209
210 // compute supergates
211 vStr = Super_PrecomputeStr( pLib, 5, 1, 100000000, 10000000, 10000000, 100, 1, 0 );
212 if ( vStr == NULL )
213 return 0;
214
215 // create supergate library
216 pFileName = Extra_FileNameGenericAppend( Mio_LibraryReadName(pLib), ".super" );
217 pLibSuper = Map_SuperLibCreate( pLib, vStr, pFileName, NULL, 1, 0 );
218 Vec_StrFree( vStr );
219
220 // replace the library
222 Abc_FrameSetLibSuper( pLibSuper );
223 return 1;
224}
225
238{
240 char * pFileName;
241 if ( pLib == NULL )
242 return 0;
243 // compute supergates
244 pFileName = Extra_FileNameGenericAppend(Mio_LibraryReadName(pLib), ".super");
245 Super_Precompute( pLib, 5, 1, 100000000, 10000000, 10000000, 100, 1, 0, pFileName );
246 // assuming that it terminated successfully
247 if ( Cmd_CommandExecute( pAbc, pFileName ) )
248 {
249 fprintf( stdout, "Cannot execute command \"read_super %s\".\n", pFileName );
250 return 0;
251 }
252 return 1;
253}
254
258
259
261
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
#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
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
Definition abcapis.h:38
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
Definition mainFrame.c:643
ABC_DLL void Abc_FrameSetLibSuper(void *pLib)
Definition mainFrame.c:97
ABC_DLL void * Abc_FrameReadLibGen()
Definition mainFrame.c:59
ABC_DLL void * Abc_FrameReadLibSuper()
Definition mainFrame.c:61
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
Definition cmdApi.c:193
Cube * p
Definition exorList.c:222
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
void Extra_MmFixedStop(Extra_MmFixed_t *p)
void Extra_MmFlexStop(Extra_MmFlex_t *p)
Extra_MmFixed_t * Extra_MmFixedStart(int nEntrySize)
char * Extra_FileNameGenericAppend(char *pBase, char *pSuffix)
Extra_MmFlex_t * Extra_MmFlexStart()
#define MAP_MAX(a, b)
Definition mapperInt.h:58
int Map_LibraryRead(Map_SuperLib_t *p, char *pFileName)
FUNCTION DEFINITIONS ///.
Definition mapperSuper.c:50
#define MAP_NO_VAR
Definition mapperInt.h:54
int Map_LibraryReadTree(Map_SuperLib_t *pLib, Mio_Library_t *pGenlib, char *pFileName, char *pExcludeFile)
Definition mapperTree.c:525
void Map_SuperTableFree(Map_HashTable_t *p)
Definition mapperTable.c:74
int Map_LibraryDeriveGateInfo(Map_SuperLib_t *pLib, st__table *tExcludeGate)
Definition mapperTree.c:586
int Map_LibraryReadFileTreeStr(Map_SuperLib_t *pLib, Mio_Library_t *pGenlib, Vec_Str_t *vStr, char *pFileName)
Definition mapperTree.c:391
Map_HashTable_t * Map_SuperTableCreate(Map_SuperLib_t *pLib)
FUNCTION DEFINITIONS ///.
Definition mapperTable.c:48
int Map_SuperLibDeriveFromGenlib(Mio_Library_t *pLib, int fVerbose)
Definition mapperLib.c:202
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:61
int Map_SuperLibDeriveFromGenlib2(Mio_Library_t *pLib, int fVerbose)
Definition mapperLib.c:237
void Map_SuperLibFree(Map_SuperLib_t *p)
Definition mapperLib.c:170
struct Map_SuperStruct_t_ Map_Super_t
Definition mapper.h:45
struct Map_SuperLibStruct_t_ Map_SuperLib_t
Definition mapper.h:46
struct Map_HashEntryStruct_t_ Map_HashEntry_t
Definition mapper.h:48
void Map_MappingSetupTruthTables(unsigned uTruths[][2])
float Mio_LibraryReadDelayInvFall(Mio_Library_t *pLib)
Definition mioApi.c:58
float Mio_LibraryReadAreaBuf(Mio_Library_t *pLib)
Definition mioApi.c:66
char * Mio_LibraryReadName(Mio_Library_t *pLib)
DECLARATIONS ///.
Definition mioApi.c:43
struct Mio_LibraryStruct_t_ Mio_Library_t
Definition mio.h:42
void Mio_LibraryDelete(Mio_Library_t *pLib)
DECLARATIONS ///.
Definition mioUtils.c:51
float Mio_LibraryReadAreaInv(Mio_Library_t *pLib)
Definition mioApi.c:65
float Mio_LibraryReadDelayInvRise(Mio_Library_t *pLib)
Definition mioApi.c:57
Mio_Gate_t * Mio_LibraryReadInv(Mio_Library_t *pLib)
Definition mioApi.c:50
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
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:175
#define assert(ex)
Definition util_old.h:213
char * memset()