summaryrefslogtreecommitdiff
path: root/kernel/driver.cc
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-01-06 13:50:30 +0100
committerClifford Wolf <clifford@clifford.at>2013-01-06 13:50:30 +0100
commitae731369ddb8838302b5d9a3fa32689c44ab7934 (patch)
treee66382b963b39412e6ec6c91eab7513a59bdf611 /kernel/driver.cc
parentbc630ba0fa249c09d4f3fb5ef48eb6d573a21879 (diff)
Improvements in command shell
- Added 'shell' command (run interactive shell from synth script) - Added support for ; as cmd seperator as in "proc; opt" - Fixed c++ static initialization order problem with pass register
Diffstat (limited to 'kernel/driver.cc')
-rw-r--r--kernel/driver.cc65
1 files changed, 40 insertions, 25 deletions
diff --git a/kernel/driver.cc b/kernel/driver.cc
index c49bf657..ae179675 100644
--- a/kernel/driver.cc
+++ b/kernel/driver.cc
@@ -140,6 +140,40 @@ static const char *create_prompt(RTLIL::Design *design)
return buffer;
}
+static void shell(RTLIL::Design *design)
+{
+ log_cmd_error_throw = true;
+
+ rl_readline_name = "yosys";
+ rl_attempted_completion_function = readline_completion;
+
+ char *command = NULL;
+ while ((command = readline(create_prompt(design))) != NULL)
+ {
+ if (command[strspn(command, " \t\r\n")] == 0)
+ continue;
+ add_history(command);
+
+ try {
+ assert(design->selection_stack.size() == 1);
+ Pass::call(design, command);
+ } catch (int) {
+ while (design->selection_stack.size() > 1)
+ design->selection_stack.pop_back();
+ log_reset_stack();
+ }
+ }
+
+ log_cmd_error_throw = false;
+}
+
+struct ShellPass : public Pass {
+ ShellPass() : Pass("shell") { }
+ virtual void execute(std::vector<std::string>, RTLIL::Design *design) {
+ shell(design);
+ }
+} ShellPass;
+
int main(int argc, char **argv)
{
std::string frontend_command = "auto";
@@ -149,6 +183,8 @@ int main(int argc, char **argv)
std::string scriptfile = "";
bool got_output_filename = false;
+ Pass::init_register();
+
RTLIL::Design *design = new RTLIL::Design;
design->selection_stack.push_back(RTLIL::Selection());
log_push();
@@ -196,33 +232,10 @@ int main(int argc, char **argv)
if (log_errfile == NULL)
log_files.push_back(stderr);
- if (optind == argc && passes_commands.size() == 0 && scriptfile.empty())
- {
- log_cmd_error_throw = true;
-
- rl_readline_name = "yosys";
- rl_attempted_completion_function = readline_completion;
-
- char *command = NULL;
- while ((command = readline(create_prompt(design))) != NULL)
- {
- if (command[strspn(command, " \t\r\n")] == 0)
- continue;
- add_history(command);
-
- try {
- assert(design->selection_stack.size() == 1);
- Pass::call(design, command);
- } catch (int) {
- while (design->selection_stack.size() > 1)
- design->selection_stack.pop_back();
- log_reset_stack();
- }
- }
-
+ if (optind == argc && passes_commands.size() == 0 && scriptfile.empty()) {
if (!got_output_filename)
backend_command = "";
- log_cmd_error_throw = false;
+ shell(design);
}
while (optind < argc)
@@ -248,6 +261,8 @@ int main(int argc, char **argv)
log_errfile = NULL;
log_files.clear();
+ Pass::done_register();
+
return 0;
}