VPR-7.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
ReadOptions.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <string.h>
3 #include <assert.h>
4 #include "util.h"
5 #include "hash.h"
6 #include "vpr_types.h"
7 #include "OptionTokens.h"
8 #include "ReadOptions.h"
9 #include "read_settings.h"
10 #include "globals.h"
11 
12 static boolean EchoEnabled;
13 
15 
16 static boolean *echoFileEnabled = NULL;
17 static char **echoFileNames = NULL;
18 
19 static char **outputFileNames = NULL;
20 
21 /******** Function prototypes ********/
22 
23 static char **ReadBaseToken(INP char **Args, OUTP enum e_OptionBaseToken *Token);
24 static void Error(INP const char *Token);
25 static char **ProcessOption(INP char **Args, INOUTP t_options * Options);
26 static void MergeOptions(INOUTP t_options * dest, INP t_options * src, int id);
27 static char **ReadFloat(INP char **Args, OUTP float *Val);
28 static char **ReadInt(INP char **Args, OUTP int *Val);
29 static char **ReadOnOff(INP char **Args, OUTP boolean * Val);
30 static char **ReadClusterSeed(INP char **Args, OUTP enum e_cluster_seed *Type);
31 static char **ReadFixPins(INP char **Args, OUTP char **PinFile);
32 static char **ReadPlaceAlgorithm(INP char **Args,
33  OUTP enum e_place_algorithm *Algo);
34 static char **ReadRouterAlgorithm(INP char **Args,
35  OUTP enum e_router_algorithm *Algo);
36 static char **ReadPackerAlgorithm(INP char **Args,
37  OUTP enum e_packer_algorithm *Algo);
38 static char **ReadBaseCostType(INP char **Args,
39  OUTP enum e_base_cost_type *BaseCostType);
40 static char **ReadRouteType(INP char **Args, OUTP enum e_route_type *Type);
41 static char **ReadString(INP char **Args, OUTP char **Val);
42 
43 /******** Globally Accessible Function ********/
44 /* Determines whether timing analysis should be on or off.
45  Unless otherwise specified, always default to timing.
46  */
47 boolean IsTimingEnabled(INP t_options *Options) {
48  /* First priority to the '--timing_analysis' flag */
49  if (Options->Count[OT_TIMING_ANALYSIS]) {
50  return Options->TimingAnalysis;
51  }
52  return TRUE;
53 }
54 
55 /* Determines whether file echo should be on or off.
56  Unless otherwise specified, always default to on.
57  */
58 boolean IsEchoEnabled(INP t_options *Options) {
59  /* First priority to the '--echo_file' flag */
60  if (Options->Count[OT_CREATE_ECHO_FILE]) {
61  return Options->CreateEchoFile;
62  }
63  return FALSE;
64 }
65 
66 
67 boolean getEchoEnabled(void) {
68  return EchoEnabled;
69 }
70 
71 void setEchoEnabled(boolean echo_enabled) {
72  /* enable echo outputs */
73  EchoEnabled = echo_enabled;
74  if(echoFileEnabled == NULL) {
75  /* initialize default echo options */
77  }
78 }
79 
80 boolean GetPostSynthesisOption(void){
82 }
83 
84 void SetPostSynthesisOption(boolean post_synthesis_enabled){
85  Generate_PostSynthesis_Netlist = post_synthesis_enabled;
86 }
87 
89  /* First priority to the '--generate_postsynthesis_netlist' flag */
90  if (Options->Count[OT_GENERATE_POST_SYNTHESIS_NETLIST]) {
91  return Options->Generate_Post_Synthesis_Netlist;
92  }
93  return FALSE;
94 }
95 
96 
97 void setAllEchoFileEnabled(boolean value) {
98  int i;
99  for(i = 0; i < (int) E_ECHO_END_TOKEN; i++) {
100  echoFileEnabled[i] = value;
101  }
102 }
103 
104 void setEchoFileEnabled(enum e_echo_files echo_option, boolean value) {
105  echoFileEnabled[(int)echo_option] = value;
106 }
107 
108 void setEchoFileName(enum e_echo_files echo_option, const char *name) {
109  if(echoFileNames[(int)echo_option] != NULL) {
110  free(echoFileNames[(int)echo_option]);
111  }
112  echoFileNames[(int)echo_option] = my_strdup(name);
113 }
114 
115 boolean isEchoFileEnabled(enum e_echo_files echo_option) {
116  if(echoFileEnabled == NULL) {
117  return FALSE;
118  } else {
119  return echoFileEnabled[(int)echo_option];
120  }
121 }
122 char *getEchoFileName(enum e_echo_files echo_option) {
123  return echoFileNames[(int)echo_option];
124 }
125 
127  echoFileEnabled = (boolean*)my_calloc((int) E_ECHO_END_TOKEN, sizeof(boolean));
128  echoFileNames = (char**)my_calloc((int) E_ECHO_END_TOKEN, sizeof(char*));
129 
131 
132  setEchoFileName(E_ECHO_INITIAL_CLB_PLACEMENT, "initial_clb_placement.echo");
133  setEchoFileName(E_ECHO_INITIAL_PLACEMENT_TIMING_GRAPH, "initial_placement_timing_graph.echo");
134  setEchoFileName(E_ECHO_INITIAL_PLACEMENT_SLACK, "initial_placement_slack.echo");
135  setEchoFileName(E_ECHO_INITIAL_PLACEMENT_CRITICALITY, "initial_placement_criticality.echo");
136  setEchoFileName(E_ECHO_END_CLB_PLACEMENT, "end_clb_placement.echo");
137  setEchoFileName(E_ECHO_PLACEMENT_SINK_DELAYS, "placement_sink_delays.echo");
138  setEchoFileName(E_ECHO_FINAL_PLACEMENT_TIMING_GRAPH, "final_placement_timing_graph.echo");
139  setEchoFileName(E_ECHO_FINAL_PLACEMENT_SLACK, "final_placement_slack.echo");
140  setEchoFileName(E_ECHO_FINAL_PLACEMENT_CRITICALITY, "final_placement_criticality.echo");
141  setEchoFileName(E_ECHO_PLACEMENT_CRIT_PATH, "placement_crit_path.echo");
142  setEchoFileName(E_ECHO_PB_GRAPH, "pb_graph.echo");
143  setEchoFileName(E_ECHO_ARCH, "arch.echo");
144  setEchoFileName(E_ECHO_PLACEMENT_CRITICAL_PATH, "placement_critical_path.echo");
145  setEchoFileName(E_ECHO_PLACEMENT_LOWER_BOUND_SINK_DELAYS, "placement_lower_bound_sink_delays.echo");
146  setEchoFileName(E_ECHO_PLACEMENT_LOGIC_SINK_DELAYS, "placement_logic_sink_delays.echo");
147  setEchoFileName(E_ECHO_ROUTING_SINK_DELAYS, "routing_sink_delays.echo");
148  setEchoFileName(E_ECHO_POST_FLOW_TIMING_GRAPH, "post_flow_timing_graph.blif");
149  setEchoFileName(E_ECHO_POST_PACK_NETLIST, "post_pack_netlist.blif");
150  setEchoFileName(E_ECHO_BLIF_INPUT, "blif_input.echo");
151  setEchoFileName(E_ECHO_NET_DELAY, "net_delay.echo");
152  setEchoFileName(E_ECHO_TIMING_GRAPH, "timing_graph.echo");
153  setEchoFileName(E_ECHO_LUT_REMAPPING, "lut_remapping.echo");
154  setEchoFileName(E_ECHO_PRE_PACKING_TIMING_GRAPH, "pre_packing_timing_graph.echo");
155  setEchoFileName(E_ECHO_PRE_PACKING_TIMING_GRAPH_AS_BLIF, "pre_packing_timing_graph_as_blif.blif");
156  setEchoFileName(E_ECHO_CLUSTERING_TIMING_INFO, "clustering_timing_info.echo");
157  setEchoFileName(E_ECHO_PRE_PACKING_SLACK, "pre_packing_slack.echo");
158  setEchoFileName(E_ECHO_PRE_PACKING_CRITICALITY, "pre_packing_criticality.echo");
159  setEchoFileName(E_ECHO_CLUSTERING_BLOCK_CRITICALITIES, "clustering_block_criticalities.echo");
160  setEchoFileName(E_ECHO_PRE_PACKING_MOLECULES_AND_PATTERNS, "pre_packing_molecules_and_patterns.echo");
161  setEchoFileName(E_ECHO_MEM, "mem.echo");
162  setEchoFileName(E_ECHO_RR_GRAPH, "rr_graph.echo");
163  setEchoFileName(E_ECHO_TIMING_CONSTRAINTS, "timing_constraints.echo");
164  setEchoFileName(E_ECHO_CRITICAL_PATH, "critical_path.echo");
165  setEchoFileName(E_ECHO_SLACK, "slack.echo");
166  setEchoFileName(E_ECHO_CRITICALITY, "criticality.echo");
167  setEchoFileName(E_ECHO_COMPLETE_NET_TRACE, "complete_net_trace.echo");
168  setEchoFileName(E_ECHO_SEG_DETAILS, "seg_details.txt");
169 }
170 
172  int i;
173  if(echoFileEnabled != NULL) {
174  for(i = 0; i < (int) E_ECHO_END_TOKEN; i++) {
175  if(echoFileNames[i] != NULL) {
176  free(echoFileNames[i]);
177  }
178  }
179  free(echoFileNames);
180  free(echoFileEnabled);
181  echoFileNames = NULL;
182  echoFileEnabled = NULL;
183  }
184 }
185 
186 void setOutputFileName(enum e_output_files ename, const char *name, const char *default_name) {
187  if(outputFileNames == NULL) {
188  alloc_and_load_output_file_names(default_name);
189  }
190  if(outputFileNames[(int)ename] != NULL) {
191  free(outputFileNames[(int)ename]);
192  }
193  outputFileNames[(int)ename] = my_strdup(name);
194 }
195 
197  return outputFileNames[(int)ename];
198 }
199 
200 void alloc_and_load_output_file_names(const char *default_name) {
201  char *name;
202 
203  if(outputFileNames == NULL) {
204 
205  outputFileNames = (char**)my_calloc((int)E_FILE_END_TOKEN, sizeof(char*));
206 
207  name = (char*)my_malloc((strlen(default_name) + 40) * sizeof(char));
208  sprintf(name, "%s.critical_path.out", default_name);
209  setOutputFileName(E_CRIT_PATH_FILE, name, default_name);
210 
211  sprintf(name, "%s.slack.out", default_name);
212  setOutputFileName(E_SLACK_FILE, name, default_name);
213 
214  sprintf(name, "%s.criticality.out", default_name);
215  setOutputFileName(E_CRITICALITY_FILE, name, default_name);
216 
217  free(name);
218  }
219 }
220 
222  int i;
223  if(outputFileNames != NULL) {
224  for(i = 0; i < (int)E_FILE_END_TOKEN; i++) {
225  if(outputFileNames[i] != NULL) {
226  free(outputFileNames[i]);
227  outputFileNames[i] = NULL;
228  }
229  }
230  free(outputFileNames);
231  outputFileNames = NULL;
232  }
233 }
234 
235 
236 
237 /******** Subroutine implementations ********/
238 
239 void ReadOptions(INP int argc, INP char **argv, OUTP t_options * Options) {
240  char **Args, **head;
241  int offset;
242 
243  /* Clear values and pointers to zero */
244  memset(Options, 0, sizeof(t_options));
245 
246  /* Alloc a new pointer list for args with a NULL at end.
247  * This makes parsing the same as for archfile for consistency.
248  * Skips the first arg as it is the program image path */
249  --argc;
250  ++argv;
251  head = Args = (char **) my_malloc(sizeof(char *) * (argc + 1));
252  memcpy(Args, argv, (sizeof(char *) * argc));
253  Args[argc] = NULL;
254 
255  /* Go through the command line args. If they have hyphens they are
256  * options. Otherwise assume they are part of the four mandatory
257  * arguments */
258  while (*Args) {
259  if (strncmp("--", *Args, 2) == 0) {
260  *Args += 2; /* Skip the prefix */
261  Args = ProcessOption(Args, Options);
262  } else if (strncmp("-", *Args, 1) == 0) {
263  *Args += 1; /* Skip the prefix */
264  Args = ProcessOption(Args, Options);
265  } else if (NULL == Options->ArchFile) {
266  Options->ArchFile = my_strdup(*Args);
267  vpr_printf(TIO_MESSAGE_INFO, "Architecture file: %s\n", Options->ArchFile);
268  ++Args;
269  } else if (NULL == Options->CircuitName) {
270  Options->CircuitName = my_strdup(*Args);
271  /*if the user entered the circuit name with the .blif extension, remove it now*/
272  offset = strlen(Options->CircuitName) - 5;
273  if (offset > 0 && !strcmp(Options->CircuitName + offset, ".blif")) {
274  Options->CircuitName[offset] = '\0';
275  }
276  vpr_printf(TIO_MESSAGE_INFO, "Circuit name: %s.blif\n", Options->CircuitName);
277  vpr_printf(TIO_MESSAGE_INFO, "\n");
278  ++Args;
279  } else {
280  /* Not an option and arch and net already specified so fail */
281  Error(*Args);
282  }
283 
284  if (Options->Count[OT_SETTINGS_FILE] != Options->read_settings)
285  {
286  int tmp_argc = 0;
287  char **tmp_argv = NULL;
288  t_options SettingsFileOptions;
289 
290  tmp_argc = read_settings_file(Options->SettingsFile, &tmp_argv);
291 
292  ReadOptions(tmp_argc, tmp_argv, &SettingsFileOptions);
293 
294  MergeOptions(Options, &SettingsFileOptions, Options->Count[OT_SETTINGS_FILE]);
295 
296  Options->read_settings = Options->Count[OT_SETTINGS_FILE];
297 
298  /* clean up local data structures */
299  free(tmp_argv);
300  }
301  }
302  free(head);
303 }
304 
305 static char **
306 ProcessOption(INP char **Args, INOUTP t_options * Options) {
307  enum e_OptionBaseToken Token;
308  char **PrevArgs;
309 
310  PrevArgs = Args;
311  Args = ReadBaseToken(Args, &Token);
312 
313  if (Token < OT_BASE_UNKNOWN) {
314  /* If this was previously set by a lower priority source
315  * (ie. a settings file), reset the provenance and the
316  * count */
317  if (Options->Provenance[Token])
318  {
319  Options->Provenance[Token] = 0;
320  Options->Count[Token] = 1;
321  }
322  else
323  ++Options->Count[Token];
324  }
325 
326  switch (Token) {
327  /* File naming options */
328  case OT_BLIF_FILE:
329  return ReadString(Args, &Options->BlifFile);
330  case OT_NET_FILE:
331  return ReadString(Args, &Options->NetFile);
332  case OT_PLACE_FILE:
333  return ReadString(Args, &Options->PlaceFile);
334  case OT_ROUTE_FILE:
335  return ReadString(Args, &Options->RouteFile);
336  case OT_SDC_FILE:
337  return ReadString(Args, &Options->SDCFile);
338  case OT_SETTINGS_FILE:
339  return ReadString(Args, &Options->SettingsFile);
340  /* General Options */
341  case OT_NODISP:
342  return Args;
343  case OT_AUTO:
344  return ReadInt(Args, &Options->GraphPause);
345  case OT_PACK:
346  case OT_ROUTE:
347  case OT_PLACE:
348  return Args;
350  return ReadFloat(Args, &Options->constant_net_delay);
351  case OT_FAST:
352  case OT_FULL_STATS:
353  return Args;
354  case OT_TIMING_ANALYSIS:
355  return ReadOnOff(Args, &Options->TimingAnalysis);
356  case OT_OUTFILE_PREFIX:
357  return ReadString(Args, &Options->out_file_prefix);
358  case OT_CREATE_ECHO_FILE:
359  return ReadOnOff(Args, &Options->CreateEchoFile);
361 
362  return ReadOnOff(Args, &Options->Generate_Post_Synthesis_Netlist);
363  /* Clustering Options */
364  case OT_GLOBAL_CLOCKS:
365  return ReadOnOff(Args, &Options->global_clocks);
367  return ReadOnOff(Args, &Options->hill_climbing_flag);
369  return ReadOnOff(Args, &Options->sweep_hanging_nets_and_inputs);
371  return ReadOnOff(Args, &Options->timing_driven);
372  case OT_CLUSTER_SEED:
373  return ReadClusterSeed(Args, &Options->cluster_seed_type);
374  case OT_ALPHA_CLUSTERING:
375  return ReadFloat(Args, &Options->alpha);
376  case OT_BETA_CLUSTERING:
377  return ReadFloat(Args, &Options->beta);
379  return ReadInt(Args, &Options->recompute_timing_after);
381  return ReadFloat(Args, &Options->block_delay);
383  return ReadOnOff(Args, &Options->allow_unrelated_clustering);
384  case OT_ALLOW_EARLY_EXIT:
385  return ReadOnOff(Args, &Options->allow_early_exit);
387  return ReadFloat(Args, &Options->intra_cluster_net_delay);
389  return ReadFloat(Args, &Options->inter_cluster_net_delay);
391  return ReadOnOff(Args, &Options->connection_driven);
392  case OT_SKIP_CLUSTERING:
393  return Args;
394  case OT_PACKER_ALGORITHM:
395  return ReadPackerAlgorithm(Args, &Options->packer_algorithm);
396 
397  /* Placer Options */
398  case OT_PLACE_ALGORITHM:
399  return ReadPlaceAlgorithm(Args, &Options->PlaceAlgorithm);
400  case OT_INIT_T:
401  return ReadFloat(Args, &Options->PlaceInitT);
402  case OT_EXIT_T:
403  return ReadFloat(Args, &Options->PlaceExitT);
404  case OT_ALPHA_T:
405  return ReadFloat(Args, &Options->PlaceAlphaT);
406  case OT_INNER_NUM:
407  return ReadFloat(Args, &Options->PlaceInnerNum);
408  case OT_SEED:
409  return ReadInt(Args, &Options->Seed);
410  case OT_PLACE_COST_EXP:
411  return ReadFloat(Args, &Options->place_cost_exp);
412  case OT_PLACE_CHAN_WIDTH:
413  return ReadInt(Args, &Options->PlaceChanWidth);
414  case OT_FIX_PINS:
415  return ReadFixPins(Args, &Options->PinFile);
417  return ReadOnOff(Args, &Options->ShowPlaceTiming);
418  case OT_BLOCK_DIST:
419  return ReadInt(Args, &Options->block_dist);
420 
421  /* Placement Options Valid Only for Timing-Driven Placement */
422  case OT_TIMING_TRADEOFF:
423  return ReadFloat(Args, &Options->PlaceTimingTradeoff);
425  return ReadInt(Args, &Options->RecomputeCritIter);
427  return ReadInt(Args, &Options->inner_loop_recompute_divider);
429  return ReadFloat(Args, &Options->place_exp_first);
431  return ReadFloat(Args, &Options->place_exp_last);
432 
433  /* Router Options */
435  return ReadInt(Args, &Options->max_router_iterations);
436  case OT_BB_FACTOR:
437  return ReadInt(Args, &Options->bb_factor);
438  case OT_INITIAL_PRES_FAC:
439  return ReadFloat(Args, &Options->initial_pres_fac);
440  case OT_PRES_FAC_MULT:
441  return ReadFloat(Args, &Options->pres_fac_mult);
442  case OT_ACC_FAC:
443  return ReadFloat(Args, &Options->acc_fac);
445  return ReadFloat(Args, &Options->first_iter_pres_fac);
446  case OT_BEND_COST:
447  return ReadFloat(Args, &Options->bend_cost);
448  case OT_ROUTE_TYPE:
449  return ReadRouteType(Args, &Options->RouteType);
451  return Args;
452  case OT_ROUTE_CHAN_WIDTH:
453  return ReadInt(Args, &Options->RouteChanWidth);
454  case OT_ROUTER_ALGORITHM:
455  return ReadRouterAlgorithm(Args, &Options->RouterAlgorithm);
456  case OT_BASE_COST_TYPE:
457  return ReadBaseCostType(Args, &Options->base_cost_type);
458 
459  /* Routing options valid only for timing-driven routing */
460  case OT_ASTAR_FAC:
461  return ReadFloat(Args, &Options->astar_fac);
462  case OT_MAX_CRITICALITY:
463  return ReadFloat(Args, &Options->max_criticality);
464  case OT_CRITICALITY_EXP:
465  return ReadFloat(Args, &Options->criticality_exp);
466 
467  /* Power options */
468  case OT_POWER:
469  return Args;
470  case OT_ACTIVITY_FILE:
471  return ReadString(Args, &Options->ActFile);
472  case OT_POWER_OUT_FILE:
473  return ReadString(Args, &Options->PowerFile);
475  return ReadString(Args, &Options->CmosTechFile);
476 
477  default:
478  vpr_printf(TIO_MESSAGE_ERROR, "Unexpected option '%s' on command line.\n", *PrevArgs);
479  exit(1);
480  }
481 }
482 
483 /*
484  * Map options set in the source t_options to a target t_options
485  * structure. Existing values in the destination have priority
486  * and will not be overwritten
487  */
488 static void MergeOptions(INOUTP t_options * dest, INP t_options * src, int id)
489 {
490  int Token;
491 
492  for (Token = 0; Token < OT_BASE_UNKNOWN; Token++)
493  {
494  /* Don't override values already set in the
495  * target destination. Also do not process
496  * Tokens that are not present in the source.
497  */
498  if ((dest->Count[Token] || (!src->Count[Token])))
499  continue;
500 
501  dest->Count[Token] = src->Count[Token];
502  dest->Provenance[Token] = id;
503 
504  switch (Token) {
505  /* File naming options */
506  case OT_BLIF_FILE:
507  dest->BlifFile = src->BlifFile;
508  break;
509  case OT_NET_FILE:
510  dest->NetFile = src->NetFile;
511  break;
512  case OT_PLACE_FILE:
513  dest->PlaceFile = src->PlaceFile;
514  break;
515  case OT_ROUTE_FILE:
516  dest->RouteFile = src->RouteFile;
517  break;
518  case OT_SETTINGS_FILE:
519  dest->SettingsFile = src->SettingsFile;
520  break;
521  case OT_SDC_FILE:
522  dest->SDCFile = src->SDCFile;
523  break;
524  /* General Options */
525  case OT_NODISP:
526  break;
527  case OT_AUTO:
528  dest->GraphPause = src->GraphPause;
529  break;
530  case OT_PACK:
531  case OT_ROUTE:
532  case OT_PLACE:
533  break;
535  dest->constant_net_delay = src->constant_net_delay;
536  break;
537  case OT_FAST:
538  case OT_FULL_STATS:
539  break;
540  case OT_TIMING_ANALYSIS:
541  dest->TimingAnalysis = src->TimingAnalysis;
542  break;
543  case OT_OUTFILE_PREFIX:
544  dest->out_file_prefix = src->out_file_prefix;
545  break;
546  case OT_CREATE_ECHO_FILE:
547  dest->CreateEchoFile = src->CreateEchoFile;
548  break;
549 
550  /* Clustering Options */
551  case OT_GLOBAL_CLOCKS:
552  dest->global_clocks = src->global_clocks;
553  break;
555  dest->hill_climbing_flag = src->hill_climbing_flag;
556  break;
558  dest->sweep_hanging_nets_and_inputs = src->sweep_hanging_nets_and_inputs;
559  break;
561  dest->timing_driven = src->timing_driven;
562  break;
563  case OT_CLUSTER_SEED:
564  dest->cluster_seed_type = src->cluster_seed_type;
565  break;
566  case OT_ALPHA_CLUSTERING:
567  dest->alpha = src->alpha;
568  break;
569  case OT_BETA_CLUSTERING:
570  dest->beta = src->beta;
571  break;
573  dest->recompute_timing_after = src->recompute_timing_after;
574  break;
576  dest->block_delay = src->block_delay;
577  break;
579  dest->allow_unrelated_clustering = src->allow_unrelated_clustering;
580  break;
581  case OT_ALLOW_EARLY_EXIT:
582  dest->allow_early_exit = src->allow_early_exit;
583  break;
585  dest->intra_cluster_net_delay = src->intra_cluster_net_delay;
586  break;
588  dest->inter_cluster_net_delay = src->inter_cluster_net_delay;
589  break;
591  dest->connection_driven = src->connection_driven;
592  break;
593  case OT_SKIP_CLUSTERING:
594  break;
595  case OT_PACKER_ALGORITHM:
596  dest->packer_algorithm = src->packer_algorithm;
597  break;
598 
599  /* Placer Options */
600  case OT_PLACE_ALGORITHM:
601  dest->PlaceAlgorithm = src->PlaceAlgorithm;
602  break;
603  case OT_INIT_T:
604  dest->PlaceInitT = src->PlaceInitT;
605  break;
606  case OT_EXIT_T:
607  dest->PlaceExitT = src->PlaceExitT;
608  break;
609  case OT_ALPHA_T:
610  dest->PlaceAlphaT = src->PlaceAlphaT;
611  break;
612  case OT_INNER_NUM:
613  dest->PlaceInnerNum = src->PlaceInnerNum;
614  break;
615  case OT_SEED:
616  dest->Seed = src->Seed;
617  break;
618  case OT_PLACE_COST_EXP:
619  dest->place_cost_exp = src->place_cost_exp;
620  break;
621  case OT_PLACE_CHAN_WIDTH:
622  dest->PlaceChanWidth = src->PlaceChanWidth;
623  break;
624  case OT_FIX_PINS:
625  dest->PinFile = src->PinFile;
626  break;
628  dest->ShowPlaceTiming = src->ShowPlaceTiming;
629  break;
630  case OT_BLOCK_DIST:
631  dest->block_dist = src->block_dist;
632  break;
633 
634  /* Placement Options Valid Only for Timing-Driven Placement */
635  case OT_TIMING_TRADEOFF:
636  dest->PlaceTimingTradeoff = src->PlaceTimingTradeoff;
637  break;
639  dest->RecomputeCritIter = src->RecomputeCritIter;
640  break;
642  dest->inner_loop_recompute_divider = src->inner_loop_recompute_divider;
643  break;
645  dest->place_exp_first = src->place_exp_first;
646  break;
648  dest->place_exp_last = src->place_exp_last;
649  break;
650 
651  /* Router Options */
653  dest->max_router_iterations = src->max_router_iterations;
654  break;
655  case OT_BB_FACTOR:
656  dest->bb_factor = src->bb_factor;
657  break;
658  case OT_INITIAL_PRES_FAC:
659  dest->initial_pres_fac = src->initial_pres_fac;
660  break;
661  case OT_PRES_FAC_MULT:
662  dest->pres_fac_mult = src->pres_fac_mult;
663  break;
664  case OT_ACC_FAC:
665  dest->acc_fac = src->acc_fac;
666  break;
668  dest->first_iter_pres_fac = src->first_iter_pres_fac;
669  break;
670  case OT_BEND_COST:
671  dest->bend_cost = src->bend_cost;
672  break;
673  case OT_ROUTE_TYPE:
674  dest->RouteType = src->RouteType;
675  break;
677  break;
678  case OT_ROUTE_CHAN_WIDTH:
679  dest->RouteChanWidth = src->RouteChanWidth;
680  break;
681  case OT_ROUTER_ALGORITHM:
682  dest->RouterAlgorithm = src->RouterAlgorithm;
683  break;
684  case OT_BASE_COST_TYPE:
685  dest->base_cost_type = src->base_cost_type;
686  break;
687 
688  /* Routing options valid only for timing-driven routing */
689  case OT_ASTAR_FAC:
690  dest->astar_fac = src->astar_fac;
691  break;
692  case OT_MAX_CRITICALITY:
693  dest->max_criticality = src->max_criticality;
694  break;
695  case OT_CRITICALITY_EXP:
696  dest->criticality_exp = src->criticality_exp;
697  break;
698  default:
699  break;
700  }
701  }
702 }
703 
704 static char **
705 ReadBaseToken(INP char **Args, OUTP enum e_OptionBaseToken *Token) {
706  struct s_TokenPair *Cur;
707 
708  /* Empty string is end of tokens marker */
709  if (NULL == *Args)
710  Error(*Args);
711 
712  /* Linear search for the pair */
713  Cur = OptionBaseTokenList;
714  while (Cur->Str) {
715  if (strcmp(*Args, Cur->Str) == 0) {
716  *Token = (enum e_OptionBaseToken) Cur->Enum;
717  return ++Args;
718  }
719  ++Cur;
720  }
721 
722  *Token = OT_BASE_UNKNOWN;
723  return ++Args;
724 }
725 
726 static char **
727 ReadToken(INP char **Args, OUTP enum e_OptionArgToken *Token) {
728  struct s_TokenPair *Cur;
729 
730  /* Empty string is end of tokens marker */
731  if (NULL == *Args)
732  Error(*Args);
733 
734  /* Linear search for the pair */
735  Cur = OptionArgTokenList;
736  while (Cur->Str) {
737  if (strcmp(*Args, Cur->Str) == 0) {
738  *Token = (enum e_OptionArgToken)Cur->Enum;
739  return ++Args;
740  }
741  ++Cur;
742  }
743 
744  *Token = OT_ARG_UNKNOWN;
745  return ++Args;
746 }
747 
748 /* Called for parse errors. Spits out a message and then exits program. */
749 static void Error(INP const char *Token) {
750  if (Token) {
751  vpr_printf(TIO_MESSAGE_ERROR, "Unexpected token '%s' on command line.\n", Token);
752  } else {
753  vpr_printf(TIO_MESSAGE_ERROR, "Missing token at end of command line.\n");
754  }
755  exit(1);
756 }
757 
758 static char **
759 ReadClusterSeed(INP char **Args, OUTP enum e_cluster_seed *Type) {
760  enum e_OptionArgToken Token;
761  char **PrevArgs;
762 
763  PrevArgs = Args;
764  Args = ReadToken(Args, &Token);
765  switch (Token) {
766  case OT_TIMING:
767  *Type = VPACK_TIMING;
768  break;
769  case OT_MAX_INPUTS:
770  *Type = VPACK_MAX_INPUTS;
771  break;
772  default:
773  Error(*PrevArgs);
774  }
775 
776  return Args;
777 }
778 
779 static char **
780 ReadPackerAlgorithm(INP char **Args, OUTP enum e_packer_algorithm *Algo) {
781  enum e_OptionArgToken Token;
782  char **PrevArgs;
783 
784  PrevArgs = Args;
785  Args = ReadToken(Args, &Token);
786  switch (Token) {
787  case OT_GREEDY:
788  *Algo = PACK_GREEDY;
789  break;
790  case OT_BRUTE_FORCE:
791  *Algo = PACK_BRUTE_FORCE;
792  break;
793  default:
794  Error(*PrevArgs);
795  }
796 
797  return Args;
798 }
799 
800 static char **
801 ReadRouterAlgorithm(INP char **Args, OUTP enum e_router_algorithm *Algo) {
802  enum e_OptionArgToken Token;
803  char **PrevArgs;
804 
805  PrevArgs = Args;
806  Args = ReadToken(Args, &Token);
807  switch (Token) {
808  case OT_BREADTH_FIRST:
809  *Algo = BREADTH_FIRST;
810  break;
811  case OT_NO_TIMING:
812  *Algo = NO_TIMING;
813  break;
814  case OT_TIMING_DRIVEN:
815  *Algo = TIMING_DRIVEN;
816  break;
817  default:
818  Error(*PrevArgs);
819  }
820 
821  return Args;
822 }
823 
824 static char **
825 ReadBaseCostType(INP char **Args, OUTP enum e_base_cost_type *BaseCostType) {
826  enum e_OptionArgToken Token;
827  char **PrevArgs;
828 
829  PrevArgs = Args;
830  Args = ReadToken(Args, &Token);
831  switch (Token) {
832  case OT_INTRINSIC_DELAY:
833  *BaseCostType = INTRINSIC_DELAY;
834  break;
835  case OT_DELAY_NORMALIZED:
836  *BaseCostType = DELAY_NORMALIZED;
837  break;
838  case OT_DEMAND_ONLY:
839  *BaseCostType = DEMAND_ONLY;
840  break;
841  default:
842  Error(*PrevArgs);
843  }
844 
845  return Args;
846 }
847 
848 static char **
849 ReadRouteType(INP char **Args, OUTP enum e_route_type *Type) {
850  enum e_OptionArgToken Token;
851  char **PrevArgs;
852 
853  PrevArgs = Args;
854  Args = ReadToken(Args, &Token);
855  switch (Token) {
856  case OT_GLOBAL:
857  *Type = GLOBAL;
858  break;
859  case OT_DETAILED:
860  *Type = DETAILED;
861  break;
862  default:
863  Error(*PrevArgs);
864  }
865 
866  return Args;
867 }
868 
869 static char **
870 ReadPlaceAlgorithm(INP char **Args, OUTP enum e_place_algorithm *Algo) {
871  enum e_OptionArgToken Token;
872  char **PrevArgs;
873 
874  PrevArgs = Args;
875  Args = ReadToken(Args, &Token);
876  switch (Token) {
877  case OT_BOUNDING_BOX:
878  *Algo = BOUNDING_BOX_PLACE;
879  break;
881  *Algo = NET_TIMING_DRIVEN_PLACE;
882  break;
884  *Algo = PATH_TIMING_DRIVEN_PLACE;
885  break;
886  default:
887  Error(*PrevArgs);
888  }
889 
890  return Args;
891 }
892 
893 static char **
894 ReadFixPins(INP char **Args, OUTP char **PinFile) {
895  enum e_OptionArgToken Token;
896  int Len;
897  char **PrevArgs = Args;
898 
899  Args = ReadToken(Args, &Token);
900  if (OT_RANDOM != Token) {
901  Len = 1 + strlen(*PrevArgs);
902  *PinFile = (char *) my_malloc(Len * sizeof(char));
903  memcpy(*PinFile, *PrevArgs, Len);
904  }
905  return Args;
906 }
907 
908 static char **
909 ReadOnOff(INP char **Args, OUTP boolean * Val) {
910  enum e_OptionArgToken Token;
911  char **PrevArgs;
912 
913  PrevArgs = Args;
914  Args = ReadToken(Args, &Token);
915  switch (Token) {
916  case OT_ON:
917  *Val = TRUE;
918  break;
919  case OT_OFF:
920  *Val = FALSE;
921  break;
922  default:
923  Error(*PrevArgs);
924  }
925  return Args;
926 }
927 
928 static char **
929 ReadInt(INP char **Args, OUTP int *Val) {
930  if (NULL == *Args)
931  Error(*Args);
932  if ((**Args > '9') || (**Args < '0'))
933  Error(*Args);
934 
935  *Val = atoi(*Args);
936 
937  return ++Args;
938 }
939 
940 static char **
941 ReadFloat(INP char ** Args, OUTP float *Val) {
942  if (NULL == *Args) {
943  Error(*Args);
944  }
945 
946  if ((**Args != '-') && (**Args != '.')
947  && ((**Args > '9') || (**Args < '0'))) {
948  Error(*Args);
949  }
950 
951  *Val = atof(*Args);
952 
953  return ++Args;
954 }
955 
956 static char **
957 ReadString(INP char **Args, OUTP char **Val) {
958  if (NULL == *Args) {
959  Error(*Args);
960  }
961 
962  *Val = my_strdup(*Args);
963 
964  return ++Args;
965 }
966 
967 
static char ** ReadString(INP char **Args, OUTP char **Val)
Definition: ReadOptions.c:957
void setEchoEnabled(boolean echo_enabled)
Definition: ReadOptions.c:71
const char * Str
Definition: vpr_types.h:1027
int Count[OT_BASE_UNKNOWN]
Definition: ReadOptions.h:88
static void Error(INP const char *Token)
Definition: ReadOptions.c:749
static char ** ReadBaseCostType(INP char **Args, OUTP enum e_base_cost_type *BaseCostType)
Definition: ReadOptions.c:825
boolean IsPostSynthesisEnabled(INP t_options *Options)
Definition: ReadOptions.c:88
static char ** ReadClusterSeed(INP char **Args, OUTP enum e_cluster_seed *Type)
Definition: ReadOptions.c:759
boolean
Definition: util.h:11
struct s_TokenPair OptionBaseTokenList[]
Definition: OptionTokens.c:7
static char ** ReadPackerAlgorithm(INP char **Args, OUTP enum e_packer_algorithm *Algo)
Definition: ReadOptions.c:780
boolean IsTimingEnabled(INP t_options *Options)
Definition: ReadOptions.c:47
boolean IsEchoEnabled(INP t_options *Options)
Definition: ReadOptions.c:58
static char ** ReadToken(INP char **Args, OUTP enum e_OptionArgToken *Token)
Definition: ReadOptions.c:727
void * my_calloc(size_t nelem, size_t size)
Definition: util.c:132
static void MergeOptions(INOUTP t_options *dest, INP t_options *src, int id)
Definition: ReadOptions.c:488
void ReadOptions(INP int argc, INP char **argv, OUTP t_options *Options)
Definition: ReadOptions.c:239
static boolean * echoFileEnabled
Definition: ReadOptions.c:16
e_cluster_seed
Definition: vpr_types.h:112
static char ** ReadInt(INP char **Args, OUTP int *Val)
Definition: ReadOptions.c:929
e_echo_files
Definition: ReadOptions.h:95
#define INOUTP
Definition: util.h:21
static boolean EchoEnabled
Definition: ReadOptions.c:12
boolean getEchoEnabled(void)
Definition: ReadOptions.c:67
void free_output_file_names()
Definition: ReadOptions.c:221
Definition: util.h:12
void setAllEchoFileEnabled(boolean value)
Definition: ReadOptions.c:97
static char ** ReadBaseToken(INP char **Args, OUTP enum e_OptionBaseToken *Token)
Definition: ReadOptions.c:705
static void * my_malloc(int ibytes)
Definition: graphics.c:499
#define INP
Definition: util.h:19
static char ** ReadFixPins(INP char **Args, OUTP char **PinFile)
Definition: ReadOptions.c:894
void setOutputFileName(enum e_output_files ename, const char *name, const char *default_name)
Definition: ReadOptions.c:186
boolean isEchoFileEnabled(enum e_echo_files echo_option)
Definition: ReadOptions.c:115
static char ** ReadPlaceAlgorithm(INP char **Args, OUTP enum e_place_algorithm *Algo)
Definition: ReadOptions.c:870
static char ** outputFileNames
Definition: ReadOptions.c:19
struct s_TokenPair OptionArgTokenList[]
Definition: OptionTokens.c:63
static char ** ReadOnOff(INP char **Args, OUTP boolean *Val)
Definition: ReadOptions.c:909
boolean GetPostSynthesisOption(void)
Definition: ReadOptions.c:80
e_output_files
Definition: ReadOptions.h:137
e_base_cost_type
Definition: vpr_types.h:688
static char ** ProcessOption(INP char **Args, INOUTP t_options *Options)
Definition: ReadOptions.c:306
char * getOutputFileName(enum e_output_files ename)
Definition: ReadOptions.c:196
static char ** echoFileNames
Definition: ReadOptions.c:17
void setEchoFileEnabled(enum e_echo_files echo_option, boolean value)
Definition: ReadOptions.c:104
e_router_algorithm
Definition: vpr_types.h:685
static char ** ReadRouteType(INP char **Args, OUTP enum e_route_type *Type)
Definition: ReadOptions.c:849
void SetPostSynthesisOption(boolean post_synthesis_enabled)
Definition: ReadOptions.c:84
e_OptionArgToken
Definition: OptionTokens.h:80
void free_echo_file_info()
Definition: ReadOptions.c:171
e_OptionBaseToken
Definition: OptionTokens.h:6
int read_settings_file(char *file_name, char ***outv)
Definition: read_settings.c:53
char * getEchoFileName(enum e_echo_files echo_option)
Definition: ReadOptions.c:122
#define OUTP
Definition: util.h:20
static char ** ReadFloat(INP char **Args, OUTP float *Val)
Definition: ReadOptions.c:941
e_route_type
Definition: vpr_types.h:682
void alloc_and_load_echo_file_info()
Definition: ReadOptions.c:126
void setEchoFileName(enum e_echo_files echo_option, const char *name)
Definition: ReadOptions.c:108
char * my_strdup(const char *str)
Definition: util.c:101
void alloc_and_load_output_file_names(const char *default_name)
Definition: ReadOptions.c:200
e_packer_algorithm
Definition: vpr_types.h:590
messagelogger vpr_printf
Definition: util.c:17
static char ** ReadRouterAlgorithm(INP char **Args, OUTP enum e_router_algorithm *Algo)
Definition: ReadOptions.c:801
e_place_algorithm
Definition: vpr_types.h:632
static boolean Generate_PostSynthesis_Netlist
Definition: ReadOptions.c:14
Definition: util.h:12