VPR-6.0

vpr/SRC/base/CheckOptions.c

Go to the documentation of this file.
00001 #include <assert.h>
00002 #include "util.h"
00003 #include "vpr_types.h"
00004 #include "globals.h"
00005 #include "OptionTokens.h"
00006 #include "ReadOptions.h"
00007 #include "read_xml_arch_file.h"
00008 #include "SetupVPR.h"
00009 
00010 /** Checks that options don't conflict and that 
00011  * options aren't specified that may conflict. 
00012  */
00013 void
00014 CheckOptions(INP t_options Options,
00015              INP boolean TimingEnabled)
00016 {
00017     boolean TimingPlacer;
00018     boolean TimingRouter;
00019         boolean default_flow;
00020 
00021         default_flow = (Options.Count[OT_ROUTE] == 0 && Options.Count[OT_PLACE] == 0 && Options.Count[OT_PACK] == 0 && Options.Count[OT_TIMING_ANALYZE_ONLY_WITH_NET_DELAY] == 0);
00022     const struct s_TokenPair *Cur;
00023     enum e_OptionBaseToken Yes;
00024 
00025     /* Check that all filenames were given */
00026         if((NULL == Options.CircuitName) ||
00027        (NULL == Options.ArchFile))
00028         {
00029             printf(ERRTAG "Not enough args. Need at least 'vpr "
00030                    "<archfile> <circuit_name>'\n");
00031             exit(1);
00032         }
00033 
00034     /* Check that options aren't over specified */
00035     Cur = OptionBaseTokenList;
00036     while(Cur->Str)
00037         {
00038             if(Options.Count[Cur->Enum] > 1)
00039                 {
00040                     printf(ERRTAG "Parameter '%s' was specified more than "
00041                            "once on command line.\n", Cur->Str);
00042                     exit(1);
00043                 }
00044             ++Cur;
00045         }
00046 
00047         /* Todo: Add in checks for packer   */
00048 
00049     /* Check for conflicting parameters and determine if placer and 
00050      * router are on. */
00051     
00052     if(Options.Count[OT_TIMING_ANALYZE_ONLY_WITH_NET_DELAY] && (Options.Count[OT_PACK] || Options.Count[OT_PLACE] || Options.Count[OT_ROUTE]))
00053         {
00054             printf(ERRTAG "'cluster'/'route'/'place', and "
00055                    "'timing_analysis_only_with_net_delay' are mutually "
00056                    "exclusive flags\n");
00057             exit(1);
00058         }
00059 
00060     /* If placing and timing is enabled, default to a timing placer */
00061     TimingPlacer = ((Options.Count[OT_PLACE] || default_flow) && TimingEnabled);
00062     if(Options.Count[OT_PLACE_ALGORITHM] > 0)
00063         {
00064             if((PATH_TIMING_DRIVEN_PLACE != Options.PlaceAlgorithm) &&
00065                (NET_TIMING_DRIVEN_PLACE != Options.PlaceAlgorithm))
00066                 {
00067                     /* Turn off the timing placer if they request a different placer */
00068                     TimingPlacer = FALSE;
00069                 }
00070         }
00071 
00072     /* If routing and timing is enabled, default to a timing router */
00073     TimingRouter = ((Options.Count[OT_ROUTE] || default_flow) && TimingEnabled);
00074     if(Options.Count[OT_ROUTER_ALGORITHM] > 0)
00075         {
00076             if(TIMING_DRIVEN != Options.RouterAlgorithm)
00077                 {
00078                     /* Turn off the timing router if they request a different router */
00079                     TimingRouter = FALSE;
00080                 }
00081         }
00082 
00083     Yes = OT_BASE_UNKNOWN;
00084     if(Options.Count[OT_SEED] > 0)
00085         {
00086             Yes = OT_SEED;
00087         }
00088     if(Options.Count[OT_INNER_NUM] > 0)
00089         {
00090             Yes = OT_INNER_NUM;
00091         }
00092     if(Options.Count[OT_INIT_T] > 0)
00093         {
00094             Yes = OT_INIT_T;
00095         }
00096     if(Options.Count[OT_ALPHA_T] > 0)
00097         {
00098             Yes = OT_ALPHA_T;
00099         }
00100     if(Options.Count[OT_EXIT_T] > 0)
00101         {
00102             Yes = OT_EXIT_T;
00103         }
00104     if(Options.Count[OT_FIX_PINS] > 0)
00105         {
00106             Yes = OT_FIX_PINS;
00107         }
00108     if(Options.Count[OT_PLACE_ALGORITHM] > 0)
00109         {
00110             Yes = OT_PLACE_ALGORITHM;
00111         }
00112     if(Options.Count[OT_PLACE_COST_TYPE] > 0)
00113         {
00114             Yes = OT_PLACE_COST_TYPE;
00115         }
00116     if(Options.Count[OT_PLACE_COST_EXP] > 0)
00117         {
00118             Yes = OT_PLACE_COST_EXP;
00119         }
00120     if(Options.Count[OT_PLACE_CHAN_WIDTH] > 0)
00121         {
00122             Yes = OT_PLACE_CHAN_WIDTH;
00123         }
00124     if(Options.Count[OT_NUM_REGIONS] > 0)
00125         {
00126             Yes = OT_NUM_REGIONS;
00127         }
00128     if(Options.Count[OT_ENABLE_TIMING_COMPUTATIONS] > 0)
00129         {
00130             Yes = OT_ENABLE_TIMING_COMPUTATIONS;
00131         }
00132     if(Options.Count[OT_BLOCK_DIST] > 0)
00133         {
00134             Yes = OT_BLOCK_DIST;
00135         }
00136     /* Make sure if place is off none of those options were given */
00137     if((Options.Count[OT_PLACE] == 0) && !default_flow && (Yes < OT_BASE_UNKNOWN))
00138         {
00139             Cur = OptionBaseTokenList;
00140             while(Cur->Str)
00141                 {
00142                     if(Yes == Cur->Enum)
00143                         {
00144                             printf(ERRTAG
00145                                    "Option '%s' is not allowed when placement is "
00146                                    "not run.\n", Cur->Str);
00147                             exit(1);
00148                         }
00149                     ++Cur;
00150                 }
00151         }
00152 
00153     Yes = OT_BASE_UNKNOWN;
00154     if(Options.Count[OT_TIMING_TRADEOFF] > 0)
00155         {
00156             Yes = OT_TIMING_TRADEOFF;
00157         }
00158     if(Options.Count[OT_RECOMPUTE_CRIT_ITER] > 0)
00159         {
00160             Yes = OT_RECOMPUTE_CRIT_ITER;
00161         }
00162     if(Options.Count[OT_INNER_LOOP_RECOMPUTE_DIVIDER] > 0)
00163         {
00164             Yes = OT_INNER_LOOP_RECOMPUTE_DIVIDER;
00165         }
00166     if(Options.Count[OT_TD_PLACE_EXP_FIRST] > 0)
00167         {
00168             Yes = OT_TD_PLACE_EXP_FIRST;
00169         }
00170     if(Options.Count[OT_TD_PLACE_EXP_LAST] > 0)
00171         {
00172             Yes = OT_TD_PLACE_EXP_LAST;
00173         }
00174     /* Make sure if place is off none of those options were given */
00175     if((FALSE == TimingPlacer) && (Yes < OT_BASE_UNKNOWN))
00176         {
00177             Cur = OptionBaseTokenList;
00178             while(Cur->Str)
00179                 {
00180                     if(Yes == Cur->Enum)
00181                         {
00182                             printf(ERRTAG
00183                                    "Option '%s' is not allowed when timing placement is "
00184                                    "not used.\n", Cur->Str);
00185                             exit(1);
00186                         }
00187                     ++Cur;
00188                 }
00189         }
00190 
00191     Yes = OT_BASE_UNKNOWN;
00192     if(Options.Count[OT_ROUTE_TYPE] > 0)
00193         {
00194             Yes = OT_ROUTE_TYPE;
00195         }
00196     if(Options.Count[OT_ROUTE_CHAN_WIDTH] > 0)
00197         {
00198             Yes = OT_ROUTE_CHAN_WIDTH;
00199         }
00200     if(Options.Count[OT_ROUTER_ALGORITHM] > 0)
00201         {
00202             Yes = OT_ROUTER_ALGORITHM;
00203         }
00204     if(Options.Count[OT_MAX_ROUTER_ITERATIONS] > 0)
00205         {
00206             Yes = OT_MAX_ROUTER_ITERATIONS;
00207         }
00208     if(Options.Count[OT_INITIAL_PRES_FAC] > 0)
00209         {
00210             Yes = OT_INITIAL_PRES_FAC;
00211         }
00212     if(Options.Count[OT_FIRST_ITER_PRES_FAC] > 0)
00213         {
00214             Yes = OT_FIRST_ITER_PRES_FAC;
00215         }
00216     if(Options.Count[OT_PRES_FAC_MULT] > 0)
00217         {
00218             Yes = OT_PRES_FAC_MULT;
00219         }
00220     if(Options.Count[OT_ACC_FAC] > 0)
00221         {
00222             Yes = OT_ACC_FAC;
00223         }
00224     if(Options.Count[OT_BB_FACTOR] > 0)
00225         {
00226             Yes = OT_BB_FACTOR;
00227         }
00228     if(Options.Count[OT_BASE_COST_TYPE] > 0)
00229         {
00230             Yes = OT_BASE_COST_TYPE;
00231         }
00232     if(Options.Count[OT_BEND_COST] > 0)
00233         {
00234             Yes = OT_BEND_COST;
00235         }
00236     if(Options.Count[OT_BASE_COST_TYPE] > 0)
00237         {
00238             Yes = OT_BASE_COST_TYPE;
00239         }
00240     if(Options.Count[OT_ASTAR_FAC] > 0)
00241         {
00242             Yes = OT_ASTAR_FAC;
00243         }
00244     Yes = OT_BASE_UNKNOWN;
00245     if(Options.Count[OT_MAX_CRITICALITY] > 0)
00246         {
00247             Yes = OT_MAX_CRITICALITY;
00248         }
00249     if(Options.Count[OT_CRITICALITY_EXP] > 0)
00250         {
00251             Yes = OT_CRITICALITY_EXP;
00252         }
00253     /* Make sure if timing router is off none of those options were given */
00254     if((FALSE == TimingRouter) && (Yes < OT_BASE_UNKNOWN))
00255         {
00256             Cur = OptionBaseTokenList;
00257             while(Cur->Str)
00258                 {
00259                     if(Yes == Cur->Enum)
00260                         {
00261                             printf(ERRTAG
00262                                    "Option '%s' is not allowed when timing router is "
00263                                    "not used.\n", Cur->Str);
00264                             exit(1);
00265                         }
00266                     ++Cur;
00267                 }
00268         }
00269 }