parent
4da8adf7ba
commit
357ffb680c
|
@ -15,7 +15,7 @@ from .hdl import *
|
||||||
# must be kept in sync with docs/reference.rst!
|
# must be kept in sync with docs/reference.rst!
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"Shape", "unsigned", "signed",
|
"Shape", "unsigned", "signed",
|
||||||
"Value", "Const", "C", "Mux", "Cat", "Repl", "Array", "Signal", "ClockSignal", "ResetSignal",
|
"Value", "Const", "C", "Mux", "Cat", "Array", "Signal", "ClockSignal", "ResetSignal",
|
||||||
"Module",
|
"Module",
|
||||||
"ClockDomain",
|
"ClockDomain",
|
||||||
"Elaboratable", "Fragment", "Instance",
|
"Elaboratable", "Fragment", "Instance",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from ._ast import Shape, unsigned, signed, ShapeCastable, ShapeLike
|
from ._ast import Shape, unsigned, signed, ShapeCastable, ShapeLike
|
||||||
from ._ast import Value, ValueCastable, ValueLike
|
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 ._dsl import SyntaxError, SyntaxWarning, Module
|
||||||
from ._cd import DomainError, ClockDomain
|
from ._cd import DomainError, ClockDomain
|
||||||
from ._ir import UnusedElaboratable, Elaboratable, DriverConflict, Fragment, Instance
|
from ._ir import UnusedElaboratable, Elaboratable, DriverConflict, Fragment, Instance
|
||||||
|
@ -13,7 +13,7 @@ __all__ = [
|
||||||
# _ast
|
# _ast
|
||||||
"Shape", "unsigned", "signed", "ShapeCastable", "ShapeLike",
|
"Shape", "unsigned", "signed", "ShapeCastable", "ShapeLike",
|
||||||
"Value", "ValueCastable", "ValueLike",
|
"Value", "ValueCastable", "ValueLike",
|
||||||
"Const", "C", "Mux", "Cat", "Repl", "Array", "Signal", "ClockSignal", "ResetSignal",
|
"Const", "C", "Mux", "Cat", "Array", "Signal", "ClockSignal", "ResetSignal",
|
||||||
# _dsl
|
# _dsl
|
||||||
"SyntaxError", "SyntaxWarning", "Module",
|
"SyntaxError", "SyntaxWarning", "Module",
|
||||||
# _cd
|
# _cd
|
||||||
|
|
|
@ -16,7 +16,7 @@ from .._unused import *
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"Shape", "signed", "unsigned", "ShapeCastable", "ShapeLike",
|
"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",
|
"Array", "ArrayProxy",
|
||||||
"Signal", "ClockSignal", "ResetSignal",
|
"Signal", "ClockSignal", "ResetSignal",
|
||||||
"ValueCastable", "ValueLike",
|
"ValueCastable", "ValueLike",
|
||||||
|
@ -1170,37 +1170,6 @@ class Cat(Value):
|
||||||
return "(cat {})".format(" ".join(map(repr, self.parts)))
|
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):
|
class _SignalMeta(ABCMeta):
|
||||||
def __call__(cls, shape=None, src_loc_at=0, **kwargs):
|
def __call__(cls, shape=None, src_loc_at=0, **kwargs):
|
||||||
signal = super().__call__(shape, **kwargs, src_loc_at=src_loc_at + 1)
|
signal = super().__call__(shape, **kwargs, src_loc_at=src_loc_at + 1)
|
||||||
|
|
|
@ -6,7 +6,7 @@ from . import _ast as __origin
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"Shape", "signed", "unsigned", "ShapeCastable", "ShapeLike",
|
"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",
|
"Array", "ArrayProxy",
|
||||||
"Signal", "ClockSignal", "ResetSignal",
|
"Signal", "ClockSignal", "ResetSignal",
|
||||||
"ValueCastable", "ValueLike",
|
"ValueCastable", "ValueLike",
|
||||||
|
|
|
@ -59,7 +59,6 @@ The prelude exports exactly the following names:
|
||||||
* :func:`C`
|
* :func:`C`
|
||||||
* :func:`Mux`
|
* :func:`Mux`
|
||||||
* :class:`Cat`
|
* :class:`Cat`
|
||||||
* :class:`Repl` (deprecated)
|
|
||||||
* :class:`Array`
|
* :class:`Array`
|
||||||
* :class:`Signal`
|
* :class:`Signal`
|
||||||
* :class:`ClockSignal`
|
* :class:`ClockSignal`
|
||||||
|
|
|
@ -970,27 +970,6 @@ class CatTestCase(FHDLTestCase):
|
||||||
self.assertEqual(a.signed, False)
|
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):
|
class ArrayTestCase(FHDLTestCase):
|
||||||
def test_acts_like_array(self):
|
def test_acts_like_array(self):
|
||||||
a = Array([1,2,3])
|
a = Array([1,2,3])
|
||||||
|
|
Loading…
Reference in a new issue