ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ifCom.c
Go to the documentation of this file.
1
20
21#include "if.h"
22#include "base/main/main.h"
23
25
26
30
31static int If_CommandReadLut ( Abc_Frame_t * pAbc, int argc, char **argv );
32static int If_CommandPrintLut( Abc_Frame_t * pAbc, int argc, char **argv );
33static int If_CommandReadBox ( Abc_Frame_t * pAbc, int argc, char **argv );
34static int If_CommandPrintBox( Abc_Frame_t * pAbc, int argc, char **argv );
35static int If_CommandWriteBox( Abc_Frame_t * pAbc, int argc, char **argv );
36static int If_CommandPrintTim( Abc_Frame_t * pAbc, int argc, char **argv );
37
41
53void If_Init( Abc_Frame_t * pAbc )
54{
55 // set the default library
56 If_LibLut_t s_LutLib = { "lutlib", 4, 0, {0,1,1,1,1}, {{0},{1},{1},{1},{1}} };
57 Abc_FrameSetLibLut( If_LibLutDup(&s_LutLib) );
58
59 Cmd_CommandAdd( pAbc, "FPGA mapping", "read_lut", If_CommandReadLut, 0 );
60 Cmd_CommandAdd( pAbc, "FPGA mapping", "print_lut", If_CommandPrintLut, 0 );
61
62 Cmd_CommandAdd( pAbc, "FPGA mapping", "read_box", If_CommandReadBox, 0 );
63 Cmd_CommandAdd( pAbc, "FPGA mapping", "print_box", If_CommandPrintBox, 0 );
64 Cmd_CommandAdd( pAbc, "FPGA mapping", "write_box", If_CommandWriteBox, 0 );
65 Cmd_CommandAdd( pAbc, "FPGA mapping", "print_tim", If_CommandPrintTim, 0 );
66}
67
84
96int If_CommandReadLut( Abc_Frame_t * pAbc, int argc, char **argv )
97{
98 FILE * pFile;
99 FILE * pOut, * pErr;
100 If_LibLut_t * pLib;
101 Abc_Ntk_t * pNet;
102 char * FileName;
103 int fVerbose;
104 int c;
105
106 pNet = Abc_FrameReadNtk(pAbc);
107 pOut = Abc_FrameReadOut(pAbc);
108 pErr = Abc_FrameReadErr(pAbc);
109
110 // set the defaults
111 fVerbose = 1;
113 while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF )
114 {
115 switch (c)
116 {
117 case 'v':
118 fVerbose ^= 1;
119 break;
120 case 'h':
121 goto usage;
122 break;
123 default:
124 goto usage;
125 }
126 }
127
128 if ( argc != globalUtilOptind + 1 )
129 goto usage;
130
131 // get the input file name
132 FileName = argv[globalUtilOptind];
133 if ( (pFile = fopen( FileName, "r" )) == NULL )
134 {
135 fprintf( pErr, "Cannot open input file \"%s\". ", FileName );
136 if ( (FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) )
137 fprintf( pErr, "Did you mean \"%s\"?", FileName );
138 fprintf( pErr, "\n" );
139 return 1;
140 }
141 fclose( pFile );
142
143 // set the new network
144 pLib = If_LibLutRead( FileName );
145 if ( pLib == NULL )
146 {
147 fprintf( pErr, "Reading LUT library has failed.\n" );
148 goto usage;
149 }
150 // replace the current library
152 Abc_FrameSetLibLut( pLib );
153 return 0;
154
155usage:
156 fprintf( pErr, "\nusage: read_lut [-vh]\n");
157 fprintf( pErr, "\t read the LUT library from the file\n" );
158 fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
159 fprintf( pErr, "\t-h : print the command usage\n");
160 fprintf( pErr, "\t \n");
161 fprintf( pErr, "\t File format for a LUT library:\n");
162 fprintf( pErr, "\t (the default library is shown)\n");
163 fprintf( pErr, "\t \n");
164 fprintf( pErr, "\t # The area/delay of k-variable LUTs:\n");
165 fprintf( pErr, "\t # k area delay\n");
166 fprintf( pErr, "\t 1 1 1\n");
167 fprintf( pErr, "\t 2 2 2\n");
168 fprintf( pErr, "\t 3 4 3\n");
169 fprintf( pErr, "\t 4 8 4\n");
170 fprintf( pErr, "\t 5 16 5\n");
171 fprintf( pErr, "\t 6 32 6\n");
172 return 1; /* error exit */
173}
174
186int If_CommandPrintLut( Abc_Frame_t * pAbc, int argc, char **argv )
187{
188 FILE * pOut, * pErr;
189 Abc_Ntk_t * pNet;
190 int fVerbose;
191 int c;
192
193 pNet = Abc_FrameReadNtk(pAbc);
194 pOut = Abc_FrameReadOut(pAbc);
195 pErr = Abc_FrameReadErr(pAbc);
196
197 // set the defaults
198 fVerbose = 1;
200 while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF )
201 {
202 switch (c)
203 {
204 case 'v':
205 fVerbose ^= 1;
206 break;
207 case 'h':
208 goto usage;
209 break;
210 default:
211 goto usage;
212 }
213 }
214
215 if ( argc != globalUtilOptind )
216 goto usage;
217
218 // set the new network
220 return 0;
221
222usage:
223 fprintf( pErr, "\nusage: print_lut [-vh]\n");
224 fprintf( pErr, "\t print the current LUT library\n" );
225 fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
226 fprintf( pErr, "\t-h : print the command usage\n");
227 return 1; /* error exit */
228}
229
241int If_CommandReadBox( Abc_Frame_t * pAbc, int argc, char **argv )
242{
243 FILE * pFile;
244 FILE * pOut, * pErr;
245 If_LibBox_t * pLib;
246 Abc_Ntk_t * pNet;
247 char * FileName;
248 int fExtended;
249 int fVerbose;
250 int c;
251
252 pNet = Abc_FrameReadNtk(pAbc);
253 pOut = Abc_FrameReadOut(pAbc);
254 pErr = Abc_FrameReadErr(pAbc);
255
256 // set the defaults
257 fExtended = 0;
258 fVerbose = 1;
260 while ( (c = Extra_UtilGetopt(argc, argv, "evh")) != EOF )
261 {
262 switch (c)
263 {
264 case 'e':
265 fExtended ^= 1;
266 break;
267 case 'v':
268 fVerbose ^= 1;
269 break;
270 case 'h':
271 goto usage;
272 break;
273 default:
274 goto usage;
275 }
276 }
277
278 if ( argc != globalUtilOptind + 1 )
279 goto usage;
280
281 // get the input file name
282 FileName = argv[globalUtilOptind];
283 if ( (pFile = fopen( FileName, "r" )) == NULL )
284 {
285 fprintf( pErr, "Cannot open input file \"%s\". ", FileName );
286 if ( (FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) )
287 fprintf( pErr, "Did you mean \"%s\"?", FileName );
288 fprintf( pErr, "\n" );
289 return 1;
290 }
291 fclose( pFile );
292
293 // set the new network
294 pLib = fExtended ? If_LibBoxRead2( FileName ) : If_LibBoxRead( FileName );
295 if ( pLib == NULL )
296 {
297 fprintf( pErr, "Reading box library has failed.\n" );
298 goto usage;
299 }
300 // replace the current library
302 Abc_FrameSetLibBox( pLib );
303 return 0;
304
305usage:
306 fprintf( pErr, "\nusage: read_box [-evh]\n");
307 fprintf( pErr, "\t read the box library from the file\n" );
308 fprintf( pErr, "\t-e : toggles reading extended format [default = %s]\n", (fExtended? "yes" : "no") );
309 fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
310 fprintf( pErr, "\t-h : print the command usage\n");
311 return 1; /* error exit */
312}
313
325int If_CommandPrintBox( Abc_Frame_t * pAbc, int argc, char **argv )
326{
327 FILE * pOut, * pErr;
328 Abc_Ntk_t * pNet;
329 int fVerbose;
330 int c;
331
332 pNet = Abc_FrameReadNtk(pAbc);
333 pOut = Abc_FrameReadOut(pAbc);
334 pErr = Abc_FrameReadErr(pAbc);
335
336 // set the defaults
337 fVerbose = 1;
339 while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF )
340 {
341 switch (c)
342 {
343 case 'v':
344 fVerbose ^= 1;
345 break;
346 case 'h':
347 goto usage;
348 break;
349 default:
350 goto usage;
351 }
352 }
353
354 if ( argc != globalUtilOptind )
355 goto usage;
356
357 // set the new network
359 return 0;
360
361usage:
362 fprintf( pErr, "\nusage: print_box [-vh]\n");
363 fprintf( pErr, "\t print the current box library\n" );
364 fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
365 fprintf( pErr, "\t-h : print the command usage\n");
366 return 1; /* error exit */
367}
368
380int If_CommandWriteBox( Abc_Frame_t * pAbc, int argc, char **argv )
381{
382 FILE * pOut, * pErr;
383 Abc_Ntk_t * pNet;
384 int fVerbose;
385 int c;
386
387 pNet = Abc_FrameReadNtk(pAbc);
388 pOut = Abc_FrameReadOut(pAbc);
389 pErr = Abc_FrameReadErr(pAbc);
390
391 fVerbose = 1;
393 while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF )
394 {
395 switch (c)
396 {
397 case 'v':
398 fVerbose ^= 1;
399 break;
400 case 'h':
401 goto usage;
402 break;
403 default:
404 goto usage;
405 }
406 }
407
408 if ( argc != globalUtilOptind+1 )
409 goto usage;
410
412 return 0;
413
414usage:
415 fprintf( pErr, "\nusage: write_box [-vh] <file>\n");
416 fprintf( pErr, "\t write the current box library into a file\n" );
417 fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
418 fprintf( pErr, "\t-h : print the command usage\n");
419 fprintf( pErr, "\t<file> : the output file name\n");
420 return 1; /* error exit */
421}
422
423
435int If_CommandPrintTim( Abc_Frame_t * pAbc, int argc, char **argv )
436{
437 Gia_Man_t * pGia = Abc_FrameReadGia(pAbc);
438 int c, fVerbose = 0;
440 while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF )
441 {
442 switch (c)
443 {
444 case 'v':
445 fVerbose ^= 1;
446 break;
447 case 'h':
448 goto usage;
449 break;
450 default:
451 goto usage;
452 }
453 }
454 if ( pGia == NULL )
455 {
456 Abc_Print( -1, "There is no AIG in the &-space.\n" );
457 return 1;
458 }
459 if ( pGia->pManTime == NULL )
460 {
461 Abc_Print( -1, "The current AIG does not have a timing manager.\n" );
462 return 1;
463 }
464 Tim_ManPrint( (Tim_Man_t *)pGia->pManTime );
465 if ( fVerbose )
467 return 0;
468
469usage:
470 Abc_Print( -2, "\nusage: print_tim [-vh]\n");
471 Abc_Print( -2, "\t print the timing manager\n" );
472 Abc_Print( -2, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
473 Abc_Print( -2, "\t-h : print the command usage\n");
474 return 1; /* error exit */
475}
476
480
481
483
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
#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 void * Abc_FrameReadLibLut()
Definition mainFrame.c:57
ABC_DLL void Abc_FrameSetLibBox(void *pLib)
Definition mainFrame.c:94
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition mainFrame.c:327
ABC_DLL void * Abc_FrameReadLibBox()
Definition mainFrame.c:58
ABC_DLL Gia_Man_t * Abc_FrameReadGia(Abc_Frame_t *p)
Definition mainFrame.c:343
ABC_DLL FILE * Abc_FrameReadErr(Abc_Frame_t *p)
Definition mainFrame.c:375
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
Definition mainFrame.c:359
ABC_DLL void Abc_FrameSetLibLut(void *pLib)
Definition mainFrame.c:93
void Cmd_CommandAdd(Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
Definition cmdApi.c:63
int globalUtilOptind
char * Extra_FileGetSimilarName(char *pFileNameWrong, char *pS1, char *pS2, char *pS3, char *pS4, char *pS5)
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
ABC_DLL void Extra_UtilGetoptReset()
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
void If_Init(Abc_Frame_t *pAbc)
FUNCTION DEFINITIONS ///.
Definition ifCom.c:53
void If_End(Abc_Frame_t *pAbc)
Definition ifCom.c:79
struct If_LibBox_t_ If_LibBox_t
Definition if.h:83
If_LibBox_t * If_LibBoxRead2(char *pFileName)
Definition ifLibBox.c:160
void If_LibBoxPrint(FILE *pFile, If_LibBox_t *p)
Definition ifLibBox.c:339
void If_LibLutPrint(If_LibLut_t *pLutLib)
Definition ifLibLut.c:352
void If_LibBoxWrite(char *pFileName, If_LibBox_t *p)
Definition ifLibBox.c:356
If_LibBox_t * If_LibBoxRead(char *pFileName)
Definition ifLibBox.c:278
If_LibLut_t * If_LibLutRead(char *FileName)
Definition ifLibLut.c:202
struct If_LibLut_t_ If_LibLut_t
Definition if.h:82
void If_LibLutFree(If_LibLut_t *pLutLib)
Definition ifLibLut.c:332
void If_LibBoxFree(If_LibBox_t *p)
Definition ifLibBox.c:98
If_LibLut_t * If_LibLutDup(If_LibLut_t *p)
Definition ifLibLut.c:312
usage()
Definition main.c:626
void * pManTime
Definition gia.h:194
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition tim.h:92
void Tim_ManPrintBoxCopy(Tim_Man_t *p)
Definition timMan.c:619
void Tim_ManPrint(Tim_Man_t *p)
Definition timMan.c:526