示例#1
0
def create_xst_script(config):
    """
    given the configuration file create a script that will
    build the verilog files declared within the configuration file

    Args:
        config (dictionary): configuraiton dictionary

    Return:
        (string) script file name

    Raises:
        Nothing
    """
    xst_abs_dir = create_xst_dir(config)
    flags = get_xst_flags(config)
    #print "Flags: %s" % str(flags)

    xst_dir = os.path.join(config["build_dir"], XST_DIR)
    temp_dir = create_temp_dir(config)
    project_dir = os.path.join(xst_dir, PROJECT_FILENAME)

    top_module = config["top_module"]

    output_file = os.path.join(xst_dir, top_module)

    xst_script_fn = os.path.join(xst_abs_dir, XST_SCRIPT_FILENAME)

    fp = open(xst_script_fn, "w")
    fp.write("set -tmpdir \"%s\"%s" % (temp_dir, os.linesep))
    fp.write("set -xsthdpdir \"%s\"%s" % (xst_dir, os.linesep))
    #fp.write("set -xsthdpini \"%s\"%s" % (xst_dir, os.linesep))
    fp.write("run%s" % os.linesep)
    fp.write("-ifn %s%s" % (project_dir, os.linesep))
    fp.write("-ofn %s%s" % (output_file, os.linesep))
    fp.write("-ofmt NGC%s" % (os.linesep))
    fp.write("-p %s%s" % (config["device"], os.linesep))
    fp.write("-top %s%s" % (top_module, os.linesep))
    coregen_files = coregen_utils.get_target_files(config)
    if len(coregen_files) > 0:
        fp.write("-sd %s%s" % (coregen_utils.get_coregen_dir(config, absolute = True), os.linesep))


    #print "flags[lso] = %s" % str(flags["-lso"]["value"])
    if ("-lso" not in flags.keys()) or (len(flags["-lso"]["value"]) == 0):
        #print "creating custom lso file"
        flags["-lso"]["value"] = create_lso_file(config)

    for flag in flags:
        if len(flags[flag]["value"]) == 0:
            continue
        #print "flag: %s: %s" % (flag, flags[flag]["value"])
        fp.write("%s %s%s" % (flag, flags[flag]["value"], os.linesep))

    fp.close()
    return xst_script_fn
示例#2
0
def get_ngd_flags(config):
    """
    Given a configuration dictionary return flags for the NGD build
    if user flags are not specified take the default flags from

    site_scons/ngd_default_flags.json

    Args:
        config (dictionary): configuration dictionary

    Return:
        (dictionary): flag dictionary

    Raises:
        Nothing
    """
    #print "Apply slave tags"
    flags = {}
    user_flags = {}
    if "ngd" in config.keys():
        if "flags" in config["ngd"].keys():
            user_flags = config["ngd"]["flags"]

    fn = os.path.join(os.path.dirname(__file__), NGD_DEFAULT_FLAG_FILE)

    default_flags = json.load(open(fn, "r"))
    default_flags["-dd"]["value"] = get_ngd_dir(config)
    default_flags["-p"]["value"] = config["device"]
    default_flags["-uc"]["value"] = create_ucf_filename(config)
    coregen_files = coregen_utils.get_target_files(config)
    if len(coregen_files) > 0:
        default_flags["-sd"]["value"] = coregen_utils.get_coregen_dir(config, absolute = True)


    for key in default_flags:
        flags[key] = default_flags[key]
        if key in user_flags.keys():
            flags[key]["value"] = user_flags[key]
    return flags
def get_ngd_flags(config):
    """
    Given a configuration dictionary return flags for the NGD build
    if user flags are not specified take the default flags from

    site_scons/ngd_default_flags.json

    Args:
        config (dictionary): configuration dictionary

    Return:
        (dictionary): flag dictionary

    Raises:
        Nothing
    """
    # print "Apply slave tags"
    flags = {}
    user_flags = {}
    if "ngd" in config.keys():
        if "flags" in config["ngd"].keys():
            user_flags = config["ngd"]["flags"]

    fn = os.path.join(os.path.dirname(__file__), NGD_DEFAULT_FLAG_FILE)

    default_flags = json.load(open(fn, "r"))
    default_flags["-dd"]["value"] = get_ngd_dir(config)
    default_flags["-p"]["value"] = config["device"]
    default_flags["-uc"]["value"] = create_ucf_filename(config)
    coregen_files = coregen_utils.get_target_files(config)
    if len(coregen_files) > 0:
        default_flags["-sd"]["value"] = coregen_utils.get_coregen_dir(config, absolute=True)

    for key in default_flags:
        flags[key] = default_flags[key]
        if key in user_flags.keys():
            flags[key]["value"] = user_flags[key]
    return flags