Wanda
67f5b61bcc
hdl._ast: add enum name argument to Format.Enum
.
...
Turns out that RTLIL enum representation requires such, so add a place to store it.
2024-04-11 18:45:16 +00:00
Wanda
49a8a942e8
lib.enum: rename EnumMeta
to EnumType
.
...
Fixes #1073 .
2024-04-11 08:40:12 +00:00
Wanda
cd6cbd71ca
hdl.{_ast,_dsl}: factor out the pattern normalization logic.
2024-04-03 07:34:09 +00:00
Wanda
efcd9a4538
hdl._ast: fix _value_repr
computation.
...
Fixes fallout from #1165 .
2024-03-25 13:53:39 +00:00
Wanda
d6bf47d549
Implement RFC 51: Add ShapeCastable.from_bits
and amaranth.lib.data.Const
.
...
Co-authored-by: Catherine <whitequark@whitequark.org>
2024-03-19 04:01:26 +00:00
Amelia Cuss
c40cfc9fb5
lib.enum: honor enum.nonmember.
...
Use _EnumDict._member_names to determine which members to consider.
This way we don't need to redo sunder/dunder checks, and `nonmember`s
(introduced in py3.11) are correctly excluded.
This is a defacto public API, given it remains usable from py3.8
until py3.12 inclusive. (_member_names changes from a list to a
keys-only dict for performance reasons in py3.11, but they iterate the
same.) In current Python main (i.e. what will most likely be 3.13), a
"member_names" property is added which returns those keys.
2024-02-19 23:06:22 +00:00
Wanda
ef5cfa72bc
Implement RFC 31: Enumeration type safety.
2023-11-29 10:50:34 +00:00
Wanda
1c3227d956
lib.enum: use plain EnumMeta
as metaclass when shape
not used.
2023-10-25 17:00:24 +00:00
Wanda
00699f7c41
lib.enum: allow using functional syntax for enum creation.
...
Fixes #910 .
2023-10-21 05:46:12 +00:00
Charlotte
7e438180e0
lib.enum: allow empty enums.
2023-07-04 10:28:22 +00:00
Catherine
54d5c4c047
Implement RFC 9: Constant initialization for shape-castable objects.
...
See amaranth-lang/rfcs#9 and #771 .
2023-05-12 23:41:57 +01:00
Catherine
4398575322
lib.enum: accept any const-castable expression as member value.
...
This behavior was introduced by amaranth-lang/rfcs#4. See #755 .
2023-05-12 16:39:02 +01:00
Catherine
bf8bbb0f63
lib.enum: check member value shapes before subclassing. NFCI
...
This commit is a preparation for accepting const-castable expressions
as enum member values.
See #755 .
2023-05-12 16:39:02 +01:00
Catherine
0c4fda92fe
hdl.ast: accept any constant-castable expression in Signal(reset=)
.
...
See amaranth-lang/rfcs#4 .
This functionality was not explicitly specified in the RFC but it
falls under "anywhere an integer or an enumeration is accepted".
2023-03-03 06:22:56 +00:00
Catherine
f77a335abf
lib.enum: change shape mismatch warning category to SyntaxWarning
.
2023-03-03 06:14:53 +00:00
Catherine
57612f1dce
lib.enum: add Enum wrappers that allow specifying shape.
...
See #756 and amaranth-lang/rfcs#3 .
2023-02-28 13:00:41 +00:00