abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ifCom.c File Reference
#include "if.h"
#include "base/main/main.h"

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int If_CommandReadLut (Abc_Frame_t *pAbc, int argc, char **argv)
 DECLARATIONS ///. More...
 
static int If_CommandPrintLut (Abc_Frame_t *pAbc, int argc, char **argv)
 
static int If_CommandReadBox (Abc_Frame_t *pAbc, int argc, char **argv)
 
static int If_CommandPrintBox (Abc_Frame_t *pAbc, int argc, char **argv)
 
void If_Init (Abc_Frame_t *pAbc)
 FUNCTION DEFINITIONS ///. More...
 
void If_End (Abc_Frame_t *pAbc)
 

Function Documentation

int If_CommandPrintBox ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

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

Synopsis [Command procedure to read LUT libraries.]

Description []

SideEffects []

SeeAlso []

Definition at line 321 of file ifCom.c.

322 {
323  FILE * pOut, * pErr;
324  Abc_Ntk_t * pNet;
325  int fVerbose;
326  int c;
327 
328  pNet = Abc_FrameReadNtk(pAbc);
329  pOut = Abc_FrameReadOut(pAbc);
330  pErr = Abc_FrameReadErr(pAbc);
331 
332  // set the defaults
333  fVerbose = 1;
335  while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF )
336  {
337  switch (c)
338  {
339  case 'v':
340  fVerbose ^= 1;
341  break;
342  case 'h':
343  goto usage;
344  break;
345  default:
346  goto usage;
347  }
348  }
349 
350  if ( argc != globalUtilOptind )
351  goto usage;
352 
353  // set the new network
355  return 0;
356 
357 usage:
358  fprintf( pErr, "\nusage: print_box [-vh]\n");
359  fprintf( pErr, "\t print the current box library\n" );
360  fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
361  fprintf( pErr, "\t-h : print the command usage\n");
362  return 1; /* error exit */
363 }
void If_LibBoxPrint(FILE *pFile, If_LibBox_t *p)
Definition: ifLibBox.c:334
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
ABC_DLL void * Abc_FrameReadLibBox()
Definition: mainFrame.c:55
int globalUtilOptind
Definition: extraUtilUtil.c:45
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition: mainFrame.c:282
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
ABC_DLL FILE * Abc_FrameReadErr(Abc_Frame_t *p)
Definition: mainFrame.c:330
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
Definition: mainFrame.c:314
int If_CommandPrintLut ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

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

Synopsis [Command procedure to read LUT libraries.]

Description []

SideEffects []

SeeAlso []

Definition at line 182 of file ifCom.c.

183 {
184  FILE * pOut, * pErr;
185  Abc_Ntk_t * pNet;
186  int fVerbose;
187  int c;
188 
189  pNet = Abc_FrameReadNtk(pAbc);
190  pOut = Abc_FrameReadOut(pAbc);
191  pErr = Abc_FrameReadErr(pAbc);
192 
193  // set the defaults
194  fVerbose = 1;
196  while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF )
197  {
198  switch (c)
199  {
200  case 'v':
201  fVerbose ^= 1;
202  break;
203  case 'h':
204  goto usage;
205  break;
206  default:
207  goto usage;
208  }
209  }
210 
211  if ( argc != globalUtilOptind )
212  goto usage;
213 
214  // set the new network
216  return 0;
217 
218 usage:
219  fprintf( pErr, "\nusage: print_lut [-vh]\n");
220  fprintf( pErr, "\t print the current LUT library\n" );
221  fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
222  fprintf( pErr, "\t-h : print the command usage\n");
223  return 1; /* error exit */
224 }
void If_LibLutPrint(If_LibLut_t *pLutLib)
Definition: ifLibLut.c:193
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
int globalUtilOptind
Definition: extraUtilUtil.c:45
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition: mainFrame.c:282
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
ABC_DLL FILE * Abc_FrameReadErr(Abc_Frame_t *p)
Definition: mainFrame.c:330
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
Definition: mainFrame.c:314
ABC_DLL void * Abc_FrameReadLibLut()
Definition: mainFrame.c:54
int If_CommandReadBox ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 237 of file ifCom.c.

238 {
239  FILE * pFile;
240  FILE * pOut, * pErr;
241  If_LibBox_t * pLib;
242  Abc_Ntk_t * pNet;
243  char * FileName;
244  int fExtended;
245  int fVerbose;
246  int c;
247 
248  pNet = Abc_FrameReadNtk(pAbc);
249  pOut = Abc_FrameReadOut(pAbc);
250  pErr = Abc_FrameReadErr(pAbc);
251 
252  // set the defaults
253  fExtended = 0;
254  fVerbose = 1;
256  while ( (c = Extra_UtilGetopt(argc, argv, "evh")) != EOF )
257  {
258  switch (c)
259  {
260  case 'e':
261  fExtended ^= 1;
262  break;
263  case 'v':
264  fVerbose ^= 1;
265  break;
266  case 'h':
267  goto usage;
268  break;
269  default:
270  goto usage;
271  }
272  }
273 
274  if ( argc != globalUtilOptind + 1 )
275  goto usage;
276 
277  // get the input file name
278  FileName = argv[globalUtilOptind];
279  if ( (pFile = fopen( FileName, "r" )) == NULL )
280  {
281  fprintf( pErr, "Cannot open input file \"%s\". ", FileName );
282  if ( (FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) )
283  fprintf( pErr, "Did you mean \"%s\"?", FileName );
284  fprintf( pErr, "\n" );
285  return 1;
286  }
287  fclose( pFile );
288 
289  // set the new network
290  pLib = fExtended ? If_LibBoxRead2( FileName ) : If_LibBoxRead( FileName );
291  if ( pLib == NULL )
292  {
293  fprintf( pErr, "Reading box library has failed.\n" );
294  goto usage;
295  }
296  // replace the current library
298  Abc_FrameSetLibBox( pLib );
299  return 0;
300 
301 usage:
302  fprintf( pErr, "\nusage: read_box [-evh]\n");
303  fprintf( pErr, "\t read the box library from the file\n" );
304  fprintf( pErr, "\t-e : toggles reading extended format [default = %s]\n", (fExtended? "yes" : "no") );
305  fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
306  fprintf( pErr, "\t-h : print the command usage\n");
307  return 1; /* error exit */
308 }
void If_LibBoxFree(If_LibBox_t *p)
Definition: ifLibBox.c:98
char * Extra_FileGetSimilarName(char *pFileNameWrong, char *pS1, char *pS2, char *pS3, char *pS4, char *pS5)
Definition: extraUtilFile.c:71
If_LibBox_t * If_LibBoxRead2(char *pFileName)
Definition: ifLibBox.c:155
If_LibBox_t * If_LibBoxRead(char *pFileName)
Definition: ifLibBox.c:273
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
ABC_DLL void * Abc_FrameReadLibBox()
Definition: mainFrame.c:55
int globalUtilOptind
Definition: extraUtilUtil.c:45
ABC_DLL void Abc_FrameSetLibBox(void *pLib)
Definition: mainFrame.c:81
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition: mainFrame.c:282
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
ABC_DLL FILE * Abc_FrameReadErr(Abc_Frame_t *p)
Definition: mainFrame.c:330
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
Definition: mainFrame.c:314
int If_CommandReadLut ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

DECLARATIONS ///.

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

FileName [ifCom.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [FPGA mapping based on priority cuts.]

Synopsis [Command handlers.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - November 21, 2006.]

Revision [

Id:
ifCom.c,v 1.00 2006/11/21 00:00:00 alanmi Exp

]

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

Synopsis [Command procedure to read LUT libraries.]

Description []

SideEffects []

SeeAlso []

Definition at line 92 of file ifCom.c.

93 {
94  FILE * pFile;
95  FILE * pOut, * pErr;
96  If_LibLut_t * pLib;
97  Abc_Ntk_t * pNet;
98  char * FileName;
99  int fVerbose;
100  int c;
101 
102  pNet = Abc_FrameReadNtk(pAbc);
103  pOut = Abc_FrameReadOut(pAbc);
104  pErr = Abc_FrameReadErr(pAbc);
105 
106  // set the defaults
107  fVerbose = 1;
109  while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF )
110  {
111  switch (c)
112  {
113  case 'v':
114  fVerbose ^= 1;
115  break;
116  case 'h':
117  goto usage;
118  break;
119  default:
120  goto usage;
121  }
122  }
123 
124  if ( argc != globalUtilOptind + 1 )
125  goto usage;
126 
127  // get the input file name
128  FileName = argv[globalUtilOptind];
129  if ( (pFile = fopen( FileName, "r" )) == NULL )
130  {
131  fprintf( pErr, "Cannot open input file \"%s\". ", FileName );
132  if ( (FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) )
133  fprintf( pErr, "Did you mean \"%s\"?", FileName );
134  fprintf( pErr, "\n" );
135  return 1;
136  }
137  fclose( pFile );
138 
139  // set the new network
140  pLib = If_LibLutRead( FileName );
141  if ( pLib == NULL )
142  {
143  fprintf( pErr, "Reading LUT library has failed.\n" );
144  goto usage;
145  }
146  // replace the current library
148  Abc_FrameSetLibLut( pLib );
149  return 0;
150 
151 usage:
152  fprintf( pErr, "\nusage: read_lut [-vh]\n");
153  fprintf( pErr, "\t read the LUT library from the file\n" );
154  fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
155  fprintf( pErr, "\t-h : print the command usage\n");
156  fprintf( pErr, "\t \n");
157  fprintf( pErr, "\t File format for a LUT library:\n");
158  fprintf( pErr, "\t (the default library is shown)\n");
159  fprintf( pErr, "\t \n");
160  fprintf( pErr, "\t # The area/delay of k-variable LUTs:\n");
161  fprintf( pErr, "\t # k area delay\n");
162  fprintf( pErr, "\t 1 1 1\n");
163  fprintf( pErr, "\t 2 2 2\n");
164  fprintf( pErr, "\t 3 4 3\n");
165  fprintf( pErr, "\t 4 8 4\n");
166  fprintf( pErr, "\t 5 16 5\n");
167  fprintf( pErr, "\t 6 32 6\n");
168  return 1; /* error exit */
169 }
ABC_DLL void Abc_FrameSetLibLut(void *pLib)
Definition: mainFrame.c:80
If_LibLut_t * If_LibLutRead(char *FileName)
FUNCTION DEFINITIONS ///.
Definition: ifLibLut.c:47
char * Extra_FileGetSimilarName(char *pFileNameWrong, char *pS1, char *pS2, char *pS3, char *pS4, char *pS5)
Definition: extraUtilFile.c:71
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
int globalUtilOptind
Definition: extraUtilUtil.c:45
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition: mainFrame.c:282
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
void If_LibLutFree(If_LibLut_t *pLutLib)
Definition: ifLibLut.c:173
ABC_DLL FILE * Abc_FrameReadErr(Abc_Frame_t *p)
Definition: mainFrame.c:330
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
Definition: mainFrame.c:314
ABC_DLL void * Abc_FrameReadLibLut()
Definition: mainFrame.c:54
void If_End ( Abc_Frame_t pAbc)

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

Synopsis [Package ending procedure.]

Description []

SideEffects []

SeeAlso []

Definition at line 75 of file ifCom.c.

76 {
79 }
void If_LibBoxFree(If_LibBox_t *p)
Definition: ifLibBox.c:98
ABC_DLL void * Abc_FrameReadLibBox()
Definition: mainFrame.c:55
void If_LibLutFree(If_LibLut_t *pLutLib)
Definition: ifLibLut.c:173
ABC_DLL void * Abc_FrameReadLibLut()
Definition: mainFrame.c:54
void If_Init ( Abc_Frame_t pAbc)

FUNCTION DEFINITIONS ///.

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

Synopsis [Package initialization procedure.]

Description []

SideEffects []

SeeAlso []

Definition at line 51 of file ifCom.c.

52 {
53  // set the default library
54  If_LibLut_t s_LutLib = { "lutlib", 4, 0, {0,1,1,1,1}, {{0},{1},{1},{1},{1}} };
55  Abc_FrameSetLibLut( If_LibLutDup(&s_LutLib) );
56 
57  Cmd_CommandAdd( pAbc, "FPGA mapping", "read_lut", If_CommandReadLut, 0 );
58  Cmd_CommandAdd( pAbc, "FPGA mapping", "print_lut", If_CommandPrintLut, 0 );
59 
60  Cmd_CommandAdd( pAbc, "FPGA mapping", "read_box", If_CommandReadBox, 0 );
61  Cmd_CommandAdd( pAbc, "FPGA mapping", "print_box", If_CommandPrintBox, 0 );
62 }
static int If_CommandPrintBox(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: ifCom.c:321
static int If_CommandReadBox(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: ifCom.c:237
ABC_DLL void Abc_FrameSetLibLut(void *pLib)
Definition: mainFrame.c:80
void Cmd_CommandAdd(Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
Definition: cmdApi.c:63
static int If_CommandPrintLut(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: ifCom.c:182
If_LibLut_t * If_LibLutDup(If_LibLut_t *p)
Definition: ifLibLut.c:153
static ABC_NAMESPACE_IMPL_START int If_CommandReadLut(Abc_Frame_t *pAbc, int argc, char **argv)
DECLARATIONS ///.
Definition: ifCom.c:92