self.clocks = int(clocks)
self.domain = domain
if not isinstance(self.value, (Const, Signal, ClockSignal, ResetSignal, Initial)):
- raise TypeError("Sampled value may only be a signal or a constant, not {!r}"
+ raise TypeError("Sampled value must be a signal or a constant, not {!r}"
.format(self.value))
if self.clocks < 0:
raise ValueError("Cannot sample a value {} cycles in the future"
.format(-self.clocks))
+ if not (self.domain is None or isinstance(self.domain, str)):
+ raise TypeError("Domain name must be a string or None, not {!r}"
+ .format(self.domain))
def shape(self):
return self.value.shape()
def test_wrong_value_operator(self):
with self.assertRaises(TypeError,
- "Sampled value may only be a signal or a constant, not "
+ "Sampled value must be a signal or a constant, not "
"(+ (sig $signal) (const 1'd1))"):
Sample(Signal() + 1, 1, "sync")
"Cannot sample a value 1 cycles in the future"):
Sample(Signal(), -1, "sync")
+ def test_wrong_domain(self):
+ with self.assertRaises(TypeError,
+ "Domain name must be a string or None, not 0"):
+ Sample(Signal(), 1, 0)
+
class InitialTestCase(FHDLTestCase):
def test_initial(self):