#!/usr/bin/env python

from lut_configurator import LUTConfigurator

if __name__ == "__main__":
    fname = "data/test_lut_file.json"
    cfg = LUTConfigurator(fname)

    print "full lut1: ", cfg.get_lut("TOP.payload.lut1")
    print "full lut2: ", cfg.get_lut("TOP.payload.lut2")

    print "lut1 data instance1:", cfg.get_lut_instance_data("TOP.payload.lut1", "instance1")
    print "lut2 data:", cfg.get_lut_data("TOP.payload.lut2")

    print "lut1 data (all instances):", cfg.get_lut_data("TOP.payload.lut1")

    print "8 randoms, 5 bit:", [hex(x) for x in LUTConfigurator.get_randoms(8, 5)]
    print "8 zeroes:", LUTConfigurator.get_zeroes(8)
    print "8 ones:", LUTConfigurator.get_ones(8)

    sine_data = LUTConfigurator.get_sin_lut(8, 32)
    print "sinus as data (addrwidth=8, datawidth=32):", [hex(x) for x in sine_data]



    print ""
    LUTConfigurator.get_2param_function_lut("a+b", 5, 6, 5)

    # from ROOT import TH1D, TCanvas
    # max_val = pow(2, 8)
    # h = TH1D("", "", max_val, 0, max_val)
        "-o",
        "--outdir",
        dest="outdir",
        help="location for output files (%default)",
        default=defaults["outdir"],
        type="string",
    )

    opts, args = parser.parse_args()

    if len(args) == 1:
        opts.json_name = args[0]
    else:
        parser.error("json filename")

    return opts, args


if __name__ == "__main__":
    opts, args = parse_options()

    with open(opts.json_name, "r") as json_file:
        lut_config = json.load(json_file)

        for name, config in lut_config.iteritems():
            if config["function"] != "":
                lut_data = LUTConfigurator.get_function_lut(
                    config["function"], config["inputs"], config["input_widths"], config["data_out_width"]
                )
                write_coe_file(name, opts.outdir, config["function"], lut_data)
    opts, args = parser.parse_args()

    if len(args) == 1:
        opts.json_name = args[0]
    else:
        parser.error('json filename')

    return opts,args

ETAMAP = {}
PHIMAP = []

if __name__ == "__main__":
    opts, args = parse_options()
    lut_cfger = LUTConfigurator()
    with open(opts.json_name, 'r') as json_file:
        lut_config = json.load(json_file)
        for name, config in lut_config.iteritems():
            owidth = config['data_out_width']
            print name
            if config["function"] != "":
                lut_data = LUTConfigurator.get_function_lut(config["function"], config["inputs"], config["input_widths"], config["data_out_width"])
                write_coe_file(name, opts.coe_out, config["function"], lut_data)
                write_dist_file(name, opts.dist_out, config["function"], lut_data, owidth)
                write_bin_file(name, opts.bin_out, config["function"], lut_data, owidth)
                write_emu_lut_file(name, opts.emu_out, config["function"], lut_data)
            elif config["map"]:
                if len(config["inputs"]) > 1: print "ERROR : Map only works with one input, currently"
                lut_data = lut_cfger.get_map_lut(config["map"], config["inputs"][0], config["input_widths"][0], config["data_out_width"])
                write_coe_file(name, opts.coe_out, config["function"], lut_data)
Beispiel #4
0
    opts, args = parser.parse_args()

    if len(args) == 1:
        opts.json_name = args[0]
    else:
        parser.error('json filename')

    return opts, args


ETAMAP = {}
PHIMAP = []

if __name__ == "__main__":
    opts, args = parse_options()
    lut_cfger = LUTConfigurator()
    with open(opts.json_name, 'r') as json_file:
        lut_config = json.load(json_file)
        for name, config in lut_config.iteritems():
            owidth = config['data_out_width']
            print name
            if config["function"] != "":
                lut_data = LUTConfigurator.get_function_lut(
                    config["function"], config["inputs"],
                    config["input_widths"], config["data_out_width"])
                write_coe_file(name, opts.coe_out, config["function"],
                               lut_data)
                write_dist_file(name, opts.dist_out, config["function"],
                                lut_data, owidth)
                write_bin_file(name, opts.bin_out, config["function"],
                               lut_data, owidth)