3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-09-08 18:51:28 +00:00

Add TCL interactive shell mode

This commit is contained in:
Miodrag Milanovic 2022-11-25 16:18:02 +01:00
parent c55c514cdb
commit 2450e6be22
2 changed files with 34 additions and 8 deletions

View file

@ -202,6 +202,11 @@ extern char *yosys_argv0;
extern char yosys_path[PATH_MAX];
};
#endif
#ifdef YOSYS_ENABLE_TCL
namespace Yosys {
extern int yosys_tcl_iterp_init(Tcl_Interp *interp);
};
#endif
int main(int argc, char **argv)
{
@ -221,6 +226,7 @@ int main(int argc, char **argv)
bool call_abort = false;
bool timing_details = false;
bool run_shell = true;
bool run_tcl_shell = false;
bool mode_v = false;
bool mode_q = false;
@ -284,6 +290,9 @@ int main(int argc, char **argv)
printf("\n");
printf(" -c tcl_scriptfile\n");
printf(" execute the commands in the tcl script file (see 'help tcl' for details)\n");
printf("\n");
printf(" -C\n");
printf(" enters TCL interatcive shell mode\n");
#endif
printf("\n");
printf(" -p command\n");
@ -358,7 +367,7 @@ int main(int argc, char **argv)
}
int opt;
while ((opt = getopt(argc, argv, "MXAQTVSgm:f:Hh:b:o:p:l:L:qv:tds:c:W:w:e:r:D:P:E:x:B:")) != -1)
while ((opt = getopt(argc, argv, "MXAQTVCSgm:f:Hh:b:o:p:l:L:qv:tds:c:W:w:e:r:D:P:E:x:B:")) != -1)
{
switch (opt)
{
@ -496,6 +505,9 @@ int main(int argc, char **argv)
case 'B':
perffile = optarg;
break;
case 'C':
run_tcl_shell = true;
break;
default:
fprintf(stderr, "Run '%s -h' for help.\n", argv[0]);
exit(1);
@ -570,10 +582,18 @@ int main(int argc, char **argv)
for (auto it = passes_commands.begin(); it != passes_commands.end(); it++)
run_pass(*it);
if (run_shell)
shell(yosys_design);
else
run_backend(output_filename, backend_command);
if (run_tcl_shell) {
#ifdef YOSYS_ENABLE_TCL
Tcl_Main(argc, argv, yosys_tcl_iterp_init);
#else
log_error("Can't exectue TCL shell: this version of yosys is not built with TCL support enabled.\n");
#endif
} else {
if (run_shell)
shell(yosys_design);
else
run_backend(output_filename, backend_command);
}
yosys_design->check();
for (auto it : saved_designs)