def test_with_block_nested(self): self.block_c = pyrtl.Block() pyrtl.set_working_block(self.block_a) self.assertIs(pyrtl.working_block(), self.block_a) with pyrtl.set_working_block(self.block_b): self.assertIs(pyrtl.working_block(), self.block_b) with pyrtl.set_working_block(self.block_c): self.assertIs(pyrtl.working_block(), self.block_c) self.assertIs(pyrtl.working_block(), self.block_b) self.assertIs(pyrtl.working_block(), self.block_a)
def test_clone_wire_different_name_different_block(self): a = pyrtl.WireVector(1, 'a') b = pyrtl.Block() with set_working_block(b): w = pyrtl.clone_wire(a, 'w') self.assertEqual(a.name, 'a') self.assertEqual(w.name, 'w') self.assertIs(pyrtl.working_block().wirevector_by_name['a'], a) self.assertEqual(pyrtl.working_block().wirevector_set, {a}) self.assertIs(b.wirevector_by_name['w'], w) self.assertEqual(b.wirevector_set, {w})
def test_net_odd_wires(self): wire = pyrtl.WireVector(2, 'wire') net = self.new_net(args=(wire, wire)) other_block = pyrtl.Block() wire._block = other_block self.invalid_net("net references different block", net) pyrtl.reset_working_block() wire = pyrtl.WireVector(2, 'wire') net = self.new_net(args=(wire,)) pyrtl.working_block().remove_wirevector(wire) self.invalid_net("net with unknown source", net)
def test_clone_wire_no_or_same_name_different_block(self): for clone_name in (None, 'a'): a = pyrtl.WireVector(1, 'a') b = pyrtl.Block() with pyrtl.set_working_block(b): w = pyrtl.clone_wire(a, name=clone_name) self.assertEqual(a.name, 'a') self.assertIs(pyrtl.working_block().wirevector_by_name['a'], a) self.assertEqual(pyrtl.working_block().wirevector_set, {a}) self.assertEqual(w.name, 'a') self.assertIs(b.wirevector_by_name['a'], w) self.assertEqual(b.wirevector_set, {w}) pyrtl.reset_working_block()
def setUp(self): pyrtl.reset_working_block() self.block_a = pyrtl.Block() self.block_b = pyrtl.Block()