Exemplo n.º 1
0
    def test_constructor(self):
        "Constructor with valid and invalid configuration"
        with self.assertRaises(TypeError):
            l = Clock('8')
        with self.assertRaises(ValueError):
            l = Clock(-1)
        with self.assertRaises(ValueError):
            l = Clock(limits.MIN_FREQUENCY - 1)
        with self.assertRaises(ValueError):
            l = Clock(limits.MAX_FREQUENCY + 1)

        valid_f = (limits.MAX_FREQUENCY - limits.MIN_FREQUENCY) / 2
        with self.assertRaises(TypeError):
            l = Clock(valid_f, '8')
        with self.assertRaises(TypeError):
            l = Clock(valid_f, -1)
        with self.assertRaises(TypeError):
            l = Clock(valid_f, 2)

        l = Clock(limits.MIN_FREQUENCY, 1)
        self.assertTrue(l.size() == 1 and l.read() == 1
                        and l.frequency() == limits.MIN_FREQUENCY)
        l = Clock(limits.MAX_FREQUENCY)
        self.assertTrue(l.size() == 1 and l.read() == 0
                        and l.frequency() == limits.MAX_FREQUENCY)
Exemplo n.º 2
0
 def test_size(self):
     "Valid bus size presented"
     l = Clock(50)
     self.assertTrue(l.size() == 1)