Fixed ifdefs for plugin unloading
[yosys.git] / kernel / yosys.cc
1 /*
2 * yosys -- Yosys Open SYnthesis Suite
3 *
4 * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 *
18 */
19
20 #include "kernel/yosys.h"
21
22 #ifdef YOSYS_ENABLE_READLINE
23 # include <readline/readline.h>
24 # include <readline/history.h>
25 #endif
26
27 #ifdef YOSYS_ENABLE_PLUGINS
28 # include <dlfcn.h>
29 #endif
30
31 #include <unistd.h>
32 #include <limits.h>
33 #include <errno.h>
34
35 YOSYS_NAMESPACE_BEGIN
36
37 int autoidx = 1;
38 RTLIL::Design *yosys_design = NULL;
39
40 #ifdef YOSYS_ENABLE_TCL
41 Tcl_Interp *yosys_tcl_interp = NULL;
42 #endif
43
44 std::string stringf(const char *fmt, ...)
45 {
46 std::string string;
47 va_list ap;
48
49 va_start(ap, fmt);
50 string = vstringf(fmt, ap);
51 va_end(ap);
52
53 return string;
54 }
55
56 std::string vstringf(const char *fmt, va_list ap)
57 {
58 std::string string;
59 char *str = NULL;
60
61 #ifdef _WIN32
62 int sz = 64, rc;
63 while (1) {
64 va_list apc;
65 va_copy(apc, ap);
66 str = (char*)realloc(str, sz);
67 rc = vsnprintf(str, sz, fmt, apc);
68 va_end(apc);
69 if (rc >= 0 && rc < sz)
70 break;
71 sz *= 2;
72 }
73 #else
74 if (vasprintf(&str, fmt, ap) < 0)
75 str = NULL;
76 #endif
77
78 if (str != NULL) {
79 string = str;
80 free(str);
81 }
82
83 return string;
84 }
85
86 std::string next_token(std::string &text, const char *sep)
87 {
88 size_t pos_begin = text.find_first_not_of(sep);
89
90 if (pos_begin == std::string::npos)
91 pos_begin = text.size();
92
93 size_t pos_end = text.find_first_of(sep, pos_begin);
94
95 if (pos_end == std::string::npos)
96 pos_end = text.size();
97
98 std::string token = text.substr(pos_begin, pos_end-pos_begin);
99 text = text.substr(pos_end);
100 return token;
101 }
102
103 // this is very similar to fnmatch(). the exact rules used by this
104 // function are:
105 //
106 // ? matches any character except
107 // * matches any sequence of characters
108 // [...] matches any of the characters in the list
109 // [!..] matches any of the characters not in the list
110 //
111 // a backslash may be used to escape the next characters in the
112 // pattern. each special character can also simply match itself.
113 //
114 bool patmatch(const char *pattern, const char *string)
115 {
116 if (*pattern == 0)
117 return *string == 0;
118
119 if (*pattern == '\\') {
120 if (pattern[1] == string[0] && patmatch(pattern+2, string+1))
121 return true;
122 }
123
124 if (*pattern == '?') {
125 if (*string == 0)
126 return false;
127 return patmatch(pattern+1, string+1);
128 }
129
130 if (*pattern == '*') {
131 while (*string) {
132 if (patmatch(pattern+1, string++))
133 return true;
134 }
135 return pattern[1] == 0;
136 }
137
138 if (*pattern == '[') {
139 bool found_match = false;
140 bool inverted_list = pattern[1] == '!';
141 const char *p = pattern + (inverted_list ? 1 : 0);
142
143 while (*++p) {
144 if (*p == ']') {
145 if (found_match != inverted_list && patmatch(p+1, string+1))
146 return true;
147 break;
148 }
149
150 if (*p == '\\') {
151 if (*++p == *string)
152 found_match = true;
153 } else
154 if (*p == *string)
155 found_match = true;
156 }
157 }
158
159 if (*pattern == *string)
160 return patmatch(pattern+1, string+1);
161
162 return false;
163 }
164
165 int GetSize(RTLIL::Wire *wire)
166 {
167 return wire->width;
168 }
169
170 void yosys_setup()
171 {
172 Pass::init_register();
173 yosys_design = new RTLIL::Design;
174 log_push();
175 }
176
177 void yosys_shutdown()
178 {
179 log_pop();
180
181 delete yosys_design;
182 yosys_design = NULL;
183
184 for (auto f : log_files)
185 if (f != stderr)
186 fclose(f);
187 log_errfile = NULL;
188 log_files.clear();
189
190 Pass::done_register();
191
192 #ifdef YOSYS_ENABLE_TCL
193 if (yosys_tcl_interp != NULL) {
194 Tcl_DeleteInterp(yosys_tcl_interp);
195 Tcl_Finalize();
196 yosys_tcl_interp = NULL;
197 }
198 #endif
199
200 #ifdef YOSYS_ENABLE_PLUGINS
201 for (auto &it : loaded_plugins)
202 dlclose(it.second);
203 #endif
204
205 loaded_plugins.clear();
206 loaded_plugin_aliases.clear();
207 }
208
209 RTLIL::IdString new_id(std::string file, int line, std::string func)
210 {
211 std::string str = "$auto$";
212 size_t pos = file.find_last_of('/');
213 str += pos != std::string::npos ? file.substr(pos+1) : file;
214 str += stringf(":%d:%s$%d", line, func.c_str(), autoidx++);
215 return str;
216 }
217
218 RTLIL::Design *yosys_get_design()
219 {
220 return yosys_design;
221 }
222
223 const char *create_prompt(RTLIL::Design *design, int recursion_counter)
224 {
225 static char buffer[100];
226 std::string str = "\n";
227 if (recursion_counter > 1)
228 str += stringf("(%d) ", recursion_counter);
229 str += "yosys";
230 if (!design->selected_active_module.empty())
231 str += stringf(" [%s]", RTLIL::unescape_id(design->selected_active_module).c_str());
232 if (!design->selection_stack.empty() && !design->selection_stack.back().full_selection) {
233 if (design->selected_active_module.empty())
234 str += "*";
235 else if (design->selection_stack.back().selected_modules.size() != 1 || design->selection_stack.back().selected_members.size() != 0 ||
236 design->selection_stack.back().selected_modules.count(design->selected_active_module) == 0)
237 str += "*";
238 }
239 snprintf(buffer, 100, "%s> ", str.c_str());
240 return buffer;
241 }
242
243 #ifdef YOSYS_ENABLE_TCL
244 static int tcl_yosys_cmd(ClientData, Tcl_Interp *interp, int argc, const char *argv[])
245 {
246 std::vector<std::string> args;
247 for (int i = 1; i < argc; i++)
248 args.push_back(argv[i]);
249
250 if (args.size() >= 1 && args[0] == "-import") {
251 for (auto &it : pass_register) {
252 std::string tcl_command_name = it.first;
253 if (tcl_command_name == "proc")
254 tcl_command_name = "procs";
255 Tcl_CmdInfo info;
256 if (Tcl_GetCommandInfo(interp, tcl_command_name.c_str(), &info) != 0) {
257 log("[TCL: yosys -import] Command name collision: found pre-existing command `%s' -> skip.\n", it.first.c_str());
258 } else {
259 std::string tcl_script = stringf("proc %s args { yosys %s {*}$args }", tcl_command_name.c_str(), it.first.c_str());
260 Tcl_Eval(interp, tcl_script.c_str());
261 }
262 }
263 return TCL_OK;
264 }
265
266 if (args.size() == 1) {
267 Pass::call(yosys_get_design(), args[0]);
268 return TCL_OK;
269 }
270
271 Pass::call(yosys_get_design(), args);
272 return TCL_OK;
273 }
274
275 extern Tcl_Interp *yosys_get_tcl_interp()
276 {
277 if (yosys_tcl_interp == NULL) {
278 yosys_tcl_interp = Tcl_CreateInterp();
279 Tcl_CreateCommand(yosys_tcl_interp, "yosys", tcl_yosys_cmd, NULL, NULL);
280 }
281 return yosys_tcl_interp;
282 }
283
284 struct TclPass : public Pass {
285 TclPass() : Pass("tcl", "execute a TCL script file") { }
286 virtual void help() {
287 log("\n");
288 log(" tcl <filename>\n");
289 log("\n");
290 log("This command executes the tcl commands in the specified file.\n");
291 log("Use 'yosys cmd' to run the yosys command 'cmd' from tcl.\n");
292 log("\n");
293 log("The tcl command 'yosys -import' can be used to import all yosys\n");
294 log("commands directly as tcl commands to the tcl shell. The yosys\n");
295 log("command 'proc' is wrapped using the tcl command 'procs' in order\n");
296 log("to avoid a name collision with the tcl builting command 'proc'.\n");
297 log("\n");
298 }
299 virtual void execute(std::vector<std::string> args, RTLIL::Design *design) {
300 if (args.size() < 2)
301 log_cmd_error("Missing script file.\n");
302 if (args.size() > 2)
303 extra_args(args, 1, design, false);
304 if (Tcl_EvalFile(yosys_get_tcl_interp(), args[1].c_str()) != TCL_OK)
305 log_cmd_error("TCL interpreter returned an error: %s\n", Tcl_GetStringResult(yosys_get_tcl_interp()));
306 }
307 } TclPass;
308 #endif
309
310 #if defined(__linux__)
311 std::string proc_self_dirname()
312 {
313 char path [PATH_MAX];
314 ssize_t buflen = readlink("/proc/self/exe", path, sizeof(path));
315 if (buflen < 0) {
316 log_error("readlink(\"/proc/self/exe\") failed: %s\n", strerror(errno));
317 }
318 while (buflen > 0 && path[buflen-1] != '/')
319 buflen--;
320 return std::string(path, buflen);
321 }
322 #elif defined(__APPLE__)
323 #include <mach-o/dyld.h>
324 std::string proc_self_dirname()
325 {
326 char * path = NULL;
327 uint32_t buflen = 0;
328 while (_NSGetExecutablePath(path, &buflen) != 0)
329 path = (char *) realloc((void *) path, buflen);
330 while (buflen > 0 && path[buflen-1] != '/')
331 buflen--;
332 return std::string(path, buflen);
333 }
334 #elif defined(_WIN32)
335 std::string proc_self_dirname()
336 {
337 #warning Fixme: Implement proc_self_dirname() for win32.
338 log_error("proc_self_dirname() is not implemented for win32 yet!\n");
339 }
340 #elif defined(EMSCRIPTEN)
341 std::string proc_self_dirname()
342 {
343 return "/";
344 }
345 #else
346 #error Dont know how to determine process executable base path!
347 #endif
348
349 std::string proc_share_dirname()
350 {
351 std::string proc_self_path = proc_self_dirname();
352 std::string proc_share_path = proc_self_path + "share/";
353 if (access(proc_share_path.c_str(), X_OK) == 0)
354 return proc_share_path;
355 proc_share_path = proc_self_path + "../share/yosys/";
356 if (access(proc_share_path.c_str(), X_OK) == 0)
357 return proc_share_path;
358 log_error("proc_share_dirname: unable to determine share/ directory!\n");
359 }
360
361 bool fgetline(FILE *f, std::string &buffer)
362 {
363 buffer = "";
364 char block[4096];
365 while (1) {
366 if (fgets(block, 4096, f) == NULL)
367 return false;
368 buffer += block;
369 if (buffer.size() > 0 && (buffer[buffer.size()-1] == '\n' || buffer[buffer.size()-1] == '\r')) {
370 while (buffer.size() > 0 && (buffer[buffer.size()-1] == '\n' || buffer[buffer.size()-1] == '\r'))
371 buffer.resize(buffer.size()-1);
372 return true;
373 }
374 }
375 }
376
377 static void handle_label(std::string &command, bool &from_to_active, const std::string &run_from, const std::string &run_to)
378 {
379 int pos = 0;
380 std::string label;
381
382 while (pos < GetSize(command) && (command[pos] == ' ' || command[pos] == '\t'))
383 pos++;
384
385 while (pos < GetSize(command) && command[pos] != ' ' && command[pos] != '\t' && command[pos] != '\r' && command[pos] != '\n')
386 label += command[pos++];
387
388 if (label.back() == ':' && GetSize(label) > 1)
389 {
390 label = label.substr(0, GetSize(label)-1);
391 command = command.substr(pos);
392
393 if (label == run_from)
394 from_to_active = true;
395 else if (label == run_to || (run_from == run_to && !run_from.empty()))
396 from_to_active = false;
397 }
398 }
399
400 void run_frontend(std::string filename, std::string command, RTLIL::Design *design, std::string *backend_command, std::string *from_to_label)
401 {
402 if (command == "auto") {
403 if (filename.size() > 2 && filename.substr(filename.size()-2) == ".v")
404 command = "verilog";
405 else if (filename.size() > 2 && filename.substr(filename.size()-3) == ".sv")
406 command = "verilog -sv";
407 else if (filename.size() > 3 && filename.substr(filename.size()-3) == ".il")
408 command = "ilang";
409 else if (filename.size() > 3 && filename.substr(filename.size()-3) == ".ys")
410 command = "script";
411 else if (filename == "-")
412 command = "script";
413 else
414 log_error("Can't guess frontend for input file `%s' (missing -f option)!\n", filename.c_str());
415 }
416
417 if (command == "script")
418 {
419 std::string run_from, run_to;
420 bool from_to_active = true;
421
422 if (from_to_label != NULL) {
423 size_t pos = from_to_label->find(':');
424 if (pos == std::string::npos) {
425 run_from = *from_to_label;
426 run_to = *from_to_label;
427 } else {
428 run_from = from_to_label->substr(0, pos);
429 run_to = from_to_label->substr(pos+1);
430 }
431 from_to_active = run_from.empty();
432 }
433
434 log("\n-- Executing script file `%s' --\n", filename.c_str());
435
436 FILE *f = stdin;
437
438 if (filename != "-")
439 f = fopen(filename.c_str(), "r");
440
441 if (f == NULL)
442 log_error("Can't open script file `%s' for reading: %s\n", filename.c_str(), strerror(errno));
443
444 FILE *backup_script_file = Frontend::current_script_file;
445 Frontend::current_script_file = f;
446
447 try {
448 std::string command;
449 while (fgetline(f, command)) {
450 while (!command.empty() && command[command.size()-1] == '\\') {
451 std::string next_line;
452 if (!fgetline(f, next_line))
453 break;
454 command.resize(command.size()-1);
455 command += next_line;
456 }
457 handle_label(command, from_to_active, run_from, run_to);
458 if (from_to_active)
459 Pass::call(design, command);
460 }
461
462 if (!command.empty()) {
463 handle_label(command, from_to_active, run_from, run_to);
464 if (from_to_active)
465 Pass::call(design, command);
466 }
467 }
468 catch (log_cmd_error_expection) {
469 Frontend::current_script_file = backup_script_file;
470 throw log_cmd_error_expection();
471 }
472
473 Frontend::current_script_file = backup_script_file;
474
475 if (filename != "-")
476 fclose(f);
477
478 if (backend_command != NULL && *backend_command == "auto")
479 *backend_command = "";
480
481 return;
482 }
483
484 if (filename == "-") {
485 log("\n-- Parsing stdin using frontend `%s' --\n", command.c_str());
486 } else {
487 log("\n-- Parsing `%s' using frontend `%s' --\n", filename.c_str(), command.c_str());
488 }
489
490 Frontend::frontend_call(design, NULL, filename, command);
491 }
492
493 void run_pass(std::string command, RTLIL::Design *design)
494 {
495 log("\n-- Running pass `%s' --\n", command.c_str());
496
497 Pass::call(design, command);
498 }
499
500 void run_backend(std::string filename, std::string command, RTLIL::Design *design)
501 {
502 if (command == "auto") {
503 if (filename.size() > 2 && filename.substr(filename.size()-2) == ".v")
504 command = "verilog";
505 else if (filename.size() > 3 && filename.substr(filename.size()-3) == ".il")
506 command = "ilang";
507 else if (filename.size() > 5 && filename.substr(filename.size()-5) == ".blif")
508 command = "blif";
509 else if (filename == "-")
510 command = "ilang";
511 else if (filename.empty())
512 return;
513 else
514 log_error("Can't guess backend for output file `%s' (missing -b option)!\n", filename.c_str());
515 }
516
517 if (filename.empty())
518 filename = "-";
519
520 if (filename == "-") {
521 log("\n-- Writing to stdout using backend `%s' --\n", command.c_str());
522 } else {
523 log("\n-- Writing to `%s' using backend `%s' --\n", filename.c_str(), command.c_str());
524 }
525
526 Backend::backend_call(design, NULL, filename, command);
527 }
528
529 #ifdef YOSYS_ENABLE_READLINE
530 static char *readline_cmd_generator(const char *text, int state)
531 {
532 static std::map<std::string, Pass*>::iterator it;
533 static int len;
534
535 if (!state) {
536 it = pass_register.begin();
537 len = strlen(text);
538 }
539
540 for (; it != pass_register.end(); it++) {
541 if (it->first.substr(0, len) == text)
542 return strdup((it++)->first.c_str());
543 }
544 return NULL;
545 }
546
547 static char *readline_obj_generator(const char *text, int state)
548 {
549 static std::vector<char*> obj_names;
550 static size_t idx;
551
552 if (!state)
553 {
554 idx = 0;
555 obj_names.clear();
556
557 RTLIL::Design *design = yosys_get_design();
558 int len = strlen(text);
559
560 if (design->selected_active_module.empty())
561 {
562 for (auto &it : design->modules_)
563 if (RTLIL::unescape_id(it.first).substr(0, len) == text)
564 obj_names.push_back(strdup(RTLIL::id2cstr(it.first)));
565 }
566 else
567 if (design->modules_.count(design->selected_active_module) > 0)
568 {
569 RTLIL::Module *module = design->modules_.at(design->selected_active_module);
570
571 for (auto &it : module->wires_)
572 if (RTLIL::unescape_id(it.first).substr(0, len) == text)
573 obj_names.push_back(strdup(RTLIL::id2cstr(it.first)));
574
575 for (auto &it : module->memories)
576 if (RTLIL::unescape_id(it.first).substr(0, len) == text)
577 obj_names.push_back(strdup(RTLIL::id2cstr(it.first)));
578
579 for (auto &it : module->cells_)
580 if (RTLIL::unescape_id(it.first).substr(0, len) == text)
581 obj_names.push_back(strdup(RTLIL::id2cstr(it.first)));
582
583 for (auto &it : module->processes)
584 if (RTLIL::unescape_id(it.first).substr(0, len) == text)
585 obj_names.push_back(strdup(RTLIL::id2cstr(it.first)));
586 }
587
588 std::sort(obj_names.begin(), obj_names.end());
589 }
590
591 if (idx < obj_names.size())
592 return strdup(obj_names[idx++]);
593
594 idx = 0;
595 obj_names.clear();
596 return NULL;
597 }
598
599 static char **readline_completion(const char *text, int start, int)
600 {
601 if (start == 0)
602 return rl_completion_matches(text, readline_cmd_generator);
603 if (strncmp(rl_line_buffer, "read_", 5) && strncmp(rl_line_buffer, "write_", 6))
604 return rl_completion_matches(text, readline_obj_generator);
605 return NULL;
606 }
607 #endif
608
609 void shell(RTLIL::Design *design)
610 {
611 static int recursion_counter = 0;
612
613 recursion_counter++;
614 log_cmd_error_throw = true;
615
616 #ifdef YOSYS_ENABLE_READLINE
617 rl_readline_name = "yosys";
618 rl_attempted_completion_function = readline_completion;
619 rl_basic_word_break_characters = " \t\n";
620 #endif
621
622 char *command = NULL;
623 #ifdef YOSYS_ENABLE_READLINE
624 while ((command = readline(create_prompt(design, recursion_counter))) != NULL)
625 #else
626 char command_buffer[4096];
627 while ((command = fgets(command_buffer, 4096, stdin)) != NULL)
628 #endif
629 {
630 if (command[strspn(command, " \t\r\n")] == 0)
631 continue;
632 #ifdef YOSYS_ENABLE_READLINE
633 add_history(command);
634 #endif
635
636 char *p = command + strspn(command, " \t\r\n");
637 if (!strncmp(p, "exit", 4)) {
638 p += 4;
639 p += strspn(p, " \t\r\n");
640 if (*p == 0)
641 break;
642 }
643
644 try {
645 log_assert(design->selection_stack.size() == 1);
646 Pass::call(design, command);
647 } catch (log_cmd_error_expection) {
648 while (design->selection_stack.size() > 1)
649 design->selection_stack.pop_back();
650 log_reset_stack();
651 }
652 }
653 if (command == NULL)
654 printf("exit\n");
655
656 recursion_counter--;
657 log_cmd_error_throw = false;
658 }
659
660 struct ShellPass : public Pass {
661 ShellPass() : Pass("shell", "enter interactive command mode") { }
662 virtual void help() {
663 log("\n");
664 log(" shell\n");
665 log("\n");
666 log("This command enters the interactive command mode. This can be useful\n");
667 log("in a script to interrupt the script at a certain point and allow for\n");
668 log("interactive inspection or manual synthesis of the design at this point.\n");
669 log("\n");
670 log("The command prompt of the interactive shell indicates the current\n");
671 log("selection (see 'help select'):\n");
672 log("\n");
673 log(" yosys>\n");
674 log(" the entire design is selected\n");
675 log("\n");
676 log(" yosys*>\n");
677 log(" only part of the design is selected\n");
678 log("\n");
679 log(" yosys [modname]>\n");
680 log(" the entire module 'modname' is selected using 'select -module modname'\n");
681 log("\n");
682 log(" yosys [modname]*>\n");
683 log(" only part of current module 'modname' is selected\n");
684 log("\n");
685 log("When in interactive shell, some errors (e.g. invalid command arguments)\n");
686 log("do not terminate yosys but return to the command prompt.\n");
687 log("\n");
688 log("This command is the default action if nothing else has been specified\n");
689 log("on the command line.\n");
690 log("\n");
691 log("Press Ctrl-D or type 'exit' to leave the interactive shell.\n");
692 log("\n");
693 }
694 virtual void execute(std::vector<std::string> args, RTLIL::Design *design) {
695 extra_args(args, 1, design, false);
696 shell(design);
697 }
698 } ShellPass;
699
700 #ifdef YOSYS_ENABLE_READLINE
701 struct HistoryPass : public Pass {
702 HistoryPass() : Pass("history", "show last interactive commands") { }
703 virtual void help() {
704 log("\n");
705 log(" history\n");
706 log("\n");
707 log("This command prints all commands in the shell history buffer. This are\n");
708 log("all commands executed in an interactive session, but not the commands\n");
709 log("from executed scripts.\n");
710 log("\n");
711 }
712 virtual void execute(std::vector<std::string> args, RTLIL::Design *design) {
713 extra_args(args, 1, design, false);
714 for(HIST_ENTRY **list = history_list(); *list != NULL; list++)
715 log("%s\n", (*list)->line);
716 }
717 } HistoryPass;
718 #endif
719
720 struct ScriptPass : public Pass {
721 ScriptPass() : Pass("script", "execute commands from script file") { }
722 virtual void help() {
723 log("\n");
724 log(" script <filename> [<from_label>:<to_label>]\n");
725 log("\n");
726 log("This command executes the yosys commands in the specified file.\n");
727 log("\n");
728 log("The 2nd argument can be used to only execute the section of the\n");
729 log("file between the specified labels. An empty from label is synonymous\n");
730 log("for the beginning of the file and an empty to label is synonymous\n");
731 log("for the end of the file.\n");
732 log("\n");
733 log("If only one label is specified (without ':') then only the block\n");
734 log("marked with that label (until the next label) is executed.\n");
735 log("\n");
736 }
737 virtual void execute(std::vector<std::string> args, RTLIL::Design *design) {
738 if (args.size() < 2)
739 log_cmd_error("Missing script file.\n");
740 else if (args.size() == 2)
741 run_frontend(args[1], "script", design, NULL, NULL);
742 else if (args.size() == 3)
743 run_frontend(args[1], "script", design, NULL, &args[2]);
744 else
745 extra_args(args, 2, design, false);
746 }
747 } ScriptPass;
748
749 YOSYS_NAMESPACE_END
750