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 ... ")
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 ...")
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!")
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")
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()
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))
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)