From 3ae393fc593b36244ad74809d404f6b289019fde Mon Sep 17 00:00:00 2001 From: LAK132 Date: Thu, 9 Jun 2022 18:32:02 +0930 Subject: [PATCH 1/2] Add analysis support --- src/ghdl.cc | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/ghdl.cc b/src/ghdl.cc index aa6f129f..00e92cd8 100644 --- a/src/ghdl.cc +++ b/src/ghdl.cc @@ -1242,6 +1242,12 @@ static void import_netlist(RTLIL::Design *design, GhdlSynth::Module top) } } +extern "C" void libghdl__set_hooks_for_analysis(void); +extern "C" int libghdl__set_option(const char* opt, int len); +extern "C" int libghdl__analyze_init_status(); +extern "C" int libghdl__analyze_file(const char* file, int len); +extern "C" void libraries__save_work_library(void); + #endif /* YOSYS_ENABLE_GHDL */ YOSYS_NAMESPACE_BEGIN @@ -1251,13 +1257,11 @@ struct GhdlPass : public Pass { virtual void help() { // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| -#if 0 log("\n"); log(" ghdl -a [OPTIONS] ..\n"); log("\n"); log("Analyze the specified VHDL files.\n"); log("\n"); -#endif log("\n"); log(" ghdl [options] unit [arch]\n"); log("\n"); @@ -1296,7 +1300,6 @@ struct GhdlPass : public Pass { if (!lib_initialized) { lib_initialized = 1; libghdl_init (); - ghdlsynth__init_for_ghdl_synth(); } if (args.size() == 2 && args[1] == "--disp-config") { @@ -1307,7 +1310,31 @@ struct GhdlPass : public Pass { #endif "\n"); } + else if (args.size() > 1 && args[1] == "-a") { + libghdl__set_hooks_for_analysis(); + + size_t arg = 2; + for (; arg < args.size() && args[arg][0] == '-'; ++arg) { + if (libghdl__set_option(args[arg].c_str(), args[arg].size()) != 0) { + log_cmd_error("set option (%s) failed.\n", args[arg].c_str()); + } + } + + if (libghdl__analyze_init_status() != 0) { + log_cmd_error("analyze init failed.\n"); + } + + for (; arg < args.size(); ++arg) { + if (libghdl__analyze_file(args[arg].c_str(), args[arg].size()) == 0) { + log_cmd_error("analyze file (%s) failed.\n", args[arg].c_str()); + } + } + + libraries__save_work_library(); + } else { + ghdlsynth__init_for_ghdl_synth(); + int cmd_argc = args.size() - 1; const char **cmd_argv = new const char *[cmd_argc]; for (int i = 0; i < cmd_argc; i++) From 51bd44249913fa2fe8b616c7a9a8478112042e67 Mon Sep 17 00:00:00 2001 From: LAK132 Date: Tue, 11 Oct 2022 20:50:43 +1030 Subject: [PATCH 2/2] Make sure to init for synth when running --disp-config --- src/ghdl.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ghdl.cc b/src/ghdl.cc index a229c8ad..90589165 100644 --- a/src/ghdl.cc +++ b/src/ghdl.cc @@ -1307,6 +1307,7 @@ struct GhdlPass : public Pass { } if (args.size() == 2 && args[1] == "--disp-config") { + ghdlsynth__init_for_ghdl_synth(); ghdlcomp__disp_config(); log("yosys plugin compiled on " __DATE__ " " __TIME__ #ifdef GHDL_VER_HASH