From a51a3fa2d274f665d371bb30de6beb01490f79e0 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Fri, 7 Feb 2014 14:17:00 +0100 Subject: [PATCH] Added echo command --- kernel/driver.cc | 2 +- kernel/register.cc | 48 +++++++++++++++++++++++++++++++++++++++++++--- kernel/register.h | 1 + 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/kernel/driver.cc b/kernel/driver.cc index d31d36b2d..00a61ec0f 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -212,7 +212,7 @@ static char **readline_completion(const char *text, int start, int) return NULL; } -static const char *create_prompt(RTLIL::Design *design, int recursion_counter) +const char *create_prompt(RTLIL::Design *design, int recursion_counter) { static char buffer[100]; std::string str = "\n"; diff --git a/kernel/register.cc b/kernel/register.cc index 10ba4f274..325709664 100644 --- a/kernel/register.cc +++ b/kernel/register.cc @@ -29,6 +29,7 @@ using namespace REGISTER_INTERN; namespace REGISTER_INTERN { + bool echo_mode = false; int raw_register_count = 0; bool raw_register_done = false; Pass *raw_register_array[MAX_REG_COUNT]; @@ -124,7 +125,7 @@ void Pass::extra_args(std::vector args, size_t argidx, RTLIL::Desig handle_extra_select_args(this, args, argidx, args.size(), design); break; } - cmd_log_args(args); + // cmd_log_args(args); } void Pass::call(RTLIL::Design *design, std::string command) @@ -173,6 +174,14 @@ void Pass::call(RTLIL::Design *design, std::vector args) { if (args.size() == 0 || args[0][0] == '#') return; + + if (echo_mode) { + log("%s", create_prompt(design, 0)); + for (size_t i = 0; i < args.size(); i++) + log("%s%s", i ? " " : "", args[i].c_str()); + log("\n"); + } + if (pass_register.count(args[0]) == 0) log_cmd_error("No such command: %s (type 'help' for a command overview)\n", args[0].c_str()); @@ -269,7 +278,7 @@ void Frontend::extra_args(FILE *&f, std::string &filename, std::vector args, RTLIL::Design*) + { + if (args.size() > 2) + cmd_error(args, 2, "Unexpected argument."); + + if (args.size() == 2) { + if (args[1] == "on") + echo_mode = true; + else if (args[1] == "off") + echo_mode = false; + else + cmd_error(args, 1, "Unexpected argument."); + } + + log("echo %s\n", echo_mode ? "on" : "off"); + } +} EchoPass; + diff --git a/kernel/register.h b/kernel/register.h index 3165d2bf8..83e1059c6 100644 --- a/kernel/register.h +++ b/kernel/register.h @@ -38,6 +38,7 @@ extern const char *yosys_version_str; extern RTLIL::Design *yosys_get_design(); std::string rewrite_yosys_exe(std::string exe); std::string get_share_file_name(std::string file); +const char *create_prompt(RTLIL::Design *design, int recursion_counter); struct Pass { -- 2.30.2