From ed0f508e8a985184e19c12dc91d8623c3d958c0b Mon Sep 17 00:00:00 2001 From: Teguh Hofstee <5227572+hofstee@users.noreply.github.com> Date: Thu, 23 Apr 2020 14:46:10 -0700 Subject: [PATCH] back.verilog: add workaround for evaluation Verific behavior. The evaluation version of Verific prints its license information to stdout, and since it is against the EULA to change that in any way, this behavior is not possible to fix in Yosys. Add a workaround in nMigen instead. --- nmigen/back/verilog.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nmigen/back/verilog.py b/nmigen/back/verilog.py index 6e2185a..04e19b6 100644 --- a/nmigen/back/verilog.py +++ b/nmigen/back/verilog.py @@ -1,6 +1,7 @@ import os import re import subprocess +import itertools from .._toolchain import * from . import rtlil @@ -17,6 +18,7 @@ def _yosys_version(): yosys_path = require_tool("yosys") version = subprocess.check_output([yosys_path, "-V"], encoding="utf-8") # If Yosys is built with Verific, then Verific license information is printed first. + # See below for details. m = re.search(r"^Yosys ([\d.]+)(?:\+(\d+))?", version, flags=re.M) tag, offset = m[1], m[2] or 0 return tuple(map(int, tag.split("."))), offset @@ -65,6 +67,13 @@ write_verilog -norename {write_verilog_opts} if popen.returncode: raise YosysError(error.strip()) else: + # If Yosys is built with an evaluation version of Verific, then Verific license information + # is printed first. It consists of empty lines and lines starting with `--`, which are not + # valid at the start of a Verilog file, and thus may be reliably removed. + verilog_text = "\n".join(itertools.dropwhile( + lambda x: x == "" or x.startswith("--"), + verilog_text.splitlines() + )) return verilog_text -- 2.30.2