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 ...")
def ask(self, question): if not self.options.interactive: return self.options else: if not self.qa_table.has_key(question): msg.warn_msg("I don't understand your question: '%s', do nothing" % question) return self.options return self.qa_table[question](question)
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 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 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 ask_run_sim(self, question): if self.options.simulator == "nosim": msg.warn_msg("Simulator is chosen as NOSIM, skip running simulation!") self.options.no_run_sim = True return self.options a = raw_input(" ".join((question,\ choice_str))) if a.upper() == "Y": msg.header_msg("Got Yes! Proceed to run simulation.") self.options.no_run_sim = False a = raw_input(ask_testcase_str) if a == "": a = "terminal" self.options.testcase = a msg.header_msg("The testcase to run: %s" % a) return self.options else: msg.header_msg("Got No! Skip running simulation.") self.options.no_run_sim = True return self.options
def check_unit_sim_result(self, sim_log): uvm_error = search_file_group_1(sim_log, "UVM_ERROR\s*:\s*(\d*)") uvm_fatal = search_file_group_1(sim_log, "UVM_FATAL\s*:\s*(\d*)") if uvm_error is None or uvm_fatal is None: msg.warn_msg("No UVM_ERROR or UVM_FATAL line found!") return False msg.warn_msg("--------> UVM_ERROR : %s" % uvm_error) msg.warn_msg("--------> UVM_FATAL : %s" % uvm_fatal) if uvm_error != '0' or uvm_fatal != '0': return False return True
def kill(self): if self.ocse_pid is None: return pid = int(self.ocse_pid) msg.warn_msg("Killing OCSE pid %d" % pid) kill_pid(pid)
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)
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 ...")