Esempio n. 1
0
def create_init_data():
    # Open a file in "w"rite mode
    filters = ts.Filters(complib='blosc', complevel=2)
    fileh = ts.openFile("place_and_route_data.h5", mode="w", filters=filters)

    # Get the HDF5 root group
    root = fileh.root
    net_files = fileh.createTable(root, 'net_files',
                                  NET_FILES_TABLE_LAYOUT)
    net_paths = path('/var/benchmarks/mcnc').files('*.net')

    placements = fileh.createGroup(root, 'placements', 'Placements')

    m = cMain()

    for i, p in enumerate(net_paths):
        parser = cVprNetFileParser(p)
        net_file = net_files.row
        net_file['id'] = i
        net_file['md5'] = p.read_hexhash('md5')
        net_file['block_count'] = len(parser.block_labels)
        net_file['net_count'] = len(parser.net_labels)

        group = fileh.createGroup(placements, p.namebase,
                                'Placements for %s' % p.namebase)
        placement_table = fileh.createTable(group, 'placements',
                                            PLACEMENT_TABLE_LAYOUT)
        placement_table.flush()
        positions_table = fileh.createTable(
                group, 'block_positions', BLOCK_POSITIONS_TABLE_LAYOUT)
        positions_table.flush()

        placement_id = len(placement_table)
        positions_id = len(positions_table)
        for j, d in enumerate(path('../place_results')
                            .files('placed-%s-*.out' % p.namebase)):
            positions = m.read_placement(
                    p, '/var/benchmarks/4lut_sanitized.arch', d)

            k = 0
            placement = placement_table.row
            placement['id'] = placement_id + j
            placement['net_file_id'] = net_file['id']
            placement['block_position_offset'] = positions_id
            placement['block_count'] = net_file['block_count']
            placement['md5'] = d.read_hexhash('md5')

            for k, b in enumerate(positions):
                row = positions_table.row
                row['id'] = positions_id + k
                row['placement_id'] = placement['id']
                row['position'] = b
                row.append()
            positions_id += len(positions)
            placement.append()
            positions_table.flush()
            placement_table.flush()
        net_file.append()
        net_files.flush()
    fileh.close()
def test_net_to_block_ids():
    r = cVprNetFileParser('/var/benchmarks/mcnc/tseng.net')

    block_to_net_ids = r.block_to_net_ids()

    for net_id, block_ids in enumerate(r.net_to_block_ids()):
        for b in block_ids:
            assert(net_id in block_to_net_ids[b])
def test_block_to_net_ids():
    r = cVprNetFileParser('/var/benchmarks/mcnc/tseng.net')

    # Verify that when we convert back from the integer-mapping of
    # block-indexes to the corresponding net-indexes, we get the original
    # block-label to net-label mapping.
    eq_(sorted(r.block_label_to_net_labels.items()),
        sorted([(r.block_labels[i], [r.net_labels[n]
                                     for n in net_ids])
                for i, net_ids in enumerate(r.block_to_net_ids())]))
Esempio n. 4
0
def vpr_placed_lines(vpr_net_path, block_positions, extents=None):
    parser = cVprNetFileParser(vpr_net_path)
    header = """\
Netlist file: %(vpr_net_path)s   Architecture file: /var/benchmarks/4lut_sanitized.arch
Array size: %(extent_x)d x %(extent_y)d logic blocks

#block name	x	y	subblk	block number
#----------	--	--	------	------------"""
    clb_positions = block_positions[parser.block_ids_by_type()[".clb"]]
    if extents is None:
        extents = tuple(clb_positions[:, :2].max(axis=0) - clb_positions[:, :2].min(axis=0))
    else:
        extents = tuple(extents)
    yield header % {"vpr_net_path": vpr_net_path, "extent_x": extents[0], "extent_y": extents[1]}
    for i, (label, slot_position) in enumerate(zip(parser.block_labels, block_positions)):
        yield "%s\t%d\t%d\t%d\t#%d" % (label, slot_position[0], slot_position[1], slot_position[2], i)