ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
mapper.c
Go to the documentation of this file.
1
18
19#include "base/abc/abc.h"
20#include "base/main/mainInt.h"
21#include "map/mio/mio.h"
22#include "mapperInt.h"
23
25
26
30
31static int Map_CommandReadLibrary ( Abc_Frame_t * pAbc, int argc, char **argv );
32
36
48void Map_Init( Abc_Frame_t * pAbc )
49{
50 Cmd_CommandAdd( pAbc, "SC mapping", "read_super", Map_CommandReadLibrary, 0 );
51}
52
64void Map_End( Abc_Frame_t * pAbc )
65{
66// Map_SuperLibFree( s_pSuperLib );
68}
69
70
82int Map_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
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
168usage:
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}
177
178
182
183
185
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_FrameSetLibSuper(void *pLib)
Definition mainFrame.c:97
ABC_DLL void * Abc_FrameReadLibGen()
Definition mainFrame.c:59
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition mainFrame.c:327
ABC_DLL FILE * Abc_FrameReadErr(Abc_Frame_t *p)
Definition mainFrame.c:375
ABC_DLL void * Abc_FrameReadLibSuper()
Definition mainFrame.c:61
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
Definition mainFrame.c:359
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()
FILE * Io_FileOpen(const char *FileName, const char *PathVar, const char *Mode, int fVerbose)
Definition ioUtil.c:828
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
void Map_Init(Abc_Frame_t *pAbc)
FUNCTION DEFINITIONS ///.
Definition mapper.c:48
void Map_End(Abc_Frame_t *pAbc)
Definition mapper.c:64
struct Map_SuperLibStruct_t_ Map_SuperLib_t
Definition mapper.h:46
void Map_SuperLibFree(Map_SuperLib_t *p)
Definition mapperLib.c:170
struct Mio_LibraryStruct_t_ Mio_Library_t
Definition mio.h:42
usage()
Definition main.c:626