-
Notifications
You must be signed in to change notification settings - Fork 184
Closed
Labels
Description
Hi,
I'm trying to generate a Record from sliced signals (i'm trying to resize a bus) and record fields must be records or signals.
Example code:
a = Signal(32)
b = Signal()
rec = Record([('a', 5), ('b', 1)], fields={'a': a[:5], 'b': b}) Error:
AssertionError Traceback (most recent call last)
<ipython-input-278-9d7bc72bde0a> in <module>
----> 1 rec = Record([('a', 5), ('b', 1)], fields={'a': a[:5], 'b': b})
~/.local/lib/python3.8/site-packages/nmigen/hdl/rec.py in __init__(self, layout, name, fields, src_loc_at)
124 assert isinstance(field, Record) and field_shape == field.layout
125 else:
--> 126 assert isinstance(field, Signal) and field_shape == field.shape()
127 self.fields[field_name] = field
128 else:
Maybe changing ithe following line is enough to support this feature
diff --git a/nmigen/hdl/rec.py b/nmigen/hdl/rec.py
index be89342..dd21464 100644
--- a/nmigen/hdl/rec.py
+++ b/nmigen/hdl/rec.py
@@ -134,7 +134,7 @@ class Record(UserValue):
if isinstance(field_shape, Layout):
assert isinstance(field, Record) and field_shape == field.layout
else:
- assert isinstance(field, Signal) and field_shape == field.shape()
+ assert isinstance(field, Value) and field_shape == field.shape()
self.fields[field_name] = field
else:
if isinstance(field_shape, Layout):
~Thank you.