import os
import re
import subprocess
+import itertools
from .._toolchain import *
from . import rtlil
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
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