Commit graph

45 commits

Author SHA1 Message Date
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 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
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 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
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 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 29502442fb hdl.ast: remove Shape<>tuple casts.
Closes #691.
2023-01-31 12:58:29 +00:00
Catherine 2ca421dea8 back.rtlil: add assertions guarding against $\d+ port names.
See #733.
2023-01-31 10:34:57 +00:00
J. Neuschäfer 91d4513682
Fix several typos. NFC. 2023-01-20 19:48:29 +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
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
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
Irides 0b74d1c5f6 back.rtlil: support slicing on Parts
Fixes #605.
2021-12-11 16:44:29 +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 fd7d01ef10 back.rtlil,cli: allow suppressing generation of src attributes.
Fixes #572.
2021-12-11 11:38:40 +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 909a3b8be7 Rename nMigen to Amaranth HDL. 2021-12-10 10:34:13 +00:00