コード例 #1
0
    def test_If_nested(self):
        _, (a, b, c) = self.sigs_by_n(3)
        stm = \
        If(a,
            If(c,
               b(c & a)
            ).Else(
               b(c | a)
            )
        ).Else(
           b(0)
        )

        stm._replace_input(a, c)
        stm_ref = \
        If(c,
            If(c,
                b(c)
            ).Else(
                b(c)
            )
        ).Else(
            b(0)
        )
        self.assertTrue(stm.isSame(stm_ref), [stm, stm_ref])
        self.assertNotIn(stm, a.endpoints)
        self.assertIn(stm, c.endpoints)
コード例 #2
0
    def test_If_simple_replace_input(self):
        _, (a, b, c) = self.sigs_by_n(3)
        stm = \
        If(a,
           b(1)
        ).Else(
           b(0)
        )

        stm._replace_input(a, c)
        stm_ref = If(c, b(1)).Else(b(0))
        self.assertTrue(stm.isSame(stm_ref), [stm, stm_ref])
        self.assertEqual(a.endpoints, [])
        self.assertEqual(c.endpoints, [stm, stm_ref])
コード例 #3
0
    def test_If_elif_replace_input(self):
        _, (a, b, c, d) = self.sigs_by_n(4)
        stm = \
        If(a,
           b(1)
        ).Elif(c & a,
           b(0)
        ).Else(
           c(0)
        )

        stm._replace_input(a, d)

        stm_ref = If(d, b(1)).Elif(c & d, b(0)).Else(c(0))
        self.assertTrue(stm.isSame(stm_ref), [stm, stm_ref])
        self.assertEqual(a.endpoints, [a._isOn().singleDriver()])
        self.assertEqual(c.endpoints, [(c & a).singleDriver(),
                                       (c & d).singleDriver()])