Skip to content

Commit a7a7d32

Browse files
wanda-phiwhitequark
authored andcommitted
hdl._ast: deprecate Value.implies.
1 parent c4370ef commit a7a7d32

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

amaranth/hdl/_ast.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -994,8 +994,9 @@ def xor(self):
994994
"""
995995
return Operator("r^", [self])
996996

997+
# TODO(amaranth-0.6): remove
998+
@deprecated("`a.implies(b)` is deprecated, use `~a | b` instead")
997999
def implies(self, conclusion):
998-
# TODO: should we document or just deprecate this?
9991000
return ~self | conclusion
10001001

10011002
def __check_shamt(self):

docs/guide.rst

-2
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,6 @@ Operation Description Notes
566566
``a & b`` bitwise AND
567567
``a | b`` bitwise OR
568568
``a ^ b`` bitwise XOR
569-
``a.implies(b)`` bitwise IMPLY_
570569
``a >> b`` arithmetic right shift by variable amount [#opB1]_, [#opB2]_
571570
``a << b`` left shift by variable amount [#opB2]_
572571
``a.rotate_left(i)`` left rotate by constant amount [#opB3]_
@@ -575,7 +574,6 @@ Operation Description Notes
575574
``a.shift_right(i)`` right shift by constant amount [#opB3]_
576575
===================== ========================================== ======
577576

578-
.. _IMPLY: https://en.wikipedia.org/wiki/IMPLY_gate
579577
.. [#opB1] Logical and arithmetic right shift of an unsigned value are equivalent. Logical right shift of a signed value can be expressed by :ref:`converting it to unsigned <lang-convops>` first.
580578
.. [#opB2] Shift amount must be unsigned; integer shifts in Python require the amount to be positive.
581579
.. [#opB3] Shift and rotate amounts can be negative, in which case the direction is reversed.

tests/test_hdl_rec.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
with warnings.catch_warnings():
77
warnings.filterwarnings(action="ignore", category=DeprecationWarning)
88
from amaranth.hdl.rec import *
9+
from amaranth._utils import _ignore_deprecated
910

1011
from .utils import *
1112

@@ -299,8 +300,9 @@ def test_operators(self):
299300
self.assertEqual(repr(r1.any()), "(r| (cat (sig r1__a)))")
300301
self.assertEqual(repr(r1.all()), "(r& (cat (sig r1__a)))")
301302
self.assertEqual(repr(r1.xor()), "(r^ (cat (sig r1__a)))")
302-
self.assertEqual(repr(r1.implies(1)), "(| (~ (cat (sig r1__a))) (const 1'd1))")
303-
self.assertEqual(repr(r1.implies(s1)), "(| (~ (cat (sig r1__a))) (sig s1))")
303+
with _ignore_deprecated():
304+
self.assertEqual(repr(r1.implies(1)), "(| (~ (cat (sig r1__a))) (const 1'd1))")
305+
self.assertEqual(repr(r1.implies(s1)), "(| (~ (cat (sig r1__a))) (sig s1))")
304306

305307
# bit_select, word_select, matches,
306308
self.assertEqual(repr(r1.bit_select(0, 1)), "(slice (cat (sig r1__a)) 0:1)")

tests/test_lib_fifo.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,15 @@ def elaborate(self, platform):
156156
gold.w_data.eq(dut.w_data),
157157
]
158158

159-
m.d.comb += Assert(dut.r_rdy.implies(gold.r_rdy))
160-
m.d.comb += Assert(dut.w_rdy.implies(gold.w_rdy))
159+
with m.If(dut.r_rdy):
160+
m.d.comb += Assert(gold.r_rdy)
161+
with m.If(dut.w_rdy):
162+
m.d.comb += Assert(gold.w_rdy)
161163
m.d.comb += Assert(dut.r_level == gold.r_level)
162164
m.d.comb += Assert(dut.w_level == gold.w_level)
163165

164-
m.d.comb += Assert(dut.r_rdy.implies(dut.r_data == gold.r_data))
166+
with m.If(dut.r_rdy):
167+
m.d.comb += Assert(dut.r_data == gold.r_data)
165168

166169
return m
167170

0 commit comments

Comments
 (0)