def create_project_file(config):
    """
    Creates a coregen project with settings for this device

    Args:
        config (dictionary): configuration dictionary

    Returns:
        (string): filename to the project file

    Raises:
        Nothing
    """
    core_dir = get_coregen_dir(config, absolute = True)
    cp_fn = os.path.join(core_dir, COREGEN_PROJECT_NAME)
    fp = open(cp_fn, "w")

    #Open up the template dictionary
    fn = COREGEN_TEMPLATE
    fn = os.path.join(os.path.dirname(__file__), fn)

    template = json.load(open(fn, "r"))

    template["device"] = utils.get_device(config)
    template["devicefamily"] = utils.get_family(config)
    template["package"] = utils.get_package(config)
    template["speedgrade"] = utils.get_speed_grade(config)
    template["workingdirectory"] = get_coregen_temp_dir(config, absolute = True)
    for t in template:
        fp.write("SET %s = %s%s" % (t, template[t], os.linesep))
    fp.close()

    return cp_fn
Exemple #2
0
def create_project_file(config):
    """
    Creates a coregen project with settings for this device

    Args:
        config (dictionary): configuration dictionary

    Returns:
        (string): filename to the project file

    Raises:
        Nothing
    """
    core_dir = get_coregen_dir(config, absolute=True)
    cp_fn = os.path.join(core_dir, COREGEN_PROJECT_NAME)
    fp = open(cp_fn, "w")

    #Open up the template dictionary
    fn = COREGEN_TEMPLATE
    fn = os.path.join(os.path.dirname(__file__), fn)

    template = json.load(open(fn, "r"))

    template["device"] = utils.get_device(config)
    template["devicefamily"] = utils.get_family(config)
    template["package"] = utils.get_package(config)
    template["speedgrade"] = utils.get_speed_grade(config)
    template["workingdirectory"] = get_coregen_temp_dir(config, absolute=True)
    for t in template:
        fp.write("SET %s = %s%s" % (t, template[t], os.linesep))
    fp.close()

    return cp_fn
 def test_get_speed_grade(self):
     config = utils.read_config(self.env)
     config["device"] = "xc6slx9-tqg144-3"
     speed = utils.get_speed_grade(config)
     self.assertEqual("-3", speed)
def customize_core(config, coregen_filename):
    """
    Reads in the xco from the the core directory and customize it for this
    Architecture

    Args:
        config (dictionary): configuration dictionary
        coregen_filename (string): filename of the coregen file to work on

    Returns:
        (string): filename to the custom core path

    Raises:
        Nothing
    """
    #Open the coregen file
    fp = open(coregen_filename)
    core_in = fp.read()
    fp.close()

    #open a reference to the output file
    c_fn = os.path.split(coregen_filename)[1]
    c_fn = os.path.join(get_coregen_dir(config, absolute = True), c_fn)

    #Open up the template dictionary
    fn = COREGEN_TEMPLATE
    fn = os.path.join(os.path.dirname(__file__), fn)

    template = json.load(open(fn, "r"))

    template["device"] = utils.get_device(config)
    template["devicefamily"] = utils.get_family(config)
    template["package"] = utils.get_package(config)
    template["speedgrade"] = utils.get_speed_grade(config)
    template["workingdirectory"] = get_coregen_temp_dir(config, absolute = True)

    #print "Open: %s" % c_fn
    fp = open(c_fn, "w")

    #Break this into lines
    core_in_lines = core_in.splitlines()
    for line in core_in_lines:
        line = line.strip()

        if re.search('BEGIN.*Project.*Options', line, re.I):
            #print "\tFound the beginning of the project"
            fp.write("%s%s" % (line, os.linesep))
            #Copy all the objects into the new file
            for key in template:
                fp.write("SET %s = %s%s" % (key, template[key], os.linesep))

            continue

        if "CRC" in line:
            #Don't write the CRC
            continue

        #if line.startswith("#"):

        #print "line: %s" % line
        items = line.split(' ')
        if "set" == items[0].lower():
            #print "Line: %s" % line
            #Now we have a line we might need to modify
            if items[1].lower() in template.keys():
                #Skip it, cause we already wrote what we wanted into the new xco
                continue

        fp.write("%s%s" % (line, os.linesep))

    fp.close()
Exemple #5
0
def customize_core(config, coregen_filename):
    """
    Reads in the xco from the the core directory and customize it for this
    Architecture

    Args:
        config (dictionary): configuration dictionary
        coregen_filename (string): filename of the coregen file to work on

    Returns:
        (string): filename to the custom core path

    Raises:
        Nothing
    """
    #Open the coregen file
    fp = open(coregen_filename)
    core_in = fp.read()
    fp.close()

    #open a reference to the output file
    c_fn = os.path.split(coregen_filename)[1]
    c_fn = os.path.join(get_coregen_dir(config, absolute=True), c_fn)

    #Open up the template dictionary
    fn = COREGEN_TEMPLATE
    fn = os.path.join(os.path.dirname(__file__), fn)

    template = json.load(open(fn, "r"))

    template["device"] = utils.get_device(config)
    template["devicefamily"] = utils.get_family(config)
    template["package"] = utils.get_package(config)
    template["speedgrade"] = utils.get_speed_grade(config)
    template["workingdirectory"] = get_coregen_temp_dir(config, absolute=True)

    #print "Open: %s" % c_fn
    fp = open(c_fn, "w")

    #Break this into lines
    core_in_lines = core_in.splitlines()
    for line in core_in_lines:
        line = line.strip()

        if re.search('BEGIN.*Project.*Options', line, re.I):
            #print "\tFound the beginning of the project"
            fp.write("%s%s" % (line, os.linesep))
            #Copy all the objects into the new file
            for key in template:
                fp.write("SET %s = %s%s" % (key, template[key], os.linesep))

            continue

        if "CRC" in line:
            #Don't write the CRC
            continue

        #if line.startswith("#"):

        #print "line: %s" % line
        items = line.split(' ')
        if "set" == items[0].lower():
            #print "Line: %s" % line
            #Now we have a line we might need to modify
            if items[1].lower() in template.keys():
                #Skip it, cause we already wrote what we wanted into the new xco
                continue

        fp.write("%s%s" % (line, os.linesep))

    fp.close()