self.value = Value.wrap(expr)
self.clocks = int(clocks)
self.domain = domain
- if not isinstance(self.value, (Const, Signal)):
+ if not isinstance(self.value, (Const, Signal, ClockSignal, ResetSignal)):
raise TypeError("Sampled value may only be a signal or a constant, not {!r}"
.format(self.value))
if self.clocks < 0:
return "c${}".format(value.value), value.value
elif isinstance(value, Signal):
return "s${}".format(value.name), value.reset
+ elif isinstance(value, ClockSignal):
+ return "clk", 0
+ elif isinstance(value, ResetSignal):
+ return "rst", 1
else:
raise NotImplementedError # :nocov:
self.assertEqual(s.shape(), (1, False))
def test_signal(self):
- s = Sample(Signal(2), 1, "sync")
- self.assertEqual(s.shape(), (2, False))
+ s1 = Sample(Signal(2), 1, "sync")
+ self.assertEqual(s1.shape(), (2, False))
+ s2 = Sample(ClockSignal(), 1, "sync")
+ s3 = Sample(ResetSignal(), 1, "sync")
def test_wrong_value_operator(self):
with self.assertRaises(TypeError,