예제 #1
0
def run():
    sites_params = []
    sites = list(gen_sites())[0:20]
    CLBN = len(sites)
    DIN_N = CLBN * 4
    DOUT_N = CLBN * 1
    ffprim = 'FDRE'
    ff_bels = (
        'AFF',
        'EFF',
    )
    for (tile_name, site_name) in sites:
        params = {}
        params['name'] = 'clb_{}'.format(ffprim)
        params['site'] = site_name
        params['bel'] = random.choice(ff_bels)
        params['rs_inv'] = random.randint(0, 1)
        sites_params.append(params)
    print(
        util.render_template(
            os.path.join(os.getenv("FUZDIR"), "top.tpl"), {
                "parameters": sites_params,
                "din_index": DIN_N - 1,
                "dout_index": DOUT_N - 1
            }))
    write_params(sites_params)
예제 #2
0
파일: top.py 프로젝트: mfkiwl/prjuray
def run():
    params = {}
    sites = list(gen_sites())
    assert len(sites) == 1
    itr = iter(util.gen_fuzz_states(len(sites)))
    for (tile_name, site_name) in sites:
        isone = next(itr)
        params[tile_name] = (site_name, isone)
        print(
            util.render_template(os.path.join(os.getenv("FUZDIR"), "top.tpl"),
                                 {"isone": isone}))

    write_params(params)
예제 #3
0
파일: top.py 프로젝트: mfkiwl/prjuray
def run():
    sites_params = []
    sites = list(gen_sites())[0:30]
    # One specimen can solve bits for 2 BEL types
    # Therefore the generated netlist contains
    # A-B LUTs/FFs or C-D, E-F or G-H LUTs/FFs
    seedn = int(os.getenv("SEEDN")) % 4
    bels = ['E', 'F', 'G', 'H', 'A', 'B', 'C', 'D']
    for (tile_name, site_name) in sites:
        bel = bels[seedn * 2 + random.randrange(2)]
        params = {}
        params['tile_name'] = tile_name
        params['site_name'] = site_name
        params['bel_lut6'] = bel + "6LUT"
        params['bel_ff'] = bel + "FF"
        sites_params.append(params)
    print(
        util.render_template(
            os.path.join(os.getenv("FUZDIR"), "top.tpl"),
            {"parameters": sites_params}))
    write_params(params)
예제 #4
0
파일: top.py 프로젝트: mfkiwl/prjuray
def run():
    # Requested number of SLICEs within the specimen
    num_slices = 200

    # Number of inputs. Assigned to SLICEs randomly
    num_inputs = 64
    # Number of outputs. Unconnected...
    num_outputs = 8

    def slice_filter(slice):
        """
        Filters only a range from all available SLICEs
        """
        site_name = slice

        match = re.match(r"SLICE_X([0-9]+)Y([0-9]+)", site_name)
        assert match is not None

        x, y = int(match.group(1)), int(match.group(2))

        # FIXME: Allow only bottom half of the X0Y0 clock region.
        # For that regions SLICE rows 30 and 31 seems to be addressed
        # differently
        if x < 0 or x > 28:
            return False
        if y < 0 or y > 30:
            return False

        return True

    all_slices = list(filter(slice_filter, gen_sites()))

    slices = random.sample(all_slices, min(num_slices, len(all_slices)))

    f = open("top.txt", "w")
    f.write("i,prim,loc,bel,init\n")

    instances = []
    for i, site in enumerate(slices):
        instance = dict()

        instance['type'] = random.choice(ffprims)
        instance['loc'] = site

        # Latch can't go in 2s
        if isff(instance['type']):
            instance['bel'] = random.choice(ff_bels)
        else:
            instance['bel'] = random.choice(ff_bels_ffl)

        instance['init'] = random.choice((0, 1))
        instance['number'] = i
        instance['din'] = 4 * i
        instance['dout'] = i

        instances.append(instance)

        f.write("%d,%s,%s,%s,%d\n" %
                (instance['number'], instance['type'], instance['loc'],
                 instance['bel'], instance['init']))

    parameters = '''parameter LOC = "SLICE_X16Y106";
        parameter BEL = "AFF";
        parameter INIT = 1'b0;
    '''

    loc = '(* LOC=LOC, BEL=BEL, KEEP, DONT_TOUCH, INIT=INIT *)'

    ios = 'input clk, input [3:0] din, output dout'

    fuzdir = os.getenv('FUZDIR', None)

    templated = util.render_template(
        '{}/top.tpl'.format(fuzdir), {
            "parameters": parameters,
            "loc": loc,
            "ios": ios,
            "dout": num_slices,
            "instances": instances
        })

    print(templated)
예제 #5
0
def run():

    # Requested number of SLICEs within the specimen
    num_slices = 600

    # Number of inputs. Assigned to SLICEs randomly
    num_inputs = 64
    # Number of outputs. Unconnected...
    num_outputs = 8

    def slice_filter(site):
        """
        Filters only a range from all available SLICEs
        """
        # FIXME: Allow only bottom half of the X0Y0 clock region.
        # For that regions SLICE rows 30 and 31 seems to be addressed
        # differently
        if site.loc[1] < 0 or site.loc[1] > 29:
            return False

        return True

    all_sites = filter(slice_filter, gen_sites())

    free_sites = {s.loc: s for s in all_sites}
    used_sites = {}

    # Template parameters
    tpl_params = {"ni": num_inputs, "no": num_outputs, "mods": []}

    # Generate
    params = []
    for i in range(num_slices):

        # No more free sites
        if not len(free_sites):
            break

        # Choices
        is_split = random.random() > 0.20
        if is_split:
            precyinit_top = random.choice(("C0", "C1", "EX"))
        else:
            precyinit_top = "CO3"

        precyinit_bot = random.choice(("C0", "C1", "AX", "CIN"))

        # Pick a random site
        site = random.choice(list(free_sites.values()))

        del free_sites[site.loc]
        used_sites[site.loc] = site

        # Choose a co-located site when "CIN" is used.
        if precyinit_bot == "CIN":

            # When bottom precyinit is set to CIN then the site next to the
            # chosen one has to be free
            loc = (site.loc[0], site.loc[1] - 1)
            if loc in used_sites or loc not in free_sites:
                precyinit_bot = "AX"
                co_site = None

                inps = random.sample(range(num_inputs), 16)

            else:
                co_site = free_sites[loc]

                del free_sites[co_site.loc]
                used_sites[co_site.loc] = co_site

                inps = random.sample(range(num_inputs), 32)

        # A single CARRY8, no CIN
        else:
            co_site = None

            inps = random.sample(range(num_inputs), 16)

        # Add a module instance
        mod_params = {
            "type": "PRECYINIT" if precyinit_bot != "CIN" else "PRECYINIT_CIN",
            "name": "precyinit_{:03d}".format(i),
            "loc_ci": site.name,
            "loc_co": co_site.name if co_site else "",
            "carry_type": "DUAL_CY4" if is_split else "SINGLE_CY8",
            "inp": "{" + ",".join(["di[{}]".format(x) for x in inps]) + "}",
            "out": "",
            "precyinit_bot": precyinit_bot,
            "precyinit_top": precyinit_top,
        }

        tpl_params["mods"].append(mod_params)

        params.append("{},{},{},{},{}".format(
            site.tile_name,
            site.name,
            precyinit_bot,
            precyinit_top,
            int(is_split),
        ))

    # Render the template
    print(
        util.render_template(
            os.path.join(os.getenv("FUZDIR"), "top.tpl"),
            {"params": tpl_params}))

    # Save parameters
    with open("params.csv", "w") as fp:
        fp.write("tile,site,precyinit_bot,precyinit_top,is_split\n")
        for l in params:
            fp.write(l + "\n")