Commit graph

65 commits

Author SHA1 Message Date
Sebastian Holzapfel
bf4f22d2d5 backends: s/ilang/rtlil as a result of https://github.com/YosysHQ/yosys/pull/4704 2025-08-18 17:46:28 +02:00
Wanda
1d2b9c309e back.rtlil: set read port init to all-x.
This is an unfortunate necessity needed to fix memory inference regressions
introduced when we switched to using v2 cells. A better approach, compatible
with RFC 54, will need to be figured out for Amaranth 0.6.

Fixes #1011.
2024-05-09 02:38:53 +00:00
meta
d2b2c9b06a back.verilog, back.rtlil: map path elements to str 2024-04-19 21:54:23 +00:00
Wanda
8bf4f77616 sim: use Format.* for VCD output, remove hdl._repr.
This also changes `decoder` a bit: when an enum is used as a decoder,
it is converted to a `Format.Enum` instead. The original enum is still
stored on the `decoder` attribute, so that it can be propagated
on `Signal.like`.
2024-04-13 10:00:16 +00:00
Wanda
580706fafd hdl._nir, back.rtlil: use Format.* to emit enum attributes and wires for fields. 2024-04-11 22:02:26 +00:00
Catherine
8c02d3ef89 Bump Yosys dependency to >=0.40. 2024-04-10 21:57:30 +00:00
Wanda
572d546e07 back.rtlil: fix use of deprecated Signal.width. 2024-04-04 22:35:42 +00:00
Catherine
d94c97981a back.rtlil: implement remaining format specifiers.
This requires a Yosys version from git. The requirement should be bumped
to a proper release before Amaranth 0.5.
2024-04-04 03:03:09 +00:00
Wanda
d3c5b958d3 back.rtlil: Opportunistically trim zero and sign extension on operands.
Fixes #1148.
2024-04-04 01:55:35 +00:00
Wanda
2d59242bf7 back.rtlil: refactor to use intermediate structures.
Fixes #1100.
2024-04-04 00:58:39 +00:00
Wanda
2eb62a8b49 hdl._ast: change Switch to operate on list of cases. 2024-04-03 08:03:52 +00:00
Catherine
738d8b7764 hdl: deprecate {Const,Signal}.{width,signed} accessors.
These accessors used to be necessary (in addition to `.shape()`) while
the AST nodes were mutable. However, after commit 2bf1b4da that made
AST nodes immutable, there is no technical requirement to keep them
around. Additionally:

- `len(value)` is shorter than `value.width` and works with any `value`
- `value.shape().signed` is longer than `value.signed` but works with
  any `value`
2024-03-26 22:56:17 +00:00
Catherine
2ab3a4a0a0 docs/install: fix Yosys version requirement. 2024-03-22 01:22:02 +00:00
Wanda
744576011f Implement RFC 53: Low-level I/O primitives.
Co-authored-by: Catherine <whitequark@whitequark.org>
Co-authored-by: mcclure <mcclure@users.noreply.github.com>
2024-03-18 20:33:22 +00:00
Wanda
bfe541a6d7 Implement RFC 50: Print and string formatting.
Co-authored-by: Catherine <whitequark@whitequark.org>
2024-03-11 09:42:43 +00:00
Wanda
ea561378ac hdl._nir: Remove ArrayMux, use AssignmentList instead. 2024-03-03 18:52:21 +00:00
Wanda
544258354b build.plat, back.rtlil: Fix #1104 fallout. 2024-02-28 13:51:10 +00:00
Wanda
c30585b47b back.rtlil: Emit proper source location for port-signals. 2024-02-27 11:06:42 +00:00
Wanda
1cb9d43841 back.rtlil: Remove code allowing internal yosys cells in Instance.
This was allowed only because Amaranth used it internally. Now that
all uses are gone, let's just disallow it entirely.
2024-02-27 10:34:30 +00:00
Wanda
751e0f4b57 ir: kill Fragment.ports 2024-02-27 08:26:30 +00:00
Wanda
ccf87c62e4 back.rtlil: strip \ from names added to name_map.
Fixes #1154.
2024-02-27 06:26:56 +00:00
Wanda
6d65dc1366 hdl, back.rtlil: track and emit module/submodule locations. 2024-02-19 21:41:32 +00:00
Wanda
188eb8d453 back.rtlil: emit wire signedness according to Signal signedness. 2024-02-16 22:03:30 +00:00
Catherine
eebb6ec3bb back.verilog: require Yosys 0.38.
This avoids the awkward requirement due to the bug in Yosys 0.37, and
will soon be required anyway once the `$check` cell is emitted.
2024-02-13 05:27:23 +00:00
Catherine
6f44438e58 hdl._ir,hdl._nir,back.rtlil: new intermediate representation.
The new intermediate representation will enable global analyses
on Amaranth code without lowering it to another representation
such as RTLIL.

This commit also changes the RTLIL builder to use the new IR.

Co-authored-by: Wanda <wanda@phinode.net>
2024-02-11 09:03:49 +00:00
Wanda
45dbce13df hdl: consistently use "comb" for combinatorial domain.
Fixes #1097.
2024-02-09 19:32:55 +00:00
Wanda
b6c5294e50 hdl.MemoryInstance: refactor and add first-class simulation support. 2024-02-09 17:36:15 +00:00
Wanda
6e06fc013f hdl.ir: associate statements with domains.
Fixes #1079.
2024-02-09 05:33:16 +00:00
Catherine
1fe7bd010f hdl: remove subclassing of AnyValue and Property.
This subclassing is unnecessary and makes downstream code more complex.
In the new IR, they are unified into cells with the same name anyway.
Even before that, this change simplifies things.
2024-02-05 05:58:12 +00:00
Catherine
4da8adf7ba back.rtlil: remove _SyncBuilder. NFC
Amaranth doesn't emit sync rules for a while since these are private
for the Yosys Verilog frontend.
2024-01-31 02:47:52 +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
Catherine
65d77f03fe back.verilog: forbid Yosys version range with dangling else bug.
Fixes #1049.
2024-01-24 16:45:22 +00:00
Wanda
9e9790377a back.rtlil: fix emitting ROMs 2024-01-18 06:40:12 +00:00
Wanda
ae36b596bb hdl.mem: Switch to first-class IR representation for memories.
Fixes #611.
2024-01-17 08:10:28 +00:00
Wanda
eb1c55859e hdl.ir: collect source location for Instance. 2024-01-13 22:33:01 +00:00
Wanda
7f76914b74 Implement RFC 17: Remove log2_int.
Reexports of `amaranth.utils` functions are removed from
`amaranth._utils` to avoid a circular import issue (for `deprecated`).
Since this is a private module, this should not be a problem.
2024-01-11 04:45:17 +00:00
Catherine
750cbbc3c7 hdl: remove deprecated Sample, Past, Stable, Rose, Fell. 2023-12-13 11:13:14 +00:00
Catherine
4bfe2cde6f sim: add support for dumping structure fields in VCD.
See #790.

This commit adds an entirely private API for describing formatting of
values that is used in the standard library, in departure from our
standing policy of not using private APIs in the standard library.

This is a temporary measure intended to get the version 0.4 released
faster, as it has been years in the making. It is expected that this
API will be made public in the version 0.5 after going through the usual
RFC process.

This commit only adds VCD lines for fields defined in `lib.data.Layout`
when using `sim.pysim`. The emitted RTLIL and Verilog remain the same.
It is expected that when `sim.cxxsim` lands, RTLIL/Verilog output will
include aliases for layout fields as well.

The value representation API also handles formatting of enumerations,
with no changes visible to the designer. The implementation of
`Signal(decoder=)` is changed as well to use the new API, with full
backwards compatibility and no public API changes.

Co-authored-by: Wanda <wanda@phinode.net>
2023-11-27 19:03:13 +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
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
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
33c2246311 back.{verilog,rtlil}: in convert(), accept a Component without ports.
Closes #883.
2023-09-04 19:05:49 +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
Charlotte
d218273b9b hdl.ast: deprecate Repl and remove from AST; add Value.replicate. 2023-06-22 03:52:55 +00:00
Catherine
0b7adcbd10 back.verilog: pass -norom to -proc if available.
Fixes #746.
2023-02-28 13:34:14 +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
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