Commit graph

43 commits

Author SHA1 Message Date
Catherine f135226a79 hdl: disallow signed(0) values with unclear semantics.
Fixes #807.
2023-09-03 04:37:59 +00:00
Catherine 21b5451036 ast: ensure Part offset is unsigned.
Co-authored-by: Marcelina Kościelnicka <mwk@0x04.net>
2023-09-03 04:25:08 +00:00
Catherine f95fe45186 Implement RFC 22: Add ValueCastable.shape().
Fixes #794.
Closes #876.
2023-08-23 10:48:48 +00:00
Charlotte d218273b9b hdl.ast: deprecate Repl and remove from AST; add Value.replicate. 2023-06-22 03:52:55 +00:00
Marcelina Kościelnicka b1cce87630 hdl.ast: make Value.__abs__ return unsigned shape. 2023-06-07 23:20:26 +00:00
Marcelina Kościelnicka 1d5e090580 hdl.ast: fix shape for subtraction.
Fixes #813.
2023-06-07 12:34:30 +00:00
Marcelina Kościelnicka 3180a17fd9 hdl.ast: fix Slice validation.
Fixes #810.
2023-06-07 12:26:36 +00:00
Marcelina Kościelnicka c7984463c7 hdl.ast: fix range handling in Shape.cast.
Fixes #803.
2023-06-07 12:26:30 +00:00
Marcelina Kościelnicka a6e33abc5f hdl.ast: guard rotate_* against 0-width values.
Fixes #808.
2023-06-07 12:12:24 +01:00
Marcelina Kościelnicka 656db317d2 hdl.ast: fix signed Const normalization.
Fixes #805.
2023-06-07 11:22:52 +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
Arusekk 5f094a23eb hdl.ast: Test *Castable subclasses on definition.
The __init_subclass__ method fires on class definition rather than use.
It also has the bonus impact that no __new__ method is defined, so the
classes can be correctly detected as mix-in classes by modules such as
enum.
2023-03-21 23:22:47 +00:00
Catherine 80343d1c4c hdl.ast: warn on fencepost error in Signal(range(x), reset=x).
Also, relax the language reference inset from "warning" to "note"
since this is no longer something developers have to keep in mind
explicitly.
2023-03-13 20:38:41 +00: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 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 0ee5de036c hdl.ast: deprecate Sample, Past, Rose, Fell, Stable.
See #526.
2023-02-28 14:30:04 +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
Catherine ef2e9fa809 hdl.ast: Value.matches() with no arguments should return C(1).
The behavior of the following must be always the same:
- `with m.Switch(v): with m.Case(*pats):`
- `with m.If(v.matches(*pats)):`
2023-02-28 09:09:27 +00:00
Catherine 58721ee4fe hdl: implement constant-castable expressions.
See #755 and amaranth-lang/rfcs#4.
2023-02-27 22:38:38 +00:00
Catherine bef2052c1e hdl.ast: implement Value.__pos__. 2023-02-27 22:31:17 +00:00
Catherine 5a79c351e3 Remove features deprecated in version 0.3. 2023-01-31 21:38:27 +00:00
Catherine 7044e09110 hdl.ast: remove Shape<>tuple comparisons.
See #691.

I missed this in commit 29502442.
2023-01-31 15:23:06 +00:00
Catherine 29502442fb hdl.ast: remove Shape<>tuple casts.
Closes #691.
2023-01-31 12:58:29 +00:00
Arusekk de6b69370f hdl.ast: Do not warn on int Enums in Cat.
This aligns with the behavior for plain Enums.
2023-01-22 23:40:39 +00:00
Arusekk 58a0c68279 hdl.ast: allow typed int enums in Value.cast. 2023-01-22 23:40:39 +00:00
Catherine bf16acf2f0 hdl.ast: implement ShapeCastable (like ValueCastable).
Refs #693.
2022-09-24 07:19:03 +00:00
Catherine 0723f6bac9 hdl.ast: recursively cast ValueCastable objects to values. 2022-09-24 07:18:57 +00:00
whitequark b452e0e871 hdl.ast: support division and modulo with negative divisor.
Fixes #621.

This commit bumps the Yosys version requirement to >=0.10.
2021-12-11 10:25:48 +00:00
whitequark 44b8bd29af hdl.ast: warn on bare integer value used in Cat()/Repl().
Fixes #639.
2021-12-11 08:18:33 +00:00
whitequark de7c9acb19 _utils: don't crash trying to flatten() strings.
Fixes #614.
2021-12-11 07:39:35 +00:00
whitequark 909a3b8be7 Rename nMigen to Amaranth HDL. 2021-12-10 10:34:13 +00:00
whitequark 11914a1e67 hdl.ast: improve interaction of ValueCastable with custom __getattr__.
Avoid calling `__getattr__("_ValueCastable__lowered_to")` when
a ValueCastable has custom `__getattr__` implementation; this avoids
the need for downstream code to be aware of this implementataion
detail.
2021-10-03 20:28:07 +00:00
whitequark e88d283ed3 hdl.ast: simplify Mux implementation. 2021-10-02 14:18:02 +00:00
whitequark 65499d5c45 hdl.ast: add tests for casting bare integers in {Cat,Repl}. 2021-10-02 13:18:11 +00:00
Robin Ole Heinemann b38b2cdad7 test.test_hdl_ast.OperatorTestCase: remove duplicate test_bool 2021-05-18 20:18:55 +00:00
Robin Ole Heinemann 2d85f888d6 tests: rename tests with duplicate names 2021-05-18 20:18:55 +00:00
whitequark c30dcea24d hdl.ast: handle int subclasses as slice start/stop values.
Fixes #601.
2021-03-18 23:52:23 +00:00
whitequark 818c8bc464 hdl.ast: normalize case values to two's complement, not signed binary.
This was an especially insidious bug because the minus character is
valid in case values but has a completely different meaning (wildcard
rather than sign).

Fixes #559.
2020-12-12 12:42:12 +00:00
whitequark bde37fe2f2 hdl.ast: deprecate UserValue in favor of ValueCastable.
Closes #527.
2020-11-06 02:21:53 +00:00
awygle 06c734992f
hdl.ast: implement ValueCastable.
Closes RFC issue #355.
2020-11-06 00:20:54 +00:00
whitequark fde242aa47 hdl.ast: clarify exception message for out of bounds indexing.
Fixes #488.
2020-08-27 01:14:05 +00:00
whitequark 67b957d4f4 tests: move out of the main package.
Compared to tests in the repository root, tests in the package have
many downsides:
  * Unless explicitly excluded in find_packages(), tests and their
    support code effectively become a part of public API.
    This, unfortunately, happened with FHDLTestCase, which was never
    intended for downstream use.
  * Even if explicitly excluded from the setuptools package, using
    an editable install, or setting PYTHONPATH still allows accessing
    the tests.
  * Having a sub-package that is present in the source tree but not
    exported (or, worse, exported only sometimes) is confusing.
  * The name `nmigen.test` cannot be used for anything else, such as
    testing utilities that *are* intended for downstream use.
2020-08-27 00:33:31 +00:00
Renamed from nmigen/test/test_hdl_ast.py (Browse further)