Skip to content

Commit e25b20c

Browse files
authored
Remove unneeded exception in memory.py (#463)
* Remove unneeded exception from memory.py * Add comment explaining why we need to call as_wires again in memory.py
1 parent 5b282f3 commit e25b20c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pyrtl/memory.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,10 @@ def _build_read_port(self, addr):
259259
def _assignment(self, item, val, is_conditional):
260260
from .conditional import _build
261261

262-
item = as_wires(item, bitwidth=self.addrwidth, truncating=False)
263-
if len(item) > self.addrwidth:
264-
raise PyrtlError('error, the wire indexing the memory bitwidth > addrwidth')
265-
addr = item
262+
# Even though as_wires is already called on item already in the __getitem__ method,
263+
# we need to call it again here because __setitem__ passes the original item
264+
# to _assignment.
265+
addr = as_wires(item, bitwidth=self.addrwidth, truncating=False)
266266

267267
if isinstance(val, MemBlock.EnabledWrite):
268268
data, enable = val.data, val.enable

0 commit comments

Comments
 (0)