Exemplo n.º 1
0
    def calc_nets(self, design, segments):
        """ Return a set of Nets from segments """

        coord2point = {}  # (x, y) -> NetPoint

        def get_point(coord):
            """ Return a new or existing NetPoint for an (x,y) point """
            coord = (int(coord[0]), int(coord[1]))
            if coord not in coord2point:
                coord2point[coord] = NetPoint('%da%d' % coord, coord[0],
                                              coord[1])
            return coord2point[coord]

        # use this to track connected pins not yet added to a net
        self.make_pin_points(design, get_point)

        # set of points connected to pins
        pin_points = set(coord2point.itervalues())

        # turn the (x, y) points into unique NetPoint objects
        segments = set((get_point(p1), get_point(p2)) for p1, p2 in segments)
        nets = []

        # Iterate over the segments, removing segments when added to a net
        while segments:
            seg = segments.pop()  # pick a point
            newnet = Net('')
            map(pin_points.discard, seg)  # mark points as used
            newnet.connect(seg)
            found = True

            while found:
                found = set()

                for seg in segments:  # iterate over segments
                    if newnet.connected(seg):  # segment touching the net
                        map(pin_points.discard, seg)  # mark points as used
                        newnet.connect(seg)  # add the segment
                        found.add(seg)

                for seg in found:
                    segments.remove(seg)

            nets.append(newnet)

        # add single-point nets for overlapping pins that are not
        # already in other nets
        for point in pin_points:
            if len(point.connected_components) > 1:
                net = Net('')
                net.add_point(point)
                nets.append(net)

        for net in nets:
            net.net_id = min(net.points)

        nets.sort(key=lambda net: net.net_id)

        return nets
Exemplo n.º 2
0
    def calc_nets(self, design, segments):
        """ Return a set of Nets from segments """

        coord2point = {} # (x, y) -> NetPoint

        def get_point(coord):
            """ Return a new or existing NetPoint for an (x,y) point """
            coord = (int(coord[0]), int(coord[1]))
            if coord not in coord2point:
                coord2point[coord] = NetPoint('%da%d' % coord, coord[0], coord[1])
            return coord2point[coord]

        # use this to track connected pins not yet added to a net
        self.make_pin_points(design, get_point)

        # set of points connected to pins
        pin_points = set(coord2point.itervalues())

        # turn the (x, y) points into unique NetPoint objects
        segments = set((get_point(p1), get_point(p2)) for p1, p2 in segments)
        nets = []

        # Iterate over the segments, removing segments when added to a net
        while segments:
            seg = segments.pop() # pick a point
            newnet = Net('')
            map(pin_points.discard, seg) # mark points as used
            newnet.connect(seg)
            found = True

            while found:
                found = set()

                for seg in segments: # iterate over segments
                    if newnet.connected(seg): # segment touching the net
                        map(pin_points.discard, seg) # mark points as used
                        newnet.connect(seg) # add the segment
                        found.add(seg)

                for seg in found:
                    segments.remove(seg)

            nets.append(newnet)

        # add single-point nets for overlapping pins that are not
        # already in other nets
        for point in pin_points:
            if len(point.connected_components) > 1:
                net = Net('')
                net.add_point(point)
                nets.append(net)

        for net in nets:
            net.net_id = min(net.points)

        nets.sort(key=lambda net : net.net_id)

        return nets
Exemplo n.º 3
0
    def calc_nets(self, segments):
        """ Return a set of Nets from segments """

        points = {}  # (x, y) -> NetPoint

        def get_point(point):
            """ Return a new or existing NetPoint for an (x,y) point """
            point = (make_length(point[0]), make_length(point[1]))
            if point not in points:
                points[point] = NetPoint('%da%d' % point, point[0], point[1])
            return points[point]

        # turn the (x, y) points into unique NetPoint objects
        segments = set((get_point(p1), get_point(p2)) for p1, p2 in segments)
        nets = []

        # Iterate over the segments, removing segments when added to a net
        while segments:
            seg = segments.pop()  # pick a point
            newnet = Net('')
            newnet.connect(seg)
            found = True

            while found:
                found = set()

                for seg in segments:  # iterate over segments
                    if newnet.connected(seg):  # segment touching the net
                        newnet.connect(seg)  # add the segment
                        found.add(seg)

                for seg in found:
                    segments.remove(seg)

            nets.append(newnet)

        for net in nets:
            net.net_id = min(net.points)

        nets.sort(key=lambda net: net.net_id)

        return nets
Exemplo n.º 4
0
    def calc_nets(self, segments):
        """ Return a set of Nets from segments """

        points = {} # (x, y) -> NetPoint

        def get_point(point):
            """ Return a new or existing NetPoint for an (x,y) point """
            point = (make_length(point[0]), make_length(point[1]))
            if point not in points:
                points[point] = NetPoint('%da%d' % point, point[0], point[1])
            return points[point]

        # turn the (x, y) points into unique NetPoint objects
        segments = set((get_point(p1), get_point(p2)) for p1, p2 in segments)
        nets = []

        # Iterate over the segments, removing segments when added to a net
        while segments:
            seg = segments.pop() # pick a point
            newnet = Net('')
            newnet.connect(seg)
            found = True

            while found:
                found = set()

                for seg in segments: # iterate over segments
                    if newnet.connected(seg): # segment touching the net
                        newnet.connect(seg) # add the segment
                        found.add(seg)

                for seg in found:
                    segments.remove(seg)

            nets.append(newnet)

        for net in nets:
            net.net_id = min(net.points)

        nets.sort(key=lambda net : net.net_id)

        return nets