Ejemplo n.º 1
0
 def run(self):
     msg.ok_msg_blue("--------> Simulation Session")
     self.print_env()
     self.simulator.run()
     if self.unit_sim == False:
         self.ocse.run()
         self.testcase.run()
Ejemplo n.º 2
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!")
Ejemplo n.º 3
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))
Ejemplo n.º 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 ... ")
Ejemplo n.º 5
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 ...")
Ejemplo n.º 6
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()
Ejemplo n.º 7
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")
Ejemplo n.º 8
0
    if options.odma == True:
        if options.odma_mode.lower() == "mm_1024":
            options.predefined_config = "hdl_unit_sim.odma.defconfig"
        elif options.odma_mode.lower() == "mm_512":
            options.predefined_config = "hdl_unit_sim.odma_mm_512.defconfig"
        elif options.odma_mode.lower() == "st_512":
            options.predefined_config = "hdl_unit_sim.odma_st_512.defconfig"
        elif options.odma_mode.lower() == "st_1024":
            options.predefined_config = "hdl_unit_sim.odma_st_1024.defconfig"
        else:
            options.predefined_config = "hdl_unit_sim.odma.defconfig"
    else:
        options.predefined_config = "hdl_unit_sim.bridge.defconfig"

if __name__ == '__main__':
    msg.ok_msg_blue("--------> WELCOME to IBM OpenCAPI Acceleration Framework")
    question_and_answer = qa.QuestionAndAnswer(options)

    question_and_answer.ask(qa.ask_clean_str)
    if options.clean:
        env_clean(ocaccel_workflow_log)

    cfg = Configuration(options)
    cfg.log = ocaccel_workflow_log
    question_and_answer.cfg = cfg
    question_and_answer.ask(qa.ask_configure_str)
    if not options.no_configure:
        cfg.configure()

    # In unit sim mode, all configurations are handled automatically, no need to update the cfg
    if not options.unit_sim: