def test_generate(self): "Check generate handler for valid and invalid message" l = Clock(50) m = None rm = l.generate(m) self.assertTrue('error' in rm) m = {} rm = l.generate(m) self.assertTrue('error' in rm) m = {'state': '0'} rm = l.generate(m) self.assertTrue('error' in rm) m = {'state': -1} rm = l.generate(m) self.assertTrue('error' in rm) m = {'state': 2} rm = l.generate(m) self.assertTrue('error' in rm) m = {'state': 1} rm = l.generate(m) self.assertTrue('success' in rm and rm['success']) self.assertTrue(l.read() == 1) m = {'frequency': limits.MAX_FREQUENCY + 1} rm = l.generate(m) self.assertTrue('error' in rm) m = {'frequency': limits.MIN_FREQUENCY - 1} rm = l.generate(m) self.assertTrue('error' in rm) m = {'frequency': '0'} rm = l.generate(m) self.assertTrue('error' in rm) m = {'frequency': '0', 'state': '0'} rm = l.generate(m) self.assertTrue('error' in rm) m = {'frequency': 10, 'state': '0'} rm = l.generate(m) self.assertTrue('error' in rm) self.assertFalse(l.frequency() == 10) self.assertTrue(l.read() == 1) m = {'frequency': '10', 'state': 0} rm = l.generate(m) self.assertTrue('error' in rm) self.assertFalse(l.frequency() == 10) self.assertTrue(l.read() == 1) m = {'frequency': 10, 'state': 0} rm = l.generate(m) self.assertTrue('success' in rm and rm['success']) self.assertTrue(l.frequency() == 10) self.assertTrue(l.read() == 0)
while True: print('-----------------------------------------------------------') print(clk.inspect()) print(rst.inspect()) print(d_bus.inspect()) print(reg.inspect()) print(q_bus.inspect()) print(f_bus.inspect()) print(r_bus.inspect()) print(c_bus.inspect()) print(v_bus.inspect()) print(n_bus.inspect()) print(z_bus.inspect()) print(ss0_bus.inspect()) print(ss1_bus.inspect()) print(ss2_bus.inspect()) print(ss3_bus.inspect()) print(bj0.inspect()) clk.generate() add.run() reg.run() regFile.run() m.run() alu.run() subset.run() join.run() time.sleep(0.01)