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.
This commit is contained in:
parent
32eabd9372
commit
80343d1c4c
3 changed files with 33 additions and 4 deletions
|
|
@ -163,7 +163,7 @@ Specifying a shape with a range is convenient for counters, indexes, and all oth
|
|||
|
||||
.. _lang-exclrange:
|
||||
|
||||
.. warning::
|
||||
.. note::
|
||||
|
||||
Python ranges are *exclusive* or *half-open*, meaning they do not contain their ``.stop`` element. Because of this, values with shapes cast from a ``range(stop)`` where ``stop`` is a power of 2 are not wide enough to represent ``stop`` itself:
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ Specifying a shape with a range is convenient for counters, indexes, and all oth
|
|||
>>> fencepost.value
|
||||
0
|
||||
|
||||
Be mindful of this edge case!
|
||||
Amaranth detects uses of :class:`Const` and :class:`Signal` that invoke such an off-by-one error, and emits a diagnostic message.
|
||||
|
||||
|
||||
.. _lang-shapeenum:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue