void initVST() { jfst_reserve_mem(1000000); if (fst_init(fstSignalHandler)) { printf("initVST failed\n"); return; } char* vstPath = getenv("VST_PATH"); if (vstPath == 0) vstPath = "/usr/lib/vst:/usr/local/lib/vst"; char* p = vstPath; while (*p != '\0') { char* pe = p; while (*pe != ':' && *pe != '\0') pe++; int n = pe - p; if (n) { char* buffer = new char[n + 1]; strncpy(buffer, p, n); buffer[n] = '\0'; scanVstDir(QString(buffer)); delete[] buffer; } p = pe; if (*p == ':') p++; } }
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; }
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; }