Skip to content

Commit

Permalink
Fork edif pass
Browse files Browse the repository at this point in the history
This allows us to use latest yosys. The upstream edif pass introduced
changes which are incompatible with SystemVerilog.

Signed-off-by: Tomasz Gorochowik <[email protected]>
  • Loading branch information
tgorochowik committed Sep 29, 2023
1 parent 66cf5de commit 4018ab3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
3 changes: 3 additions & 0 deletions frontends/systemverilog/uhdm_common_frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include "uhdm_common_frontend.h"
#include "edif.h"

namespace systemverilog_plugin
{
Expand All @@ -30,6 +31,8 @@ static void set_line_num(int) {}
/* Stub for AST::process */
static int get_line_num(void) { return 1; }

UhdmCommonFrontend::UhdmCommonFrontend(std::string name, std::string short_help) : Frontend(name, short_help) { register_synlig_edif_backend(); }

void UhdmCommonFrontend::print_read_options()
{
log(" -noassert\n");
Expand Down
30 changes: 23 additions & 7 deletions third_party/yosys_mod/edif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
#include "kernel/sigtools.h"
#include <string>

USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN
namespace systemverilog_plugin
{

using namespace ::Yosys;

#define EDIF_DEF(_id) edif_names(RTLIL::unescape_id(_id), true).c_str()
#define EDIF_DEFR(_id, _ren, _bl, _br) edif_names(RTLIL::unescape_id(_id), true, _ren, _bl, _br).c_str()
Expand Down Expand Up @@ -86,8 +88,8 @@ struct EdifNames {
}
};

struct EdifBackend : public Backend {
EdifBackend() : Backend("edif", "write design to EDIF netlist file") {}
struct SynligEdifBackend : public Backend {
SynligEdifBackend() : Backend("edif", "write design to EDIF netlist file") {}
void help() override
{
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
Expand Down Expand Up @@ -129,7 +131,7 @@ struct EdifBackend : public Backend {
}
void execute(std::ostream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing EDIF backend.\n");
log_header(design, "Executing Synlig EDIF backend.\n");
std::string top_module_name;
bool port_rename = false;
bool attr_properties = false;
Expand Down Expand Up @@ -598,6 +600,20 @@ struct EdifBackend : public Backend {

*f << stringf(")\n");
}
} EdifBackend;
};

SynligEdifBackend *seb = NULL;
;

void register_synlig_edif_backend()
{
if (seb == NULL) {
backend_register.erase("edif");
pass_register.erase("edif");
pass_register.erase("write_edif");
seb = new SynligEdifBackend;
seb->init_register();
}
}

PRIVATE_NAMESPACE_END
} // namespace systemverilog_plugin
4 changes: 4 additions & 0 deletions third_party/yosys_mod/edif.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace systemverilog_plugin
{
void register_synlig_edif_backend();
}

0 comments on commit 4018ab3

Please sign in to comment.