Log functions handling Signed-off-by: Ryszard Różak <rrozak@antmicro.com>
diff --git a/uhdm-plugin/uhdmastfrontend.cc b/uhdm-plugin/uhdmastfrontend.cc index 41aa93c..739ef64 100644 --- a/uhdm-plugin/uhdmastfrontend.cc +++ b/uhdm-plugin/uhdmastfrontend.cc
@@ -30,8 +30,18 @@ YOSYS_NAMESPACE_BEGIN struct UhdmAstFrontend : public UhdmCommonFrontend { - UhdmAstFrontend() : UhdmCommonFrontend("uhdm", "read UHDM file") {} - AST::AstNode *parse(std::string filename) + UhdmAstFrontend() : UhdmCommonFrontend("uhdm", "read UHDM file") { this->log_header_message = "Executing UHDM frontend.\n"; } + void help() override + { + // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| + log("\n"); + log(" read_uhdm [options] [filename]\n"); + log("\n"); + log("Load design from a UHDM file into the current design\n"); + log("\n"); + this->print_read_options(); + } + AST::AstNode *parse(std::string filename) override { UHDM::Serializer serializer;
diff --git a/uhdm-plugin/uhdmcommonfrontend.cc b/uhdm-plugin/uhdmcommonfrontend.cc index 8d643be..3cf755d 100644 --- a/uhdm-plugin/uhdmcommonfrontend.cc +++ b/uhdm-plugin/uhdmcommonfrontend.cc
@@ -29,14 +29,8 @@ /* Stub for AST::process */ static int get_line_num(void) { return 1; } -void UhdmCommonFrontend::help() +void UhdmCommonFrontend::print_read_options() { - // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| - log("\n"); - log(" read_uhdm [options] [filename]\n"); - log("\n"); - log("Load design from a UHDM file into the current design\n"); - log("\n"); log(" -noassert\n"); log(" ignore assert() statements"); log("\n"); @@ -55,10 +49,11 @@ void UhdmCommonFrontend::execute(std::istream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design) { + log_header(design, this->log_header_message); + this->args = args; bool defer = false; - std::string report_directory; for (size_t i = 1; i < args.size(); i++) { if (args[i] == "-debug") { this->shared.debug_flag = true;
diff --git a/uhdm-plugin/uhdmcommonfrontend.h b/uhdm-plugin/uhdmcommonfrontend.h index 4920524..253cf18 100644 --- a/uhdm-plugin/uhdmcommonfrontend.h +++ b/uhdm-plugin/uhdmcommonfrontend.h
@@ -30,9 +30,11 @@ struct UhdmCommonFrontend : public Frontend { UhdmAstShared shared; std::string report_directory; + const char *log_header_message; std::vector<std::string> args; UhdmCommonFrontend(std::string name, std::string short_help) : Frontend(name, short_help) {} - void help(); + virtual void print_read_options(); + virtual void help() = 0; virtual AST::AstNode *parse(std::string filename) = 0; void execute(std::istream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design); };
diff --git a/uhdm-plugin/uhdmsurelogastfrontend.cc b/uhdm-plugin/uhdmsurelogastfrontend.cc index f045ed2..b52bb1c 100644 --- a/uhdm-plugin/uhdmsurelogastfrontend.cc +++ b/uhdm-plugin/uhdmsurelogastfrontend.cc
@@ -78,8 +78,18 @@ } struct UhdmSurelogAstFrontend : public UhdmCommonFrontend { - UhdmSurelogAstFrontend() : UhdmCommonFrontend("verilog_with_uhdm", "generate/read UHDM file") {} - void help() + UhdmSurelogAstFrontend() : UhdmCommonFrontend("verilog_with_uhdm", "generate/read UHDM file") + { + this->log_header_message = "Executing Verilog with UHDM frontend.\n"; + } + void print_read_options() override + { + log(" -process\n"); + log(" loads design from given UHDM file\n"); + log("\n"); + UhdmCommonFrontend::print_read_options(); + } + void help() override { // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| log("\n"); @@ -87,25 +97,9 @@ log("\n"); log("Generate or load design from a UHDM file into the current design\n"); log("\n"); - log(" -process\n"); - log(" loads design from given UHDM file\n"); - log("\n"); - log(" -noassert\n"); - log(" ignore assert() statements"); - log("\n"); - log(" -debug\n"); - log(" print debug info to stdout"); - log("\n"); - log(" -report [directory]\n"); - log(" write a coverage report for the UHDM file\n"); - log("\n"); - log(" -defer\n"); - log(" only read the abstract syntax tree and defer actual compilation\n"); - log(" to a later 'hierarchy' command. Useful in cases where the default\n"); - log(" parameters of modules yield invalid or not synthesizable code.\n"); - log("\n"); + this->print_read_options(); } - AST::AstNode *parse(std::string filename) + AST::AstNode *parse(std::string filename) override { std::vector<const char *> cstrings; cstrings.reserve(this->args.size());