You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide.rst
+6-19Lines changed: 6 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -255,9 +255,7 @@ Any Python value that implements the :class:`ShapeCastable` interface can extend
255
255
Value casting
256
256
=============
257
257
258
-
Like shapes, values may be *cast* from other objects, which are called *value-like*. Casting to values allows objects that are not provided by Amaranth, such as integers or enumeration members, to be used in Amaranth expressions directly. Values are value-like objects as well.
259
-
260
-
.. TODO: link to ValueCastable
258
+
Like shapes, values may be *cast* from other objects, which are called *value-like*. Casting to values allows objects that are not provided by Amaranth, such as integers or enumeration members, to be used in Amaranth expressions directly. Custom value-like objects can be defined by implementing the :class:`~amaranth.hdl.ValueCastable` interface. Values are value-like objects as well.
261
259
262
260
Casting to a value can be done explicitly with :meth:`Value.cast`, but is usually implicit, since value-like objects are accepted anywhere values are.
263
261
@@ -422,9 +420,7 @@ Signals :ref:`assigned <lang-assigns>` in a :ref:`combinatorial <lang-comb>` dom
422
420
Reset-less signals
423
421
------------------
424
422
425
-
Signals assigned in a :ref:`synchronous <lang-sync>` domain can be *resettable* or *reset-less*, specified with the ``reset_less=`` parameter. If the parameter is not specified, signals are resettable by default. Resettable signals assume their :ref:`initial value <lang-initial>` on explicit reset, which can be asserted via the clock domain or by using ``ResetInserter``. Reset-less signals are not affected by explicit reset.
426
-
427
-
.. TODO: link to clock domain and ResetInserter docs
423
+
Signals assigned in a :ref:`synchronous <lang-sync>` domain can be *resettable* or *reset-less*, specified with the ``reset_less=`` parameter. If the parameter is not specified, signals are resettable by default. Resettable signals assume their :ref:`initial value <lang-initial>` on explicit reset, which can be asserted via the :ref:`clock domain <lang-clockdomains>` or by :ref:`modifying control flow <lang-controlinserter>` with :class:`ResetInserter`. Reset-less signals are not affected by explicit reset.
428
424
429
425
Signals assigned in a :ref:`combinatorial <lang-comb>` domain are not affected by the ``reset_less`` parameter.
430
426
@@ -774,8 +770,6 @@ The ``.as_signed()`` and ``.as_unsigned()`` conversion operators reinterpret the
774
770
775
771
For example, ``(pc + imm[:7].as_signed()).as_unsigned()`` sign-extends the 7 least significant bits of ``imm`` to the width of ``pc``, performs the addition, and produces an unsigned result.
776
772
777
-
.. TODO: more general shape conversion? https://github.com/amaranth-lang/amaranth/issues/381
778
-
779
773
780
774
.. _lang-muxop:
781
775
@@ -993,8 +987,6 @@ Control flow
993
987
994
988
Although it is possible to write any decision tree as a combination of :ref:`assignments <lang-assigns>` and :ref:`choice expressions <lang-muxop>`, Amaranth provides *control flow syntax* tailored for this task: :ref:`If/Elif/Else <lang-if>`, :ref:`Switch/Case <lang-switch>`, and :ref:`FSM/State <lang-fsm>`. The control flow syntax uses :py:`with` blocks (it is implemented using :ref:`context managers <python:context-managers>`), for example:
995
989
996
-
.. TODO: link to relevant subsections
997
-
998
990
.. testcode::
999
991
1000
992
timer = Signal(8)
@@ -1133,8 +1125,6 @@ Case comparison, where a single value is examined against several different *pat
1133
1125
with m.Default():
1134
1126
m.d.comb += too_big.eq(1)
1135
1127
1136
-
.. TODO: diagnostic for `Case` blocks after `Default`?
1137
-
1138
1128
Within a single :py:`Switch` block, the statements within at most one block will be active at any time. This will be the first :py:`Case` block in the order of definition whose pattern :ref:`matches <lang-matchop>` the value, or the first :py:`Default` block, whichever is earlier.
1139
1129
1140
1130
If a :py:`Default` block is present, or the patterns in the :py:`Case` blocks cover every possible :py:`Switch` value, then the statements within exactly one block will be active at any time, and the sequence as a whole is called a *full condition*.
@@ -1275,9 +1265,7 @@ A combinatorial signal that is computed directly or indirectly based on its own
1275
1265
Synchronous evaluation
1276
1266
======================
1277
1267
1278
-
Signals in synchronous :ref:`control domains <lang-domains>` change whenever the *active edge* (a 0-to-1 or 1-to-0 transition, configured when :ref:`creating the domain <lang-clockdomains>`) occurs on the clock of the synchronous domain. In addition, the signals in clock domains with an asynchronous reset change when such a reset is asserted. The final value of a synchronous signal is equal to its :ref:`initial value <lang-initial>` if the reset (of any type) is asserted, or to its current value updated by the :ref:`active assignments <lang-active>` in the :ref:`assignment order <lang-assignorder>` otherwise. Synchronous signals always hold state.
1279
-
1280
-
.. TODO: link to clock domains
1268
+
Signals in synchronous :ref:`control domains <lang-domains>` change whenever the *active edge* (a 0-to-1 or 1-to-0 transition, configured when :ref:`creating the domain <lang-clockdomains>`) occurs on the clock of the synchronous domain. In addition, the signals in :ref:`clock domains <lang-clockdomains>` with an asynchronous reset change when such a reset is asserted. The final value of a synchronous signal is equal to its :ref:`initial value <lang-initial>` if the reset (of any type) is asserted, or to its current value updated by the :ref:`active assignments <lang-active>` in the :ref:`assignment order <lang-assignorder>` otherwise. Synchronous signals always hold state.
1281
1269
1282
1270
Consider the following code:
1283
1271
@@ -1337,7 +1325,9 @@ A clock domain also has a reset signal, which can be accessed through the :attr:
If a clock domain is defined in a module, all of its submodules can refer to that domain under the same name.
1328
+
Signals in a reset-less clock domain can still be explicitly reset using the :class:`ResetInserter` :ref:`control flow modifier <lang-controlinserter>`.
1329
+
1330
+
If a clock domain is defined in a module, all of its :ref:`submodules <lang-submodules>` can refer to that domain under the same name.
1341
1331
1342
1332
.. warning::
1343
1333
@@ -1353,9 +1343,6 @@ If a clock domain is defined in a module, all of its submodules can refer to tha
1353
1343
1354
1344
A new asynchronous control set is necessary when some signals must change on a different active edge of a clock, at a different frequency, with a different phase, or when a different asynchronous reset signal is asserted.
1355
1345
1356
-
.. TODO: mention that ResetInserter will add a reset even to a reset-less domain
0 commit comments