aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiodrag Milanović <mmicko@gmail.com>2022-11-25 17:40:57 +0100
committerGitHub <noreply@github.com>2022-11-25 17:40:57 +0100
commit448a796e155416884c5fa45465da4e5ecc9f75a4 (patch)
tree164722d2699a98b149b740562f0f7c04a2628919
parentc55c514cdbd5a7968c17689876f2ced282071f9c (diff)
parentf764cd16556b638b2857a3df9b77281c1bf872a0 (diff)
downloadyosys-448a796e155416884c5fa45465da4e5ecc9f75a4.tar.gz
yosys-448a796e155416884c5fa45465da4e5ecc9f75a4.tar.bz2
yosys-448a796e155416884c5fa45465da4e5ecc9f75a4.zip
Merge pull request #3560 from YosysHQ/verific_conf
Support importing verilog configurations using Verific
-rw-r--r--frontends/verific/verific.cc47
-rw-r--r--frontends/verific/verific.h2
-rw-r--r--passes/hierarchy/hierarchy.cc2
3 files changed, 43 insertions, 8 deletions
diff --git a/frontends/verific/verific.cc b/frontends/verific/verific.cc
index 6ef563929..1e61b3a31 100644
--- a/frontends/verific/verific.cc
+++ b/frontends/verific/verific.cc
@@ -47,6 +47,7 @@ USING_YOSYS_NAMESPACE
#include "VeriModule.h"
#include "VeriWrite.h"
#include "VeriLibrary.h"
+#include "VeriExpression.h"
#ifdef VERIFIC_VHDL_SUPPORT
#include "vhdl_file.h"
@@ -2267,7 +2268,7 @@ struct VerificExtNets
}
};
-void verific_import(Design *design, const std::map<std::string,std::string> &parameters, std::string top)
+std::string verific_import(Design *design, const std::map<std::string,std::string> &parameters, std::string top)
{
verific_sva_fsm_limit = 16;
@@ -2300,6 +2301,18 @@ void verific_import(Design *design, const std::map<std::string,std::string> &par
VeriModule *veri_module = veri_lib->GetModule(top.c_str(), 1);
if (veri_module) {
veri_modules.InsertLast(veri_module);
+ if (veri_module->IsConfiguration()) {
+ VeriConfiguration *cfg = (VeriConfiguration*)veri_module;
+ VeriName *module_name = (VeriName*)cfg->GetTopModuleNames()->GetLast();
+ VeriLibrary *lib = veri_module->GetLibrary() ;
+ if (module_name && module_name->IsHierName()) {
+ VeriName *prefix = module_name->GetPrefix() ;
+ const char *lib_name = (prefix) ? prefix->GetName() : 0 ;
+ if (!Strings::compare("work", lib_name)) lib = veri_file::GetLibrary(lib_name, 1) ;
+ }
+ veri_module = (lib && module_name) ? lib->GetModule(module_name->GetName(), 1) : 0;
+ top = veri_module->GetName();
+ }
}
// Also elaborate all root modules since they may contain bind statements
@@ -2378,6 +2391,7 @@ void verific_import(Design *design, const std::map<std::string,std::string> &par
if (!verific_error_msg.empty())
log_error("%s\n", verific_error_msg.c_str());
+ return top;
}
YOSYS_NAMESPACE_END
@@ -2527,10 +2541,10 @@ struct VerificPass : public Pass {
log("is printed, such as VERI-1209.\n");
log("\n");
log("\n");
- log(" verific -import [options] <top-module>..\n");
+ log(" verific -import [options] <top>..\n");
log("\n");
- log("Elaborate the design for the specified top modules, import to Yosys and\n");
- log("reset the internal state of Verific.\n");
+ log("Elaborate the design for the specified top modules or configurations, import to\n");
+ log("Yosys and reset the internal state of Verific.\n");
log("\n");
log("Import options:\n");
log("\n");
@@ -3246,8 +3260,29 @@ struct VerificPass : public Pass {
VeriModule *veri_module = veri_lib ? veri_lib->GetModule(name, 1) : nullptr;
if (veri_module) {
- log("Adding Verilog module '%s' to elaboration queue.\n", name);
- veri_modules.InsertLast(veri_module);
+ if (veri_module->IsConfiguration()) {
+ log("Adding Verilog configuration '%s' to elaboration queue.\n", name);
+ veri_modules.InsertLast(veri_module);
+
+ top_mod_names.erase(name);
+
+ VeriConfiguration *cfg = (VeriConfiguration*)veri_module;
+ VeriName *module_name;
+ int i;
+ FOREACH_ARRAY_ITEM(cfg->GetTopModuleNames(), i, module_name) {
+ VeriLibrary *lib = veri_module->GetLibrary() ;
+ if (module_name && module_name->IsHierName()) {
+ VeriName *prefix = module_name->GetPrefix() ;
+ const char *lib_name = (prefix) ? prefix->GetName() : 0 ;
+ if (!Strings::compare("work", lib_name)) lib = veri_file::GetLibrary(lib_name, 1) ;
+ }
+ veri_module = (lib && module_name) ? lib->GetModule(module_name->GetName(), 1) : 0;
+ top_mod_names.insert(veri_module->GetName());
+ }
+ } else {
+ log("Adding Verilog module '%s' to elaboration queue.\n", name);
+ veri_modules.InsertLast(veri_module);
+ }
continue;
}
#ifdef VERIFIC_VHDL_SUPPORT
diff --git a/frontends/verific/verific.h b/frontends/verific/verific.h
index 695c04f3b..d9f0077db 100644
--- a/frontends/verific/verific.h
+++ b/frontends/verific/verific.h
@@ -26,7 +26,7 @@ YOSYS_NAMESPACE_BEGIN
extern int verific_verbose;
extern bool verific_import_pending;
-extern void verific_import(Design *design, const std::map<std::string,std::string> &parameters, std::string top = std::string());
+extern std::string verific_import(Design *design, const std::map<std::string,std::string> &parameters, std::string top = std::string());
extern pool<int> verific_sva_prims;
diff --git a/passes/hierarchy/hierarchy.cc b/passes/hierarchy/hierarchy.cc
index eea6abb04..bf0137503 100644
--- a/passes/hierarchy/hierarchy.cc
+++ b/passes/hierarchy/hierarchy.cc
@@ -960,7 +960,7 @@ struct HierarchyPass : public Pass {
if (top_mod == nullptr && !load_top_mod.empty()) {
#ifdef YOSYS_ENABLE_VERIFIC
if (verific_import_pending) {
- verific_import(design, parameters, load_top_mod);
+ load_top_mod = verific_import(design, parameters, load_top_mod);
top_mod = design->module(RTLIL::escape_id(load_top_mod));
}
#endif