Ejemplo n.º 1
0
def plot_pl(plfile,
            nodesfile,
            netsfile,
            figname,
            shapesfile=None,
            board_dim=None):
    board_pins = {}
    components = load_bookshelf.read_nodes(nodesfile)
    if shapesfile:
        components = load_bookshelf.read_shapes(shapesfile, components)
    components, comp2rot, board_pins, _ = load_bookshelf.read_pl2(
        plfile, components)
    nets, mod2net = load_bookshelf.read_nets2(netsfile, components, board_pins)
    if board_dim is None:
        if board_pins is not None and len(board_pins) > 0:
            xs = [pin[1].x for pin in board_pins.items()]
            ys = [pin[1].y for pin in board_pins.items()]
            board_dim = [xs, ys]
            pass
        else:
            board_dim = [[-25, 120], [-25, 120]]
    else:
        board_dim = board_dim  #[[boarddimmin,boarddimmax],[boarddimmin, boarddimmax]]
    plot_circuit(
        plfile.split('.')[0], components, comp2rot, nets, board_dim, figname)
Ejemplo n.º 2
0
def animate(i):
    data = routabilities[i]
    ax = sns.heatmap(data, vmax=.8, square=True, cbar=False, ax=ax1)
    ax.invert_yaxis()

    report_dict = {
        'wirelength': wl,
        'overlap': oa,
        'cost': cost,
        'acceptance ratio': ar
    }
    ax2.plot(wl[:i], label='wirelength')
    ax2.plot(oa[:i], label='overlap')
    ax2.plot(cost[:i], label='cost')
    ax3.plot(ar[:i], label='acceptance ratio')

    components = load_bookshelf.read_nodes(nodesfile)
    components, comp2rot, board_pins, _ = load_bookshelf.read_pl2(
        './cache/' + placements[i], components)
    nets, mod2net = load_bookshelf.read_nets2(netsfile, components, board_pins)
    plot.plot_circuit(ff.split('.')[0],
                      components,
                      comp2rot,
                      nets,
                      board_dim,
                      './cache/img/' + ff.split('.')[0] + '.png',
                      ax=ax4)
Ejemplo n.º 3
0
def make_placement_anim():
    f = []
    board_pins = {}
    for (dirpath, dirnames, filenames) in walk('./cache/'):
        f.extend(filenames)
    f = sorted(f, key=lambda x: float(x.split('.')[0]))

    for i,ff in enumerate(tqdm(f)):
        if i > 10000:
            break
        if i % 20 == 0:
            components = load_bookshelf.read_nodes(nodesfile)
            components,comp2rot,board_pins,_ = load_bookshelf.read_pl2('./cache/'+ff,components)
            nets,mod2net = load_bookshelf.read_nets2(netsfile,components,board_pins)
            board_dim = [[-5,100],[-5,55]]
            plot_circuit(ff.split('.')[0], components,comp2rot,nets,board_dim,'./cache/img/'+ff.split('.')[0]+'.png')

    f = []
    for (dirpath, dirnames, filenames) in walk('./cache/img/'):
        f.extend(filenames)
    f = sorted(f, key=lambda x: float(x.split('.')[0]))

    with imageio.get_writer(figname, mode='I') as writer:
        for ff in tqdm(f):
            try:
                if ff == "" or ff == "anim":
                    continue
                ff = './cache/img/' + ff
                image = imageio.imread(ff)
                writer.append_data(image)
            except:
                tqdm.write("exception: " + ff)
                continue
Ejemplo n.º 4
0
def new2old(dir,cname,outdir):
	pl_fname = dir + cname + '.pl'
	nets_fname = dir + cname + '.nets'
	nodes_fname = dir + cname + '.nodes'

	components = load_bookshelf.read_nodes(nodesfile)
	components,comp2rot,_,board_pins = load_bookshelf.read_pl2(plfile,components)
	nets,mod2net = load_bookshelf.read_nets2(netsfile,components,board_pins)

	load_bookshelf.write_pl(outdir+circuit_name+'.pl',placed_components,board_pins)
	load_bookshelf.write_blocks(outdir+circuit_name+'.nodes',components,board_pins)
	load_bookshelf.write_nets(outdir+circuit_name+'.nets',nets,components)
Ejemplo n.º 5
0
from os import walk
from tqdm import tqdm

f = []
for (dirpath, dirnames, filenames) in walk('./cache/'):
    f.extend(filenames)
f = sorted(f, key=lambda x: float(x.split('.')[0]))

#_,comp2rot,_,board_pins = load_bookshelf.read_pl2(plfile,components)
for i,ff in enumerate(tqdm(f)):
	if i > 10000:
		break
	if i % 20 == 0:
		components = load_bookshelf.read_nodes(nodesfile)
		components,comp2rot,board_pins,_ = load_bookshelf.read_pl2('./cache/'+ff,components)
		nets,mod2net = load_bookshelf.read_nets2(netsfile,components,board_pins)
		#board_dim = [[-10,100],[-5,55]]
		board_dim = [[-5,60],[-5,50]]
		plot_circuit(ff.split('.')[0], components,comp2rot,nets,board_dim,'./cache/img/'+ff.split('.')[0]+'.png')

f = []
for (dirpath, dirnames, filenames) in walk('./cache/img/'):
    f.extend(filenames)
f = sorted(f, key=lambda x: float(x.split('.')[0]))

import imageio
with imageio.get_writer(figname, mode='I') as writer:
	for ff in tqdm(f):
		try:
			if ff == "" or ff == "anim":
Ejemplo n.º 6
0
for i, ff in enumerate(congestion_maps):
    x = np.loadtxt(cachedir + ff)
    plt.title('congestion map')
    plt.imsave(cachedir + 'cmap.png', np.log(x))
plt.clf()
plt.cla()
plt.close()
for i, ff in enumerate(tqdm(f)):
    if not make_gif:
        continue
    components = load_bookshelf.read_nodes(nodesfile)
    for c in components:
        shape = components[c]
    if '.pl' in ff:
        components, comp2rot, board_pins, _, comp2layer = load_bookshelf.read_pl2(
            cachedir + ff, components)
        radii = load_bookshelf.read_rad(cachedir + ff.split('.')[0] + '.rad')
    if '.rad' in ff:
        continue
    elif '.txt' in ff:
        continue
    elif '.png' in ff:
        continue
    elif '.gif' in ff:
        continue
    elif '.nodes' in ff:
        continue
    elif '_history' in ff:
        with open(ff) as f:
            d = f.read().splitlines()
        d = [float(x) for x in d]
Ejemplo n.º 7
0
                    pin2y = pin2[1].y
                mwl += np.abs(pin1x -
                              pin2x) + np.abs(pin1y - pin2y) / (len(net) - 1)
    return int(mwl)


#nodesfile = sys.argv[1]
#plfile = sys.argv[2]
#netsfile = sys.argv[3]

#circuitname = './benchmarks/pcb_benchmark_devel-master/bm1'
#plfile = circuitname + '.pl'
circuitname = 'apte'
plfile = 'cache/400.pl'
nodesfile = circuitname + '.nodes'
netsfile = circuitname + '.nets'
board_pins = {}

components = load_bookshelf.read_nodes(nodesfile)
components, comp2rot, _, board_pins = load_bookshelf.read_pl2(
    plfile, components)
nets, mod2net = load_bookshelf.read_nets2(netsfile, components, board_pins)
print(nets)
#eu_wl = euclidean(components, board_pins, nets)
hpwl = hpwl(components, board_pins, nets)
#mh_wl = manhattan(components, board_pins, nets)

#print('euclidean: ' + str(eu_wl))
print('hpwl: ' + str(hpwl))
#print('manhattan: ' + str(mh_wl))