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: amaranth-lang/amaranth
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b1eba5fd82a8
Choose a base ref
...
head repository: amaranth-lang/amaranth
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 599615ee3a34
Choose a head ref
  • 2 commits
  • 8 files changed
  • 1 contributor

Commits on Dec 11, 2021

  1. build.plat,vendor: add missing compatibility shims for NMIGEN_ENV_*.

    These have been mistakenly omitted from commit 909a3b8.
    whitequark committed Dec 11, 2021
    Copy the full SHA
    90777a6 View commit details
  2. Copy the full SHA
    599615e View commit details
2 changes: 1 addition & 1 deletion amaranth/build/plat.py
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ def build(self, elaboratable, name="top",
# may fail.
# This is OK because even if `require_tool` succeeds, the toolchain might be broken anyway.
# The check only serves to catch common errors earlier.
if do_build and (self._deprecated_toolchain_env_var not in os.environ or
if do_build and (self._deprecated_toolchain_env_var not in os.environ and
self._toolchain_env_var not in os.environ):
for tool in self.required_tools:
require_tool(tool)
9 changes: 6 additions & 3 deletions amaranth/hdl/ir.py
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ def get(obj, platform):
elif isinstance(obj, Elaboratable):
code = obj.elaborate.__code__
obj._MustUse__used = True
obj = obj.elaborate(platform)
new_obj = obj.elaborate(platform)
elif hasattr(obj, "elaborate"):
warnings.warn(
message="Class {!r} is an elaboratable that does not explicitly inherit from "
@@ -43,15 +43,18 @@ def get(obj, platform):
category=RuntimeWarning,
stacklevel=2)
code = obj.elaborate.__code__
obj = obj.elaborate(platform)
new_obj = obj.elaborate(platform)
else:
raise AttributeError("Object {!r} cannot be elaborated".format(obj))
if obj is None and code is not None:
if new_obj is obj:
raise RecursionError("Object {!r} elaborates to itself".format(obj))
if new_obj is None and code is not None:
warnings.warn_explicit(
message=".elaborate() returned None; missing return statement?",
category=UserWarning,
filename=code.co_filename,
lineno=code.co_firstlineno)
obj = new_obj

def __init__(self):
self.ports = SignalDict()
5 changes: 5 additions & 0 deletions amaranth/vendor/intel.py
Original file line number Diff line number Diff line change
@@ -86,6 +86,11 @@ class IntelPlatform(TemplatedPlatform):
**TemplatedPlatform.build_script_templates,
"build_{{name}}.sh": r"""
# {{autogenerated}}
if [ -n "${{platform._deprecated_toolchain_env_var}}" ]; then
QUARTUS_ROOTDIR=$(dirname $(dirname "${{platform._deprecated_toolchain_env_var}}"))
# Quartus' qenv.sh does not work with `set -e`.
. "${{platform._deprecated_toolchain_env_var}}"
fi
if [ -n "${{platform._toolchain_env_var}}" ]; then
QUARTUS_ROOTDIR=$(dirname $(dirname "${{platform._toolchain_env_var}}"))
# Quartus' qenv.sh does not work with `set -e`.
4 changes: 4 additions & 0 deletions amaranth/vendor/lattice_ecp5.py
Original file line number Diff line number Diff line change
@@ -191,6 +191,10 @@ class LatticeECP5Platform(TemplatedPlatform):
# {{autogenerated}}
set -e{{verbose("x")}}
if [ -z "$BASH" ] ; then exec /bin/bash "$0" "$@"; fi
if [ -n "${{platform._deprecated_toolchain_env_var}}" ]; then
bindir=$(dirname "${{platform._deprecated_toolchain_env_var}}")
. "${{platform._deprecated_toolchain_env_var}}"
fi
if [ -n "${{platform._toolchain_env_var}}" ]; then
bindir=$(dirname "${{platform._toolchain_env_var}}")
. "${{platform._toolchain_env_var}}"
13 changes: 12 additions & 1 deletion amaranth/vendor/lattice_ice40.py
Original file line number Diff line number Diff line change
@@ -182,7 +182,18 @@ class LatticeICE40Platform(TemplatedPlatform):
"build_{{name}}.sh": r"""
# {{autogenerated}}
set -e{{verbose("x")}}
if [ -n "${{platform._toolchain_env_var}}" ]; then
if [ -n "${{platform._deprecated_toolchain_env_var}}" ]; then
# LSE environment
export LD_LIBRARY_PATH=${{platform._deprecated_toolchain_env_var}}/LSE/bin/lin64:$LD_LIBRARY_PATH
export PATH=${{platform._deprecated_toolchain_env_var}}/LSE/bin/lin64:$PATH
export FOUNDRY=${{platform._deprecated_toolchain_env_var}}/LSE
# Synplify environment
export LD_LIBRARY_PATH=${{platform._deprecated_toolchain_env_var}}/sbt_backend/bin/linux/opt/synpwrap:$LD_LIBRARY_PATH
export PATH=${{platform._deprecated_toolchain_env_var}}/sbt_backend/bin/linux/opt/synpwrap:$PATH
export SYNPLIFY_PATH=${{platform._deprecated_toolchain_env_var}}/synpbase
# Common environment
export SBT_DIR=${{platform._deprecated_toolchain_env_var}}/sbt_backend
elif [ -n "${{platform._toolchain_env_var}}" ]; then
# LSE environment
export LD_LIBRARY_PATH=${{platform._toolchain_env_var}}/LSE/bin/lin64:$LD_LIBRARY_PATH
export PATH=${{platform._toolchain_env_var}}/LSE/bin/lin64:$PATH
4 changes: 4 additions & 0 deletions amaranth/vendor/lattice_machxo_2_3l.py
Original file line number Diff line number Diff line change
@@ -55,6 +55,10 @@ class LatticeMachXO2Or3LPlatform(TemplatedPlatform):
# {{autogenerated}}
set -e{{verbose("x")}}
if [ -z "$BASH" ] ; then exec /bin/bash "$0" "$@"; fi
if [ -n "${{platform._deprecated_toolchain_env_var}}" ]; then
bindir=$(dirname "${{platform._deprecated_toolchain_env_var}}")
. "${{platform._deprecated_toolchain_env_var}}"
fi
if [ -n "${{platform._toolchain_env_var}}" ]; then
bindir=$(dirname "${{platform._toolchain_env_var}}")
. "${{platform._toolchain_env_var}}"
2 changes: 2 additions & 0 deletions amaranth/vendor/xilinx.py
Original file line number Diff line number Diff line change
@@ -129,6 +129,7 @@ def _part(self):
# {{autogenerated}}
set -e{{verbose("x")}}
if [ -z "$BASH" ] ; then exec /bin/bash "$0" "$@"; fi
[ -n "${{platform._deprecated_toolchain_env_var}}" ] && . "${{platform._deprecated_toolchain_env_var}}"
[ -n "${{platform._toolchain_env_var}}" ] && . "${{platform._toolchain_env_var}}"
{{emit_commands("sh")}}
""",
@@ -235,6 +236,7 @@ def _part(self):
# {{autogenerated}}
set -e{{verbose("x")}}
if [ -z "$BASH" ] ; then exec /bin/bash "$0" "$@"; fi
[ -n "${{platform._deprecated_toolchain_env_var}}" ] && . "${{platform._deprecated_toolchain_env_var}}"
[ -n "${{platform._toolchain_env_var}}" ] && . "${{platform._toolchain_env_var}}"
{{emit_commands("sh")}}
""",
16 changes: 13 additions & 3 deletions tests/test_hdl_ir.py
Original file line number Diff line number Diff line change
@@ -10,13 +10,18 @@
from .utils import *


class BadElaboratable(Elaboratable):
class ElaboratesToNone(Elaboratable):
def elaborate(self, platform):
return


class ElaboratesToSelf(Elaboratable):
def elaborate(self, platform):
return self


class FragmentGetTestCase(FHDLTestCase):
def test_get_wrong(self):
def test_get_wrong_none(self):
with self.assertRaisesRegex(AttributeError,
r"^Object None cannot be elaborated$"):
Fragment.get(None, platform=None)
@@ -25,7 +30,12 @@ def test_get_wrong(self):
r"^\.elaborate\(\) returned None; missing return statement\?$"):
with self.assertRaisesRegex(AttributeError,
r"^Object None cannot be elaborated$"):
Fragment.get(BadElaboratable(), platform=None)
Fragment.get(ElaboratesToNone(), platform=None)

def test_get_wrong_self(self):
with self.assertRaisesRegex(RecursionError,
r"^Object <.+?ElaboratesToSelf.+?> elaborates to itself$"):
Fragment.get(ElaboratesToSelf(), platform=None)


class FragmentGeneratedTestCase(FHDLTestCase):