src/map/super/super.c File Reference

#include "superInt.h"
#include "mainInt.h"
#include "mio.h"
Include dependency graph for super.c:

Go to the source code of this file.

Functions

static int Super_CommandSupergates (Abc_Frame_t *pAbc, int argc, char **argv)
static int Super_CommandSupergatesAnd (Abc_Frame_t *pAbc, int argc, char **argv)
void Super_Init (Abc_Frame_t *pAbc)
void Super_End ()

Function Documentation

int Super_CommandSupergates ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
) [static]

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

FileName [super.c]

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

Synopsis [Pre-computation of supergates.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - August 18, 2003.]

Revision [

Id
super.c,v 1.6 2004/10/30 20:51:11 satrajit Exp

] DECLARATIONS ///

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 147 of file super.c.

00148 {
00149     FILE * pFile;
00150     FILE * pOut, * pErr;
00151     Mio_Library_t * pLib;
00152     char * FileName, * ExcludeFile;
00153     float DelayLimit;
00154     float AreaLimit;
00155     bool fSkipInvs;
00156     bool fWriteOldFormat; 
00157     int nVarsMax, nLevels, TimeLimit;
00158     int fVerbose;
00159     int c;
00160 
00161     pOut = Abc_FrameReadOut(pAbc);
00162     pErr = Abc_FrameReadErr(pAbc);
00163 
00164     // set the defaults
00165     nVarsMax   = 5;
00166     nLevels    = 3;
00167     DelayLimit = 3.5;
00168     AreaLimit  = 9;
00169     TimeLimit  = 10;
00170     fSkipInvs  = 1;
00171     fVerbose   = 0;
00172     fWriteOldFormat = 0;
00173     ExcludeFile = 0;
00174 
00175     Extra_UtilGetoptReset();
00176     while ( (c = Extra_UtilGetopt(argc, argv, "eiltdasovh")) != EOF ) 
00177     {
00178         switch (c) 
00179         {
00180             case 'e':
00181                 ExcludeFile = argv[globalUtilOptind];
00182                 if ( ExcludeFile == 0 )
00183                     goto usage;
00184                 globalUtilOptind++;
00185                 break;
00186             case 'i':
00187                 nVarsMax = atoi(argv[globalUtilOptind]);
00188                 globalUtilOptind++;
00189                 if ( nVarsMax < 0 ) 
00190                     goto usage;
00191                 break;
00192             case 'l':
00193                 nLevels = atoi(argv[globalUtilOptind]);
00194                 globalUtilOptind++;
00195                 if ( nLevels < 0 ) 
00196                     goto usage;
00197                 break;
00198             case 't':
00199                 TimeLimit = atoi(argv[globalUtilOptind]);
00200                 globalUtilOptind++;
00201                 if ( TimeLimit < 0 ) 
00202                     goto usage;
00203                 break;
00204                         case 'd':
00205                                 DelayLimit = (float)atof(argv[globalUtilOptind]);
00206                                 globalUtilOptind++;
00207                                 if ( DelayLimit <= 0.0 ) 
00208                                         goto usage;
00209                                 break;
00210                         case 'a':
00211                                 AreaLimit = (float)atof(argv[globalUtilOptind]);
00212                                 globalUtilOptind++;
00213                                 if ( AreaLimit <= 0.0 ) 
00214                                         goto usage;
00215                                 break;
00216             case 's':
00217                 fSkipInvs ^= 1;
00218                 break;
00219             case 'o':
00220                 fWriteOldFormat ^= 1;
00221                 break;
00222             case 'v':
00223                 fVerbose ^= 1;
00224                 break;
00225             case 'h':
00226                 goto usage;
00227                 break;
00228             default:
00229                 goto usage;
00230         }
00231     }
00232 
00233 
00234     if ( argc != globalUtilOptind + 1 )
00235     {
00236         fprintf( pErr, "The GENLIB library file should be given on the command line.\n" );
00237         goto usage;
00238     }
00239 
00240     if ( nVarsMax < 2 || nVarsMax > 6 )
00241     {
00242         fprintf( pErr, "The max number of variables (%d) should be more than 1 and less than 7.\n", nVarsMax );
00243         goto usage;
00244     }
00245 
00246     // get the input file name
00247     FileName = argv[globalUtilOptind];
00248     if ( (pFile = Io_FileOpen( FileName, "open_path", "r", 0 )) == NULL )
00249 //    if ( (pFile = fopen( FileName, "r" )) == NULL )
00250     {
00251         fprintf( pErr, "Cannot open input file \"%s\". ", FileName );
00252         if (( FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL ) ))
00253             fprintf( pErr, "Did you mean \"%s\"?", FileName );
00254         fprintf( pErr, "\n" );
00255         return 1;
00256     }
00257     fclose( pFile );
00258 
00259     // set the new network
00260     pLib = Mio_LibraryRead( pAbc, FileName, ExcludeFile, fVerbose );
00261     if ( pLib == NULL )
00262     {
00263         fprintf( pErr, "Reading library has failed.\n" );
00264         goto usage;
00265     }
00266 
00267     // compute the gates
00268     Super_Precompute( pLib, nVarsMax, nLevels, DelayLimit, AreaLimit, TimeLimit, fSkipInvs, fWriteOldFormat, fVerbose );
00269 
00270     // delete the library
00271     Mio_LibraryDelete( pLib );
00272     return 0;
00273 
00274 usage:
00275     fprintf( pErr, "usage: super [-i num] [-l num] [-d float] [-a float] [-t num] [-sovh] <genlib_file>\n");
00276     fprintf( pErr, "\t         precomputes the supergates for the given GENLIB library\n" );  
00277     fprintf( pErr, "\t-i num   : the max number of supergate inputs [default = %d]\n", nVarsMax );
00278     fprintf( pErr, "\t-l num   : the max number of levels of gates [default = %d]\n", nLevels );
00279         fprintf( pErr, "\t-d float : the max delay of the supergates [default = %.2f]\n", DelayLimit );
00280         fprintf( pErr, "\t-a float : the max area of the supergates [default = %.2f]\n", AreaLimit );
00281     fprintf( pErr, "\t-t num   : the approximate runtime limit in seconds [default = %d]\n", TimeLimit );
00282     fprintf( pErr, "\t-s       : toggle the use of inverters at the inputs [default = %s]\n", (fSkipInvs? "no": "yes") );
00283     fprintf( pErr, "\t-o       : toggle dumping the supergate library in old format [default = %s]\n", (fWriteOldFormat? "yes": "no") );
00284     fprintf( pErr, "\t-e file  : file contains list of genlib gates to exclude\n" );
00285     fprintf( pErr, "\t-v       : enable verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
00286     fprintf( pErr, "\t-h       : print the help message\n");
00287     fprintf( pErr, "\n");
00288     fprintf( pErr, "\tHere is a piece of advice on precomputing supergate libraries:\n");
00289     fprintf( pErr, "\t\n");
00290     fprintf( pErr, "\tStart with the number of inputs equal to 5 (-i 5), the number of \n");
00291     fprintf( pErr, "\tlevels equal to 3 (-l 3), the delay equal to 2-3 delays of inverter, \n");
00292     fprintf( pErr, "\tthe area equal to 3-4 areas of two input NAND, and runtime limit equal \n");
00293     fprintf( pErr, "\tto 10 seconds (-t 10). Run precomputation and learn from the result.\n");
00294     fprintf( pErr, "\tDetermine what parameter is most constraining and try to increase \n");
00295     fprintf( pErr, "\tthe value of that parameter. The goal is to have a well-balanced\n");
00296     fprintf( pErr, "\tset of constraints and the resulting supergate library containing\n");
00297     fprintf( pErr, "\tapproximately 100K-200K supergates. Typically, it is better to increase\n");
00298     fprintf( pErr, "\tdelay limit rather than area limit, because having large-area supergates\n");
00299     fprintf( pErr, "\tmay result in a considerable increase in area.\n");
00300     fprintf( pErr, "\t\n");
00301     fprintf( pErr, "\tNote that a good supergate library for experiments typically can be \n");
00302     fprintf( pErr, "\tprecomputed in 30 sec. Increasing the runtime limit makes sense when\n");
00303     fprintf( pErr, "\tother parameters are well-balanced and it is needed to enumerate more\n");
00304     fprintf( pErr, "\tchoices to have a good result. In the end, to compute the final library\n");
00305     fprintf( pErr, "\tthe runtime can be set to 300 sec to ensure the ultimate quality.\n");
00306     fprintf( pErr, "\tIn some cases, the runtime has to be reduced if the supergate library\n");
00307     fprintf( pErr, "\tcontains too many supergates (> 500K).\n");
00308     fprintf( pErr, "\t\n");
00309     fprintf( pErr, "\tWhen precomputing libraries of 6 inputs (-i 6), start with even more \n");
00310     fprintf( pErr, "\trestricted parameters and gradually increase them until the goal is met.\n");
00311     fprintf( pErr, "\t\n");
00312     return 1;       /* error exit */
00313 }

int Super_CommandSupergatesAnd ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
) [static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 79 of file super.c.

00080 {
00081     FILE * pOut, * pErr;
00082     int nVarsMax, nLevels;
00083     int fVerbose;
00084     int c;
00085 
00086     pOut = Abc_FrameReadOut(pAbc);
00087     pErr = Abc_FrameReadErr(pAbc);
00088 
00089     // set the defaults
00090     nVarsMax = 4;
00091     nLevels  = 3;
00092     fVerbose = 0;
00093     Extra_UtilGetoptReset();
00094     while ( (c = Extra_UtilGetopt(argc, argv, "ilvh")) != EOF ) 
00095     {
00096         switch (c) 
00097         {
00098             case 'i':
00099                 nVarsMax = atoi(argv[globalUtilOptind]);
00100                 globalUtilOptind++;
00101                 if ( nVarsMax < 0 ) 
00102                     goto usage;
00103                 break;
00104             case 'l':
00105                 nLevels = atoi(argv[globalUtilOptind]);
00106                 globalUtilOptind++;
00107                 if ( nLevels < 0 ) 
00108                     goto usage;
00109                 break;
00110             case 'v':
00111                 fVerbose ^= 1;
00112                 break;
00113             case 'h':
00114                 goto usage;
00115                 break;
00116             default:
00117                 goto usage;
00118         }
00119     }
00120 
00121     Super2_Precompute( nVarsMax, nLevels, fVerbose );
00122 
00123     return 0;
00124 
00125 usage:
00126     fprintf( pErr, "usage: super2 [-i num] [-l num] [-vh]\n");
00127     fprintf( pErr, "\t         precomputes the supergates composed of AND2s and INVs\n" );  
00128     fprintf( pErr, "\t-i num : the max number of inputs to the supergate [default = %d]\n", nVarsMax );
00129     fprintf( pErr, "\t-l num : the max number of logic levels of gates [default = %d]\n", nLevels );
00130     fprintf( pErr, "\t-v     : enable verbose output\n");
00131     fprintf( pErr, "\t-h     : print the help message\n");
00132     return 1;       /* error exit */
00133 }

void Super_End (  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 62 of file super.c.

00063 {
00064 }

void Super_Init ( Abc_Frame_t pAbc  ) 

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file super.c.

00046 {
00047     Cmd_CommandAdd( pAbc, "SC mapping",  "super",   Super_CommandSupergates,    0 ); 
00048     Cmd_CommandAdd( pAbc, "SC mapping",  "super2",  Super_CommandSupergatesAnd, 0 ); 
00049 }


Generated on Tue Jan 5 12:19:08 2010 for abc70930 by  doxygen 1.6.1