From 1a6f10e8bacfe36ac436c86f8e4b3bdda05e267c Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Tue, 4 Oct 2022 09:18:44 +0200 Subject: [PATCH] Add support for EDIF file reading using Verific --- Makefile | 5 ++++ frontends/verific/verific.cc | 48 +++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7361ba079..9421bb807 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ ENABLE_READLINE := 1 ENABLE_EDITLINE := 0 ENABLE_GHDL := 0 ENABLE_VERIFIC := 0 +ENABLE_VERIFIC_EDIF := 0 DISABLE_VERIFIC_EXTENSIONS := 0 DISABLE_VERIFIC_VHDL := 0 ENABLE_COVER := 1 @@ -527,6 +528,10 @@ ifneq ($(wildcard $(VERIFIC_DIR)/vhdl),) VERIFIC_COMPONENTS += vhdl endif endif +ifeq ($(ENABLE_VERIFIC_EDIF),1) +VERIFIC_COMPONENTS += edif +CXXFLAGS += -DVERIFIC_EDIF_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 b6f48a9de..820ac042c 100644 --- a/frontends/verific/verific.cc +++ b/frontends/verific/verific.cc @@ -53,6 +53,10 @@ USING_YOSYS_NAMESPACE #include "VhdlUnits.h" #endif +#ifdef VERIFIC_EDIF_SUPPORT +#include "edif_file.h" +#endif + #include "VerificStream.h" #include "FileSystem.h" @@ -2351,6 +2355,9 @@ void verific_import(Design *design, const std::map &par veri_file::Reset(); #ifdef VERIFIC_VHDL_SUPPORT vhdl_file::Reset(); +#endif +#ifdef VERIFIC_EDIF_SUPPORT + edif_file::Reset(); #endif Libset::Reset(); Message::Reset(); @@ -2412,6 +2419,13 @@ struct VerificPass : public Pass { log("Load the specified VHDL files into Verific.\n"); log("\n"); log("\n"); +#endif +#ifdef VERIFIC_EDIF_SUPPORT + log(" verific {-edif} ..\n"); + log("\n"); + log("Load the specified EDIF files into Verific.\n"); + log("\n"); + log("\n"); #endif log(" verific {-f|-F} [-vlog95|-vlog2k|-sv2005|-sv2009|\n"); log(" -sv2012|-sv|-formal] \n"); @@ -2958,7 +2972,18 @@ struct VerificPass : public Pass { goto check_error; } #endif - +#ifdef VERIFIC_EDIF_SUPPORT + if (GetSize(args) > argidx && args[argidx] == "-edif") { + edif_file edif; + argidx++; + while (argidx < GetSize(args)) { + std::string filename = frontent_rewrite(args, argidx, tmp_files); + if (!edif.Read(filename.c_str())) + log_cmd_error("Reading `%s' in EDIF mode failed.\n", filename.c_str()); + } + goto check_error; + } +#endif if (argidx < GetSize(args) && args[argidx] == "-pp") { const char* filename = nullptr; @@ -3221,6 +3246,9 @@ struct VerificPass : public Pass { veri_file::Reset(); #ifdef VERIFIC_VHDL_SUPPORT vhdl_file::Reset(); +#endif +#ifdef VERIFIC_EDIF_SUPPORT + edif_file::Reset(); #endif Libset::Reset(); Message::Reset(); @@ -3347,6 +3375,13 @@ struct ReadPass : public Pass { log("Load the specified VHDL files. (Requires Verific.)\n"); log("\n"); log("\n"); +#endif +#ifdef VERIFIC_EDIF_SUPPORT + log(" read {-edif} ..\n"); + log("\n"); + log("Load the specified EDIF files. (Requires Verific.)\n"); + log("\n"); + log("\n"); #endif log(" read {-f|-F} \n"); log("\n"); @@ -3440,6 +3475,17 @@ struct ReadPass : public Pass { } return; } +#endif +#ifdef VERIFIC_EDIF_SUPPORT + if (args[1] == "-edif") { + if (use_verific) { + args[0] = "verific"; + Pass::call(design, args); + } else { + cmd_error(args, 1, "This version of Yosys is built without Verific support.\n"); + } + return; + } #endif if (args[1] == "-f" || args[1] == "-F") { if (use_verific) {