Skip to content

Commit

Permalink
hdl.mem: warn about indexing memories with a Value.
Browse files Browse the repository at this point in the history
  • Loading branch information
wanda-phi authored and whitequark committed Apr 3, 2024
1 parent 08ec36f commit 4d1c4fc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions amaranth/hdl/mem.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import operator
import warnings
from collections import OrderedDict

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

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

def elaborate(self, platform):
Expand Down

0 comments on commit 4d1c4fc

Please sign in to comment.