Beispiel #1
0
    def test_clear(self):
        "Tests memory's clear method"
        clk = Bus(1, 0)
        rst = Bus(1, 0)
        d_bus = Bus(8, 0)
        q_bus = Bus(8, 0)
        reg = Register(8, clk, rst, d_bus, q_bus, 1)

        #write data
        reg.modify({'state': 0xFF})
        msg = reg.inspect()
        self.assertEqual(msg['state'], 0xFF)

        #clear data
        msg = reg.clear()
        self.assertTrue('success' in msg)

        #validate clear
        msg = reg.inspect()
        self.assertEqual(msg['state'], 1)
Beispiel #2
0
    def test_modify(self):
        "Verifies internal hook modify function"
        clk = Bus(1, 0)
        rst = Bus(1, 0)
        d_bus = Bus(8, 0)
        q_bus = Bus(8, 0)
        reg = Register(8, clk, rst, d_bus, q_bus, 1)

        tm = None
        rm = reg.modify(tm)
        self.assertTrue('error' in rm)

        tm = {}
        rm = reg.modify(tm)
        self.assertTrue('error' in rm)

        tm = {'state': '0'}
        rm = reg.modify(tm)
        self.assertTrue('error' in rm)

        tm = {'state': -1}
        rm = reg.modify(tm)
        self.assertTrue('error' in rm)

        tm = {'state': 256}
        rm = reg.modify(tm)
        self.assertTrue('error' in rm)

        tm = {'state': 128}
        rm = reg.modify(tm)
        self.assertTrue('success' in rm and rm['success'])
        reg.run()
        self.assertTrue(q_bus.read() == 128)