Commit graph

390 commits

Author SHA1 Message Date
Catherine e7b15e1321 sim._pyrtl: formatting. NFCI 2023-11-25 06:26:36 +00:00
William D. Jones abd74ead55 lib.wiring: flip sub-interfaces accessed via FlippedInterface. 2023-11-22 03:07:41 +00:00
Wanda 1802f7fddd lib.wiring: fix search-and-replace accident. NFC 2023-11-21 16:16:59 +00:00
Catherine fc06dd7644 back.verilog: require Yosys >=0.35.
Fixes #931.
2023-11-21 14:52:42 +00:00
Catherine f9da3c0d16 Pyupgrade to 3.8+. NFCI 2023-11-14 13:07:21 +00:00
Vegard Storheil Eriksen 879601380d ast: allow overriding Value operators. 2023-10-30 20:17:51 +00:00
Wanda 1c3227d956 lib.enum: use plain EnumMeta as metaclass when shape not used. 2023-10-25 17:00:24 +00:00
Wanda 4e4085a95b Implement RFC 20: Deprecate non-FWFT FIFOs.
Tracking issue #875.
2023-10-24 20:49:51 +00:00
Wanda a60b9960c5 lib.fifo: reimplement SyncFIFOBuffered without inner SyncFIFO. 2023-10-24 20:49:51 +00:00
Wanda bfd962670d lib.fifo: make fwft=True the default 2023-10-24 20:49:51 +00:00
Wanda 00699f7c41 lib.enum: allow using functional syntax for enum creation.
Fixes #910.
2023-10-21 05:46:12 +00:00
Catherine 7e254b8657 build.res: fix issue #937. 2023-10-20 15:08:10 +00:00
Wanda 1159e52921 tracer: recognize Python 3.13's CALL_KW opcode. 2023-10-20 14:45:11 +00:00
Nelson Gauthier bc316b41a8 lib.io: Pin.oe should have Flow.Out 2023-10-20 13:41:36 +00:00
Vegard Storheil Eriksen 392ead8d00 lib.data: return View from .const() 2023-10-10 09:59:37 +00:00
Wanda 470477a88f lib.wiring: fix Component.signature on subclasses without annotations.
On Python <3.10, classes without annotations do not get an
`__annotations__` member at all, so the `getattr` on a subclass falls
back to the parent class `__annotations__`, attempting to create
signature members twice.  Fix that by looking at the `__dict__` instead.
2023-10-08 22:49:47 +00:00
Jean-François Nguyen c7da6c1292 lib.wiring: add Interface to __all__. 2023-10-05 14:11:38 +00:00
Wanda ccf7aaf00d sim._pyrtl: fix masking for bitwise operands and muxes.
Fixes #926.
2023-10-05 12:26:47 +00:00
Catherine cce4e4462e build.plat: allow removing src attributes from RTLIL output.
This is important for Glasgow, which uses RTLIL hash as cache key,
and expects it to be stable between CI jobs.
2023-10-05 01:51:20 +00:00
Wanda c9416674d1 hdl.mem: fix transparent read handling for simple write ports.
Fixes #922.
2023-10-03 09:39:32 +00:00
Nelson Gauthier 8c56b2033f lib.wiring: Remove superfluous method alias 2023-09-27 17:50:33 +00:00
Catherine ec9da2d4d6 lib.wiring: Component.signature should not be a class method.
While the capability of providing signatures for components that are not
parametric is useful, most Amaranth gateware is heavily parameterized,
and the capability is not worth making most subclasses Liskov-incompatible
with the base class (where the derived class would not provide `signature`
as a class method anymore).
2023-09-27 11:32:06 +00:00
Catherine a90bc7b91a lib.wiring: create flipped interface from flipped signature.
Fixes #914.

Co-authored-by: Nelson Gauthier <nelson.gauthier@gmail.com>
2023-09-27 11:17:29 +00:00
Catherine fcafad1f70 hdl.ir: Elaboratable does not need ABCMeta as its metaclass.
This was introduced in commit 44711b7d, and was never used within
Amaranth itself. While technically a breaking change I think this
will not cause enough breakage to warrant a deprecation cycle
(nor can we make this a deprecation this without a lot of work).
2023-09-25 17:19:48 +00:00
Catherine 04b542a626 vendor._gowin: fix typo. 2023-09-25 14:15:11 +00:00
Catherine 57933b974d ast: fix pylance's type inference on Value._rhs_signals(). NFC 2023-09-25 14:15:11 +00:00
Catherine d27681b157 vendor.GowinPlatform: account for rouding error in frequency calculation. 2023-09-25 08:41:49 +00:00
Catherine 47851c2328 vendor.GowinPlatform: fix fencepost error in oscillator range.
Python ranges are half-open (exclusive).
2023-09-25 08:41:49 +00:00
Catherine bfd62569c8 vendor.GowinPlatform: improve oscillator frequency diagnostic. 2023-09-25 08:41:49 +00:00
Wanda 05cb82b8fc ast: fix const-castable expression handling in Signal(reset=).
The code to accept const-castable expressions was previously added in
0c4fda92fe, but it was untested and had
a few bugs.

Fixes #911.
2023-09-24 02:46:43 +00:00
crzwdjk 11d5bb19eb vendor._lattice_ice40: add an icepack_opts override
Add an icepack_opts override in case the user wants to pass
extra options to icepack as part of the build process.
2023-09-13 20:05:01 +00:00
Catherine ecba1a1863 back.rtlil: put hierarchy in module name instead of an attribute.
The attribute sees essentially no use and the information is much
better served by putting it in the module name. In addition this
means that the entire tree can be renamed simply by renaming the top
module.

Tools like GTKWave show the names of the instances, not the modules,
so they are not affected by the longer names.
2023-09-13 12:46:46 +00:00
Catherine a9d03805ff lib.io: add a deprecation warning on Pin.eq.
This will stop working once `Pin` is no longer inheriting from
`Record`.
2023-09-05 14:07:33 +00:00
Catherine 6683c3a916 hdl.mem: fix INIT parameter of emitted $mem_v2 cell.
Unspecified memory slots are initialized to zero, not uninitialized.
2023-09-05 13:25:55 +00:00
Catherine c53eee961c back.rtlil: fix MEMID parameter to match $mem_v2 cell name. 2023-09-05 13:25:55 +00:00
Catherine 525c7e2be0 back.rtlil: do not translate empty subfragments at all.
It was thought previously (by me) that adding a wire that does
nothing to an empty subfragment is enough to prevent it from being
treated as a blackbox. This is enough for Yosys but not Vivado.
Another workaround could probably be used that satisfies both, but
instead let's just not translate any empty subfragments.

This doesn't account for the case of the empty toplevel, but that
does not seem worth addressing.

Fixes #899.
2023-09-05 06:29:57 +00:00
Catherine 4e078322a0 lib.io: make Pin an interface object.
Tracking #879.

The directions of signals in `Pin` make it convenient to use a pin
signature in a component, such as in:

    class LEDDriver(Component):
        pins: Out(Signature({"o": Out(1)}))

    led_driver = LEDDriver()
    connect(led_driver.pins, platform.request("led"))

The `platform.request` call, correspondingly, returns a flipped `Pin`
object.
2023-09-04 20:48:36 +00:00
Catherine 33c2246311 back.{verilog,rtlil}: in convert(), accept a Component without ports.
Closes #883.
2023-09-04 19:05:49 +00:00
Catherine 87fbcedecf lib.wiring: implement Signature.flatten. 2023-09-04 19:05:49 +00:00
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
Marcelina Kościelnicka 8c4a15ab92 hdl.mem: lower Memory directly to $mem_v2 RTLIL cell.
The design decision of using split memory ports in the internal
representation (copied from Yosys) was misguided and caused no end
of misery. Remove any uses of `$memrd`/`$memwr` and lower memories
directly to a combined memory cell, currently the RTLIL one.
2023-09-03 03:27:51 +00:00
Catherine f28b20fc84 lib.wiring: ensure flipped(flipped(intf)) is intf. 2023-09-01 05:42:04 +00:00
Catherine 5a17f94fdc hdl.rec: deprecate in favor of lib.data and lib.wiring.
Tracking #879.
2023-09-01 04:20:16 +00:00
Catherine 7f1397b281 vendor/*: add missing __all__.
This broke code that did e.g.

    from amaranth.vendor.xilinx import *

which is common in amaranth-boards.
2023-09-01 01:30:46 +00:00
Catherine cd4ea96bd1 Implement RFC 19: Remove amaranth.lib.scheduler 2023-09-01 00:56:12 +00:00
Catherine 796068a192 Implement RFC 18: Reorganize vendor platforms 2023-09-01 00:37:48 +00:00
Catherine 88cbf30128 lib.wiring: use is for type comparison in Component.
This avoids running custom `__eq__` implementations, which could
cause issues such as #882.
2023-08-31 19:26:07 +00:00
Catherine 44d5fac01c lib.wiring: fix equality of FlippedSignature with other object.
Fixes #882.
2023-08-31 19:26:07 +00:00
Catherine f95fe45186 Implement RFC 22: Add ValueCastable.shape().
Fixes #794.
Closes #876.
2023-08-23 10:48:48 +00:00
Catherine 7714ce329a Fix broken commit c9fd0d83. 2023-08-22 17:15:15 +00:00
Catherine c9fd0d8391 build.run: prohibit absolute paths in BuildPlan.add_file.
This makes the build impure and also causes the contents of a file
outside of the build directory to be overwritten.

The check in `BuildPlan.execute_local` is also expanded to cover
the possibility of an absolute path sneaking through.
2023-08-22 16:27:51 +00:00
Catherine 4ffadff20d lib.wiring: implement amaranth-lang/rfcs#2.
Co-authored-by: Charlotte <charlotte@lottia.net>
2023-08-22 16:22:09 +00:00
Catherine 20e8bbdfbd Bring __version__ retrieval up to date. NFCI
Because `importlib.metadata.PackageNotFoundError` inherits from
`ImportError`, the code did not previously work in the way that was
stated in the comment. We should probably deprecate `__version__`
entirely at some point.
2023-08-16 14:40:16 +00:00
Catherine 49a56c4467 vendor.gowin: unbreak dir="o" pins with xdr=2. 2023-08-08 19:51:22 +00:00
Bastian Löher 93e89f5632 vendor.gowin: new platform.
Co-authored-by: Catherine <whitequark@whitequark.org>
2023-08-08 12:38:36 +00:00
Catherine d491288e32 Eliminate uses of deprecated abstractproperty() decorator.
Its docstring with the deprecation notice polluted the documentation.
2023-07-24 13:46:48 +00:00
Catherine cb5b0e38d9 build.run: make BuildPlan.execute_local(env=) override environment.
If it adds to the environment then it ultimately creates the same
kind of problem it was intended to solve--a need to reproduce
the calls to `subprocess` in the code outside. It's not that hard
to merge two dicts, plus much of the time enough you can get by with
having just `PATH` and `AMARANTH_ENV_*` (if even that).

If an override is wanted it can be done easily enough with:

    .execute_local(env={**os.environ, "VAR": "VALUE"})
2023-07-23 17:11:10 +00:00
Catherine a921261215 build.run: add env= argument to BuildPlan.execute_local().
Build scripts are explicitly intended to have overrides that are
done through the use of environment variables, and right now this
would require a very awkward `run_script=False` invocation followed
by copying a bit of code out of the Amaranth codebase, which is
clearly suboptimal.
2023-07-23 04:12:32 +00:00
Catherine a6d67f7477 hdl.ir: use additional heuristic for silencing warning.
Using `sys.excepthook` to silence the must-use warning has some false
negatives: applications may catch the exception and then quit
normally, e.g. becaue the error is well known and does not require
a traceback to be shown (which would be noisy). The current
implementation prints even more noise in that case.

In addition to the existing heuristic, silence the warning if
*nothing* has been elaborated, which is almost always a reliable
sign. It doesn't work if multiple designs are independently created
in the application and some of them are dropped without being used,
but this is unavoidable as it is not distinguishable from the mistake
this warning is attempting to prevent.

Fixes #848.
2023-07-23 04:12:22 +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
Darrell Harmon ea36c80663 vendor.xilinx: recognize Artix Ultrascale+ part numbers 2023-07-10 20:39:45 +00:00
Jean-François Nguyen 4be5e81012 lib.data: remove unused import. 2023-07-10 01:52:57 +00:00
Charlotte 7e438180e0 lib.enum: allow empty enums. 2023-07-04 10:28:22 +00:00
Marcelina Kościelnicka e6d8d5a354 lib.io: allow 0-width Pin
The main purpose of this change is migrating glasgow from the compat
`TSTriple` (which allows 0 width) to `Pin`.  This sort of change would
normally require a RFC, but `Pin` is already slated for
removal/replacement, so that was deemed to be unnecessary.
2023-07-03 23:06:14 +00:00
Charlotte f4b013ac73 lib.data: no loop required, we return or die. 2023-07-02 05:31:42 +00:00
Charlotte cdf8fcc32f lib.enum: allow import * from amaranth.lib.enum.
There's an actual `py_enum.member` (which we briefly overwrite our loop
index with (!)).  We delete our `member`, but it's still in the
`__all__` that came from `py_enum`, so `import *` fails.
2023-06-29 04:24:38 +00:00
Adam Greig 45b9730786 Implement RFC 6: CRC Generator
See amaranth-lang/rfcs#6 and #681.
2023-06-29 02:42:47 +00:00
Charlotte 60c2a1b4b8 sim._pyrtl: don't blow parser stack on older Pythons.
Python pre-3.9 can't handle parentheses nested this deeply.

* https://github.com/amaranth-lang/amaranth/pull/681 -- motivating
  example.
* https://github.com/amaranth-lang/amaranth/pull/827 -- what added
  enough extra parentheses to make this only break now.
* https://peps.python.org/pep-0617/ -- new parser as of 3.9.
2023-06-29 01:28:44 +00:00
Catherine b77e33f16a Drop support for Python 3.7. 2023-06-28 14:50:30 +00:00
Charlotte 99417d6499 sim._pyrtl: mask bitwise binary operands.
Boolean negation produces negative integers, which when unmasked
drastically affects the result of these operations.
2023-06-24 06:34:48 +00:00
Charlotte 4ec9cbbffe sim._pyrtl: py3.12+: convert to int before bitwise negating.
Amaranth bitwise negation `~` compiles to Python bitwise negation `~` in
simulation; the same holds for comparison operators such as `==`. Thus
an expression such as `~(a == b)` in simulation will compile to Python
that takes the bitwise negation of the comparison result, which will be
an actual bool.

On 3.12, the result is a `DeprecationWarning` emitted only at simulation
run-time.

When negating in simulation, coerce the value to an int. `mask` is
sufficient as we do no further arithmetic here.
2023-06-22 17:37:30 +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 51391be1ae hdl.ast: ensure Value.cast in Part and Slice constructors. 2023-06-07 19:53:16 +00:00
Marcelina Kościelnicka 1b0fb1afbc hdl.ast: fix src_loc for Slice. 2023-06-07 19:52:14 +00:00
Marcelina Kościelnicka 3d3846e996 hdl.ast: fix ValueKey.__eq__. 2023-06-07 15:32:21 +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 a4402b507f hdl.dsl: py3.12+: turn off heuristic warning on ~True and ~False.
There is now an upstream deprecation warning for the same.
We don't have to duplicate it.
2023-06-02 13:45:15 +01:00
Catherine 58b8acac0d _toolchain.cxx: remove.
This is causing issues on Python 3.12 and in any case should be
based on the Python `ziglang` package instead of this cursed
setuptools hack.
2023-06-02 13:45:15 +01:00
Marcelina Kościelnicka c343e879d3 tracer: fix STORE_DEREF handling, add EXTENDED_ARG support.
This fixes the following issues:

- on Python 3.10 and earlier, storing to free variables is now handled
  correctly
- on Python 3.11, `_varname_from_oparg` is now used, fixing problems
  with cell variables that are also arguments
- on all supported versions, EXTENDED_ARG is now parsed, ensuring proper
  handling for long functions

Fixes #792.
2023-06-01 19:18:43 +01: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 52b9d3f799 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-23 12:37:21 +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
Jean-François Nguyen e9975587bf build.plat: replace -+ characters in _all_toolchain_env_vars.
Mixed-case variables are allowed since af7c1144, but '-' or '+' must be
replaced to avoid invalid names (e.g. "$AMARANTH_ENV_oss-cad-suite").
2023-05-15 18:25:49 +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 ea5a150155 lib.data: fix documentation style. NFC 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 68e292c681 lib.data: add reference documentation. 2023-05-12 19:54:47 +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
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 32eabd9372 hdl.ast: remove Value.__hash__.
This is already undefined when defining `Value.__eq__`, and it makes
typecheckers (mypy, pyright/pylance) unhappy.
2023-03-06 19:44:53 +00:00
Catherine ae1aeff0f2 lib.data: at most one Union field can have annotation with a default. 2023-03-04 09:34:50 +00:00
Jonathan Neuschäfer e2ce959c90 build.run: Handle UTF-8 encoding errors in SSH output gracefully
In some cases, a toolchain might produce shell output that isn't correct
UTF-8. To avoid crashing in such cases, pass errors="replace" to
bytes.decode.

For example, Lattice Diamond uses the Latin-1 encoding for some reason.
This recently broke my setup because the month turned to "März" in a
German locale:

--- Start Time: Fr. M�r 3 20:01:41 2023
2023-03-04 00:51:29 +00:00
Catherine 16be75e02c lib.data: fix typo. 2023-03-03 09:03:53 +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 f77a335abf lib.enum: change shape mismatch warning category to SyntaxWarning. 2023-03-03 06:14:53 +00:00
Catherine c1b9c64e10 lib.data: ignore Python typing annotations in aggregate base class. 2023-03-03 03:45:12 +00:00
mndza 90b374c17a build.plat: fix strings as build option overrides.
This was broken in 097da99.
2023-03-02 10:50:14 +00:00
Marcelina Kościelnicka e3e542afff vendor.xilinx: fix a SyntaxWarning. 2023-03-01 00:51:13 +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 0ee5de036c hdl.ast: deprecate Sample, Past, Rose, Fell, Stable.
See #526.
2023-02-28 14:30:04 +00:00
Catherine 9ec7f5b507 build.plat: accept lists as build option overrides.
This was unintentionally removed in 9eb208c3.

Fixes #727.
2023-02-28 13:40:59 +00:00
Catherine 0b7adcbd10 back.verilog: pass -norom to -proc if available.
Fixes #746.
2023-02-28 13:34:14 +00:00
Catherine 7ea2e175e4 lib.enum: fix shape calculation for const-castable member values. 2023-02-28 13:30:26 +00:00
Catherine de36e3c162 lib.enum: add Python 3.7..3.8 compatibility shim. 2023-02-28 13:26:52 +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 f602ce1f8f hdl.ast: deprecate Const.normalize.
Tracking issue #754.
2023-02-27 18:19:59 +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
Jean THOMAS a7fec279aa
hdl,back: add support for name= in property checks (Assert, ...).
Co-authored-by: Jean THOMAS <virgule@jeanthomas.me>
2023-02-12 11:21:31 +00:00
Catherine 666ee27fd0 build.run: ensure shell script is run with /bin/sh.
Fixes #665.
2023-02-06 17:08:39 +00:00
Catherine dafefa87a9 build.run: in BuildPlan.execute_local, always use LF line endings.
This way the files are written identically on *nix and Windows.

Fixes #732.
2023-02-04 23:31:34 +00:00
Catherine a704b1b218 vendor.xilinx: update build script template for prjxray. 2023-02-03 06:09:56 +00:00
Catherine 897400ee59 pyproject: relax amaranth-yosys dependency. 2023-02-03 02:40:25 +00:00
Catherine 5a79c351e3 Remove features deprecated in version 0.3. 2023-01-31 21:38:27 +00:00
Catherine 7bf15bc466 back.rtlil: do not add src attribute to cases if emit_src=False.
Fixes #706.
2023-01-31 19:10:32 +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 f133646e9b Remove all remaining code references to nmigen and the namespace.
Closes #741.
2023-01-31 13:49:13 +00:00
Catherine 29502442fb hdl.ast: remove Shape<>tuple casts.
Closes #691.
2023-01-31 12:58:29 +00:00
Catherine 309f647c0e Update documentation and changelog to reflect existing changes. 2023-01-31 12:57:44 +00:00
Catherine aaec7e0d27 tracer: return default name on unrecognized opcode.
The default name is more commonly returned on code such as:

    x, y = Signal(), Signal()

The case where the opcode is not recognized is only encountered
when older Amaranth is ran on a newer Python interpreter (with more
opcodes).

Returning None instead of a name here caused issues in the RTLIL
backend, which would incorrectly use $\d+ names for ports, since
the RTLIL backend assumed the name of a signal is always a string.

Fixes #733.
2023-01-31 10:34:57 +00:00
Catherine 2ca421dea8 back.rtlil: add assertions guarding against $\d+ port names.
See #733.
2023-01-31 10:34:57 +00:00
Bastian Löher 64b96e143b
vendor.xilinx: Add support for more parts when using Symbiflow. 2023-01-23 19:26:58 +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
J. Neuschäfer 91d4513682
Fix several typos. NFC. 2023-01-20 19:48:29 +00:00
Bastian Löher 427c82fcbc
hdl.ast: handle Repl in ValueKey.
Fixes #735.
2023-01-16 23:16:37 +00:00
Gwenhael Goavec-Merou e3b2ba4316
vendor.xilinx: add support for Xray-based toolchain. 2022-12-13 20:09:57 +00:00
Bastian Löher 0a1ba22050
vendor.xilinx: update symbiflow toolchain scripts. 2022-12-01 20:00:48 +00:00
Adam Greig af7c11441d Use all-uppercase toolchain_env_var names.
Accepts previous case for backwards compatibility.

Fixes #728.
2022-11-16 02:37:53 +00:00
Emil J db24a14b57
lib.coding: remove GrayDecoder apparent comb loop for consistency 2022-11-03 11:51:26 +00:00
Marcelina Kościelnicka a9f1c35cb1 _toolchain.cxx: fix use of distutils.ccompiler on newer setuptools.
Starting with setuptools 64.0.2, the monkeypatching process performed as
part of its bootstrap no longer imports distutils.ccompiler, causing an
AttributeError.
2022-10-27 10:16:25 +00:00
Alan Vekselman 9857039a6b hdl.ast: fix non-existing variable in SignalKey.__lt__ 2022-10-05 23:53:33 +00:00
Jin Xue 3a51b61284
sim._pyrtl: translate ArrayProxy to pattern matching when supported.
Current the value compiler translates ArrayProxy into if-elif trees 
which can cause the compiler to crash due to deep recursion (#359).

After this commit, it instead translates them into pattern matching 
when it is supported (on Python >= 3.10) to avoid this problem.
2022-09-24 10:22:47 +00:00
Mrmaxmeier c4be739d48 sim._pyrtl: work around Python's new integer-string conversion limits
Formatting large ints to decimal raises an ValueError in Python versions
that include a mitigation for CVE-2020-10735. Formatting to hexadecimal
instead avoids the algorithmic complexity and is not impacted by the
new conversion limits.

Note that the simulator already rejects very large values, but the
integer-string conversion limits trigger in cases that previously
worked.
2022-09-24 07:40:15 +00:00
Catherine da26f1c915 hdl,back,sim: accept .as_signed() and .as_unsigned() on LHS.
These operators are ignored when they are encountered on LHS, as
the signedness of the assignment target does not matter in Amaranth.
.as_signed() appears on LHS of assigns to signed aggregate fields.
2022-09-24 07:19:47 +00:00
Catherine 90fcbfc357 hdl.ast: improve style of {Shape,Value}Castable doc. NFC. 2022-09-24 07:19:32 +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
Marcelina Kościelnicka 851546bf2d tracer: add Python 3.11 support. 2022-06-30 18:20:18 +00:00
jreyesr 9b8354e137
vendor.lattice_machxo_2_3l: add support for the internal oscillator, OSCH. 2022-04-06 04:12:52 +00:00
Irides ee9da63287 build/plat: implement an override disabling debug Verilog generation.
Currently debug Verilog generation can take many 10's of seconds.
A new override can now be passed as `AMARANTH_debug_verilog`=0 on
the environment or by setting the `debug_verilog` keyword argument
to `Platform.build()` or `Platform.prepare_toolchain()` to `False`.

Fixes #623.
2022-04-05 23:09:43 +00:00
Irides 9eb208c332 build/plat: improve handling of get_override().
The existing functionality of get_override was poorly specified and
ill-purposed for boolean flags. This change extracts the core
variable retrieval logic to a helper function and adds a new handler
`get_override_flag` which special cases boolean flags.

The new behavior will also perform type checking on kwargs and inform
the user of the desired type expected.
2022-04-05 23:09:43 +00:00
Catherine 64771a065a Drop support for Python 3.6. 2022-04-04 09:39:28 +00:00
Irides 85d56a74a5 build.plat,setup: fix Jinja2 dependency.
Jinja2 version 2.11 has a broken dependency constraint that allows its
dependency on markupsafe to pull in a version that it is not actually
compatible with the interface of. Fix this by upgrading the dependency
to `~=3.0`. This requires a small patch to the code to replace the
deprecated `@jinja2.contextfunction` decorator with the replacement
`@jinja2.pass_context`since `@jinja2.contextfunction` is removed in
Jinja2 version 3.1.0.
2022-03-30 21:38:58 +00:00
Jean-François Nguyen f6253b3851 build.plat: use tool_env_var() in _toolchain_env_var. 2022-03-29 21:04:51 +00:00
Catherine 1f1d189441 build.run: pipeline SFTP operations to improve performance. 2022-03-17 05:38:58 +00:00
Catherine 4dea0b2d0f vendor.lattice_ecp5: on Diamond, only emit attributes if there are any. 2022-03-12 13:25:00 +00:00
Bastian Löher 02364a4fd7 sim: Fix clock phase in add_clock having to be specified in ps. 2022-02-04 16:46:52 +00:00
Alyssa Rosenzweig c83b51db6d back.verilog: Fix strip_internal_attrs
Fix the strip_internal_attrs parameter to verilog.convert by passing it
down the call stack as intended.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
2022-01-27 06:42:59 +00:00
Irides 5a4d45b599
back.rtlil: avoid sync process emission in RTLIL.
Avoiding emission of sync processes in RTLIL allows us to avoid a dependency on
matching the behavior expected by Yosys, which generally expects sync processes
in RTLIL to match those emitted by the output from its own Verilog parser.
This also simplifies the logic used in emitting RTLIL overall.

Combinatorial processes are still emitted however. Without these the RTLIL does
not have a high-level understanding of Switch statements, which significantly
diminishes the quality of emitted Verilog, as these are converted to `$mux`
cells in Yosys, which become `?` constructs when converted back to Verilog.

Fixes #603.
Fixes #672.
2022-01-01 18:18:33 +00:00
Irides 538c14116c sim.pysim: use "bench" as a top level root for testbench signals.
Fixes #561.
2021-12-16 15:46:05 +00:00
Catherine 847e46927b back.{verilog,rtlil}: fix commit d83c4a1b.
The `ports` argument has been passed implicitly, via `**kwargs`, and
that was broken during the deprecation.

Closes #659.
2021-12-14 10:47:04 +00:00
Irides d83c4a1b21 back.{rtlil,verilog}: deprecate implicit ports.
Fixes #630.
2021-12-13 12:21:44 +00:00
Catherine 24c4da2b2f lib.fifo: clarify AsyncFIFO{,Buffered}.r_rst documentation. NFC. 2021-12-13 09:53:57 +00:00
Irides 40b92965c9 docs: cover amaranth.vendor. 2021-12-13 09:17:50 +00:00
modwizcode 1ee2482c6b sim: represent time internally as 1ps units
Using floats to represent simulation time internally isn't ideal
instead use 1ps internal units while continuing to use a floating
point based interface for compatibility.

Fixes #535.
2021-12-13 08:15:11 +00:00
modwizcode d2c569c45e docs: cover amaranth.lib.fifo. 2021-12-13 07:48:43 +00:00
Catherine 2adbe59e4f docs: formatting and readability improvements. 2021-12-13 06:33:36 +00:00
Catherine 18837b9029 docs: cover amaranth.lib.cdc. 2021-12-13 06:23:12 +00:00
Catherine 3a8cd63b23 docs: cover amaranth.lib.coding. 2021-12-13 05:48:31 +00:00
Irides 0b74d1c5f6 back.rtlil: support slicing on Parts
Fixes #605.
2021-12-11 16:44:29 +00:00
whitequark 7c161957bf build.dsl: check type of resource number.
Fixes #599.
2021-12-11 13:37:15 +00:00
whitequark 7e2b72826f sim.core: warn when driving a clock domain not in the simulation.
Closes #566.
2021-12-11 13:22:24 +00:00
whitequark ac13a5b3c9 sim._pyrtl: reject very large values.
A check that rejects very large wires already exists in back.rtlil
because they cause performance and correctness issues with Verilog
tooling. Similar performance issues exist with the Python simulator.

This commit also adjusts back.rtlil to use the OverflowError
exception, same as in sim._pyrtl.

Fixes #588.
2021-12-11 13:00:46 +00:00
whitequark 599615ee3a hdl.ir: reject elaboratables that elaborate to themselves.
Fixes #592.
2021-12-11 12:40:05 +00:00
whitequark 90777a65c8 build.plat,vendor: add missing compatibility shims for NMIGEN_ENV_*.
These have been mistakenly omitted from commit 909a3b8b.
2021-12-11 12:40:05 +00:00
Irides b1eba5fd82 vendor.xilinx: support setting options on synth_design
Closes #606.
2021-12-11 12:09:09 +00:00
whitequark fd7d01ef10 back.rtlil,cli: allow suppressing generation of src attributes.
Fixes #572.
2021-12-11 11:38:40 +00:00
whitequark 66295fa388 sim.pysim: refuse to write VCD files with whitespace in signal names.
Closes #595.
2021-12-11 11:12:25 +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 25573c5eff back.rtlil: extend unsigned operand of binop if another is signed.
Fixes #580.
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