Remove features deprecated in version 0.3.

This commit is contained in:
Catherine 2023-01-31 21:38:27 +00:00
parent 47551e8c71
commit 5a79c351e3
15 changed files with 21 additions and 319 deletions

View file

@ -1,11 +0,0 @@
import warnings
from ..sim import *
__all__ = ["Settle", "Delay", "Tick", "Passive", "Active", "Simulator"]
# TODO(amaranth-0.4): remove
warnings.warn("instead of amaranth.back.pysim.*, use amaranth.sim.*",
DeprecationWarning, stacklevel=2)

View file

@ -411,11 +411,7 @@ class _ValueCompiler(xfrm.ValueVisitor):
if value.start == 0 and value.stop == len(value.value):
return self(value.value)
if isinstance(value.value, ast.UserValue):
sigspec = self._prepare_value_for_Slice(value.value._lazy_lower())
else:
sigspec = self._prepare_value_for_Slice(value.value)
sigspec = self._prepare_value_for_Slice(value.value)
if value.start == value.stop:
return "{}"
elif value.start + 1 == value.stop:
@ -1041,11 +1037,7 @@ def convert_fragment(fragment, name="top", *, emit_src=True):
return str(builder), name_map
def convert(elaboratable, name="top", platform=None, ports=None, *, emit_src=True, **kwargs):
# TODO(amaranth-0.4): remove
if ports is None:
warnings.warn("Implicit port determination is deprecated, specify ports explicitly",
DeprecationWarning, stacklevel=2)
def convert(elaboratable, name="top", platform=None, *, ports, emit_src=True, **kwargs):
fragment = ir.Fragment.get(elaboratable, platform).prepare(ports=ports, **kwargs)
il_text, name_map = convert_fragment(fragment, name, emit_src=emit_src)
return il_text

View file

@ -42,11 +42,8 @@ def convert_fragment(*args, strip_internal_attrs=False, **kwargs):
return _convert_rtlil_text(rtlil_text, strip_internal_attrs=strip_internal_attrs), name_map
def convert(elaboratable, name="top", platform=None, ports=None, *, emit_src=True, strip_internal_attrs=False, **kwargs):
# TODO(amaranth-0.4): remove
if ports is None:
warnings.warn("Implicit port determination is deprecated, specify ports explicitly",
DeprecationWarning, stacklevel=2)
def convert(elaboratable, name="top", platform=None, *, ports, emit_src=True,
strip_internal_attrs=False, **kwargs):
fragment = ir.Fragment.get(elaboratable, platform).prepare(ports=ports, **kwargs)
verilog_text, name_map = convert_fragment(fragment, name, emit_src=emit_src, strip_internal_attrs=strip_internal_attrs)
return verilog_text

View file

@ -16,7 +16,7 @@ __all__ = [
"Value", "Const", "C", "AnyConst", "AnySeq", "Operator", "Mux", "Part", "Slice", "Cat", "Repl",
"Array", "ArrayProxy",
"Signal", "ClockSignal", "ResetSignal",
"UserValue", "ValueCastable",
"ValueCastable",
"Sample", "Past", "Stable", "Rose", "Fell", "Initial",
"Statement", "Switch",
"Property", "Assign", "Assert", "Assume", "Cover",
@ -1243,55 +1243,6 @@ class ArrayProxy(Value):
return "(proxy (array [{}]) {!r})".format(", ".join(map(repr, self.elems)), self.index)
# TODO(amaranth-0.4): remove
class UserValue(Value):
"""Value with custom lowering.
A ``UserValue`` is a value whose precise representation does not have to be immediately known,
which is useful in certain metaprogramming scenarios. Instead of providing fixed semantics
upfront, it is kept abstract for as long as possible, only being lowered to a concrete Amaranth
value when required.
Note that the ``lower`` method will only be called once; this is necessary to ensure that
Amaranth's view of representation of all values stays internally consistent. If the class
deriving from ``UserValue`` is mutable, then it must ensure that after ``lower`` is called,
it is not mutated in a way that changes its representation.
The following is an incomplete list of actions that, when applied to an ``UserValue`` directly
or indirectly, will cause it to be lowered, provided as an illustrative reference:
* Querying the shape using ``.shape()`` or ``len()``;
* Creating a similarly shaped signal using ``Signal.like``;
* Indexing or iterating through individual bits;
* Adding an assignment to the value to a ``Module`` using ``m.d.<domain> +=``.
"""
@deprecated("instead of `UserValue`, use `ValueCastable`", stacklevel=3)
def __init__(self, *, src_loc_at=0):
super().__init__(src_loc_at=1 + src_loc_at)
self.__lowered = None
@abstractmethod
def lower(self):
"""Conversion to a concrete representation."""
pass # :nocov:
def _lazy_lower(self):
if self.__lowered is None:
lowered = self.lower()
if isinstance(lowered, UserValue):
lowered = lowered._lazy_lower()
self.__lowered = Value.cast(lowered)
return self.__lowered
def shape(self):
return self._lazy_lower().shape()
def _lhs_signals(self):
return self._lazy_lower()._lhs_signals()
def _rhs_signals(self):
return self._lazy_lower()._rhs_signals()
class ValueCastable:
"""Interface of user-defined objects that can be cast to :class:`Value` s.

View file

@ -114,9 +114,6 @@ class ValueVisitor(metaclass=ABCMeta):
new_value = self.on_Sample(value)
elif type(value) is Initial:
new_value = self.on_Initial(value)
elif isinstance(value, UserValue):
# Uses `isinstance()` and not `type() is` to allow inheriting.
new_value = self.on_value(value._lazy_lower())
else:
new_value = self.on_unknown_value(value)
if isinstance(new_value, Value) and self.replace_value_src_loc(value, new_value):

View file

@ -151,11 +151,6 @@ class Simulator:
"""
self._engine.reset()
# TODO(amaranth-0.4): replace with _real_step
@deprecated("instead of `sim.step()`, use `sim.advance()`")
def step(self):
return self.advance()
def advance(self):
"""Advance the simulation.

View file

@ -1 +0,0 @@
# TODO(amaranth-0.4): remove the entire package

View file

@ -1,84 +0,0 @@
import os
import re
import shutil
import subprocess
import textwrap
import traceback
import unittest
import warnings
from ..hdl.ast import *
from ..hdl.ir import *
from ..back import rtlil
from .._toolchain import require_tool
warnings.warn("amaranth.test.utils is an internal utility module that has several design flaws "
"and was never intended as a public API; it will be removed in amaranth 0.4. "
"if you are using FHDLTestCase, include its implementation in your codebase. "
"see also amaranth-lang/amaranth#487",
DeprecationWarning, stacklevel=2)
__all__ = ["FHDLTestCase"]
class FHDLTestCase(unittest.TestCase):
def assertRepr(self, obj, repr_str):
if isinstance(obj, list):
obj = Statement.cast(obj)
def prepare_repr(repr_str):
repr_str = re.sub(r"\s+", " ", repr_str)
repr_str = re.sub(r"\( (?=\()", "(", repr_str)
repr_str = re.sub(r"\) (?=\))", ")", repr_str)
return repr_str.strip()
self.assertEqual(prepare_repr(repr(obj)), prepare_repr(repr_str))
def assertFormal(self, spec, mode="bmc", depth=1):
caller, *_ = traceback.extract_stack(limit=2)
spec_root, _ = os.path.splitext(caller.filename)
spec_dir = os.path.dirname(spec_root)
spec_name = "{}_{}".format(
os.path.basename(spec_root).replace("test_", "spec_"),
caller.name.replace("test_", "")
)
# The sby -f switch seems not fully functional when sby is reading from stdin.
if os.path.exists(os.path.join(spec_dir, spec_name)):
shutil.rmtree(os.path.join(spec_dir, spec_name))
if mode == "hybrid":
# A mix of BMC and k-induction, as per personal communication with Claire Wolf.
script = "setattr -unset init w:* a:amaranth.sample_reg %d"
mode = "bmc"
else:
script = ""
config = textwrap.dedent("""\
[options]
mode {mode}
depth {depth}
wait on
[engines]
smtbmc
[script]
read_ilang top.il
prep
{script}
[file top.il]
{rtlil}
""").format(
mode=mode,
depth=depth,
script=script,
rtlil=rtlil.convert(Fragment.get(spec, platform="formal"))
)
with subprocess.Popen([require_tool("sby"), "-f", "-d", spec_name], cwd=spec_dir,
universal_newlines=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE) as proc:
stdout, stderr = proc.communicate(config)
if proc.returncode != 0:
self.fail("Formal verification failed:\n" + stdout)

View file

@ -1,11 +0,0 @@
import warnings
from .lattice_machxo_2_3l import LatticeMachXO2Platform
__all__ = ["LatticeMachXO2Platform"]
# TODO(amaranth-0.4): remove
warnings.warn("instead of amaranth.vendor.lattice_machxo2, use amaranth.vendor.lattice_machxo_2_3l",
DeprecationWarning, stacklevel=2)

View file

@ -1,15 +0,0 @@
import warnings
from .xilinx import XilinxPlatform
__all__ = ["Xilinx7SeriesPlatform"]
Xilinx7SeriesPlatform = XilinxPlatform
# TODO(amaranth-0.4): remove
warnings.warn("instead of amaranth.vendor.xilinx_7series.Xilinx7SeriesPlatform, "
"use amaranth.vendor.xilinx.XilinxPlatform",
DeprecationWarning, stacklevel=2)

View file

@ -1,16 +0,0 @@
import warnings
from .xilinx import XilinxPlatform
__all__ = ["XilinxSpartan3APlatform", "XilinxSpartan6Platform"]
XilinxSpartan3APlatform = XilinxPlatform
XilinxSpartan6Platform = XilinxPlatform
# TODO(amaranth-0.4): remove
warnings.warn("instead of amaranth.vendor.xilinx_spartan_3_6.XilinxSpartan3APlatform and "
".XilinxSpartan6Platform, use amaranth.vendor.xilinx.XilinxPlatform",
DeprecationWarning, stacklevel=2)

View file

@ -1,15 +0,0 @@
import warnings
from .xilinx import XilinxPlatform
__all__ = ["XilinxUltraScalePlatform"]
XilinxUltraScalePlatform = XilinxPlatform
# TODO(amaranth-0.4): remove
warnings.warn("instead of amaranth.vendor.xilinx_ultrascale.XilinxUltraScalePlatform, "
"use amaranth.vendor.xilinx.XilinxPlatform",
DeprecationWarning, stacklevel=2)