Exemple #1
0
void group_nets(tree_t top)
{
   const int nnets = tree_attr_int(top, nnets_i, 0);

   group_nets_ctx_t ctx;
   group_init_context(&ctx, nnets);
   tree_visit(top, group_nets_visit_fn, &ctx);

   group_write_netdb(top, &ctx);

   if (opt_get_int("verbose")) {
      int ngroups = 0;
      for (group_t *it = ctx.groups; it != NULL; it = it->next)
         ngroups++;

      notef("%d nets, %d groups", nnets, ngroups);
      notef("nets:groups ratio %.3f", (float)nnets / (float)ngroups);
   }

   group_free_list(ctx.groups);
   group_free_list(ctx.free_list);
   free(ctx.lookup);
}
Exemple #2
0
static void elab_verbose(bool verbose, const char *fmt, ...)
{
   if (verbose) {
      va_list ap;
      va_start(ap, fmt);
      char *msg LOCAL = xvasprintf(fmt, ap);
      va_end(ap);

      static nvc_rusage_t last_ru;

      nvc_rusage_t ru;
      nvc_rusage(&ru);
      notef("%s [%ums %+dkB]", msg, ru.ms, ru.rss - last_ru.rss);

      last_ru = ru;
   }
}
Exemple #3
0
void cover_report(tree_t top, const int32_t *stmts)
{
   stmt_tag_i = ident_new("stmt_tag");

   tree_visit(top, cover_report_stmts_fn, (void *)stmts);

   ident_t name = ident_strip(tree_ident(top), ident_new(".elab"));

   char dir[256];
   snprintf(dir, sizeof(dir), "%s.cover", istr(name));

   lib_t work = lib_work();
   lib_mkdir(work, dir);

   for (cover_file_t *f = files; f != NULL; f = f->next)
      cover_report_file(f, dir);

   cover_index(name, dir);

   char output[PATH_MAX];
   lib_realpath(work, dir, output, sizeof(output));
   notef("coverage report generated in %s/", output);
}
Exemple #4
0
void customrequest_helper(struct OperationConfig *config, HttpReq req,
                          char *method)
{
  /* this mirrors the HttpReq enum in tool_sdecls.h */
  const char *dflt[]= {
    "GET",
    "GET",
    "HEAD",
    "POST",
    "POST"
  };

  if(!method)
    ;
  else if(curl_strequal(method, dflt[req])) {
    notef(config->global, "Unnecessary use of -X or --request, %s is already "
          "inferred.\n", dflt[req]);
  }
  else if(curl_strequal(method, "head")) {
    warnf(config->global,
          "Setting custom HTTP method to HEAD with -X/--request may not work "
          "the way you want. Consider using -I/--head instead.\n");
  }
}
Exemple #5
0
static int run(int argc, char **argv)
{
   set_work_lib();

   static struct option long_options[] = {
      { "trace",      no_argument,       0, 't' },
      { "batch",      no_argument,       0, 'b' },
      { "command",    no_argument,       0, 'c' },
      { "stop-time",  required_argument, 0, 's' },
      { "stats",      no_argument,       0, 'S' },
      { "wave",       optional_argument, 0, 'w' },
      { "stop-delta", required_argument, 0, 'd' },
      { "format",     required_argument, 0, 'f' },
      { "include",    required_argument, 0, 'i' },
      { "exclude",    required_argument, 0, 'e' },
      { 0, 0, 0, 0 }
   };

   enum { BATCH, COMMAND } mode = BATCH;
   enum { LXT, FST, VCD} wave_fmt = FST;

   uint64_t stop_time = UINT64_MAX;
   const char *wave_fname = NULL;

   int c, index = 0;
   const char *spec = "bcw::";
   optind = 1;
   while ((c = getopt_long(argc, argv, spec, long_options, &index)) != -1) {
      switch (c) {
      case 0:
         // Set a flag
         break;
      case '?':
         // getopt_long already printed an error message
         exit(EXIT_FAILURE);
      case 't':
         opt_set_int("rt_trace_en", 1);
         break;
      case 'b':
         mode = BATCH;
         break;
      case 'c':
         mode = COMMAND;
         break;
      case 's':
         stop_time = parse_time(optarg);
         break;
      case 'f':
         if (strcmp(optarg, "vcd") == 0)
            wave_fmt = VCD;
         else if (strcmp(optarg, "fst") == 0)
            wave_fmt = FST;
         else if (strcmp(optarg, "lxt") == 0)
            wave_fmt = LXT;
         else
            fatal("invalid waveform format: %s", optarg);
         break;
      case 'S':
         opt_set_int("rt-stats", 1);
         break;
      case 'w':
         if (optarg == NULL)
            wave_fname = "";
         else
            wave_fname = optarg;
         break;
      case 'd':
         opt_set_int("stop-delta", parse_int(optarg));
         break;
      case 'i':
         wave_include_glob(optarg);
         break;
      case 'e':
         wave_exclude_glob(optarg);
         break;
      default:
         abort();
      }
   }

   if (optind == argc)
      fatal("missing top-level unit name");

   ident_t top = to_unit_name(argv[optind]);
   ident_t ename = ident_prefix(top, ident_new("elab"), '.');
   tree_rd_ctx_t ctx;
   tree_t e = lib_get_ctx(lib_work(), ename, &ctx);
   if (e == NULL)
      fatal("%s not elaborated", istr(top));
   else if (tree_kind(e) != T_ELAB)
      fatal("%s not suitable top level", istr(top));

   if (wave_fname != NULL) {
      const char *name_map[] = { "LXT", "FST", "VCD" };
      const char *ext_map[]  = { "lxt", "fst", "vcd" };
      char *tmp = NULL;

      if (*wave_fname == '\0') {
         tmp = xasprintf("%s.%s", argv[optind], ext_map[wave_fmt]);
         wave_fname = tmp;
         notef("writing %s waveform data to %s", name_map[wave_fmt], tmp);
      }

      wave_include_file(argv[optind]);

      switch (wave_fmt) {
      case LXT:
         lxt_init(wave_fname, e);
         break;
      case VCD:
         vcd_init(wave_fname, e);
         break;
      case FST:
         fst_init(wave_fname, e);
         break;
      }

      if (tmp != NULL)
         free(tmp);
   }

   if (mode == BATCH)
      rt_batch_exec(e, stop_time, ctx);
   else {
      bool master = slave_fork();
      if (master)
         shell_run(e, ctx);
      else
         rt_slave_exec(e, ctx);
   }

   tree_read_end(ctx);
   return EXIT_SUCCESS;
}
Exemple #6
0
static int run(int argc, char **argv)
{
   static struct option long_options[] = {
      { "trace",         no_argument,       0, 't' },
      { "batch",         no_argument,       0, 'b' },
      { "command",       no_argument,       0, 'c' },
      { "stop-time",     required_argument, 0, 's' },
      { "stats",         no_argument,       0, 'S' },
      { "wave",          optional_argument, 0, 'w' },
      { "stop-delta",    required_argument, 0, 'd' },
      { "format",        required_argument, 0, 'f' },
      { "include",       required_argument, 0, 'i' },
      { "exclude",       required_argument, 0, 'e' },
      { "exit-severity", required_argument, 0, 'x' },
#if ENABLE_VHPI
      { "load",          required_argument, 0, 'l' },
      { "vhpi-trace",    no_argument,       0, 'T' },
#endif
      { 0, 0, 0, 0 }
   };

   enum { BATCH, COMMAND } mode = BATCH;
   enum { LXT, FST, VCD} wave_fmt = FST;

   uint64_t stop_time = UINT64_MAX;
   const char *wave_fname = NULL;
   const char *vhpi_plugins = NULL;

   static bool have_run = false;
   if (have_run)
      fatal("multiple run commands are not supported");

   have_run = true;

   const int next_cmd = scan_cmd(2, argc, argv);

   int c, index = 0;
   const char *spec = "bcw::l:";
   while ((c = getopt_long(next_cmd, argv, spec, long_options, &index)) != -1) {
      switch (c) {
      case 0:
         // Set a flag
         break;
      case '?':
         fatal("unrecognised run option %s", argv[optind - 1]);
      case 't':
         opt_set_int("rt_trace_en", 1);
         break;
      case 'T':
         opt_set_int("vhpi_trace_en", 1);
         break;
      case 'b':
         mode = BATCH;
         break;
      case 'c':
         mode = COMMAND;
         break;
      case 's':
         stop_time = parse_time(optarg);
         break;
      case 'f':
         if (strcmp(optarg, "vcd") == 0)
            wave_fmt = VCD;
         else if (strcmp(optarg, "fst") == 0)
            wave_fmt = FST;
         else if (strcmp(optarg, "lxt") == 0)
            wave_fmt = LXT;
         else
            fatal("invalid waveform format: %s", optarg);
         break;
      case 'S':
         opt_set_int("rt-stats", 1);
         break;
      case 'w':
         if (optarg == NULL)
            wave_fname = "";
         else
            wave_fname = optarg;
         break;
      case 'd':
         opt_set_int("stop-delta", parse_int(optarg));
         break;
      case 'i':
         wave_include_glob(optarg);
         break;
      case 'e':
         wave_exclude_glob(optarg);
         break;
      case 'l':
         vhpi_plugins = optarg;
         break;
      case 'x':
         rt_set_exit_severity(parse_severity(optarg));
         break;
      default:
         abort();
      }
   }

   set_top_level(argv, next_cmd);

   ident_t ename = ident_prefix(top_level, ident_new("elab"), '.');
   tree_rd_ctx_t ctx;
   tree_t e = lib_get_ctx(lib_work(), ename, &ctx);
   if (e == NULL)
      fatal("%s not elaborated", istr(top_level));
   else if (tree_kind(e) != T_ELAB)
      fatal("%s not suitable top level", istr(top_level));

   if (wave_fname != NULL) {
      const char *name_map[] = { "LXT", "FST", "VCD" };
      const char *ext_map[]  = { "lxt", "fst", "vcd" };
      char *tmp LOCAL = NULL;

      if (*wave_fname == '\0') {
         tmp = xasprintf("%s.%s", argv[optind], ext_map[wave_fmt]);
         wave_fname = tmp;
         notef("writing %s waveform data to %s", name_map[wave_fmt], tmp);
      }

      wave_include_file(argv[optind]);

      switch (wave_fmt) {
      case LXT:
         lxt_init(wave_fname, e);
         break;
      case VCD:
         vcd_init(wave_fname, e);
         break;
      case FST:
         fst_init(wave_fname, e);
         break;
      }
   }

   rt_start_of_tool(e, ctx);

   if (vhpi_plugins != NULL)
      vhpi_load_plugins(e, vhpi_plugins);

   rt_restart(e);

   if (mode == COMMAND)
      shell_run(e, ctx);
   else
      rt_run_sim(stop_time);

   rt_end_of_tool(e);
   tree_read_end(ctx);

   argc -= next_cmd - 1;
   argv += next_cmd - 1;

   return argc > 1 ? process_command(argc, argv) : EXIT_SUCCESS;
}