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

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int Fpga_CommandReadLibrary (Abc_Frame_t *pAbc, int argc, char **argv)
 DECLARATIONS ///. More...
 
static int Fpga_CommandPrintLibrary (Abc_Frame_t *pAbc, int argc, char **argv)
 
void Fpga_Init (Abc_Frame_t *pAbc)
 FUNCTION DEFINITIONS ///. More...
 
void Fpga_End (Abc_Frame_t *pAbc)
 
void Fpga_SetSimpleLutLib (int nLutSize)
 

Function Documentation

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

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

Synopsis [Command procedure to read LUT libraries.]

Description []

SideEffects []

SeeAlso []

Definition at line 194 of file fpga.c.

195 {
196  FILE * pOut, * pErr;
197  Abc_Ntk_t * pNet;
198  int fVerbose;
199  int c;
200 
201  pNet = Abc_FrameReadNtk(pAbc);
202  pOut = Abc_FrameReadOut(pAbc);
203  pErr = Abc_FrameReadErr(pAbc);
204 
205  // set the defaults
206  fVerbose = 1;
208  while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF )
209  {
210  switch (c)
211  {
212  case 'v':
213  fVerbose ^= 1;
214  break;
215  case 'h':
216  goto usage;
217  break;
218  default:
219  goto usage;
220  }
221  }
222 
223 
224  if ( argc != globalUtilOptind )
225  {
226  goto usage;
227  }
228 
229  // set the new network
231  return 0;
232 
233 usage:
234  fprintf( pErr, "usage: print_lut [-vh]\n");
235  fprintf( pErr, "\t print the current LUT library\n" );
236  fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
237  fprintf( pErr, "\t-h : print the command usage\n");
238  return 1; /* error exit */
239 }
void Fpga_LutLibPrint(Fpga_LutLib_t *pLutLib)
Definition: fpgaLib.c:205
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 Fpga_CommandReadLibrary ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

DECLARATIONS ///.

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

FileName [fpga.c]

PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]

Synopsis [Command file for the FPGA package.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 2.0. Started - August 18, 2004.]

Revision [

Id:
fpga.c,v 1.4 2004/10/28 17:36:07 alanmi Exp

]

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

Synopsis [Command procedure to read LUT libraries.]

Description []

SideEffects []

SeeAlso []

Definition at line 101 of file fpga.c.

102 {
103  FILE * pFile;
104  FILE * pOut, * pErr;
105  Fpga_LutLib_t * pLib;
106  Abc_Ntk_t * pNet;
107  char * FileName;
108  int fVerbose;
109  int c;
110 
111  pNet = Abc_FrameReadNtk(pAbc);
112  pOut = Abc_FrameReadOut(pAbc);
113  pErr = Abc_FrameReadErr(pAbc);
114 
115  // set the defaults
116  fVerbose = 1;
118  while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF )
119  {
120  switch (c)
121  {
122  case 'v':
123  fVerbose ^= 1;
124  break;
125  case 'h':
126  goto usage;
127  break;
128  default:
129  goto usage;
130  }
131  }
132 
133 
134  if ( argc != globalUtilOptind + 1 )
135  {
136  goto usage;
137  }
138 
139  // get the input file name
140  FileName = argv[globalUtilOptind];
141  if ( (pFile = fopen( FileName, "r" )) == NULL )
142  {
143  fprintf( pErr, "Cannot open input file \"%s\". ", FileName );
144  if ( (FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) )
145  fprintf( pErr, "Did you mean \"%s\"?", FileName );
146  fprintf( pErr, "\n" );
147  return 1;
148  }
149  fclose( pFile );
150 
151  // set the new network
152  pLib = Fpga_LutLibRead( FileName, fVerbose );
153  if ( pLib == NULL )
154  {
155  fprintf( pErr, "Reading LUT library has failed.\n" );
156  goto usage;
157  }
158  // replace the current library
160  Abc_FrameSetLibLut( pLib );
161  return 0;
162 
163 usage:
164  fprintf( pErr, "usage: read_lut [-vh]\n");
165  fprintf( pErr, "\t read the LUT library from the file\n" );
166  fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
167  fprintf( pErr, "\t-h : print the command usage\n");
168  fprintf( pErr, "\t \n");
169  fprintf( pErr, "\t File format for a LUT library:\n");
170  fprintf( pErr, "\t (the default library is shown)\n");
171  fprintf( pErr, "\t \n");
172  fprintf( pErr, "\t # The area/delay of k-variable LUTs:\n");
173  fprintf( pErr, "\t # k area delay\n");
174  fprintf( pErr, "\t 1 1 1\n");
175  fprintf( pErr, "\t 2 2 2\n");
176  fprintf( pErr, "\t 3 4 3\n");
177  fprintf( pErr, "\t 4 8 4\n");
178  fprintf( pErr, "\t 5 16 5\n");
179  fprintf( pErr, "\t 6 32 6\n");
180  return 1; /* error exit */
181 }
Fpga_LutLib_t * Fpga_LutLibRead(char *FileName, int fVerbose)
Definition: fpgaLib.c:58
ABC_DLL void Abc_FrameSetLibLut(void *pLib)
Definition: mainFrame.c:80
char * Extra_FileGetSimilarName(char *pFileNameWrong, char *pS1, char *pS2, char *pS3, char *pS4, char *pS5)
Definition: extraUtilFile.c:71
void Fpga_LutLibFree(Fpga_LutLib_t *p)
Definition: fpgaLib.c:185
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
void Fpga_End ( Abc_Frame_t pAbc)

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

Synopsis [Package ending procedure.]

Description []

SideEffects []

SeeAlso []

Definition at line 84 of file fpga.c.

85 {
87 }
void Fpga_LutLibFree(Fpga_LutLib_t *p)
Definition: fpgaLib.c:185
ABC_DLL void * Abc_FrameReadLibLut()
Definition: mainFrame.c:54
void Fpga_Init ( Abc_Frame_t pAbc)

FUNCTION DEFINITIONS ///.

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

Synopsis [Package initialization procedure.]

Description []

SideEffects []

SeeAlso []

Definition at line 59 of file fpga.c.

60 {
61  // set the default library
62  //Fpga_LutLib_t s_LutLib = { "lutlib", 6, 0, {0,1,2,4,8,16,32}, {{0},{1},{2},{3},{4},{5},{6}} };
63 // Fpga_LutLib_t s_LutLib = { "lutlib", 5, 0, {0,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1}} };
64  Fpga_LutLib_t s_LutLib = { "lutlib", 4, 0, {0,1,1,1,1}, {{0},{1},{1},{1},{1}} };
65  //Fpga_LutLib_t s_LutLib = { "lutlib", 3, 0, {0,1,1,1}, {{0},{1},{1},{1}} };
66 
67  Abc_FrameSetLibLut( Fpga_LutLibDup(&s_LutLib) );
68 
69  Cmd_CommandAdd( pAbc, "FPGA mapping", "read_lut", Fpga_CommandReadLibrary, 0 );
70  Cmd_CommandAdd( pAbc, "FPGA mapping", "print_lut", Fpga_CommandPrintLibrary, 0 );
71 }
ABC_DLL void Abc_FrameSetLibLut(void *pLib)
Definition: mainFrame.c:80
Fpga_LutLib_t * Fpga_LutLibDup(Fpga_LutLib_t *p)
Definition: fpgaLib.c:165
void Cmd_CommandAdd(Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
Definition: cmdApi.c:63
static int Fpga_CommandPrintLibrary(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: fpga.c:194
static ABC_NAMESPACE_IMPL_START int Fpga_CommandReadLibrary(Abc_Frame_t *pAbc, int argc, char **argv)
DECLARATIONS ///.
Definition: fpga.c:101
void Fpga_SetSimpleLutLib ( int  nLutSize)

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

Synopsis [Sets simple LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 252 of file fpga.c.

253 {
254  Fpga_LutLib_t s_LutLib10= { "lutlib",10, 0, {0,1,1,1,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1},{1},{1},{1}} };
255  Fpga_LutLib_t s_LutLib9 = { "lutlib", 9, 0, {0,1,1,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1},{1},{1}} };
256  Fpga_LutLib_t s_LutLib8 = { "lutlib", 8, 0, {0,1,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1},{1}} };
257  Fpga_LutLib_t s_LutLib7 = { "lutlib", 7, 0, {0,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1}} };
258  Fpga_LutLib_t s_LutLib6 = { "lutlib", 6, 0, {0,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1}} };
259  Fpga_LutLib_t s_LutLib5 = { "lutlib", 5, 0, {0,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1}} };
260  Fpga_LutLib_t s_LutLib4 = { "lutlib", 4, 0, {0,1,1,1,1}, {{0},{1},{1},{1},{1}} };
261  Fpga_LutLib_t s_LutLib3 = { "lutlib", 3, 0, {0,1,1,1}, {{0},{1},{1},{1}} };
262  Fpga_LutLib_t * pLutLib;
263  assert( nLutSize >= 3 && nLutSize <= 10 );
264  switch ( nLutSize )
265  {
266  case 3: pLutLib = &s_LutLib3; break;
267  case 4: pLutLib = &s_LutLib4; break;
268  case 5: pLutLib = &s_LutLib5; break;
269  case 6: pLutLib = &s_LutLib6; break;
270  case 7: pLutLib = &s_LutLib7; break;
271  case 8: pLutLib = &s_LutLib8; break;
272  case 9: pLutLib = &s_LutLib9; break;
273  case 10: pLutLib = &s_LutLib10; break;
274  default: pLutLib = NULL; break;
275  }
276  if ( pLutLib == NULL )
277  return;
280 }
ABC_DLL void Abc_FrameSetLibLut(void *pLib)
Definition: mainFrame.c:80
Fpga_LutLib_t * Fpga_LutLibDup(Fpga_LutLib_t *p)
Definition: fpgaLib.c:165
void Fpga_LutLibFree(Fpga_LutLib_t *p)
Definition: fpgaLib.c:185
#define assert(ex)
Definition: util_old.h:213
ABC_DLL void * Abc_FrameReadLibLut()
Definition: mainFrame.c:54