hdl: remove Repl per RFC 10.

Closes #770.
This commit is contained in:
Catherine 2024-01-31 02:55:57 +00:00
parent 4da8adf7ba
commit 357ffb680c
6 changed files with 5 additions and 58 deletions

View file

@ -15,7 +15,7 @@ from .hdl import *
# must be kept in sync with docs/reference.rst!
__all__ = [
"Shape", "unsigned", "signed",
"Value", "Const", "C", "Mux", "Cat", "Repl", "Array", "Signal", "ClockSignal", "ResetSignal",
"Value", "Const", "C", "Mux", "Cat", "Array", "Signal", "ClockSignal", "ResetSignal",
"Module",
"ClockDomain",
"Elaboratable", "Fragment", "Instance",

View file

@ -1,6 +1,6 @@
from ._ast import Shape, unsigned, signed, ShapeCastable, ShapeLike
from ._ast import Value, ValueCastable, ValueLike
from ._ast import Const, C, Mux, Cat, Repl, Array, Signal, ClockSignal, ResetSignal
from ._ast import Const, C, Mux, Cat, Array, Signal, ClockSignal, ResetSignal
from ._dsl import SyntaxError, SyntaxWarning, Module
from ._cd import DomainError, ClockDomain
from ._ir import UnusedElaboratable, Elaboratable, DriverConflict, Fragment, Instance
@ -13,7 +13,7 @@ __all__ = [
# _ast
"Shape", "unsigned", "signed", "ShapeCastable", "ShapeLike",
"Value", "ValueCastable", "ValueLike",
"Const", "C", "Mux", "Cat", "Repl", "Array", "Signal", "ClockSignal", "ResetSignal",
"Const", "C", "Mux", "Cat", "Array", "Signal", "ClockSignal", "ResetSignal",
# _dsl
"SyntaxError", "SyntaxWarning", "Module",
# _cd

View file

@ -16,7 +16,7 @@ from .._unused import *
__all__ = [
"Shape", "signed", "unsigned", "ShapeCastable", "ShapeLike",
"Value", "Const", "C", "AnyConst", "AnySeq", "Operator", "Mux", "Part", "Slice", "Cat", "Repl",
"Value", "Const", "C", "AnyConst", "AnySeq", "Operator", "Mux", "Part", "Slice", "Cat",
"Array", "ArrayProxy",
"Signal", "ClockSignal", "ResetSignal",
"ValueCastable", "ValueLike",
@ -1170,37 +1170,6 @@ class Cat(Value):
return "(cat {})".format(" ".join(map(repr, self.parts)))
# TODO(amaranth-0.5): remove
@deprecated("instead of `Repl(value, count)`, use `value.replicate(count)`")
def Repl(value, count):
"""Replicate a value
An input value is replicated (repeated) several times
to be used on the RHS of assignments::
len(Repl(s, n)) == len(s) * n
Parameters
----------
value : Value, in
Input value to be replicated.
count : int
Number of replications.
Returns
-------
Value, out
Replicated value.
"""
if isinstance(value, int) and value not in [0, 1]:
warnings.warn("Value argument of Repl() is a bare integer {} used in bit vector "
"context; consider specifying explicit width using C({}, {}) instead"
.format(value, value, bits_for(value)),
SyntaxWarning, stacklevel=3)
return Value.cast(value).replicate(count)
class _SignalMeta(ABCMeta):
def __call__(cls, shape=None, src_loc_at=0, **kwargs):
signal = super().__call__(shape, **kwargs, src_loc_at=src_loc_at + 1)

View file

@ -6,7 +6,7 @@ from . import _ast as __origin
__all__ = [
"Shape", "signed", "unsigned", "ShapeCastable", "ShapeLike",
"Value", "Const", "C", "AnyConst", "AnySeq", "Operator", "Mux", "Part", "Slice", "Cat", "Repl",
"Value", "Const", "C", "AnyConst", "AnySeq", "Operator", "Mux", "Part", "Slice", "Cat",
"Array", "ArrayProxy",
"Signal", "ClockSignal", "ResetSignal",
"ValueCastable", "ValueLike",

View file

@ -59,7 +59,6 @@ The prelude exports exactly the following names:
* :func:`C`
* :func:`Mux`
* :class:`Cat`
* :class:`Repl` (deprecated)
* :class:`Array`
* :class:`Signal`
* :class:`ClockSignal`

View file

@ -970,27 +970,6 @@ class CatTestCase(FHDLTestCase):
self.assertEqual(a.signed, False)
class ReplTestCase(FHDLTestCase):
@_ignore_deprecated
def test_cast(self):
r = Repl(0, 3)
self.assertEqual(repr(r), "(cat (const 1'd0) (const 1'd0) (const 1'd0))")
@_ignore_deprecated
def test_int_01(self):
with warnings.catch_warnings():
warnings.filterwarnings(action="error", category=SyntaxWarning)
Repl(0, 3)
Repl(1, 3)
@_ignore_deprecated
def test_int_wrong(self):
with self.assertWarnsRegex(SyntaxWarning,
r"^Value argument of Repl\(\) is a bare integer 2 used in bit vector context; "
r"consider specifying explicit width using C\(2, 2\) instead$"):
Repl(2, 3)
class ArrayTestCase(FHDLTestCase):
def test_acts_like_array(self):
a = Array([1,2,3])