예제 #1
0
def make_image(log, options=None):
    msg.ok_msg_blue("--------> Make the FPGA image")
    msg.warn_msg(
        "Make image might take quiet a long time to finish, be patient ... ")
    rc = run_and_poll_with_progress(cmd="make image",
                                    work_dir=".",
                                    log=log,
                                    max_log_len=120,
                                    timeout=options.make_timeout)

    if rc == 0:
        msg.ok_msg("====================")
        msg.ok_msg("FPGA image generated")
        msg.ok_msg("====================")
        msg.ok_msg(
            "Images are available in %s" %
            pathjoin(options.ocaccel_root, 'hardware', 'build', 'Images'))
    else:
        msg.warn_msg("Failed to make image, check log in %s" % log)
        msg.warn_msg("Failed to make image! Exiting ... ")
        msg.warn_msg("Here are some of the error logs:")
        f = open(log, "r")
        l = f.readlines()
        f.close()
        print "".join(l[-10:])
        msg.fail_msg("End of the error log!")
예제 #2
0
    def run(self):
        msg.ok_msg_blue("--------> Running testcase %s" % self.cmd)
        self.test_log = pathjoin(self.simout, self.cmd + ".log")
        rc = None
        if self.cmd == "terminal":
            cmd = "xterm -title \"testcase window, look at log in \"" + self.test_log
            rc = run_and_wait(cmd=cmd, work_dir=self.simout, log=self.test_log)
        else:
            cmd = " ".join((self.cmd, self.args))
            rc = run_and_poll(cmd=cmd, work_dir=self.simout, log=self.test_log)

        if rc != 0:
            msg.warn_msg("============")
            msg.warn_msg("Test FAILED!")
            msg.warn_msg("============")
            msg.fail_msg("Testcase returned %d, please check log in %s" %
                         (rc, self.test_log))
        else:
            if self.cmd == "terminal":
                msg.ok_msg("================================================")
                msg.ok_msg("An xterm (terminal) is chosen to run, ")
                msg.ok_msg("please refer to the results of commands")
                msg.ok_msg("you've ran in the terminal for testcase status.")
                msg.ok_msg(" To display traces, execute: ./display_traces")
                msg.ok_msg("================================================")
            else:
                msg.ok_msg("============")
                msg.ok_msg("Test PASSED!")
                msg.ok_msg("============")
                msg.ok_msg("Testcase returned %d, please check log in %s" %
                           (rc, self.test_log))
예제 #3
0
    def check_root_path(self):
        if not isdir(self.ocaccel_root):
            msg.warn_msg("SNAP_ROOT path: %s is not valid!" % self.ocaccel_root)
            msg.fail_msg("SNAP_ROOT is not valid! Exiting ...")

        if not isdir(self.action_root):
            msg.warn_msg("ACTION_ROOT path: %s is not valid!" % self.action_root)
            msg.fail_msg("ACTION_ROOT is not valid! Exiting ...")
예제 #4
0
def make_model(log, timeout = 2592000):
    msg.ok_msg_blue("--------> Make the simulation model")
    rc = run_and_poll_with_progress(cmd = "make model", work_dir = ".", log = log, max_log_len = 150, timeout = timeout)

    if rc == 0:
        msg.ok_msg("SNAP simulation model generated")
    else:
        msg.warn_msg("Failed to make simulation model, check log in %s" % log)
        msg.fail_msg("Failed to make simulation model! Exiting ... ")
예제 #5
0
    def run_ocse(self):
        self.ocse_log = pathjoin(self.simout, "ocse.log")
        ocse_cmd = pathjoin(self.ocse_root, "ocse", "ocse")

        self.ocse_pid =\
                run_in_background(cmd = ocse_cmd, work_dir = self.simout, log = self.ocse_log)
        if int(self.ocse_pid) > 0:
            msg.header_msg("OCSE running with pid %s" % self.ocse_pid)
        else:
            msg.fail_msg("Failed to run OCSE! Exiting ... ")
예제 #6
0
def env_clean(log):
    msg.ok_msg_blue("--------> Clean the environment")
    rc = run_and_wait(cmd="make clean", work_dir=".", log=log)
    if rc == 0:
        msg.ok_msg("Environment clean DONE")
    else:
        msg.fail_msg("Error running 'make clean'! Exiting ...")

    rc = run_and_wait(cmd="make clean_config", work_dir=".", log=log)
    if rc == 0:
        msg.ok_msg("Configuration clean DONE")
    else:
        msg.fail_msg("Error running 'make clean_config'! Exiting ...")
예제 #7
0
    def setup_cfg(self):
        if self.ocse_root is not None:
            ocse_line = 'OCSE_PATH="%s"' % self.ocse_root
            if isfile(self.snap_cfg_file):
                sed_file(self.snap_cfg_file, "\s*OCSE_PATH\s*=.*", ocse_line)
            else:
                append_file(self.snap_cfg_file, ocse_line)

        if self.simulator is not None:
            simulator_line = ""
            if self.simulator.lower() == "xsim":
                simulator_line = "SIM_XSIM=y"
            elif self.simulator.lower() == "xcelium":
                simulator_line = "SIM_XCELIUM=y"
            elif self.simulator.lower() == "nosim":
                simulator_line = "NO_SIM=y"
            else:
                msg.fail_msg("%s is unknown simulator! Exiting ... " %
                             self.simulator)

            if isfile(self.snap_cfg_file):
                sed_file(self.snap_cfg_file, r"^\s*(SIM_.*)\s*=.*",
                         r"# \1 is not set")
                sed_file(self.snap_cfg_file, "\s*NO_SIM\s*=.*",
                         "# NO_SIM is not set")

                if simulator_line == "SIM_XSIM=y":
                    sed_file(self.snap_cfg_file, "# SIM_XSIM is not set",
                             simulator_line)
                elif simulator_line == "SIM_XCELIUM=y":
                    sed_file(self.snap_cfg_file, "# SIM_XCELIUM is not set",
                             simulator_line)
                elif simulator_line == "NO_SIM=y":
                    sed_file(self.snap_cfg_file, "# NO_SIM is not set",
                             simulator_line)
            else:
                append_file(self.snap_cfg_file, simulator_line)

            sed_file(self.snap_cfg_file, '\s*SIMULATOR\s*=\s*".*"\s*$',
                     'SIMULATOR="%s"' % self.simulator.lower())

        if isfile(self.snap_env_file):
            sed_file(self.snap_env_file,
                     "^.*OCSE_ROOT\s*=.*",
                     "",
                     remove_matched_line=True)
예제 #8
0
    def configure(self):
        msg.ok_msg_blue("--------> Configuration")
        os.environ['SNAP_ROOT'] = self.ocaccel_root

        if self.options.predefined_config is not None:
            defconf = pathjoin(self.options.ocaccel_root, 'defconfig',
                               self.options.predefined_config)

            if not isfile(defconf):
                msg.fail_msg("%s is not a valid defconfig file" % defconf)

            copyfile(defconf,
                     pathjoin(self.options.ocaccel_root, self.snap_cfg_file))

        self.setup_cfg()
        if self.options.predefined_config is not None:
            run_and_wait(cmd="make -s oldconfig", work_dir=".", log=self.log)
            run_and_wait(cmd="make -s snap_env", work_dir=".", log=self.log)
        else:
            rc = run_to_stdout(cmd="make snap_config", work_dir=".")

            if rc != 0:
                msg.warn_msg(
                    "====================================================================="
                )
                msg.warn_msg(
                    "==== Failed to bringup the configuration window.                 ===="
                )
                msg.warn_msg(
                    "==== Please check if libncurses5-dev is installed on your system.===="
                )
                msg.warn_msg(
                    "==== Also check if 'https://github.com/guillon/kconfig' ")
                msg.warn_msg(
                    "====     is accessible from your system.                         ===="
                )
                msg.fail_msg(
                    "================= Configuration FAILED! ============================="
                )

        self.setup_ocaccel_env()
        msg.ok_msg("SNAP Configured")

        msg.header_msg("You've got configuration like:")
        self.print_cfg()
예제 #9
0
    def get_ocse_server_dat(self):
        ocse_server_dat_file = pathjoin(self.simout, "ocse_server.dat")
        ocse_server_dat_line = None
        progress_bar_size = 30
        for i in range(self.timeout):
            sleep(1)
            progress_bar(i, self.timeout, progress_bar_size)
            ocse_server_dat_line = grep_file(self.ocse_log, "listening on")
            if ocse_server_dat_line is not None:
                break

        if ocse_server_dat_line is None:
            msg.fail_msg("Timeout waiting for OCSE to startup! Exiting ...")

        progress_bar(self.timeout - 1, self.timeout, progress_bar_size, True)
        ocse_server_dat = re.search("listening on (.*$)", ocse_server_dat_line).group(1)
        with open(ocse_server_dat_file, 'w+') as outfile:
            outfile.write(ocse_server_dat)
        msg.header_msg(" OCSE listening on socket: %s" % ocse_server_dat)
예제 #10
0
    def get_host_shim(self):
        sim_host_shim = pathjoin(self.simout, "shim_host.dat")
        sim_host_shim_line = None
        msg.header_msg("Waiting for simulator running!")
        progress_bar_size = 30
        for i in range(self.timeout):
            sleep(1)
            progress_bar(i, self.timeout, progress_bar_size)
            sim_host_shim_line = grep_file(self.sim_log, "waiting for connection")
            if sim_host_shim_line is not None:
                break

        if sim_host_shim_line is None:
            msg.fail_msg("Timeout waiting for simulator to startup! Exiting ...")

        progress_bar(self.timeout - 1, self.timeout, progress_bar_size, True)
        host_shim = re.search("waiting for connection on (.*$)", sim_host_shim_line).group(1)
        with open(sim_host_shim, 'w+') as outfile:
            outfile.write("tlx0," + host_shim)
        msg.header_msg(" Simulator running successfully on socket: %s" % host_shim)
예제 #11
0
def env_check(options):
    assert sys.version_info >= (2, 6)

    msg.ok_msg_blue("--------> Environment Check")

    gcc = SystemCMD("gcc")
    gcc.check(existence_critical=True, minimum_version="4.4.6")

    if not options.no_make_model or not options.no_run_sim or options.make_image:
        vivado = SystemCMD("vivado")
        xterm = SystemCMD("xterm")
        vivado.check(existence_critical=True, minimum_version="2018.2")
        xterm.check(existence_critical=True)

    if options.simulator.lower() == "xcelium":
        xrun = SystemCMD("xrun")
        xrun.check(existence_critical=True)
    elif options.simulator.lower() == "vcs":
        vcs = SystemCMD("vcs")
        vcs.check(existence_critical=True)
    elif options.simulator.lower() == "nosim":
        pass
    elif options.simulator.lower() == "xsim":
        # xsim is bundled with vivado, no need to check
        pass
    else:
        msg.fail_msg("%s is an unknown simulator! Exiting ... " %
                     options.simulator)

    if options.no_run_sim == False or options.no_make_model == False:
        if options.simulator.lower() != "nosim" and options.unit_sim != True:
            if isdir(pathjoin(options.ocse_root, "ocse")) and\
               isdir(pathjoin(options.ocse_root, "afu_driver")) and\
               isdir(pathjoin(options.ocse_root, "libocxl")):
                msg.ok_msg_blue("OCSE path %s is valid" % options.ocse_root)
            else:
                msg.fail_msg("OCSE path %s is not valid! Exiting ... " %
                             options.ocse_root)

    if isdir(pathjoin(options.ocaccel_root, "actions")) and\
       isdir(pathjoin(options.ocaccel_root, "hardware")) and\
       isdir(pathjoin(options.ocaccel_root, "software")):
        msg.ok_msg_blue("SNAP ROOT %s is valid" % options.ocaccel_root)
    else:
        msg.fail_msg("SNAP ROOT %s is not valid! Exiting ... " %
                     options.ocaccel_root)

    msg.ok_msg("Environment check PASSED")
예제 #12
0
    def run_simulator(self):
        if self.simulator == "xcelium":
            sim_cmd = "xrun"
            sim_init = "-xminitialize x"
            sim_args = "-batch +model_data+. -64bit"
            if self.wave:
                sim_args += " -input ncaet.tcl"
            sim_args += " -input ncrun.tcl -r"
            unit_args = "".join(
                ("+UVM_TESTNAME=", self.unit_test, " -seed ", self.sv_seed,
                 " +UVM_VERBOSITY=", self.uvm_ver))
            if self.unit_sim == False:
                sim_top = "work.top"
            else:
                sim_top = "work.unit_top"
            self.sim_log = pathjoin(self.simout, "sim.log")

            if self.unit_sim == False:
                self.simulator_pid =\
                        run_in_background(cmd = " ".join((sim_cmd, sim_init, sim_args, sim_top)),\
                          work_dir = self.simout,\
                          log = self.sim_log)
                if int(self.simulator_pid) > 0:
                    msg.header_msg("Simulator running on process ID %s" %
                                   self.simulator_pid)
                else:
                    msg.fail_msg("Failed to run simulator! Exiting ... ")
            else:
                try:
                    rc = run_and_poll(cmd = " ".join((sim_cmd, sim_init, sim_args, sim_top, unit_args)),\
                                      work_dir = self.simout,\
                                      log = self.sim_log)
                    unit_sim_passed = self.check_unit_sim_result(self.sim_log)

                    os.remove(pathjoin(self.simout, '.RUNNING'))
                    if not unit_sim_passed:
                        msg.warn_msg("============")
                        msg.warn_msg("Test FAILED!")
                        msg.warn_msg("============")
                        # Generate a flag in simout for simulation status
                        open(pathjoin(self.simout, '.FAILED'), 'a').close()
                        msg.fail_msg(
                            "UVM check failed, please check log in %s" %
                            (self.sim_log))
                    else:
                        msg.ok_msg("============")
                        msg.ok_msg("Test PASSED!")
                        msg.ok_msg("============")
                        # Generate a flag in simout for simulation status
                        open(pathjoin(self.simout, '.PASSED'), 'a').close()
                        msg.ok_msg("UVM check passed, please check log in %s" %
                                   (self.sim_log))
                except:
                    if isfile(pathjoin(self.simout, '.RUNNING')):
                        os.remove(pathjoin(self.simout, '.RUNNING'))
                    open(pathjoin(self.simout, '.FAILED'), 'a').close()
                    msg.fail_msg("An error occured, please check log in %s" %
                                 (self.sim_log))

        elif self.simulator == "xsim":
            sim_cmd = "xsim"
            sim_init = ""

            sim_args = ""
            if self.wave:
                sim_args += "-t xsaet.tcl"
            sim_args += " -t xsrun.tcl"
            sim_top = "top"
            self.sim_log = pathjoin(self.simout, "sim.log")

            self.simulator_pid =\
                    run_in_background(cmd = " ".join((sim_cmd, sim_init, sim_args, sim_top)),\
                      work_dir = self.simout,\
                      log = self.sim_log)
            if int(self.simulator_pid) > 0:
                msg.header_msg("Simulator running on process ID %s" %
                               self.simulator_pid)
            else:
                msg.fail_msg("Failed to run simulator! Exiting ... ")
        else:
            msg.fail_msg("%s is not supported" % self.simulator)
예제 #13
0
 def check_simout(self):
     if not isdir(self.simout):
         msg.warn_msg("SIMOUT path: %s is not valid!" % self.simout)
         msg.fail_msg("SIMOUT is not valid! Exiting ...")