Add (heavily work in progress) documentation.

To render correctly, the docs require:
 * pygments/pygments#1441
This commit is contained in:
whitequark 2020-04-27 07:21:31 +00:00
parent 8dacbbb2b2
commit 399b8f9863
21 changed files with 1565 additions and 23 deletions

View file

@ -135,7 +135,7 @@ class Value(metaclass=ABCMeta):
self.src_loc = tracer.get_src_loc(1 + src_loc_at)
def __bool__(self):
raise TypeError("Attempted to convert nMigen value to boolean")
raise TypeError("Attempted to convert nMigen value to Python boolean")
def __invert__(self):
return Operator("~", [self])
@ -184,7 +184,7 @@ class Value(metaclass=ABCMeta):
# Neither Python nor HDLs implement shifts by negative values; prohibit any shifts
# by a signed value to make sure the shift amount can always be interpreted as
# an unsigned value.
raise NotImplementedError("Shift by a signed value is not supported")
raise TypeError("Shift amount must be unsigned")
def __lshift__(self, other):
other = Value.cast(other)
other.__check_shamt()

View file

@ -214,10 +214,9 @@ class Module(_ModuleBuilderRoot, Elaboratable):
width, signed = cond.shape()
if signed:
warnings.warn("Signed values in If/Elif conditions usually result from inverting "
"Python booleans with ~, which leads to unexpected results: ~True is "
"-2, which is truthful. Replace `~flag` with `not flag`. (If this is "
"a false positive, silence this warning with "
"`m.If(x)` → `m.If(x.bool())`.)",
"Python booleans with ~, which leads to unexpected results. "
"Replace `~flag` with `not flag`. (If this is a false positive, "
"silence this warning with `m.If(x)` → `m.If(x.bool())`.)",
SyntaxWarning, stacklevel=4)
return cond