Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/nmigen
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2168ff512bfe
Choose a base ref
...
head repository: m-labs/nmigen
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b14f5572d8f7
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Aug 28, 2019

  1. Copy the full SHA
    b14f557 View commit details
Showing with 20 additions and 6 deletions.
  1. +13 −0 nmigen/_toolchain.py
  2. +6 −2 nmigen/back/verilog.py
  3. +1 −4 nmigen/build/plat.py
13 changes: 13 additions & 0 deletions nmigen/_toolchain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os


__all__ = ["get_tool"]


def get_tool(name):
return os.environ.get(name.upper().replace("-", "_"), overrides.get(name, name))


# Packages for systems like Nix can inject full paths to certain tools by adding them in
# this dictionary, e.g. ``overrides = {"yosys": "/full/path/to/yosys"}``.
overrides = {}
8 changes: 6 additions & 2 deletions nmigen/back/verilog.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
import re
import subprocess

from .._toolchain import *
from . import rtlil


@@ -13,15 +14,18 @@ class YosysError(Exception):


def _yosys_version():
yosys_path = get_tool("yosys")
try:
version = subprocess.check_output([os.getenv("YOSYS", "yosys"), "-V"], encoding="utf-8")
version = subprocess.check_output([yosys_path, "-V"], encoding="utf-8")
except FileNotFoundError as e:
if os.getenv("YOSYS"):
raise YosysError("Could not find Yosys in {} as specified via the YOSYS environment "
"variable".format(os.getenv("YOSYS"))) from e
else:
elif yosys_path == "yosys":
raise YosysError("Could not find Yosys in PATH. Place `yosys` in PATH or specify "
"path explicitly via the YOSYS environment variable") from e
else:
raise

m = re.match(r"^Yosys ([\d.]+)(?:\+(\d+))?", version)
tag, offset = m[1], m[2] or 0
5 changes: 1 addition & 4 deletions nmigen/build/plat.py
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import jinja2

from .. import __version__
from .._toolchain import *
from ..hdl.ast import *
from ..hdl.cd import *
from ..hdl.dsl import *
@@ -263,10 +264,6 @@ def emit_commands(format):
assert False
return "\n".join(commands)

def get_tool(tool):
tool_env = tool.upper().replace("-", "_")
return os.environ.get(tool_env, tool)

def get_override(var):
var_env = "NMIGEN_{}".format(var)
if var_env in os.environ: