From 00af73d25bd37b41ed3e414e567fc0043eea2c22 Mon Sep 17 00:00:00 2001 From: Gabor Szita Date: Fri, 17 Jan 2025 16:05:13 -0800 Subject: [PATCH 1/2] Remove unneeded exception from memory.py --- pyrtl/memory.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pyrtl/memory.py b/pyrtl/memory.py index 451e3dcf..3bdafa3e 100644 --- a/pyrtl/memory.py +++ b/pyrtl/memory.py @@ -259,10 +259,7 @@ def _build_read_port(self, addr): def _assignment(self, item, val, is_conditional): from .conditional import _build - item = as_wires(item, bitwidth=self.addrwidth, truncating=False) - if len(item) > self.addrwidth: - raise PyrtlError('error, the wire indexing the memory bitwidth > addrwidth') - addr = item + addr = as_wires(item, bitwidth=self.addrwidth, truncating=False) if isinstance(val, MemBlock.EnabledWrite): data, enable = val.data, val.enable From 3b1c7d444ac2ab83849c2ce7c9d89463c9b977df Mon Sep 17 00:00:00 2001 From: Gabor Szita Date: Thu, 23 Jan 2025 16:27:16 -0800 Subject: [PATCH 2/2] Add comment explaining why we need to call as_wires again in memory.py --- pyrtl/memory.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyrtl/memory.py b/pyrtl/memory.py index 3bdafa3e..38dd0660 100644 --- a/pyrtl/memory.py +++ b/pyrtl/memory.py @@ -259,6 +259,9 @@ def _build_read_port(self, addr): def _assignment(self, item, val, is_conditional): from .conditional import _build + # Even though as_wires is already called on item already in the __getitem__ method, + # we need to call it again here because __setitem__ passes the original item + # to _assignment. addr = as_wires(item, bitwidth=self.addrwidth, truncating=False) if isinstance(val, MemBlock.EnabledWrite):