r_attributes="")
def __init__(self, width, depth, *, fwft):
- if depth <= 0:
- raise ValueError("FIFO depth must be positive, not {}".format(depth))
-
+ if not isinstance(width, int) or width < 0:
+ raise TypeError("FIFO width must be a non-negative integer, not '{!r}'"
+ .format(width))
+ if not isinstance(depth, int) or depth <= 0:
+ raise TypeError("FIFO depth must be a positive integer, not '{!r}'"
+ .format(depth))
self.width = width
self.depth = depth
self.fwft = fwft
class FIFOTestCase(FHDLTestCase):
def test_depth_wrong(self):
- with self.assertRaises(ValueError,
- msg="FIFO depth must be positive, not -1"):
- FIFOInterface(width=8, depth=-1, fwft=True)
- with self.assertRaises(ValueError,
- msg="FIFO depth must be positive, not 0"):
+ with self.assertRaises(TypeError,
+ msg="FIFO width must be a non-negative integer, not '-1'"):
+ FIFOInterface(width=-1, depth=8, fwft=True)
+ with self.assertRaises(TypeError,
+ msg="FIFO depth must be a positive integer, not '0'"):
FIFOInterface(width=8, depth=0, fwft=True)
def test_async_depth(self):