Skip to content

Commit 4d1c4fc

Browse files
wanda-phiwhitequark
authored andcommitted
hdl.mem: warn about indexing memories with a Value.
1 parent 08ec36f commit 4d1c4fc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

amaranth/hdl/mem.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import operator
2+
import warnings
23
from collections import OrderedDict
34

45
from .. import tracer
@@ -116,6 +117,10 @@ def write_port(self, *, src_loc_at=0, **kwargs):
116117

117118
def __getitem__(self, index):
118119
"""Simulation only."""
120+
if not isinstance(index, int):
121+
warnings.warn(f"Memory index is {index!r} instead of an 'int'; indexing a memory with "
122+
f"values is deprecated and will be removed in Amaranth 0.5",
123+
DeprecationWarning, stacklevel=2)
119124
return self._array[index]
120125

121126
def elaborate(self, platform):

0 commit comments

Comments
 (0)