VPR-6.0

vpr/SRC/base/SetupVPR.c

Go to the documentation of this file.
00001 #include <assert.h>
00002 #include <string.h>
00003 #include "util.h"
00004 #include "vpr_types.h"
00005 #include "OptionTokens.h"
00006 #include "ReadOptions.h"
00007 #include "globals.h"
00008 #include "read_xml_arch_file.h"
00009 #include "SetupVPR.h"
00010 #include "pb_type_graph.h"
00011 
00012 static void SetupOperation(INP t_options Options,
00013                            OUTP enum e_operation *Operation);
00014 static void SetupPackerOpts(INP t_options Options, 
00015                                                         INP boolean TimingEnabled, 
00016                                                         INP t_arch Arch, 
00017                                                         INP char *net_file,
00018                                                         OUTP struct s_packer_opts *PackerOpts);
00019 static void SetupPlacerOpts(INP t_options Options,
00020                             INP boolean TimingEnabled,
00021                             OUTP struct s_placer_opts *PlacerOpts);
00022 static void SetupAnnealSched(INP t_options Options,
00023                              OUTP struct s_annealing_sched *AnnealSched);
00024 static void SetupRouterOpts(INP t_options Options,
00025                             INP boolean TimingEnabled,
00026                             OUTP struct s_router_opts *RouterOpts);
00027 static void SetupRoutingArch(INP t_arch Arch,
00028                              OUTP struct s_det_routing_arch *RoutingArch);
00029 static void SetupTiming(INP t_options Options,
00030                         INP t_arch Arch,
00031                         INP boolean TimingEnabled,
00032                         INP enum e_operation Operation,
00033                         INP struct s_placer_opts PlacerOpts,
00034                         INP struct s_router_opts RouterOpts,
00035                         OUTP t_timing_inf * Timing);
00036 static void SetupSwitches(INP t_arch Arch,
00037                           INOUTP struct s_det_routing_arch *RoutingArch,
00038                           INP struct s_switch_inf *ArchSwitches,
00039                           INP int NumArchSwitches);
00040 
00041 /** Sets VPR parameters and defaults. Does not do any error checking
00042  * as this should have been done by the various input checkers 
00043  */
00044 void
00045 SetupVPR(INP t_options Options,
00046          INP boolean TimingEnabled,
00047          OUTP struct s_file_name_opts *FileNameOpts,
00048          OUTP t_arch * Arch,
00049          OUTP enum e_operation *Operation,
00050          OUTP t_model ** user_models,
00051          OUTP t_model ** library_models,
00052          OUTP struct s_packer_opts *PackerOpts,
00053          OUTP struct s_placer_opts *PlacerOpts,
00054          OUTP struct s_annealing_sched *AnnealSched,
00055          OUTP struct s_router_opts *RouterOpts,
00056          OUTP struct s_det_routing_arch *RoutingArch,
00057          OUTP t_segment_inf ** Segments,
00058          OUTP t_timing_inf * Timing,
00059          OUTP boolean * ShowGraphics,
00060          OUTP int *GraphPause)
00061 {
00062         int i, j, len;
00063 
00064         
00065         /* init default filenames */
00066         if(Options.BlifFile == NULL) {
00067                 len = strlen(Options.CircuitName) + 6; /* circuit_name.blif/0*/
00068                 if(Options.OutFilePrefix != NULL) {
00069                         len += strlen(Options.OutFilePrefix);
00070                 }
00071                 Options.BlifFile = my_calloc(len,sizeof(char));
00072                 if(Options.OutFilePrefix == NULL) {
00073                         sprintf(Options.BlifFile, "%s.blif", Options.CircuitName);
00074                 } else {
00075                         sprintf(Options.BlifFile, "%s%s.blif", Options.OutFilePrefix, Options.CircuitName);
00076                 }
00077         }
00078         
00079         if(Options.NetFile == NULL) {
00080                 len = strlen(Options.CircuitName) + 5; /* circuit_name.net/0*/
00081                 if(Options.OutFilePrefix != NULL) {
00082                         len += strlen(Options.OutFilePrefix);
00083                 }
00084                 Options.NetFile = my_calloc(len,sizeof(char));
00085                 if(Options.OutFilePrefix == NULL) {
00086                         sprintf(Options.NetFile, "%s.net", Options.CircuitName);
00087                 } else {
00088                         sprintf(Options.NetFile, "%s%s.net", Options.OutFilePrefix, Options.CircuitName);
00089                 }
00090         }
00091 
00092         if(Options.PlaceFile == NULL) {
00093                 len = strlen(Options.CircuitName) + 7; /* circuit_name.place/0*/
00094                 if(Options.OutFilePrefix != NULL) {
00095                         len += strlen(Options.OutFilePrefix);
00096                 }
00097                 Options.PlaceFile = my_calloc(len,sizeof(char));
00098                 if(Options.OutFilePrefix == NULL) {
00099                         sprintf(Options.PlaceFile, "%s.place", Options.CircuitName);
00100                 } else {
00101                         sprintf(Options.PlaceFile, "%s%s.place", Options.OutFilePrefix, Options.CircuitName);
00102                 }
00103         }
00104 
00105         if(Options.RouteFile == NULL) {
00106                 len = strlen(Options.CircuitName) + 7; /* circuit_name.route/0*/
00107                 if(Options.OutFilePrefix != NULL) {
00108                         len += strlen(Options.OutFilePrefix);
00109                 }
00110                 Options.RouteFile = my_calloc(len,sizeof(char));
00111                 if(Options.OutFilePrefix == NULL) {
00112                         sprintf(Options.RouteFile, "%s.route", Options.CircuitName);
00113                 } else {
00114                         sprintf(Options.RouteFile, "%s%s.route", Options.OutFilePrefix, Options.CircuitName);
00115                 }
00116         }
00117 
00118         FileNameOpts->CircuitName = Options.CircuitName;
00119         FileNameOpts->ArchFile = Options.ArchFile;
00120         FileNameOpts->BlifFile = Options.BlifFile;
00121         FileNameOpts->NetFile = Options.NetFile;
00122         FileNameOpts->PlaceFile = Options.PlaceFile;
00123         FileNameOpts->RouteFile = Options.RouteFile;    
00124         FileNameOpts->OutFilePrefix = Options.OutFilePrefix;    
00125 
00126     SetupOperation(Options, Operation);
00127     SetupPlacerOpts(Options, TimingEnabled, PlacerOpts);
00128     SetupAnnealSched(Options, AnnealSched);
00129     SetupRouterOpts(Options, TimingEnabled, RouterOpts);
00130 
00131     XmlReadArch(Options.ArchFile, TimingEnabled, Arch,
00132                 &type_descriptors, &num_types);
00133 
00134         *user_models = Arch->models;
00135         *library_models = Arch->model_library;
00136         
00137         /* TODO: this is inelegant, I should be populating this information in XmlReadArch */
00138         EMPTY_TYPE = NULL;
00139         FILL_TYPE = NULL;
00140         IO_TYPE = NULL;
00141         for(i = 0; i < num_types; i++) {
00142                 if(strcmp(type_descriptors[i].name, "<EMPTY>") == 0) {
00143                         EMPTY_TYPE = &type_descriptors[i];
00144                 } else if(strcmp(type_descriptors[i].name, "io") == 0) {
00145                         IO_TYPE = &type_descriptors[i];
00146                 } else {
00147                         for(j = 0; j < type_descriptors[i].num_grid_loc_def; j++) {
00148                                 if(type_descriptors[i].grid_loc_def[j].grid_loc_type == FILL) {
00149                                         assert(FILL_TYPE == NULL);
00150                                         FILL_TYPE = &type_descriptors[i];
00151                                 }
00152                         }
00153                 }
00154 
00155         }
00156         assert(EMPTY_TYPE != NULL && FILL_TYPE != NULL && IO_TYPE != NULL);
00157 
00158 
00159     *Segments = Arch->Segments;
00160     RoutingArch->num_segment = Arch->num_segments;
00161 
00162     SetupSwitches(*Arch, RoutingArch, Arch->Switches, Arch->num_switches);
00163     SetupRoutingArch(*Arch, RoutingArch);
00164     SetupTiming(Options, *Arch, TimingEnabled, *Operation,
00165                 *PlacerOpts, *RouterOpts, Timing);
00166         SetupPackerOpts(Options, TimingEnabled, *Arch, Options.NetFile, PackerOpts);
00167 
00168     /* init global variables */
00169         OutFilePrefix = Options.OutFilePrefix;
00170     grid_logic_tile_area = Arch->grid_logic_tile_area;
00171     ipin_mux_trans_size = Arch->ipin_mux_trans_size;
00172 
00173 
00174     /* Set seed for pseudo-random placement, default seed to 1 */
00175     PlacerOpts->seed = 1;
00176     if(Options.Count[OT_SEED])
00177         {
00178             PlacerOpts->seed = Options.Seed;
00179         }
00180     my_srandom(PlacerOpts->seed);
00181 
00182         
00183         printf("Building complex block graph \n");
00184         alloc_and_load_all_pb_graphs();
00185         #ifdef DUMP_PB_GRAPH
00186                 echo_pb_graph("pb_graph.echo");
00187         #endif
00188 
00189 
00190     *GraphPause = 1;            /* DEFAULT */
00191     if(Options.Count[OT_AUTO])
00192         {
00193             *GraphPause = Options.GraphPause;
00194         }
00195 #ifdef NO_GRAPHICS
00196     *ShowGraphics = FALSE;      /* DEFAULT */
00197 #else /* NO_GRAPHICS */
00198     *ShowGraphics = TRUE;       /* DEFAULT */
00199     if(Options.Count[OT_NODISP])
00200         {
00201             *ShowGraphics = FALSE;
00202         }
00203 #endif /* NO_GRAPHICS */
00204 
00205 #ifdef CREATE_ECHO_FILES
00206     EchoArch("arch.echo", type_descriptors, num_types, Arch);
00207 #endif
00208         
00209 }
00210 
00211 static void
00212 SetupTiming(INP t_options Options,
00213             INP t_arch Arch,
00214             INP boolean TimingEnabled,
00215             INP enum e_operation Operation,
00216             INP struct s_placer_opts PlacerOpts,
00217             INP struct s_router_opts RouterOpts,
00218             OUTP t_timing_inf * Timing)
00219 {
00220 
00221     /* Don't do anything if they don't want timing */
00222     if(FALSE == TimingEnabled)
00223         {
00224             memset(Timing, 0, sizeof(t_timing_inf));
00225             Timing->timing_analysis_enabled = FALSE;
00226             return;
00227         }
00228 
00229     Timing->C_ipin_cblock = Arch.C_ipin_cblock;
00230     Timing->T_ipin_cblock = Arch.T_ipin_cblock;
00231     Timing->timing_analysis_enabled = TimingEnabled;
00232 }
00233 
00234 
00235 /** This loads up VPR's switch_inf data by combining the switches from 
00236  * the arch file with the special switches that VPR needs. 
00237  */
00238 static void
00239 SetupSwitches(INP t_arch Arch,
00240               INOUTP struct s_det_routing_arch *RoutingArch,
00241               INP struct s_switch_inf *ArchSwitches,
00242               INP int NumArchSwitches)
00243 {
00244 
00245     RoutingArch->num_switch = NumArchSwitches;
00246 
00247     /* Depends on RoutingArch->num_switch */
00248     RoutingArch->wire_to_ipin_switch = RoutingArch->num_switch;
00249     ++RoutingArch->num_switch;
00250 
00251     /* Depends on RoutingArch->num_switch */
00252     RoutingArch->delayless_switch = RoutingArch->num_switch;
00253     RoutingArch->global_route_switch = RoutingArch->delayless_switch;
00254     ++RoutingArch->num_switch;
00255 
00256     /* Alloc the list now that we know the final num_switch value */
00257     switch_inf =
00258         (struct s_switch_inf *)my_malloc(sizeof(struct s_switch_inf) *
00259                                          RoutingArch->num_switch);
00260 
00261     /* Copy the switch data from architecture file */
00262     memcpy(switch_inf, ArchSwitches,
00263            sizeof(struct s_switch_inf) * NumArchSwitches);
00264 
00265     /* Delayless switch for connecting sinks and sources with their pins. */
00266     switch_inf[RoutingArch->delayless_switch].buffered = TRUE;
00267     switch_inf[RoutingArch->delayless_switch].R = 0.;
00268     switch_inf[RoutingArch->delayless_switch].Cin = 0.;
00269     switch_inf[RoutingArch->delayless_switch].Cout = 0.;
00270     switch_inf[RoutingArch->delayless_switch].Tdel = 0.;
00271 
00272     /* The wire to ipin switch for all types. Curently all types
00273      * must share ipin switch. Some of the timing code would
00274      * need to be changed otherwise. */
00275     switch_inf[RoutingArch->wire_to_ipin_switch].buffered = TRUE;
00276     switch_inf[RoutingArch->wire_to_ipin_switch].R = 0.;
00277     switch_inf[RoutingArch->wire_to_ipin_switch].Cin = Arch.C_ipin_cblock;
00278     switch_inf[RoutingArch->wire_to_ipin_switch].Cout = 0.;
00279     switch_inf[RoutingArch->wire_to_ipin_switch].Tdel = Arch.T_ipin_cblock;
00280 }
00281 
00282 
00283 /** Sets up routing structures. Since checks are already done, this
00284  * just copies values across 
00285  */
00286 static void
00287 SetupRoutingArch(INP t_arch Arch,
00288                  OUTP struct s_det_routing_arch *RoutingArch)
00289 {
00290 
00291     RoutingArch->switch_block_type = Arch.SBType;
00292     RoutingArch->R_minW_nmos = Arch.R_minW_nmos;
00293     RoutingArch->R_minW_pmos = Arch.R_minW_pmos;
00294     RoutingArch->Fs = Arch.Fs;
00295     RoutingArch->directionality = BI_DIRECTIONAL;
00296     if(Arch.Segments)
00297         RoutingArch->directionality = Arch.Segments[0].directionality;
00298 }
00299 
00300 
00301 static void
00302 SetupRouterOpts(INP t_options Options,
00303                 INP boolean TimingEnabled,
00304                 OUTP struct s_router_opts *RouterOpts)
00305 {
00306         RouterOpts->astar_fac = 1.2;    /* DEFAULT */
00307         if(Options.Count[OT_ASTAR_FAC])
00308         {
00309             RouterOpts->astar_fac = Options.astar_fac;
00310         }
00311 
00312     RouterOpts->bb_factor = 3;  /* DEFAULT */
00313         if(Options.Count[OT_FAST])
00314         {
00315                 RouterOpts->bb_factor = 0;      /* DEFAULT */
00316         }
00317         if(Options.Count[OT_BB_FACTOR])
00318         {
00319             RouterOpts->bb_factor = Options.bb_factor;
00320         }
00321 
00322     RouterOpts->criticality_exp = 1.0;  /* DEFAULT */
00323         if(Options.Count[OT_CRITICALITY_EXP])
00324         {
00325             RouterOpts->criticality_exp = Options.criticality_exp;
00326         }
00327 
00328     RouterOpts->max_criticality = 0.99; /* DEFAULT */
00329         if(Options.Count[OT_MAX_CRITICALITY])
00330         {
00331             RouterOpts->max_criticality = Options.max_criticality;
00332         }
00333 
00334     RouterOpts->max_router_iterations = 50;     /* DEFAULT */
00335         if(Options.Count[OT_FAST])
00336         {
00337             RouterOpts->max_router_iterations = 10;
00338         }
00339         if(Options.Count[OT_MAX_ROUTER_ITERATIONS])
00340         {
00341             RouterOpts->max_router_iterations = Options.max_router_iterations;
00342         }
00343 
00344     RouterOpts->pres_fac_mult = 1.3;    /* DEFAULT */
00345         if(Options.Count[OT_PRES_FAC_MULT])
00346         {
00347             RouterOpts->pres_fac_mult = Options.pres_fac_mult;
00348         }
00349 
00350 
00351     RouterOpts->route_type = DETAILED;  /* DEFAULT */
00352     if(Options.Count[OT_ROUTE_TYPE])
00353         {
00354             RouterOpts->route_type = Options.RouteType;
00355         }
00356 
00357         RouterOpts->full_stats = FALSE; /* DEFAULT */
00358         if(Options.Count[OT_FULL_STATS])
00359         {
00360             RouterOpts->full_stats = TRUE;
00361         }
00362 
00363         RouterOpts->verify_binary_search = FALSE; /* DEFAULT */
00364         if(Options.Count[OT_VERIFY_BINARY_SEARCH])
00365         {
00366             RouterOpts->verify_binary_search = TRUE;
00367         }
00368 
00369     /* Depends on RouteOpts->route_type */
00370     RouterOpts->router_algorithm = DIRECTED_SEARCH;     /* DEFAULT */
00371     if(TimingEnabled)
00372         {
00373             RouterOpts->router_algorithm = TIMING_DRIVEN;       /* DEFAULT */
00374         }
00375     if(GLOBAL == RouterOpts->route_type)
00376         {
00377             RouterOpts->router_algorithm = DIRECTED_SEARCH;     /* DEFAULT */
00378         }
00379     if(Options.Count[OT_ROUTER_ALGORITHM])
00380         {
00381             RouterOpts->router_algorithm = Options.RouterAlgorithm;
00382         }
00383 
00384     RouterOpts->fixed_channel_width = NO_FIXED_CHANNEL_WIDTH;   /* DEFAULT */
00385     if(Options.Count[OT_ROUTE_CHAN_WIDTH])
00386         {
00387             RouterOpts->fixed_channel_width = Options.RouteChanWidth;
00388         }
00389 
00390     /* Depends on RouterOpts->router_algorithm */
00391     RouterOpts->initial_pres_fac = 0.5; /* DEFAULT */
00392     if(DIRECTED_SEARCH == RouterOpts->router_algorithm || 
00393                 Options.Count[OT_FAST])
00394         {
00395             RouterOpts->initial_pres_fac = 10000.0;     /* DEFAULT */
00396         }
00397     if(Options.Count[OT_INITIAL_PRES_FAC])
00398         {
00399             RouterOpts->initial_pres_fac = Options.initial_pres_fac;
00400         }
00401 
00402     /* Depends on RouterOpts->router_algorithm */
00403     RouterOpts->base_cost_type = DELAY_NORMALIZED;      /* DEFAULT */
00404     if(BREADTH_FIRST == RouterOpts->router_algorithm)
00405         {
00406             RouterOpts->base_cost_type = DEMAND_ONLY;   /* DEFAULT */
00407         }
00408     if(DIRECTED_SEARCH == RouterOpts->router_algorithm)
00409         {
00410             RouterOpts->base_cost_type = DEMAND_ONLY;   /* DEFAULT */
00411         }
00412         if(Options.Count[OT_BASE_COST_TYPE])
00413         {
00414             RouterOpts->base_cost_type = Options.base_cost_type;
00415         }
00416 
00417     /* Depends on RouterOpts->router_algorithm */
00418     RouterOpts->first_iter_pres_fac = 0.5;      /* DEFAULT */
00419     if(BREADTH_FIRST == RouterOpts->router_algorithm)
00420         {
00421             RouterOpts->first_iter_pres_fac = 0.0;      /* DEFAULT */
00422         }
00423     if(DIRECTED_SEARCH == RouterOpts->router_algorithm ||
00424                 Options.Count[OT_FAST])
00425         {
00426             RouterOpts->first_iter_pres_fac = 10000.0;  /* DEFAULT */
00427         }
00428         if(Options.Count[OT_FIRST_ITER_PRES_FAC])
00429         {
00430             RouterOpts->first_iter_pres_fac = Options.first_iter_pres_fac;
00431         }
00432 
00433     /* Depends on RouterOpts->router_algorithm */
00434     RouterOpts->acc_fac = 1.0;
00435     if(BREADTH_FIRST == RouterOpts->router_algorithm)
00436         {
00437             RouterOpts->acc_fac = 0.2;
00438         }
00439         if(Options.Count[OT_ACC_FAC])
00440         {
00441             RouterOpts->acc_fac = Options.acc_fac;
00442         }
00443 
00444     /* Depends on RouterOpts->route_type */
00445     RouterOpts->bend_cost = 0.0;        /* DEFAULT */
00446     if(GLOBAL == RouterOpts->route_type)
00447         {
00448             RouterOpts->bend_cost = 1.0;        /* DEFAULT */
00449         }
00450         if(Options.Count[OT_BEND_COST])
00451         {
00452             RouterOpts->bend_cost = Options.bend_cost;
00453         }
00454 
00455         RouterOpts->doRouting = FALSE;
00456         if(Options.Count[OT_ROUTE])
00457         {
00458             RouterOpts->doRouting = TRUE;
00459         } else if (!Options.Count[OT_PACK] && !Options.Count[OT_PLACE] && !Options.Count[OT_ROUTE]) {
00460                 if(!Options.Count[OT_TIMING_ANALYZE_ONLY_WITH_NET_DELAY])
00461                         RouterOpts->doRouting = TRUE;
00462         }
00463     
00464 }
00465 
00466 
00467 static void
00468 SetupAnnealSched(INP t_options Options,
00469                  OUTP struct s_annealing_sched *AnnealSched)
00470 {
00471     AnnealSched->alpha_t = 0.8; /* DEFAULT */
00472     if(Options.Count[OT_ALPHA_T])
00473         {
00474             AnnealSched->alpha_t = Options.PlaceAlphaT;
00475         }
00476     if(AnnealSched->alpha_t >= 1 || AnnealSched->alpha_t <= 0)
00477         {
00478             printf(ERRTAG "alpha_t must be between 0 and 1 exclusive\n");
00479             exit(1);
00480         }
00481     AnnealSched->exit_t = 0.01; /* DEFAULT */
00482     if(Options.Count[OT_EXIT_T])
00483         {
00484             AnnealSched->exit_t = Options.PlaceExitT;
00485         }
00486     if(AnnealSched->exit_t <= 0)
00487         {
00488             printf(ERRTAG "exit_t must be greater than 0\n");
00489             exit(1);
00490         }
00491     AnnealSched->init_t = 100.0;        /* DEFAULT */
00492     if(Options.Count[OT_INIT_T])
00493         {
00494             AnnealSched->init_t = Options.PlaceInitT;
00495         }
00496     if(AnnealSched->init_t <= 0)
00497         {
00498             printf(ERRTAG "init_t must be greater than 0\n");
00499             exit(1);
00500         }
00501     if(AnnealSched->init_t < AnnealSched->exit_t)
00502         {
00503             printf(ERRTAG "init_t must be greater or equal to than exit_t\n");
00504             exit(1);
00505         }
00506     AnnealSched->inner_num = 10.0;      /* DEFAULT */
00507         if(Options.Count[OT_FAST]) {
00508                 AnnealSched->inner_num = 1.0;   /* DEFAULT for fast*/
00509         }
00510     if(Options.Count[OT_INNER_NUM])
00511         {
00512             AnnealSched->inner_num = Options.PlaceInnerNum;
00513         }
00514     if(AnnealSched->inner_num <= 0)
00515         {
00516             printf(ERRTAG "init_t must be greater than 0\n");
00517             exit(1);
00518         }
00519     AnnealSched->type = AUTO_SCHED;     /* DEFAULT */
00520     if((Options.Count[OT_ALPHA_T]) ||
00521        (Options.Count[OT_EXIT_T]) || (Options.Count[OT_INIT_T]))
00522         {
00523             AnnealSched->type = USER_SCHED;
00524         }
00525 }
00526 
00527 /** Sets up the s_packer_opts structure baesd on users inputs and on the architecture specified.  
00528  * Error checking, such as checking for conflicting params is assumed to be done beforehand 
00529  */
00530 void SetupPackerOpts(INP t_options Options, 
00531                                                         INP boolean TimingEnabled, 
00532                                                         INP t_arch Arch, 
00533                                                         INP char *net_file,
00534                                                         OUTP struct s_packer_opts *PackerOpts) {
00535 
00536         if(Arch.clb_grid.IsAuto) {
00537                 PackerOpts->aspect = Arch.clb_grid.Aspect;
00538         } else {
00539                 PackerOpts->aspect = (float)Arch.clb_grid.H / (float)Arch.clb_grid.W;
00540         }
00541         PackerOpts->output_file = net_file;
00542 
00543         PackerOpts->hack_no_legal_frac_lut = FALSE; /* DEFAULT */
00544         if(Options.Count[OT_HACK_NO_LEGAL_FRAC_LUT])
00545         {
00546                 PackerOpts->hack_no_legal_frac_lut = TRUE;
00547         }
00548 
00549         PackerOpts->hack_safe_latch = FALSE; /* DEFAULT */
00550         if(Options.Count[OT_HACK_SAFE_LATCH])
00551         {
00552                 PackerOpts->hack_safe_latch = TRUE;
00553         }
00554 
00555         PackerOpts->blif_file_name = Options.BlifFile; 
00556         
00557         PackerOpts->doPacking = FALSE; /* DEFAULT */
00558         if(Options.Count[OT_PACK])
00559         {
00560                 PackerOpts->doPacking = TRUE;
00561         } else if (!Options.Count[OT_PACK] && !Options.Count[OT_PLACE] && !Options.Count[OT_ROUTE]) {
00562                 if(!Options.Count[OT_TIMING_ANALYZE_ONLY_WITH_NET_DELAY])
00563                         PackerOpts->doPacking = TRUE;
00564         }
00565         
00566         PackerOpts->global_clocks = TRUE; /* DEFAULT */
00567         if(Options.Count[OT_GLOBAL_CLOCKS])
00568         {
00569                 PackerOpts->global_clocks = Options.global_clocks;
00570         }
00571 
00572         PackerOpts->hill_climbing_flag = FALSE; /* DEFAULT */
00573         if(Options.Count[OT_HILL_CLIMBING_FLAG])
00574         {
00575                 PackerOpts->hill_climbing_flag = Options.hill_climbing_flag;
00576         }
00577 
00578         PackerOpts->sweep_hanging_nets_and_inputs = TRUE;
00579         if(Options.Count[OT_SWEEP_HANGING_NETS_AND_INPUTS])
00580         {
00581                 PackerOpts->sweep_hanging_nets_and_inputs = Options.sweep_hanging_nets_and_inputs;
00582         }
00583 
00584         PackerOpts->skip_clustering = FALSE; /* DEFAULT */
00585         if(Options.Count[OT_SKIP_CLUSTERING])
00586         {
00587                 PackerOpts->skip_clustering = TRUE;
00588         }
00589         PackerOpts->allow_unrelated_clustering = TRUE; /* DEFAULT */
00590         if(Options.Count[OT_ALLOW_UNRELATED_CLUSTERING])
00591         {
00592                 PackerOpts->allow_unrelated_clustering = Options.allow_unrelated_clustering;
00593         }
00594         PackerOpts->allow_early_exit = FALSE; /* DEFAULT */
00595         if(Options.Count[OT_ALLOW_EARLY_EXIT])
00596         {
00597                 PackerOpts->allow_early_exit = Options.allow_early_exit;
00598         }
00599         PackerOpts->connection_driven = TRUE; /* DEFAULT */
00600         if(Options.Count[OT_CONNECTION_DRIVEN_CLUSTERING])
00601         {
00602                 PackerOpts->connection_driven = Options.connection_driven;
00603         }
00604 
00605         PackerOpts->timing_driven = TimingEnabled; /* DEFAULT */
00606         if(Options.Count[OT_TIMING_DRIVEN_CLUSTERING])
00607         {
00608                 PackerOpts->timing_driven = Options.timing_driven;
00609         }
00610         PackerOpts->cluster_seed_type = (TimingEnabled ? VPACK_TIMING : VPACK_MAX_INPUTS); /* DEFAULT */
00611         if(Options.Count[OT_CLUSTER_SEED])
00612         {
00613                 PackerOpts->cluster_seed_type = Options.cluster_seed_type;
00614         }
00615         PackerOpts->alpha=0.75; /* DEFAULT */
00616         if(Options.Count[OT_ALPHA_CLUSTERING])
00617         {
00618                 PackerOpts->alpha= Options.alpha;
00619         }
00620         PackerOpts->beta=0.9; /* DEFAULT */
00621         if(Options.Count[OT_BETA_CLUSTERING])
00622         {
00623                 PackerOpts->beta= Options.beta;
00624         }
00625 
00626         /* never recomputer timing */
00627         PackerOpts->recompute_timing_after = MAX_SHORT; /* DEFAULT */
00628         if(Options.Count[OT_RECOMPUTE_TIMING_AFTER])
00629         {
00630                 PackerOpts->recompute_timing_after = Options.recompute_timing_after;
00631         }
00632         PackerOpts->block_delay = 0; /* DEFAULT */
00633         if(Options.Count[OT_CLUSTER_BLOCK_DELAY])
00634         {
00635                 PackerOpts->block_delay = Options.block_delay;
00636         }
00637         PackerOpts->intra_cluster_net_delay = 0; /* DEFAULT */
00638         if(Options.Count[OT_INTRA_CLUSTER_NET_DELAY])
00639         {
00640                 PackerOpts->intra_cluster_net_delay = Options.intra_cluster_net_delay;
00641         }
00642         PackerOpts->inter_cluster_net_delay = 1.0; /* DEFAULT */
00643         if(Options.Count[OT_INTER_CLUSTER_NET_DELAY])
00644         {
00645                 PackerOpts->inter_cluster_net_delay = Options.inter_cluster_net_delay;
00646         }
00647 
00648         PackerOpts->packer_algorithm = PACK_GREEDY; /* DEFAULT */
00649         if(Options.Count[OT_PACKER_ALGORITHM])
00650         {
00651                 PackerOpts->packer_algorithm = Options.packer_algorithm;
00652         }
00653 }
00654 
00655 /** Sets up the s_placer_opts structure based on users input. Error checking,
00656  * such as checking for conflicting params is assumed to be done beforehand 
00657  */
00658 static void
00659 SetupPlacerOpts(INP t_options Options,
00660                 INP boolean TimingEnabled,
00661                 OUTP struct s_placer_opts *PlacerOpts)
00662 {
00663     PlacerOpts->block_dist = 1; /* DEFAULT */
00664     if(Options.Count[OT_BLOCK_DIST])
00665         {
00666             PlacerOpts->block_dist = Options.block_dist;
00667         }
00668 
00669     PlacerOpts->inner_loop_recompute_divider = 0;       /* DEFAULT */
00670     if(Options.Count[OT_INNER_LOOP_RECOMPUTE_DIVIDER])
00671         {
00672             PlacerOpts->inner_loop_recompute_divider = Options.inner_loop_recompute_divider;
00673         }
00674 
00675     PlacerOpts->place_cost_exp = 1.0;   /* DEFAULT */
00676     if(Options.Count[OT_PLACE_COST_EXP])
00677         {
00678             PlacerOpts->place_cost_exp = Options.place_cost_exp;
00679         }
00680 
00681     PlacerOpts->td_place_exp_first = 1; /* DEFAULT */
00682     if(Options.Count[OT_TD_PLACE_EXP_FIRST])
00683         {
00684             PlacerOpts->td_place_exp_first = Options.place_exp_first;
00685         }
00686 
00687     PlacerOpts->td_place_exp_last = 8;  /* DEFAULT */
00688     if(Options.Count[OT_TD_PLACE_EXP_LAST])
00689         {
00690             PlacerOpts->td_place_exp_last = Options.place_exp_last;
00691         }
00692 
00693     PlacerOpts->place_cost_type = LINEAR_CONG;  /* DEFAULT */
00694     if(Options.Count[OT_PLACE_COST_TYPE])
00695         {
00696             PlacerOpts->place_cost_type = Options.PlaceCostType;
00697         }
00698 
00699     /* Depends on PlacerOpts->place_cost_type */
00700     PlacerOpts->place_algorithm = BOUNDING_BOX_PLACE;   /* DEFAULT */
00701     if(TimingEnabled)
00702         {
00703             PlacerOpts->place_algorithm = PATH_TIMING_DRIVEN_PLACE;     /* DEFAULT */
00704         }
00705     if(NONLINEAR_CONG == PlacerOpts->place_cost_type)
00706         {
00707             PlacerOpts->place_algorithm = BOUNDING_BOX_PLACE;   /* DEFAULT */
00708         }
00709     if(Options.Count[OT_PLACE_ALGORITHM])
00710         {
00711             PlacerOpts->place_algorithm = Options.PlaceAlgorithm;
00712         }
00713 
00714     PlacerOpts->num_regions = 4;        /* DEFAULT */
00715     if(Options.Count[OT_NUM_REGIONS])
00716         {
00717             PlacerOpts->num_regions = Options.PlaceNonlinearRegions;
00718         }
00719 
00720     PlacerOpts->pad_loc_file = NULL;    /* DEFAULT */
00721     if(Options.Count[OT_FIX_PINS])
00722         {
00723             if(Options.PinFile)
00724                 {
00725                     PlacerOpts->pad_loc_file = my_strdup(Options.PinFile);
00726                 }
00727         }
00728 
00729     PlacerOpts->pad_loc_type = FREE;    /* DEFAULT */
00730     if(Options.Count[OT_FIX_PINS])
00731         {
00732             PlacerOpts->pad_loc_type = (Options.PinFile ? USER : RANDOM);
00733         }
00734 
00735     /* Depends on PlacerOpts->place_cost_type */
00736     PlacerOpts->place_chan_width = 100; /* DEFAULT */
00737     if((NONLINEAR_CONG == PlacerOpts->place_cost_type) &&
00738        (Options.Count[OT_ROUTE_CHAN_WIDTH]))
00739         {
00740             PlacerOpts->place_chan_width = Options.RouteChanWidth;
00741         }
00742     if(Options.Count[OT_PLACE_CHAN_WIDTH])
00743         {
00744             PlacerOpts->place_chan_width = Options.PlaceChanWidth;
00745         }
00746 
00747     PlacerOpts->recompute_crit_iter = 1;        /* DEFAULT */
00748     if(Options.Count[OT_RECOMPUTE_CRIT_ITER])
00749         {
00750             PlacerOpts->recompute_crit_iter = Options.RecomputeCritIter;
00751         }
00752 
00753     PlacerOpts->timing_tradeoff = 0.5;  /* DEFAULT */
00754     if(Options.Count[OT_TIMING_TRADEOFF])
00755         {
00756             PlacerOpts->timing_tradeoff = Options.PlaceTimingTradeoff;
00757         }
00758 
00759     /* Depends on PlacerOpts->place_algorithm */
00760     PlacerOpts->enable_timing_computations = FALSE;     /* DEFAULT */
00761     if((PlacerOpts->place_algorithm == PATH_TIMING_DRIVEN_PLACE) ||
00762        (PlacerOpts->place_algorithm == NET_TIMING_DRIVEN_PLACE))
00763         {
00764             PlacerOpts->enable_timing_computations = TRUE;      /* DEFAULT */
00765         }
00766     if(Options.Count[OT_ENABLE_TIMING_COMPUTATIONS])
00767         {
00768             PlacerOpts->enable_timing_computations = Options.ShowPlaceTiming;
00769         }
00770 
00771     /* Depends on PlacerOpts->place_cost_type */
00772     PlacerOpts->place_freq = PLACE_ONCE;        /* DEFAULT */
00773     if(NONLINEAR_CONG == PlacerOpts->place_cost_type)
00774         {
00775             PlacerOpts->place_freq = PLACE_ALWAYS;      /* DEFAULT */
00776         }
00777     if((Options.Count[OT_ROUTE_CHAN_WIDTH]) ||
00778        (Options.Count[OT_PLACE_CHAN_WIDTH]))
00779         {
00780             PlacerOpts->place_freq = PLACE_ONCE;
00781         }
00782 
00783         PlacerOpts->doPlacement = FALSE; /* DEFAULT */
00784         if(Options.Count[OT_PLACE])
00785         {
00786                 PlacerOpts->doPlacement = TRUE;
00787         } else if (!Options.Count[OT_PACK] && !Options.Count[OT_PLACE] && !Options.Count[OT_ROUTE]) {
00788                 if(!Options.Count[OT_TIMING_ANALYZE_ONLY_WITH_NET_DELAY])
00789                         PlacerOpts->doPlacement = TRUE;
00790         }
00791         if(PlacerOpts->doPlacement == FALSE) {
00792                 PlacerOpts->place_freq = PLACE_NEVER;
00793         }
00794         
00795 }
00796 
00797 
00798 static void
00799 SetupOperation(INP t_options Options,
00800                OUTP enum e_operation *Operation)
00801 {
00802     *Operation = RUN_FLOW;      /* DEFAULT */
00803     if(Options.Count[OT_TIMING_ANALYZE_ONLY_WITH_NET_DELAY])
00804         {
00805             *Operation = TIMING_ANALYSIS_ONLY;
00806         }
00807 }
00808 
00809 
00810 /** Determines whether timing analysis should be on or off. 
00811  * Unless otherwise specified, always default to timing.
00812  */
00813 boolean
00814 IsTimingEnabled(INP t_options Options)
00815 {
00816     /* First priority to the '--timing_analysis' flag */
00817     if(Options.Count[OT_TIMING_ANALYSIS])
00818         {
00819             return Options.TimingAnalysis;
00820         }
00821     return TRUE;
00822 }
00823 
00824