From e702f2894a1089ee50ede6edee1b6999369a2486 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 31 Oct 2022 10:15:05 +0100 Subject: [PATCH 1/3] Support for reading liberty files using verific --- Makefile | 5 ++++ frontends/verific/verific.cc | 46 +++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b7071f53c..25e412413 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ ENABLE_EDITLINE := 0 ENABLE_GHDL := 0 ENABLE_VERIFIC := 0 ENABLE_VERIFIC_EDIF := 0 +ENABLE_VERIFIC_LIBERTY := 0 DISABLE_VERIFIC_EXTENSIONS := 0 DISABLE_VERIFIC_VHDL := 0 ENABLE_COVER := 1 @@ -531,6 +532,10 @@ ifeq ($(ENABLE_VERIFIC_EDIF),1) VERIFIC_COMPONENTS += edif CXXFLAGS += -DVERIFIC_EDIF_SUPPORT endif +ifeq ($(ENABLE_VERIFIC_LIBERTY),1) +VERIFIC_COMPONENTS += synlib +CXXFLAGS += -DVERIFIC_LIBERTY_SUPPORT +endif ifneq ($(DISABLE_VERIFIC_EXTENSIONS),1) VERIFIC_COMPONENTS += extensions CXXFLAGS += -DYOSYSHQ_VERIFIC_EXTENSIONS diff --git a/frontends/verific/verific.cc b/frontends/verific/verific.cc index 71b87755d..0f4eceba4 100644 --- a/frontends/verific/verific.cc +++ b/frontends/verific/verific.cc @@ -57,6 +57,10 @@ USING_YOSYS_NAMESPACE #include "edif_file.h" #endif +#ifdef VERIFIC_LIBERTY_SUPPORT +#include "synlib_file.h" +#endif + #include "VerificStream.h" #include "FileSystem.h" @@ -2358,6 +2362,9 @@ void verific_import(Design *design, const std::map &par #endif #ifdef VERIFIC_EDIF_SUPPORT edif_file::Reset(); +#endif +#ifdef VERIFIC_LIBERTY_SUPPORT + synlib_file::Reset(); #endif Libset::Reset(); Message::Reset(); @@ -2426,6 +2433,13 @@ struct VerificPass : public Pass { log("Load the specified EDIF files into Verific.\n"); log("\n"); log("\n"); +#endif +#ifdef VERIFIC_LIBERTY_SUPPORT + log(" verific {-liberty} ..\n"); + log("\n"); + log("Load the specified Liberty files into Verific.\n"); + log("\n"); + log("\n"); #endif log(" verific {-f|-F} [-vlog95|-vlog2k|-sv2005|-sv2009|\n"); log(" -sv2012|-sv|-formal] \n"); @@ -2535,7 +2549,7 @@ struct VerificPass : public Pass { log("\n"); log(" -cells\n"); log(" Import all cell definitions from Verific loaded libraries even if they are\n"); - log(" unused in design. Useful with \"-edif\" option.\n"); + log(" unused in design. Useful with \"-edif\" and \"-liberty\" option.\n"); log("\n"); log(" -chparam name value \n"); log(" Elaborate the specified top modules (all modules when -all given) using\n"); @@ -2729,6 +2743,7 @@ struct VerificPass : public Pass { int argidx = 1; std::string work = "work"; + bool is_work_set = false; veri_file::RegisterCallBackVerificStream(&verific_read_cb); if (GetSize(args) > argidx && (args[argidx] == "-set-error" || args[argidx] == "-set-warning" || @@ -2813,6 +2828,7 @@ struct VerificPass : public Pass { { if (args[argidx] == "-work" && argidx+1 < GetSize(args)) { work = args[++argidx]; + is_work_set = true; continue; } if (args[argidx] == "-L" && argidx+1 < GetSize(args)) { @@ -3001,6 +3017,17 @@ struct VerificPass : public Pass { } goto check_error; } +#endif +#ifdef VERIFIC_LIBERTY_SUPPORT + if (GetSize(args) > argidx && args[argidx] == "-liberty") { + argidx++; + while (argidx < GetSize(args)) { + std::string filename = frontent_rewrite(args, argidx, tmp_files); + if (!synlib_file::Read(filename.c_str(), is_work_set ? work.c_str() : nullptr)) + log_cmd_error("Reading `%s' in LIBERTY mode failed.\n", filename.c_str()); + } + goto check_error; + } #endif if (argidx < GetSize(args) && args[argidx] == "-pp") { @@ -3293,6 +3320,9 @@ struct VerificPass : public Pass { #endif #ifdef VERIFIC_EDIF_SUPPORT edif_file::Reset(); +#endif +#ifdef VERIFIC_LIBERTY_SUPPORT + synlib_file::Reset(); #endif Libset::Reset(); Message::Reset(); @@ -3427,6 +3457,11 @@ struct ReadPass : public Pass { log("\n"); log("\n"); #endif + log(" read {-liberty} ..\n"); + log("\n"); + log("Load the specified Liberty files.\n"); + log("\n"); + log("\n"); log(" read {-f|-F} \n"); log("\n"); log("Load and execute the specified command file. (Requires Verific.)\n"); @@ -3531,6 +3566,15 @@ struct ReadPass : public Pass { return; } #endif + if (args[1] == "-liberty") { + if (use_verific) { + args[0] = "verific"; + } else { + args[0] = "read_liberty"; + } + Pass::call(design, args); + return; + } if (args[1] == "-f" || args[1] == "-F") { if (use_verific) { args[0] = "verific"; From 6fb80bce1577e298fb25e387beb1ff5fb6c7c53e Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 31 Oct 2022 10:51:28 +0100 Subject: [PATCH 2/3] Enable importing blackbox modules only --- frontends/verific/verific.cc | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/frontends/verific/verific.cc b/frontends/verific/verific.cc index 0f4eceba4..fb5fc0c6c 100644 --- a/frontends/verific/verific.cc +++ b/frontends/verific/verific.cc @@ -59,6 +59,7 @@ USING_YOSYS_NAMESPACE #ifdef VERIFIC_LIBERTY_SUPPORT #include "synlib_file.h" +#include "SynlibGroup.h" #endif #include "VerificStream.h" @@ -2439,6 +2440,9 @@ struct VerificPass : public Pass { log("\n"); log("Load the specified Liberty files into Verific.\n"); log("\n"); + log(" -lib\n"); + log(" only create empty blackbox modules\n"); + log("\n"); log("\n"); #endif log(" verific {-f|-F} [-vlog95|-vlog2k|-sv2005|-sv2009|\n"); @@ -3020,11 +3024,36 @@ struct VerificPass : public Pass { #endif #ifdef VERIFIC_LIBERTY_SUPPORT if (GetSize(args) > argidx && args[argidx] == "-liberty") { - argidx++; + bool flag_lib = false; + for (argidx++; argidx < GetSize(args); argidx++) { + if (args[argidx] == "-lib") { + flag_lib = true; + continue; + } + if (args[argidx].compare(0, 1, "-") == 0) { + cmd_error(args, argidx, "unknown option"); + goto check_error; + } + break; + } + while (argidx < GetSize(args)) { std::string filename = frontent_rewrite(args, argidx, tmp_files); if (!synlib_file::Read(filename.c_str(), is_work_set ? work.c_str() : nullptr)) log_cmd_error("Reading `%s' in LIBERTY mode failed.\n", filename.c_str()); + SynlibLibrary *lib = synlib_file::GetLastLibraryAnalyzed(); + if (lib && flag_lib) { + MapIter mi ; + Verific::Cell *c ; + FOREACH_CELL_OF_LIBRARY(lib->GetLibrary(),mi,c) { + MapIter ni ; + Netlist *nl; + FOREACH_NETLIST_OF_CELL(c, ni, nl) { + if (nl) + nl->MakeBlackBox(); + } + } + } } goto check_error; } @@ -3461,6 +3490,9 @@ struct ReadPass : public Pass { log("\n"); log("Load the specified Liberty files.\n"); log("\n"); + log(" -lib\n"); + log(" only create empty blackbox modules\n"); + log("\n"); log("\n"); log(" read {-f|-F} \n"); log("\n"); From 59b6ac47c9121278c9259b82c68b38477ccb73ad Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 31 Oct 2022 18:04:34 +0100 Subject: [PATCH 3/3] Add additional help info --- frontends/verific/verific.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontends/verific/verific.cc b/frontends/verific/verific.cc index fb5fc0c6c..6ef563929 100644 --- a/frontends/verific/verific.cc +++ b/frontends/verific/verific.cc @@ -2439,6 +2439,8 @@ struct VerificPass : public Pass { log(" verific {-liberty} ..\n"); log("\n"); log("Load the specified Liberty files into Verific.\n"); + log("Default library when -work is not present is one specified in liberty file.\n"); + log("To use from SystemVerilog or VHDL use -L to specify liberty library."); log("\n"); log(" -lib\n"); log(" only create empty blackbox modules\n");