def wait_on_and_dump_trace(self, result_file=None, emu_time_scaled=True): """ Wait until the trace unit stopped recording data. Transmit this data to the host PC, store by default to the raw result file path, or a custom path provided by the user, and convert analog values from fixed-point to float. Finally store it to a .vcd file in the default location. :param result_file: Optionally, it is possible to provide a custom result file path. """ if result_file is not None: # Expand provided path, paths relative to project root are also supported result_path = expand_path(result_file, rel_path_reference=self.pcfg.root) # Create raw result path by adding _raw to the filename result_path_raw = os.path.join( os.path.dirname(result_path), os.path.basename(os.path.splitext(result_path)[0]) + '_raw' + os.path.splitext(result_path)[1]) print(f'Simulation results will be stored in:{result_path}') else: result_path = self.result_path result_path_raw = self.result_path_raw if not result_path: raise Exception( f'ERROR: provided result_file:{result_file} is not valid!') # wait until trace buffer is full self.sendline( f'wait_on_hw_ila -timeout {self.record_timeout} $ila_0_i') # transmit and dump trace buffer data to a CSV file self.sendline('current_hw_ila_data [upload_hw_ila_data $ila_0_i]') if not os.path.isdir(os.path.dirname(result_path_raw)): mkdir_p(os.path.dirname(result_path_raw)) self.sendline( f'write_hw_ila_data -csv_file -force {{{result_path_raw}}} [current_hw_ila_data]' ) # Convert to .vcd and from fixed-point to float ConvertWaveform(result_path_raw=result_path_raw, result_type_raw=self.result_type_raw, result_path=result_path, str_cfg=self.scfg, float_type=self.float_type, dt_scale=self.pcfg.cfg.dt_scale, emu_time_scaled=emu_time_scaled)
def view(self, result_file=None): """ View results from selected target run. :param result_file: Path to the result file that shall be opened """ root = self._prj_cfg.root if result_file is not None: result_file = expand_path(result_file, rel_path_reference=root) target = getattr(self, self.args.active_target) # pick viewer viewer_cls = { 'gtkwave': GtkWaveViewer, 'simvision': SimVisionViewer, 'scansion': ScansionViewer }[self.args.viewer_name] # set config file location for GTKWave # TODO: clean this up; it's a bit messy... if isinstance(target, FPGATarget): gtkw_search_order = ['view_fpga.gtkw', 'view.gtkw'] elif isinstance(target, CPUTarget): gtkw_search_order = ['view_sim.gtkw', 'view.gtkw'] else: gtkw_search_order = ['view.gtkw'] for basename in gtkw_search_order: candidate_path = os.path.join(root, basename) if os.path.isfile(candidate_path): self._prj_cfg.gtkwave_config.gtkw_config = candidate_path break else: self._prj_cfg.gtkwave_config.gtkw_config = None # set config file location for SimVision self._prj_cfg.simvision_config.svcf_config = os.path.join( root, 'view.svcf') # run viewer viewer = viewer_cls(target=target) viewer.view(result_file=result_file)