-
Notifications
You must be signed in to change notification settings - Fork 182
Open
Description
For example, look at this assertion:
AssertionError: (cycle 0) Const(StructLayout({'port': StructLayout({'io0': StructLayout({'o': 1, 'oe': 1}), 'io1': StructLayout({'o': 1, 'oe': 1}), 'io2': StructLayout({'o': 1, 'oe': 1}), 'io3': StructLayout({'o': 1, 'oe': 1}), 'cs': StructLayout({'o': 1, 'oe': 1})}), 'i_en': 1, 'meta': <enum 'QSPIMode'>}), 1539) != Const(StructLayout({'port': StructLayout({'io0': StructLayout({'o': 1, 'oe': 1}), 'io1': StructLayout({'o': 1, 'oe': 1}), 'io2': StructLayout({'o': 1, 'oe': 1}), 'io3': StructLayout({'o': 1, 'oe': 1}), 'cs': StructLayout({'o': 1, 'oe': 1})}), 'i_en': 1, 'meta': <enum 'QSPIMode'>}), 1795)
It's completely incomprehensible. There are three issues:
- Information overload, with excess
StructLayouteverywhere. This is probably not solvable. - Typing this back into a shell doesn't actually reproduce the value, because
data.ConstandConsthave different argument order, andConstonly accepts structured data anyway. - The actual value is just a decimal number.
I think this needs at least two fixes:
- In general, change all
amaranth.lib.*classes to prepend whatever*is to the repr. This matches our suggested import offrom amaranth.lib import data, wiring, <etc>and isn't onerous, although it would make the "information overload" part surely worse. - In this particular case, return
hdl.Constand not adata.Constsince the former casts a by-field decomposition back into a value, fulfilling both the repr contract, and being useful to read. - Maybe ameliorating the info overload by adding newlines and indents to
StructLayoutand friends? It's kind of difficult to implement, but probably feasible, at least as an experiment.