Example #1
0
def gen_sites(tile_type):
    o = {}

    db = Database(util.get_db_root(), util.get_part())
    grid = db.grid()

    allowed_sites = read_allowed_sites()

    for tile_name in sorted(grid.tiles()):
        loc = grid.loc_of_tilename(tile_name)
        gridinfo = grid.gridinfo_at_loc(loc)

        if gridinfo.tile_type != tile_type:
            continue

        for site_name, site_type in gridinfo.sites.items():
            if site_type in ['HPIOB_S', 'HPIOB_M', 'HDIOB_S', 'HDIOB_M'
                             ] and site_name in allowed_sites:
                if tile_name not in o:
                    o[tile_name] = []

                o[tile_name].append(site_name)

    for tile_name in o:
        o[tile_name].sort(key=util.create_xy_fun('IOB_'))

    return o
Example #2
0
def gen_sites():
    db = Database(util.get_db_root(), util.get_part())
    grid = db.grid()

    xy_fun = util.create_xy_fun('BITSLICE_RX_TX_')

    o = {}
    for tile_name in sorted(grid.tiles()):
        loc = grid.loc_of_tilename(tile_name)
        gridinfo = grid.gridinfo_at_loc(loc)

        for site_name, site_type in gridinfo.sites.items():
            if site_type == 'BITSLICE_RX_TX':
                if tile_name not in o:
                    o[tile_name] = []

                o[tile_name].append(site_name)

        if tile_name in o:
            o[tile_name].sort(key=lambda site: xy_fun(site))

    return o
Example #3
0
#
# Copyright (C) 2020  The Project U-Ray Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC

import csv
import numpy as np
from utils import util
from utils.clock_utils import make_bufg, MAX_GLOBAL_CLOCKS
from prjuray.db import Database

CMT_XY_FUN = util.create_xy_fun('')


def print_top(seed):
    np.random.seed(seed)

    db = Database(util.get_db_root(), util.get_part())
    grid = db.grid()

    site_to_tile = {}
    site_to_site_type = {}
    for tile_name in sorted(grid.tiles()):
        loc = grid.loc_of_tilename(tile_name)
        gridinfo = grid.gridinfo_at_loc(loc)

        for site, site_type in gridinfo.sites.items():
Example #4
0
def read_io_pins(f):
    pin_to_banks = {}
    pin_to_sites = {}
    pin_to_site_offsets = {}

    tile_to_pins = {}
    tile_to_bank_types = {}
    pin_to_tile_types = {}

    bank_type_to_tiles = {}

    for row in csv.DictReader(f):
        bank = row['bank']
        pin = row['pin']
        site_name = row['site_name']
        site_type = row['site_type']
        tile = row['tile']
        tile_type = row['tile_type']

        assert pin not in pin_to_sites
        pin_to_sites[pin] = site_name

        assert pin not in pin_to_banks
        pin_to_banks[pin] = bank

        if tile not in tile_to_pins:
            tile_to_pins[tile] = []
        tile_to_pins[tile].append(pin)

        assert pin not in pin_to_tile_types
        pin_to_tile_types[pin] = tile_type

        bank_type = site_type.split('_')[0]
        if tile not in tile_to_bank_types:
            tile_to_bank_types[tile] = bank_type
        else:
            assert tile_to_bank_types[tile] == bank_type, tile

    bank_type_to_tiles = {}
    for tile, bank_type in tile_to_bank_types.items():
        if bank_type not in bank_type_to_tiles:
            bank_type_to_tiles[bank_type] = []
        bank_type_to_tiles[bank_type].append(tile)

    xy_fun = create_xy_fun('IOB_')

    for tile, tile_pins in tile_to_pins.items():
        assert len(tile_pins) > 0
        min_x, min_y = xy_fun(pin_to_sites[tile_pins[0]])

        for pin in tile_pins:
            x, y = xy_fun(pin_to_sites[pin])

            if x < min_x:
                min_x = x

            if y < min_y:
                min_y = y

        for pin in tile_pins:
            x, y = xy_fun(pin_to_sites[pin])
            pin_to_site_offsets[pin] = (x - min_x, y - min_y)

    return bank_type_to_tiles, tile_to_pins, pin_to_banks, pin_to_site_offsets, pin_to_tile_types
Example #5
0
def print_top(seed):
    np.random.seed(seed)

    db = Database(util.get_db_root(), util.get_part())
    grid = db.grid()
    slices = sorted(gen_sites(grid))
    np.random.shuffle(slices)

    print("""
module top();
        """)
    print("""
    (* BEL="A6LUT", LOC="{loc}", KEEP, DONT_TOUCH *) LUT5 lut ();
    """.format(loc=slices.pop()))
    print('endmodule')

    leafs = populate_leafs(grid)

    site_to_site_type = {}
    site_to_tile = {}
    for tile_name in sorted(grid.tiles()):
        loc = grid.loc_of_tilename(tile_name)
        gridinfo = grid.gridinfo_at_loc(loc)

        for site, site_type in gridinfo.sites.items():
            site_to_site_type[site] = site_type
            site_to_tile[site] = tile_name

    bufgs = GlobalClockBuffers('../bufg_outputs.csv')

    clock_column = sorted(leafs.keys())
    np.random.shuffle(clock_column)

    bufg_leaf = util.create_xy_fun(prefix='BUFCE_LEAF_')

    delays = [0, 1, 2, 4, 8]

    global_clocks = list(range(MAX_GLOBAL_CLOCKS))
    np.random.shuffle(global_clocks)

    with open('complete_top.tcl', 'w') as f:
        print('place_design -directive Quick', file=f)
        print('source $::env(URAY_UTILS_DIR)/utils.tcl', file=f)

        for idx, global_clock in enumerate(global_clocks):
            bufg_list = [
                bufg for bufg in bufgs.bufgs[global_clock]
                if bufg.startswith('BUFGCE_X')
            ]
            bufg_list.sort()
            np.random.shuffle(bufg_list)

            bufg = bufg_list.pop()

            loc, column_direction = clock_column.pop()
            print('# {} {}'.format(loc, column_direction), file=f)

            gridinfo = grid.gridinfo_at_loc(loc)

            coords = []

            for site in gridinfo.sites.keys():
                x, y = bufg_leaf(site)
                coords.append((x, y))

            coords.sort()
            y_min = coords[0][1]

            buf_leafs = []
            for site in gridinfo.sites.keys():
                _, y = bufg_leaf(site)

                if y - y_min < 2 and column_direction > 0:
                    buf_leafs.append(site)

                if y - y_min >= 2 and column_direction < 0:
                    buf_leafs.append(site)

            buf_leafs.sort()
            np.random.shuffle(buf_leafs)

            bufce_leaf = buf_leafs.pop()

            slices = list(leafs[loc, column_direction])
            slices.sort()
            np.random.shuffle(slices)

            slice_site = slices.pop()

            delay = np.random.choice(delays)

            print(
                "create_leaf_delay {idx} {delay} {bufgce_site} {bufce_leaf_site} {slice_site}"
                .format(
                    idx=idx,
                    delay=delay,
                    bufgce_site=bufg,
                    bufce_leaf_site=bufce_leaf,
                    slice_site=slice_site,
                ),
                file=f)

        print('route_design -directive Quick', file=f)

        print('set_property IS_ENABLED 0 [get_drc_checks {RTRES-2}]', file=f)