Creating an IntEnum
programmatically
#1577
-
I have an integer range that I want to encode so that the encoding begins at zero. I used an from enum import IntEnum as pyIntEnum
sum_range = range(4, 21 + 1)
SumEnum = pyIntEnum('SumEnum', {f'SUM_{x}': x-4 for x in sum_range})
display(type(SumEnum))
# enum.EnumType
from amaranth.lib.enum import IntEnum as amaranthIntEnum
SumEnum = amaranthIntEnum('SumEnum', names={f'SUM_{x}': x-4 for x in sum_range}, shape=unsigned(5))
# TypeError: EnumType.__call__() got an unexpected keyword argument 'shape' What would be the right way to create an Enum programmatically? I am new to Amaranth, so an alternative Amarantish approach is also welcome. |
Beta Was this translation helpful? Give feedback.
Answered by
whitequark
Apr 18, 2025
Replies: 1 comment
-
This is a known bug: #1535 I think if you ask in the IRC/Matrix channel, someone might help you out with it. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
goekce
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a known bug: #1535
I think if you ask in the IRC/Matrix channel, someone might help you out with it.