summaryrefslogtreecommitdiffstats
path: root/src/map/mapper/mapper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/mapper/mapper.c')
-rw-r--r--src/map/mapper/mapper.c176
1 files changed, 176 insertions, 0 deletions
diff --git a/src/map/mapper/mapper.c b/src/map/mapper/mapper.c
new file mode 100644
index 00000000..546186a2
--- /dev/null
+++ b/src/map/mapper/mapper.c
@@ -0,0 +1,176 @@
+/**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 $]
+
+***********************************************************************/
+
+#include "abc.h"
+#include "mainInt.h"
+#include "mio.h"
+#include "mapperInt.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static int Map_CommandReadLibrary ( Abc_Frame_t * pAbc, int argc, char **argv );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Map_Init( Abc_Frame_t * pAbc )
+{
+ Cmd_CommandAdd( pAbc, "SC mapping", "read_super", Map_CommandReadLibrary, 0 );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Map_End()
+{
+// Map_SuperLibFree( s_pSuperLib );
+ Map_SuperLibFree( Abc_FrameReadLibSuper(Abc_FrameGetGlobalFrame()) );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Map_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
+{
+ FILE * pFile;
+ FILE * pOut, * pErr;
+ Map_SuperLib_t * pLib;
+ Abc_Ntk_t * pNet;
+ char * FileName, * ExcludeFile;
+ int fVerbose;
+ int fAlgorithm;
+ int c;
+
+ pNet = Abc_FrameReadNet(pAbc);
+ pOut = Abc_FrameReadOut(pAbc);
+ pErr = Abc_FrameReadErr(pAbc);
+
+ // set the defaults
+ fVerbose = 1;
+ fAlgorithm = 1;
+ ExcludeFile = 0;
+ util_getopt_reset();
+ while ( (c = util_getopt(argc, argv, "eovh")) != EOF )
+ {
+ switch (c)
+ {
+ case 'e':
+ ExcludeFile = argv[util_optind];
+ if ( ExcludeFile == 0 )
+ goto usage;
+ util_optind++;
+ break;
+ case 'o':
+ fAlgorithm ^= 1;
+ break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ break;
+ default:
+ goto usage;
+ }
+ }
+
+
+ if ( argc != util_optind + 1 )
+ {
+ goto usage;
+ }
+
+ // get the input file name
+ FileName = argv[util_optind];
+// if ( (pFile = Io_FileOpen( FileName, "open_path", "r" )) == NULL )
+ if ( (pFile = fopen( FileName, "r" )) == NULL )
+ {
+ fprintf( pErr, "Cannot open input file \"%s\". ", FileName );
+ if ( FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL ) )
+ fprintf( pErr, "Did you mean \"%s\"?", FileName );
+ fprintf( pErr, "\n" );
+ return 1;
+ }
+ fclose( pFile );
+
+ // set the new network
+ pLib = Map_SuperLibCreate( FileName, ExcludeFile, fAlgorithm, fVerbose );
+ if ( pLib == NULL )
+ {
+ fprintf( pErr, "Reading supergate library has failed.\n" );
+ goto usage;
+ }
+ // replace the current library
+// Map_SuperLibFree( s_pSuperLib );
+// s_pSuperLib = pLib;
+ Map_SuperLibFree( Abc_FrameReadLibSuper(Abc_FrameGetGlobalFrame()) );
+ Abc_FrameSetLibSuper( Abc_FrameGetGlobalFrame(), pLib );
+ // replace the current genlib library
+// if ( s_pLib ) Mio_LibraryDelete( s_pLib );
+// s_pLib = s_pSuperLib->pGenlib;
+ Mio_LibraryDelete( Abc_FrameReadLibGen(Abc_FrameGetGlobalFrame()) );
+ Abc_FrameSetLibGen( Abc_FrameGetGlobalFrame(), pLib->pGenlib );
+ return 0;
+
+usage:
+ fprintf( pErr, "\nusage: read_super [-ovh]\n");
+ fprintf( pErr, "\t read the supergate library from the file\n" );
+ fprintf( pErr, "\t-e file : file contains list of genlib gates to exclude\n" );
+ fprintf( pErr, "\t-o : toggles the use of old file format [default = %s]\n", (fAlgorithm? "new" : "old") );
+ fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
+ fprintf( pErr, "\t-h : print the command usage\n");
+ return 1; /* error exit */
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+