コード例 #1
0
ファイル: testcase_builder.py プロジェクト: GaphGroup/hemps
def main():
    #HEMPS_PATH - must to point to the root directory of hemps
    HEMPS_PATH = os.getenv("HEMPS_PATH", 0)
    
    #Test if testcase file HEMPS_PATH is valid
    if HEMPS_PATH == 0:
        sys.exit("ENV PATH ERROR: HEMPS_PATH not defined")
    
    #Test if testcase file is passed as arg1 by testing the lenght of argv list
    if len(sys.argv) <= 1 :
        sys.exit("ARG ERROR: arg1 must be a valid testcase file with a extension .yaml (<my_testcase>.yaml) ")
    
    #testcase name without .yaml
    INPUT_TESTCASE_FILE_PATH = sys.argv[1]

    if os.path.exists(INPUT_TESTCASE_FILE_PATH) == False:
    	sys.exit("ARG ERROR: arg1 must be a valid testcase file with a extension .yaml (<my_testcase>.yaml) ")
    
    #Gets the testcase name:
    path_list = INPUT_TESTCASE_FILE_PATH.split("/") #The testcase path can have severals '/' into its composition
    input_yaml_name = path_list[len(path_list)-1] #Gets the last element of the split list
    TESTCASE_NAME = input_yaml_name.split(".")[0]
    
    #Copies the simulation time in ms if exists
    simul_time = 1
    try:
        simul_time = int(sys.argv[2])
    except:
        pass    
    
    
    #Test if there are some differences between the input testcase file and the testcase file into testcase directory 
    #If there are differences, them deleted the testcase directory to rebuild a new testcase
    testcase_file_inside_dir = TESTCASE_NAME+"/"+TESTCASE_NAME+".yaml"
    if os.path.exists(testcase_file_inside_dir):
        testecase_changes = not filecmp.cmp(INPUT_TESTCASE_FILE_PATH, testcase_file_inside_dir)
        if testecase_changes:
            delete_if_exists(TESTCASE_NAME)
    
    
    #Clean all undesired simulation files traces
    delete_if_exists(TESTCASE_NAME+"/log")
    if os.path.exists(TESTCASE_NAME+"/log"):
        os.system("cd "+TESTCASE_NAME+"/log; rm -rf *")
    
    #Create the testcase path if not exist
    create_ifn_exists(TESTCASE_NAME)
    
    #Reads some importats parameters from testcase
    yaml_reader = get_yaml_reader(INPUT_TESTCASE_FILE_PATH)
    apps_name_list = get_apps_name_list(yaml_reader)
    model_description = get_model_description(yaml_reader)
    page_size_KB = get_page_size_KB(yaml_reader)
    memory_size_KB = get_memory_size_KB(yaml_reader)
    
    
    #Testcase generation: updates source files...
    copy_scripts ( HEMPS_PATH,  TESTCASE_NAME)
    copy_kernel( HEMPS_PATH,  TESTCASE_NAME)
    copy_apps( HEMPS_PATH,  TESTCASE_NAME,  apps_name_list)
    copy_hardware( HEMPS_PATH,  TESTCASE_NAME, model_description)
    copy_makefiles( HEMPS_PATH,  TESTCASE_NAME, page_size_KB, memory_size_KB, model_description, apps_name_list, simul_time)
    copy_testcase_file( TESTCASE_NAME, INPUT_TESTCASE_FILE_PATH)
    
    #Create other importatants dirs
    create_ifn_exists(TESTCASE_NAME+"/include")
    create_ifn_exists(TESTCASE_NAME+"/log")
    
    #Calls the deloream_env.py to generate all necessary debugging dir and files
    generate_deloream_env(TESTCASE_NAME, yaml_reader)
    
    #Calls the hemps-wave_gen script if
    generate_wave(INPUT_TESTCASE_FILE_PATH)
コード例 #2
0
def main():

    #This script copies and compile a given app
    MEMPHIS_PATH = os.getenv("MEMPHIS_PATH", 0)
    MEMPHIS_HOME = os.getenv("MEMPHIS_HOME", 0)
    INPUT_TESTCASE_FILE_PATH = sys.argv[1]
    INPUT_SCENARIO_FILE_PATH = sys.argv[2]
    SIM_TIME = sys.argv[3]

    print ""
    #Test if testcase file MEMPHIS_PATH is valid
    if MEMPHIS_HOME == 0:
        print "\nWARNING: MEMPHIS_HOME not defined, using as default testcase dir MEMPHIS_PATH/testcases\n"
        MEMPHIS_HOME = MEMPHIS_PATH + "/testcases"

    path_list = INPUT_TESTCASE_FILE_PATH.split(
        "/")  #The testcase path can have severals '/' into its composition
    input_yaml_name = path_list[len(path_list) -
                                1]  #Gets the last element of the split list
    TESTCASE_PATH = MEMPHIS_HOME + "/" + input_yaml_name.split(".")[
        0]  #Creates a new path using the MEMPHIS_HOME + the YAML name
    TESTCASE_NAME = input_yaml_name.split(".")[0]
    path_list = INPUT_SCENARIO_FILE_PATH.split("/")
    input_yaml_name = path_list[len(path_list) - 1]
    SCENARIO_NAME = input_yaml_name.split(".")[0]
    SCENARIO_PATH = TESTCASE_PATH + "/" + SCENARIO_NAME

    yaml_scenario_r = get_yaml_reader(INPUT_SCENARIO_FILE_PATH)
    yaml_testcase_r = get_yaml_reader(INPUT_TESTCASE_FILE_PATH)

    create_ifn_exists(SCENARIO_PATH)
    os.system("rm -rf " + SCENARIO_PATH + "/*")
    create_ifn_exists(SCENARIO_PATH + "/log")

    #Copy scenario.yaml to scenario dir and testcase dir
    try:
        copyfile(INPUT_SCENARIO_FILE_PATH,
                 SCENARIO_PATH + "/" + SCENARIO_NAME + ".yaml")
        copyfile(INPUT_SCENARIO_FILE_PATH,
                 TESTCASE_PATH + "/" + SCENARIO_NAME + ".yaml")
    except:
        pass

    system_model = get_model_description(yaml_testcase_r)

    #subprocess.call("cd "+testacase_dir+"; vsim -c -do sim.do", shell=True)
    if system_model == "sc":

        #Copy the executable
        copyfile(TESTCASE_PATH + "/base_scenario/" + TESTCASE_NAME + "",
                 SCENARIO_PATH + "/" + SCENARIO_NAME)
        os.system("chmod 777 " + SCENARIO_PATH + "/" + SCENARIO_NAME)

    elif system_model == "scmod" or system_model == "vhdl":

        copyfile(TESTCASE_PATH + "/base_scenario/sim.do",
                 SCENARIO_PATH + "/sim.do")
        copyfile(TESTCASE_PATH + "/base_scenario/wave.do",
                 SCENARIO_PATH + "/wave.do")
        delete_if_exists(SCENARIO_PATH + "/hardware")
        create_ifn_exists(SCENARIO_PATH + "/hardware")
        create_ifn_exists(SCENARIO_PATH + "/hardware/work")
        generic_copy(TESTCASE_PATH + "/hardware/work",
                     SCENARIO_PATH + "/hardware/work", [".svn"])

    if system_model == "sc" or system_model == "scmod":
        #Copy ram_pe
        delete_if_exists(SCENARIO_PATH + "/ram_pe")
        os.system("cp -rf " + TESTCASE_PATH + "/base_scenario/ram_pe " +
                  SCENARIO_PATH)

    apps_name_list = get_apps_name_list(yaml_scenario_r)

    check_app_exist(apps_name_list, TESTCASE_PATH)

    #Generates the appstart.txt and appstart_debug.txt files
    apps_info_list = get_app_info_list(yaml_scenario_r, TESTCASE_PATH)

    generate_appstart_file(apps_info_list, TESTCASE_PATH, SCENARIO_PATH)

    #Calls the deloream_env.py to generate all necessary debugging dir and files
    generate_deloream_env(TESTCASE_PATH, yaml_testcase_r, SCENARIO_PATH,
                          yaml_scenario_r)

    print SCENARIO_NAME + " successfully generated!"
コード例 #3
0
def main():
    #HEMPS_PATH - must to point to the root directory of hemps
    HEMPS_PATH = os.getenv("HEMPS_PATH", 0)

    #Test if testcase file HEMPS_PATH is valid
    if HEMPS_PATH == 0:
        sys.exit("ENV PATH ERROR: HEMPS_PATH not defined")

    #Test if testcase file is passed as arg1 by testing the lenght of argv list
    if len(sys.argv) <= 1:
        sys.exit(
            "ARG ERROR: arg1 must be a valid testcase file with a extension .yaml (<my_testcase>.yaml) "
        )

    #testcase name without .yaml
    INPUT_TESTCASE_FILE_PATH = sys.argv[1]

    if os.path.exists(INPUT_TESTCASE_FILE_PATH) == False:
        sys.exit(
            "ARG ERROR: arg1 must be a valid testcase file with a extension .yaml (<my_testcase>.yaml) "
        )

    #Gets the testcase name:
    path_list = INPUT_TESTCASE_FILE_PATH.split(
        "/")  #The testcase path can have severals '/' into its composition
    input_yaml_name = path_list[len(path_list) -
                                1]  #Gets the last element of the split list
    TESTCASE_NAME = input_yaml_name.split(".")[0]

    #Copies the simulation time in ms if exists
    simul_time = 1
    try:
        simul_time = int(sys.argv[2])
    except:
        pass

    #Test if there are some differences between the input testcase file and the testcase file into testcase directory
    #If there are differences, them deleted the testcase directory to rebuild a new testcase
    testcase_file_inside_dir = TESTCASE_NAME + "/" + TESTCASE_NAME + ".yaml"
    if os.path.exists(testcase_file_inside_dir):
        testecase_changes = not filecmp.cmp(INPUT_TESTCASE_FILE_PATH,
                                            testcase_file_inside_dir)
        if testecase_changes:
            delete_if_exists(TESTCASE_NAME)

    #Clean all undesired simulation files traces
    delete_if_exists(TESTCASE_NAME + "/log")
    if os.path.exists(TESTCASE_NAME + "/log"):
        os.system("cd " + TESTCASE_NAME + "/log; rm -rf *")

    #Create the testcase path if not exist
    create_ifn_exists(TESTCASE_NAME)

    #Reads some importats parameters from testcase
    yaml_reader = get_yaml_reader(INPUT_TESTCASE_FILE_PATH)
    apps_name_list = get_apps_name_list(yaml_reader)
    model_description = get_model_description(yaml_reader)
    page_size_KB = get_page_size_KB(yaml_reader)
    memory_size_KB = get_memory_size_KB(yaml_reader)
    mpsocXsize = get_mpsoc_x_dim(yaml_reader)
    mpsocYsize = get_mpsoc_y_dim(yaml_reader)
    clusterXsize = get_cluster_x_dim(yaml_reader)
    clusterYsize = get_cluster_y_dim(yaml_reader)

    #Testcase generation: updates source files...
    copy_scripts(HEMPS_PATH, TESTCASE_NAME)
    copy_kernel(HEMPS_PATH, TESTCASE_NAME, INPUT_TESTCASE_FILE_PATH)
    copy_apps(HEMPS_PATH, TESTCASE_NAME, apps_name_list)
    copy_hardware(HEMPS_PATH, TESTCASE_NAME, model_description)
    copy_makefiles_and_waves(HEMPS_PATH, TESTCASE_NAME, page_size_KB,
                             memory_size_KB, model_description, apps_name_list,
                             simul_time)
    copy_testcase_file(TESTCASE_NAME, INPUT_TESTCASE_FILE_PATH)

    if not (os.path.isfile(TESTCASE_NAME + "/wave.do")):
        os.system("python " + HEMPS_PATH + "/build_env/waves/wavegen.py " +
                  str(mpsocXsize) + " " + str(mpsocYsize) + " " +
                  str(clusterXsize) + " " + str(clusterYsize) + " > " +
                  TESTCASE_NAME + "/wave.do")

    #Create other importatants dirs
    create_ifn_exists(TESTCASE_NAME + "/include")
    create_ifn_exists(TESTCASE_NAME + "/log")

    #Calls the deloream_env.py to generate all necessary debugging dir and files
    generate_deloream_env(TESTCASE_NAME, yaml_reader)
コード例 #4
0
ファイル: scenario_builder.py プロジェクト: GaphGroup/hemps
def main():
    
    #This script copies and compile a given app
    MEMPHIS_PATH                  = os.getenv("MEMPHIS_PATH", 0)
    MEMPHIS_HOME                  = os.getenv("MEMPHIS_HOME", 0)
    INPUT_TESTCASE_FILE_PATH    = sys.argv[1]
    INPUT_SCENARIO_FILE_PATH    = sys.argv[2]
    SIM_TIME                    = sys.argv[3]
    
    print ""
     #Test if testcase file MEMPHIS_PATH is valid
    if MEMPHIS_HOME == 0:
        print "\nWARNING: MEMPHIS_HOME not defined, using as default testcase dir MEMPHIS_PATH/testcases\n"
        MEMPHIS_HOME = MEMPHIS_PATH + "/testcases"
        
    path_list = INPUT_TESTCASE_FILE_PATH.split("/") #The testcase path can have severals '/' into its composition
    input_yaml_name = path_list[len(path_list)-1] #Gets the last element of the split list
    TESTCASE_PATH = MEMPHIS_HOME + "/" + input_yaml_name.split(".")[0] #Creates a new path using the MEMPHIS_HOME + the YAML name
    TESTCASE_NAME = input_yaml_name.split(".")[0]
    path_list = INPUT_SCENARIO_FILE_PATH.split("/")
    input_yaml_name = path_list[len(path_list)-1]
    SCENARIO_NAME = input_yaml_name.split(".")[0]
    SCENARIO_PATH = TESTCASE_PATH + "/" + SCENARIO_NAME
    
    yaml_scenario_r = get_yaml_reader(INPUT_SCENARIO_FILE_PATH)
    yaml_testcase_r = get_yaml_reader(INPUT_TESTCASE_FILE_PATH)
    
    create_ifn_exists(SCENARIO_PATH)
    os.system("rm -rf "+SCENARIO_PATH+"/*")
    create_ifn_exists(SCENARIO_PATH+"/log")
    
    #Copy scenario.yaml to scenario dir
    copyfile(INPUT_SCENARIO_FILE_PATH, SCENARIO_PATH+"/"+SCENARIO_NAME+".yaml")

    
    system_model = get_model_description(yaml_testcase_r)
    
    #subprocess.call("cd "+testacase_dir+"; vsim -c -do sim.do", shell=True)
    if system_model == "sc":
       
        #Copy the executable
        copyfile(TESTCASE_PATH + "/base_scenario/" + TESTCASE_NAME +"", SCENARIO_PATH + "/" + SCENARIO_NAME)
        os.system("chmod 777 "+SCENARIO_PATH + "/" + SCENARIO_NAME)
        
    elif system_model == "scmod" or system_model == "vhdl":
        
        copyfile(TESTCASE_PATH+"/base_scenario/sim.do" , SCENARIO_PATH+"/sim.do")
        copyfile(TESTCASE_PATH+"/base_scenario/wave.do" , SCENARIO_PATH+"/wave.do")
        delete_if_exists(SCENARIO_PATH+"/hardware")
        create_ifn_exists(SCENARIO_PATH+"/hardware")
        create_ifn_exists(SCENARIO_PATH+"/hardware/work")
        generic_copy(TESTCASE_PATH+"/hardware/work", SCENARIO_PATH+"/hardware/work", [".svn"])
        
    if system_model == "sc" or system_model == "scmod":
        #Copy ram_pe
        delete_if_exists(SCENARIO_PATH+"/ram_pe")
        os.system("cp -rf "+TESTCASE_PATH+"/base_scenario/ram_pe "+SCENARIO_PATH)    
    
    apps_name_list = get_apps_name_list(yaml_scenario_r)
    
    check_app_exist(apps_name_list, TESTCASE_PATH)
    
    #Generates the appstart.txt and appstart_debug.txt files
    apps_info_list = get_app_info_list(yaml_scenario_r, TESTCASE_PATH)
    
    generate_appstart_file(apps_info_list, TESTCASE_PATH, SCENARIO_PATH)
    
    #Calls the deloream_env.py to generate all necessary debugging dir and files
    generate_deloream_env(TESTCASE_PATH, yaml_testcase_r, SCENARIO_PATH, yaml_scenario_r)