Exemplo n.º 1
0
def write_newnets(fname, nets, components):
    with open(fname, 'w') as f:
        f.write('UCLA nets 1.0\n')
        f.write('\n')
        f.write('\n')
        f.write('\n')
        f.write('NumNets\t :\t ' + str(len(nets)))
        f.write('\n')
        f.write('NumPins\t :\t ' +
                str(len(set([pin[0] for net in nets for pin in net]))))

        f.write('\n')

        for net in nets:
            f.write('NetDegree : ' + str(len(net)) + '\n')
            for pin in net:
                pinname, pinloc = pin
                if isinstance(pinloc, list):  # component pin
                    centroid = components[pinname].centroid
                    pinx, piny = utils.pin_pos(pin, components)
                    f.write(pinname + ' B : ' +
                            str(round(pinx - centroid.x, 2) / 100) + ' ' +
                            str(round(piny - centroid.y, 2) / 100) + '\n')
                else:  # terminal pin
                    f.write(pinname + ' B \n')
Exemplo n.º 2
0
def manhattan(components, board_pins, nets):
    """
	Compute sum manhattan distance over all nets
	"""
    mwl = 0
    for net in nets:
        hist = set()
        for i, pin1 in enumerate(net):
            if pin1[0] not in board_pins or 'cc' in pin1[0] or 'clk' in pin1[0]:
                pin1x, pin1y = utils.pin_pos(pin1, components)
            else:
                pin1x = pin1[1].x
                pin1y = pin1[1].y
            for j, pin2 in enumerate(net, i + 1):  # for each pin in connection
                if pin2[0] not in board_pins or 'cc' in pin2[
                        0] or 'clk' in pin2[0]:
                    pin2x, pin2y = utils.pin_pos(pin2, components)
                else:
                    pin2x = pin2[1].x
                    pin2y = pin2[1].y
                mwl += np.abs(pin1x -
                              pin2x) + np.abs(pin1y - pin2y) / (len(net) - 1)
    return int(mwl)
Exemplo n.º 3
0
def euclidean(components, board_pins, nets):
    """
	Compute sum euclidean distance over all nets
	"""
    euwl = 0
    for net in nets:
        for i, pin1 in enumerate(net):
            if pin1[0] not in board_pins or 'cc' in pin1[0] or 'clk' in pin1[0]:
                pin1x, pin1y = utils.pin_pos(pin1, components)
            else:
                pin1x = pin1[1].x
                pin1y = pin1[1].y
            for j, pin2 in enumerate(net, i + 1):  # for each pin in connection
                if pin2[0] not in board_pins or 'cc' in pin2[
                        0] or 'clk' in pin2[0]:
                    pin2x, pin2y = utils.pin_pos(pin2, components)
                else:
                    pin2x = pin2[1].x
                    pin2y = pin2[1].y
                euwl += np.sqrt(
                    np.square(pin1x - pin2x) +
                    np.square(pin1y - pin2y)) / (len(net) - 1)
    return int(euwl)