Commit graph

25 commits

Author SHA1 Message Date
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
Wanda 49dee891e8 tests: Exorcise some star-imports. 2024-03-13 18:03:22 +00:00
Wanda 24a392887a Implement RFC 43: Rename reset= to init=. 2024-02-15 22:52:24 +00:00
Catherine 9e75962c35 Implement RFC 27: Testbench processes for the simulator.
Co-authored-by: Wanda <wanda@phinode.net>
2024-02-06 23:12:07 +00:00
Catherine 5dd1223cf8 amaranth.hdl: start all private names with an underscore.
This change completes commit 9dc0617e and makes all the tests pass.
It corresponds with the ongoing langauge reference documentation effort.

Fixes #781.
2024-01-30 17:20:45 +00:00
Wanda c6000b1097 lib.data: implement equality for View, reject all other operators. 2023-11-27 21:44:52 +00:00
Vegard Storheil Eriksen 392ead8d00 lib.data: return View from .const() 2023-10-10 09:59:37 +00:00
Catherine f95fe45186 Implement RFC 22: Add ValueCastable.shape().
Fixes #794.
Closes #876.
2023-08-23 10:48:48 +00:00
Marcelina Kościelnicka f6c38061ff lib.data: fix Layout.const masking for signed fields.
Fixes #846.
2023-07-22 00:35:42 +00:00
Catherine d1ca9c46a5 lib.data: allow Const as value of Layout.const(...) field.
Fixes #838.
2023-07-18 14:35:57 +00:00
Catherine 385b10d743 lib.data: improve diagnostics for field access on array layout view.
Fixes #837.
2023-07-18 14:35:49 +00:00
Catherine 2a45d0e9ad lib.data: warn if a field is shadowed by an attribute of the view.
Fixes #796.
2023-05-31 13:27:20 +01:00
Catherine f96604f667 lib.data: make all layouts immutable.
This is actually an existing correctness requirement (for the similar
reasons that ValueCastable.as_value() must always return the same
value every time) that for some reason wasn't respected.
2023-05-23 23:19:29 +01:00
Catherine 7d99981d57 Implement RFC 15: Lifting shape-castable objects.
See amaranth-lang/rfcs#15 and #784.

Note that this RFC breaks the existing syntax for initializing a view
with a new signal. Instances of `View(layout)` *must* be changed to
`Signal(layout)`.
2023-05-15 19:42:12 +01: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 7166455a6a lib.data: implement extensibility as specified in RFC 8.
See amaranth-lang/rfcs#8 and #772.
2023-05-12 20:03:08 +01:00
Catherine ae1aeff0f2 lib.data: at most one Union field can have annotation with a default. 2023-03-04 09:34:50 +00:00
Catherine 16be75e02c lib.data: fix typo. 2023-03-03 09:03:53 +00:00
Catherine c1b9c64e10 lib.data: ignore Python typing annotations in aggregate base class. 2023-03-03 03:45:12 +00:00
Catherine 14e73a73de hdl.ast: do not cast comparand to shape in Shape.__eq__.
This doesn't match how other Python comparison operators work.
E.g. `1 == int("1")` but `1 != "1"`.
2023-02-28 15:52:50 +00:00
Catherine 35561ea11a lib.data: improve reset value handling for Union.
* Reject union initialization with more than one reset value.
* Replace the reset value specified in the class definition with
  the one provided during initalization instead of merging.
2023-02-28 15:38:20 +00:00
Catherine c7ef05c894 lib.data: improve annotation handling for Struct and Union.
* Annotations like `s: unsigned(4) = 1` are recognized and
  the assigned value is used as the reset value for the implicitly
  created `Signal`.
* Base classes inheriting from `Struct` and `Union` without
  specifying a layout are recognized.
* Classes that both inherit from a base class with a layout and
  specify a layout are rejected.
2023-02-28 15:38:18 +00:00
Catherine fcc4f54367 lib.data: make Field() immutable.
Mutability of Field isn't specified by the RFC and can cause issues
if the objects stored in Layout subclasses are mutated. There isn't
any reason to do that (the subclasses themselves are mutable and
handle that correctly), so disallow it.
2023-02-21 17:58:28 +00:00
Catherine 7e3e10e733 lib.data: implement RFC 1 "Aggregate data structure library".
See amaranth-lang/rfcs#1.
2023-02-15 10:10:01 +00:00