hdl.ast: add Sample.
This commit is contained in:
parent
b78a2be9f6
commit
b3de114d67
2 changed files with 52 additions and 1 deletions
|
|
@ -496,3 +496,24 @@ class ResetSignalTestCase(FHDLTestCase):
|
|||
def test_repr(self):
|
||||
s1 = ResetSignal()
|
||||
self.assertEqual(repr(s1), "(rst sync)")
|
||||
|
||||
|
||||
class SampleTestCase(FHDLTestCase):
|
||||
def test_const(self):
|
||||
s = Sample(1, 1, "sync")
|
||||
self.assertEqual(s.shape(), (1, False))
|
||||
|
||||
def test_signal(self):
|
||||
s = Sample(Signal(2), 1, "sync")
|
||||
self.assertEqual(s.shape(), (2, False))
|
||||
|
||||
def test_wrong_value_operator(self):
|
||||
with self.assertRaises(TypeError,
|
||||
"Sampled value may only be a signal or a constant, not "
|
||||
"(+ (sig $signal) (const 1'd1))"):
|
||||
Sample(Signal() + 1, 1, "sync")
|
||||
|
||||
def test_wrong_clocks_neg(self):
|
||||
with self.assertRaises(ValueError,
|
||||
"Cannot sample a value 1 cycles in the future"):
|
||||
Sample(Signal(), -1, "sync")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue