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)
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)
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
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)
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": continue