mirror of https://github.com/YosysHQ/yosys.git
Merge pull request #3985 from jix/static-elaboration-top
This commit is contained in:
commit
6b8203f8a0
|
@ -2495,51 +2495,71 @@ std::string verific_import(Design *design, const std::map<std::string,std::strin
|
|||
for (const auto &i : parameters)
|
||||
verific_params.Insert(i.first.c_str(), i.second.c_str());
|
||||
|
||||
#ifdef YOSYSHQ_VERIFIC_EXTENSIONS
|
||||
VerificExtensions::ElaborateAndRewrite("work", &verific_params);
|
||||
verific_error_msg.clear();
|
||||
#endif
|
||||
|
||||
if (top.empty()) {
|
||||
|
||||
#ifdef YOSYSHQ_VERIFIC_EXTENSIONS
|
||||
VerificExtensions::ElaborateAndRewrite("work", &verific_params);
|
||||
verific_error_msg.clear();
|
||||
#endif
|
||||
netlists = hier_tree::ElaborateAll(&veri_libs, &vhdl_libs, &verific_params);
|
||||
}
|
||||
else {
|
||||
Array veri_modules, vhdl_units;
|
||||
|
||||
if (veri_lib) {
|
||||
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) ;
|
||||
#ifdef YOSYSHQ_VERIFIC_EXTENSIONS
|
||||
for (int static_elaborate = 1; static_elaborate >= 0; static_elaborate--)
|
||||
#endif
|
||||
{
|
||||
Array veri_modules, vhdl_units;
|
||||
|
||||
if (veri_lib) {
|
||||
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) ;
|
||||
}
|
||||
if (lib && module_name)
|
||||
top = lib->GetModule(module_name->GetName(), 1)->GetName();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef YOSYSHQ_VERIFIC_EXTENSIONS
|
||||
if (!static_elaborate)
|
||||
#endif
|
||||
{
|
||||
// Also elaborate all root modules since they may contain bind statements
|
||||
MapIter mi;
|
||||
FOREACH_VERILOG_MODULE_IN_LIBRARY(veri_lib, mi, veri_module) {
|
||||
if (!veri_module->IsRootModule()) continue;
|
||||
veri_modules.InsertLast(veri_module);
|
||||
}
|
||||
if (lib && module_name)
|
||||
top = lib->GetModule(module_name->GetName(), 1)->GetName();
|
||||
}
|
||||
}
|
||||
|
||||
// Also elaborate all root modules since they may contain bind statements
|
||||
MapIter mi;
|
||||
FOREACH_VERILOG_MODULE_IN_LIBRARY(veri_lib, mi, veri_module) {
|
||||
if (!veri_module->IsRootModule()) continue;
|
||||
veri_modules.InsertLast(veri_module);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERIFIC_VHDL_SUPPORT
|
||||
if (vhdl_lib) {
|
||||
VhdlDesignUnit *vhdl_unit = vhdl_lib->GetPrimUnit(top.c_str());
|
||||
if (vhdl_unit)
|
||||
vhdl_units.InsertLast(vhdl_unit);
|
||||
}
|
||||
if (vhdl_lib) {
|
||||
VhdlDesignUnit *vhdl_unit = vhdl_lib->GetPrimUnit(top.c_str());
|
||||
if (vhdl_unit)
|
||||
vhdl_units.InsertLast(vhdl_unit);
|
||||
}
|
||||
#endif
|
||||
netlists = hier_tree::Elaborate(&veri_modules, &vhdl_units, &verific_params);
|
||||
|
||||
#ifdef YOSYSHQ_VERIFIC_EXTENSIONS
|
||||
if (static_elaborate) {
|
||||
VerificExtensions::ElaborateAndRewrite("work", &veri_modules, &vhdl_units, &verific_params);
|
||||
verific_error_msg.clear();
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
netlists = hier_tree::Elaborate(&veri_modules, &vhdl_units, &verific_params);
|
||||
}
|
||||
}
|
||||
|
||||
Netlist *nl;
|
||||
|
@ -3595,15 +3615,16 @@ struct VerificPass : public Pass {
|
|||
|
||||
std::set<std::string> top_mod_names;
|
||||
|
||||
#ifdef YOSYSHQ_VERIFIC_EXTENSIONS
|
||||
VerificExtensions::ElaborateAndRewrite(work, ¶meters);
|
||||
verific_error_msg.clear();
|
||||
#endif
|
||||
if (!ppfile.empty())
|
||||
veri_file::PrettyPrint(ppfile.c_str(), nullptr, work.c_str());
|
||||
|
||||
if (mode_all)
|
||||
{
|
||||
|
||||
#ifdef YOSYSHQ_VERIFIC_EXTENSIONS
|
||||
VerificExtensions::ElaborateAndRewrite(work, ¶meters);
|
||||
verific_error_msg.clear();
|
||||
#endif
|
||||
if (!ppfile.empty())
|
||||
veri_file::PrettyPrint(ppfile.c_str(), nullptr, work.c_str());
|
||||
|
||||
log("Running hier_tree::ElaborateAll().\n");
|
||||
|
||||
VeriLibrary *veri_lib = veri_file::GetLibrary(work.c_str(), 1);
|
||||
|
@ -3628,73 +3649,93 @@ struct VerificPass : public Pass {
|
|||
if (argidx == GetSize(args))
|
||||
cmd_error(args, argidx, "No top module specified.\n");
|
||||
|
||||
VeriLibrary* veri_lib = veri_file::GetLibrary(work.c_str(), 1);
|
||||
#ifdef VERIFIC_VHDL_SUPPORT
|
||||
VhdlLibrary *vhdl_lib = vhdl_file::GetLibrary(work.c_str(), 1);
|
||||
#endif
|
||||
Array *netlists = nullptr;
|
||||
|
||||
Array veri_modules, vhdl_units;
|
||||
for (; argidx < GetSize(args); argidx++)
|
||||
#ifdef YOSYSHQ_VERIFIC_EXTENSIONS
|
||||
for (int static_elaborate = 1; static_elaborate >= 0; static_elaborate--)
|
||||
#endif
|
||||
{
|
||||
const char *name = args[argidx].c_str();
|
||||
top_mod_names.insert(name);
|
||||
|
||||
VeriModule *veri_module = veri_lib ? veri_lib->GetModule(name, 1) : nullptr;
|
||||
if (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 (work != lib_name) lib = veri_file::GetLibrary(lib_name, 1) ;
|
||||
}
|
||||
if (lib && module_name)
|
||||
top_mod_names.insert(lib->GetModule(module_name->GetName(), 1)->GetName());
|
||||
}
|
||||
} else {
|
||||
log("Adding Verilog module '%s' to elaboration queue.\n", name);
|
||||
veri_modules.InsertLast(veri_module);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
VeriLibrary* veri_lib = veri_file::GetLibrary(work.c_str(), 1);
|
||||
#ifdef VERIFIC_VHDL_SUPPORT
|
||||
VhdlDesignUnit *vhdl_unit = vhdl_lib ? vhdl_lib->GetPrimUnit(name) : nullptr;
|
||||
if (vhdl_unit) {
|
||||
log("Adding VHDL unit '%s' to elaboration queue.\n", name);
|
||||
vhdl_units.InsertLast(vhdl_unit);
|
||||
VhdlLibrary *vhdl_lib = vhdl_file::GetLibrary(work.c_str(), 1);
|
||||
#endif
|
||||
|
||||
Array veri_modules, vhdl_units;
|
||||
for (int i = argidx; i < GetSize(args); i++)
|
||||
{
|
||||
const char *name = args[i].c_str();
|
||||
top_mod_names.insert(name);
|
||||
|
||||
VeriModule *veri_module = veri_lib ? veri_lib->GetModule(name, 1) : nullptr;
|
||||
if (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 (work != lib_name) lib = veri_file::GetLibrary(lib_name, 1) ;
|
||||
}
|
||||
if (lib && module_name)
|
||||
top_mod_names.insert(lib->GetModule(module_name->GetName(), 1)->GetName());
|
||||
}
|
||||
} else {
|
||||
log("Adding Verilog module '%s' to elaboration queue.\n", name);
|
||||
veri_modules.InsertLast(veri_module);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
#ifdef VERIFIC_VHDL_SUPPORT
|
||||
VhdlDesignUnit *vhdl_unit = vhdl_lib ? vhdl_lib->GetPrimUnit(name) : nullptr;
|
||||
if (vhdl_unit) {
|
||||
log("Adding VHDL unit '%s' to elaboration queue.\n", name);
|
||||
vhdl_units.InsertLast(vhdl_unit);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
log_error("Can't find module/unit '%s'.\n", name);
|
||||
}
|
||||
|
||||
#ifdef YOSYSHQ_VERIFIC_EXTENSIONS
|
||||
if (static_elaborate) {
|
||||
VerificExtensions::ElaborateAndRewrite(work, &veri_modules, &vhdl_units, ¶meters);
|
||||
verific_error_msg.clear();
|
||||
#endif
|
||||
if (!ppfile.empty())
|
||||
veri_file::PrettyPrint(ppfile.c_str(), nullptr, work.c_str());
|
||||
|
||||
#ifdef YOSYSHQ_VERIFIC_EXTENSIONS
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
log_error("Can't find module/unit '%s'.\n", name);
|
||||
}
|
||||
|
||||
|
||||
const char *lib_name = nullptr;
|
||||
SetIter si;
|
||||
FOREACH_SET_ITEM(veri_file::GetAllLOptions(), si, &lib_name) {
|
||||
VeriLibrary* veri_lib = veri_file::GetLibrary(lib_name, 0);
|
||||
if (veri_lib) {
|
||||
// Also elaborate all root modules since they may contain bind statements
|
||||
MapIter mi;
|
||||
VeriModule *veri_module;
|
||||
FOREACH_VERILOG_MODULE_IN_LIBRARY(veri_lib, mi, veri_module) {
|
||||
if (!veri_module->IsRootModule()) continue;
|
||||
veri_modules.InsertLast(veri_module);
|
||||
const char *lib_name = nullptr;
|
||||
SetIter si;
|
||||
FOREACH_SET_ITEM(veri_file::GetAllLOptions(), si, &lib_name) {
|
||||
VeriLibrary* veri_lib = veri_file::GetLibrary(lib_name, 0);
|
||||
if (veri_lib) {
|
||||
// Also elaborate all root modules since they may contain bind statements
|
||||
MapIter mi;
|
||||
VeriModule *veri_module;
|
||||
FOREACH_VERILOG_MODULE_IN_LIBRARY(veri_lib, mi, veri_module) {
|
||||
if (!veri_module->IsRootModule()) continue;
|
||||
veri_modules.InsertLast(veri_module);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log("Running hier_tree::Elaborate().\n");
|
||||
netlists = hier_tree::Elaborate(&veri_modules, &vhdl_units, ¶meters);
|
||||
}
|
||||
|
||||
log("Running hier_tree::Elaborate().\n");
|
||||
Array *netlists = hier_tree::Elaborate(&veri_modules, &vhdl_units, ¶meters);
|
||||
Netlist *nl;
|
||||
int i;
|
||||
|
||||
|
|
Loading…
Reference in New Issue