def test_netlist_several_lib(self): netlist = Netlist() lib1 = netlist.create_library() lib2 = netlist.create_library() lib3 = netlist.create_library() lib4 = netlist.create_library() def1a = lib1.create_definition() def2a = lib2.create_definition() def3a = lib3.create_definition() def4a = lib4.create_definition() def1b = lib1.create_definition() def2b = lib2.create_definition() def3b = lib3.create_definition() def4b = lib4.create_definition() ins1a = def1a.create_child() ins2a = def2a.create_child() ins3a = def3a.create_child() ins4a = def4a.create_child() ins1b = def1b.create_child() ins2b = def2b.create_child() ins3b = def3b.create_child() def4b.create_child() ins1a.reference = def2a ins2a.reference = def3a ins3a.reference = def4a ins4a.reference = def1b ins1b.reference = def2b ins2b.reference = def3b ins3b.reference = def4b netlist2 = clone(netlist) self._compare_netlists(netlist, netlist2) self.check_overlap_references(netlist, netlist2)
def test_netlist(self): nl1, nl2 = self._get_two_netlists() nl3 = clone(nl1) self._compare_netlists(nl1, nl3) self._compare_netlists(nl1, nl2) #now check that no references overlap. self.check_overlap_references(nl1, nl3)
def test_library_instance_references(self): lib1 = Library() lib2 = Library() def1 = lib1.create_definition() def2 = lib1.create_definition() def3 = lib2.create_definition() ins2 = def1.create_child() ins3 = def1.create_child() ins2.reference = def2 ins3.reference = def3 lib3 = clone(lib1) assert lib3.netlist == None assert len(lib3.definitions) == len(lib1.definitions) for d in lib3.definitions: assert d not in lib1.definitions def1c = lib3.definitions[0] def2c = lib3.definitions[1] ins2c = def1c.children[0] ins3c = def1c.children[1] assert ins2c in def2c.references assert ins2c not in def2.references assert ins3c in def3.references assert ins2c.reference is def2c assert ins3c.reference is def3 assert ins2 in def2.references assert ins2 not in def2c.references assert len(def3.references) == 2
def test_netlist_top_instance_instanced_elsewhere(self): nl1 = self._create_netlist() in1 = nl1.libraries[0].definitions[0].create_child() in1.reference = nl1.libraries[0].create_definition() nl1.top_instance = in1 nl2 = clone(nl1) self._compare_netlists(nl1, nl2) self.check_overlap_references(nl1, nl2)
def test_outerpin(self): op = OuterPin() wire = Wire() inner = InnerPin() op._wire = wire op._inner_pin = inner op2 = clone(op) assert op2.wire == None assert op2.instance == None assert op2.inner_pin == None
def test_netlist_change_top_instance(self): nl1 = Netlist() lib1 = nl1.create_library() def1 = lib1.create_definition() nl1.top_instance = Instance() nl1.top_instance.reference = def1 nl1.top_instance = None nl2 = clone(nl1) self._compare_netlists(nl1, nl2) self.check_overlap_references(nl1, nl2)
def test_library_definition_references(self): lib1 = Library() lib2 = Library() def1 = lib1.create_definition() def2 = lib2.create_definition() ins1 = def2.create_child() ins1.reference = def1 lib3 = clone(lib1) def1c = lib3.definitions[0] assert len(def1c.references) == 0 assert ins1.reference is def1
def test_instance(self): def1 = Definition() def2 = Definition() por2 = def2.create_port() por2.create_pins(5) child = def1.create_child() child.reference = def2 inst2 = clone(child) assert inst2.parent == None assert inst2.reference is def2 assert set(inst2.pins.keys()).difference(set( child.pins.keys())) == set() for v in inst2.pins.values(): assert v not in child.pins.values()
def create_and_clone_cable(self, wirecount, array, downto, index, key, value): definition = Definition() p1 = definition.create_cable() p1[key] = value p1.create_wires(wirecount) p1.is_array = array p1.is_downto = downto p1.lower_index = index p2 = clone(p1) assert p2.lower_index == index assert p2.is_downto == downto assert p2.is_array == array assert len(p2.wires) == wirecount assert p2[key] == value assert p2.definition == None for pin in p2.wires: assert pin.cable is p2 assert len(pin.pins) == 0
def create_and_clone_port(self, pincount, direction, array, downto, index, key, value): definition = Definition() p1 = definition.create_port() p1[key] = value p1.create_pins(pincount) p1.direction = direction p1.is_array = array p1.is_downto = downto p1.lower_index = index p2 = clone(p1) assert p2.lower_index == index assert p2.is_downto == downto assert p2.is_array == array assert p2.direction == direction assert len(p2.pins) == pincount assert p2[key] == value assert p2.definition == None for pin in p2.pins: assert pin.port is p2 assert pin.wire == None
def test_definition(self): lib = Library() def1 = lib.create_definition() def2 = lib.create_definition() ins1 = def2.create_child() ins2 = def2.create_child() ins1.reference = def1 ins2.reference = def1 def2.create_port() def2.create_cable() def3 = clone(def2) assert def3.library == None assert len(def3.children) == len(def2.children) assert len(def3.cables) == len(def2.cables) assert len(def3.ports) == len(def2.ports) for p in def3.ports: assert p not in def2.ports for c in def3.cables: assert c not in def2.cables for c in def3.children: assert c not in def2.children assert c in def1.references assert len(def1.references) == 4
def test_wire(self): cable = Cable() wire = cable.create_wire() wire2 = clone(wire) assert len(wire2.pins) == 0 assert wire2.cable == None
def test_netlist_empty_top_instance(self): nl1 = self._create_netlist() nl1.top_instance = None nl2 = clone(nl1) self._compare_netlists(nl1, nl2) self.check_overlap_references(nl1, nl2)