abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mapper.c File Reference
#include "base/abc/abc.h"
#include "base/main/mainInt.h"
#include "map/mio/mio.h"
#include "mapperInt.h"

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int Map_CommandReadLibrary (Abc_Frame_t *pAbc, int argc, char **argv)
 DECLARATIONS ///. More...
 
void Map_Init (Abc_Frame_t *pAbc)
 FUNCTION DEFINITIONS ///. More...
 
void Map_End (Abc_Frame_t *pAbc)
 

Function Documentation

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

DECLARATIONS ///.

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

FileName [mapper.c]

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

Synopsis [Command file for the mapper package.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 2.0. Started - June 1, 2004.]

Revision [

Id:
mapper.c,v 1.7 2005/01/23 06:59:42 alanmi Exp

]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 82 of file mapper.c.

83 {
84  FILE * pFile;
85  FILE * pOut, * pErr;
86  Map_SuperLib_t * pLib;
87  Abc_Ntk_t * pNet;
88  char * FileName, * ExcludeFile;
89  int fVerbose;
90  int fAlgorithm;
91  int c;
92 
93  pNet = Abc_FrameReadNtk(pAbc);
94  pOut = Abc_FrameReadOut(pAbc);
95  pErr = Abc_FrameReadErr(pAbc);
96 
97  // set the defaults
98  fVerbose = 1;
99  fAlgorithm = 1;
100  ExcludeFile = 0;
102  while ( (c = Extra_UtilGetopt(argc, argv, "eovh")) != EOF )
103  {
104  switch (c)
105  {
106  case 'e':
107  ExcludeFile = argv[globalUtilOptind];
108  if ( ExcludeFile == 0 )
109  goto usage;
111  break;
112  case 'o':
113  fAlgorithm ^= 1;
114  break;
115  case 'v':
116  fVerbose ^= 1;
117  break;
118  case 'h':
119  goto usage;
120  break;
121  default:
122  goto usage;
123  }
124  }
125 
126 
127  if ( argc != globalUtilOptind + 1 )
128  {
129  goto usage;
130  }
131 
132  // get the input file name
133  FileName = argv[globalUtilOptind];
134  if ( (pFile = Io_FileOpen( FileName, "open_path", "r", 0 )) == NULL )
135 // if ( (pFile = fopen( FileName, "r" )) == NULL )
136  {
137  fprintf( pErr, "Cannot open input file \"%s\". ", FileName );
138  if (( FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) )
139  fprintf( pErr, "Did you mean \"%s\"?", FileName );
140  fprintf( pErr, "\n" );
141  return 1;
142  }
143  fclose( pFile );
144 
145  if ( Abc_FrameReadLibGen() == NULL )
146  {
147  fprintf( pErr, "Genlib library should be read in first..\n" );
148  return 1;
149  }
150 
151  // set the new network
152  pLib = Map_SuperLibCreate( (Mio_Library_t *)Abc_FrameReadLibGen(), NULL, FileName, ExcludeFile, fAlgorithm, fVerbose );
153  if ( pLib == NULL )
154  {
155  fprintf( pErr, "Reading supergate library has failed.\n" );
156  return 1;
157  }
158  // replace the current library
159 // Map_SuperLibFree( s_pSuperLib );
160 // s_pSuperLib = pLib;
162  Abc_FrameSetLibSuper( pLib );
163  // replace the current genlib library
164 // Mio_LibraryDelete( (Mio_Library_t *)Abc_FrameReadLibGen() );
165 // Abc_FrameSetLibGen( (Mio_Library_t *)pLib->pGenlib );
166  return 0;
167 
168 usage:
169  fprintf( pErr, "\nusage: read_super [-ovh]\n");
170  fprintf( pErr, "\t read the supergate library from the file\n" );
171  fprintf( pErr, "\t-e file : file contains list of genlib gates to exclude\n" );
172  fprintf( pErr, "\t-o : toggles the use of old file format [default = %s]\n", (fAlgorithm? "new" : "old") );
173  fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
174  fprintf( pErr, "\t-h : print the command usage\n");
175  return 1; /* error exit */
176 }
FILE * Io_FileOpen(const char *FileName, const char *PathVar, const char *Mode, int fVerbose)
Definition: ioUtil.c:819
ABC_DLL void Abc_FrameSetLibSuper(void *pLib)
Definition: mainFrame.c:84
void Map_SuperLibFree(Map_SuperLib_t *p)
Definition: mapperLib.c:167
ABC_DLL void * Abc_FrameReadLibGen()
Definition: mainFrame.c:56
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 void * Abc_FrameReadLibSuper()
Definition: mainFrame.c:58
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
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
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
void Map_End ( Abc_Frame_t pAbc)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 64 of file mapper.c.

65 {
66 // Map_SuperLibFree( s_pSuperLib );
68 }
void Map_SuperLibFree(Map_SuperLib_t *p)
Definition: mapperLib.c:167
ABC_DLL void * Abc_FrameReadLibSuper()
Definition: mainFrame.c:58
void Map_Init ( Abc_Frame_t pAbc)

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file mapper.c.

49 {
50  Cmd_CommandAdd( pAbc, "SC mapping", "read_super", Map_CommandReadLibrary, 0 );
51 }
void Cmd_CommandAdd(Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
Definition: cmdApi.c:63
static ABC_NAMESPACE_IMPL_START int Map_CommandReadLibrary(Abc_Frame_t *pAbc, int argc, char **argv)
DECLARATIONS ///.
Definition: mapper.c:82