hdl.ast: fix some type checks.
This commit is contained in:
parent
0a2a7025a6
commit
50fa2516fa
|
@ -246,7 +246,8 @@ class Const(Value):
|
||||||
shape = shape, self.value < 0
|
shape = shape, self.value < 0
|
||||||
self.nbits, self.signed = shape
|
self.nbits, self.signed = shape
|
||||||
if not isinstance(self.nbits, int) or self.nbits < 0:
|
if not isinstance(self.nbits, int) or self.nbits < 0:
|
||||||
raise TypeError("Width must be a non-negative integer, not '{!r}'", self.nbits)
|
raise TypeError("Width must be a non-negative integer, not '{!r}'"
|
||||||
|
.format(self.nbits))
|
||||||
self.value = self.normalize(self.value, shape)
|
self.value = self.normalize(self.value, shape)
|
||||||
|
|
||||||
def shape(self):
|
def shape(self):
|
||||||
|
@ -272,7 +273,8 @@ class AnyValue(Value, DUID):
|
||||||
shape = shape, False
|
shape = shape, False
|
||||||
self.nbits, self.signed = shape
|
self.nbits, self.signed = shape
|
||||||
if not isinstance(self.nbits, int) or self.nbits < 0:
|
if not isinstance(self.nbits, int) or self.nbits < 0:
|
||||||
raise TypeError("Width must be a non-negative integer, not '{!r}'", self.nbits)
|
raise TypeError("Width must be a non-negative integer, not '{!r}'"
|
||||||
|
.format(self.nbits))
|
||||||
|
|
||||||
def shape(self):
|
def shape(self):
|
||||||
return self.nbits, self.signed
|
return self.nbits, self.signed
|
||||||
|
|
Loading…
Reference in a new issue