Implement RFC 43: Rename reset= to init=.
This commit is contained in:
parent
b30c87fa3e
commit
24a392887a
30 changed files with 476 additions and 276 deletions
|
|
@ -29,6 +29,7 @@ Apply the following changes to code written against Amaranth 0.4 to migrate it t
|
|||
* Replace uses of ``Value.matches()`` with no patterns with ``Const(1)``
|
||||
* Update uses of ``amaranth.utils.log2_int(need_pow2=False)`` to :func:`amaranth.utils.ceil_log2`
|
||||
* Update uses of ``amaranth.utils.log2_int(need_pow2=True)`` to :func:`amaranth.utils.exact_log2`
|
||||
* Update uses of ``reset=`` keyword argument to ``init=``
|
||||
* Convert uses of ``Simulator.add_sync_process`` used as testbenches to ``Simulator.add_testbench``
|
||||
* Convert other uses of ``Simulator.add_sync_process`` to ``Simulator.add_process``
|
||||
|
||||
|
|
@ -39,11 +40,13 @@ Implemented RFCs
|
|||
.. _RFC 17: https://amaranth-lang.org/rfcs/0017-remove-log2-int.html
|
||||
.. _RFC 27: https://amaranth-lang.org/rfcs/0027-simulator-testbenches.html
|
||||
.. _RFC 39: https://amaranth-lang.org/rfcs/0039-empty-case.html
|
||||
.. _RFC 43: https://amaranth-lang.org/rfcs/0043-rename-reset-to-init.html
|
||||
.. _RFC 46: https://amaranth-lang.org/rfcs/0046-shape-range-1.html
|
||||
|
||||
* `RFC 17`_: Remove ``log2_int``
|
||||
* `RFC 27`_: Testbench processes for the simulator
|
||||
* `RFC 39`_: Change semantics of no-argument ``m.Case()``
|
||||
* `RFC 43`_: Rename ``reset=`` to ``init=``
|
||||
* `RFC 46`_: Change ``Shape.cast(range(1))`` to ``unsigned(0)``
|
||||
|
||||
|
||||
|
|
@ -56,9 +59,10 @@ Language changes
|
|||
* Added: :func:`amaranth.utils.ceil_log2`, :func:`amaranth.utils.exact_log2`. (`RFC 17`_)
|
||||
* Changed: ``m.Case()`` with no patterns is never active instead of always active. (`RFC 39`_)
|
||||
* Changed: ``Value.matches()`` with no patterns is ``Const(0)`` instead of ``Const(1)``. (`RFC 39`_)
|
||||
* Changed: ``Signal(range(stop), reset=stop)`` warning has been changed into a hard error and made to trigger on any out-of range value.
|
||||
* Changed: ``Signal(range(stop), init=stop)`` warning has been changed into a hard error and made to trigger on any out-of range value.
|
||||
* Changed: ``Signal(range(0))`` is now valid without a warning.
|
||||
* Changed: ``Shape.cast(range(1))`` is now ``unsigned(0)``. (`RFC 46`_)
|
||||
* Changed: the ``reset=`` argument of :class:`Signal`, :meth:`Signal.like`, :class:`amaranth.lib.wiring.Member`, :class:`amaranth.lib.cdc.FFSynchronizer`, and ``m.FSM()`` has been renamed to ``init=``. (`RFC 43`_)
|
||||
* Deprecated: :func:`amaranth.utils.log2_int`. (`RFC 17`_)
|
||||
* Removed: (deprecated in 0.4) :meth:`Const.normalize`. (`RFC 5`_)
|
||||
* Removed: (deprecated in 0.4) :class:`Repl`. (`RFC 10`_)
|
||||
|
|
|
|||
|
|
@ -407,19 +407,17 @@ The names do not need to be unique; if two signals with the same name end up in
|
|||
Initial signal values
|
||||
---------------------
|
||||
|
||||
Each signal has an *initial value*, specified with the ``reset=`` parameter. If the initial value is not specified explicitly, zero is used by default. An initial value can be specified with an integer or an enumeration member.
|
||||
Each signal has an *initial value*, specified with the ``init=`` parameter. If the initial value is not specified explicitly, zero is used by default. An initial value can be specified with an integer or an enumeration member.
|
||||
|
||||
Signals :ref:`assigned <lang-assigns>` in a :ref:`combinatorial <lang-comb>` domain assume their initial value when none of the assignments are :ref:`active <lang-active>`. Signals assigned in a :ref:`synchronous <lang-sync>` domain assume their initial value after *power-on reset* and, unless the signal is :ref:`reset-less <lang-resetless>`, *explicit reset*. Signals that are used but never assigned are equivalent to constants of their initial value.
|
||||
|
||||
.. TODO: using "reset" for "initial value" is awful, let's rename it to "init"
|
||||
|
||||
.. doctest::
|
||||
|
||||
>>> Signal(4).reset
|
||||
>>> Signal(4).init
|
||||
0
|
||||
>>> Signal(4, reset=5).reset
|
||||
>>> Signal(4, init=5).init
|
||||
5
|
||||
>>> Signal(Direction, reset=Direction.LEFT).reset
|
||||
>>> Signal(Direction, init=Direction.LEFT).init
|
||||
1
|
||||
|
||||
|
||||
|
|
@ -467,7 +465,7 @@ In contrast, code written in the Amaranth language *describes* computations on a
|
|||
|
||||
.. doctest::
|
||||
|
||||
>>> a = Signal(8, reset=5)
|
||||
>>> a = Signal(8, init=5)
|
||||
>>> a + 1
|
||||
(+ (sig a) (const 1'd1))
|
||||
|
||||
|
|
@ -1190,11 +1188,11 @@ Simple `finite state machines <https://en.wikipedia.org/wiki/Finite-state_machin
|
|||
|
||||
.. TODO: FSM() should require keyword arguments, for good measure
|
||||
|
||||
The reset state of the FSM can be provided when defining it using the :py:`with m.FSM(reset="Name"):` argument. If not provided, it is the first state in the order of definition. For example, this definition is equivalent to the one at the beginning of this section:
|
||||
The initial (and reset) state of the FSM can be provided when defining it using the :py:`with m.FSM(init="Name"):` argument. If not provided, it is the first state in the order of definition. For example, this definition is equivalent to the one at the beginning of this section:
|
||||
|
||||
.. testcode::
|
||||
|
||||
with m.FSM(reset="Set Address"):
|
||||
with m.FSM(init="Set Address"):
|
||||
...
|
||||
|
||||
The FSM belongs to a :ref:`clock domain <lang-domains>`, which is specified using the :py:`with m.FSM(domain="dom")` argument. If not specified, it is the ``sync`` domain. For example, this definition is equivalent to the one at the beginning of this section:
|
||||
|
|
@ -1255,7 +1253,7 @@ Consider the following code:
|
|||
|
||||
.. testcode::
|
||||
|
||||
a = Signal(8, reset=1)
|
||||
a = Signal(8, init=1)
|
||||
with m.If(en):
|
||||
m.d.comb += a.eq(b + 1)
|
||||
|
||||
|
|
@ -1534,7 +1532,7 @@ The application of control flow modifiers in it causes the behavior of the final
|
|||
with m.If(en):
|
||||
m.d.sync += n.eq(n + 1)
|
||||
with m.If(rst):
|
||||
m.d.sync += n.eq(n.reset)
|
||||
m.d.sync += n.eq(n.init)
|
||||
m.d.comb += z.eq(n == 0)
|
||||
|
||||
.. tip::
|
||||
|
|
|
|||
|
|
@ -555,7 +555,7 @@ Signatures
|
|||
.. autodata:: Out
|
||||
.. autodata:: In
|
||||
|
||||
.. autoclass:: Member(flow, description, *, reset=None)
|
||||
.. autoclass:: Member(flow, description, *, init=None)
|
||||
|
||||
.. autoexception:: SignatureError
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue