예제 #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 COREGEN(env, target, source):
    """
    A pseudo-builder wrapper for Xilinx coregen
    """
    config = utils.read_config(env)
    source = coregen_utils.get_new_coregen_file_list(config)
    env["COREGEN_SOURCES"] = source
    env["COREGEN_TARGETS"] = target
    for s in source:
        env["COREGEN_SCRIPT"] = s
        _coregen_builder.__call__(env, target, s)
    return coregen_utils.get_target_files(config)
예제 #3
0
def generate(env):
    env["COREGEN_COMMAND"] = _detect(env)
    config = utils.read_config(env)
    coregen_utils.create_coregen_dir(config)
    coregen_utils.create_coregen_temp_dir(config)
    coregen_utils.create_project_file(config)

    project_path = coregen_utils.get_project_file(config, absolute = True)

    coregen_outfiles = coregen_utils.get_target_files(config)
    #Need to get targets

    env.SetDefault(
            COREGEN_OUTFILES = coregen_outfiles,
            COREGEN_PROJECT = project_path,
            COREGEN_COM = "$COREGEN_COMMAND -b $COREGEN_SCRIPT -p $COREGEN_PROJECT -r"
            )
    env.AddMethod(COREGEN, "coregen")
    return None
예제 #4
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
예제 #5
0
def _xst_emitter(target, source, env):
    #Sources are okay but I need to tell SCons all the stuff this thing
    #makes
    config = utils.read_config(env)
    coregen_outfiles = coregen_utils.get_target_files(config)
    if not SCons.Util.is_List(source):
        source = [source]

    if len(coregen_outfiles) > 0:
        source.append(coregen_outfiles)
    #print "source: %s" % source

    #Targets:
    #   .lso file
    #   .prj file
    #   .ngr file
    #   .ngc file (This may already be there)
    #   .xrpt file
    #   .xst file
    #target.append(xst_utils.get_xst_dir(config))

    return target, source
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
예제 #7
0
def _xst_emitter(target, source, env):
    #Sources are okay but I need to tell SCons all the stuff this thing
    #makes
    config = utils.read_config(env)
    coregen_outfiles = coregen_utils.get_target_files(config)
    if not SCons.Util.is_List(source):
        source = [source]

    if len(coregen_outfiles) > 0:
        source.append(coregen_outfiles)
    #print "source: %s" % source

    #Targets:
    #   .lso file
    #   .prj file
    #   .ngr file
    #   .ngc file (This may already be there)
    #   .xrpt file
    #   .xst file
    #target.append(xst_utils.get_xst_dir(config))



    return target, source
예제 #8
0
def get_coregen_targets(env):
    config = utils.read_config(env)
    return coregen_utils.get_target_files(config)
예제 #9
0
def _coregen_emitter(target, source, env):
    config = utils.read_config(env)
    coregen_outfiles = coregen_utils.get_target_files(config)
    target = coregen_outfiles
    return target, source
 def test_get_target_files(self):
     config = self.config
     files = coregen_utils.get_target_files(config)
     print "files: %s" % str(files)