Skip to content
Snippets Groups Projects

Moved printing functionality out from Processor class + minor refactor of...

Merged Johannes Kung requested to merge smaller_files into main
5 unresolved threads

Closes #54 (closed)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
13 def pretty_print_verbose(
14 processor: Processor, ignore_keys: list[str] | None = None
15 ) -> None:
16 """
17 Print the most relevant information about each module in a compact and
18 readable format.
19
20 State variables of modules can be ignored with the optional argument.
21
22 Parameters
23 ----------
24 ignore_keys : list[str]
25 List of names of state variables of modules to exclude when
26 printing module states.
27 """
28 # TODO: ignore keys per module and not for all modules
  • 36 for module in processor.get_modules():
    37 if not isinstance(module, Bus):
    38 if isinstance(module, Memory) or isinstance(module, MicroMemory):
    39 memory_modules.append(module)
    40 else:
    41 other_modules.append(module)
    42
    43 # sort the modules by name to ensure that they appear in the
    44 # same order
    45 memory_modules.sort(key=lambda x: x.name, reverse=True)
    46 other_modules.sort(key=lambda x: x.name, reverse=True)
    47
    48 # specify which keys to ignore from the modules 'get_state'
    49 # function
    50 # TODO: ignore fields per module, this will ignore 'mask'
    51 # for every module
  • 65 self.lambdas: dict[str, Callable[..., bool]] = {}
    66 self._breakpoint_id_counter: int = 1
    67 self._breakpoints: dict[int, Breakpoint] = {}
    68 self.breakpoint_reached: bool = False
    69 self.last_breakpoint: Breakpoint | None = None
    70 self._lambdas: dict[str, Callable[..., bool]] = {}
    66 71
    67 72 # Saving processor state for saving/loading to file and undoing ticks
    68 self.removed_cycles = 0
    69 self.assembly_cycles = [0] # Map asm instruction to clock cycle
    70 self.module_history: list[dict[str, dict[str, Any]]] = []
    71 self.signal_history: list[list] = [] # TODO: Is this needed?
    73 self._removed_cycles: int = 0
    74 self._assembly_cycles: list[int] = [0] # Map asm instruction to clock cycle
    75 self._module_history: list[dict[str, dict[str, Any]]] = []
    76 self._signal_history: list[list] = [] # TODO: Is this needed?
  • 73 78 # For showing which instructions are being done and signalling
    74 79 # the start of a new one
    75 self.new_instruction = False
    80 self._new_instruction: bool = False
    76 81
    77 82 # It is the responsibility of the CPU to tell the gui:s pipeline
    78 83 # diagram what information to be displayed and how to display it.
    79 84 # Thus each CPU keeps track of its current instructions together with
    80 85 # each instructions position in the pipeline diagram.
    81 self.current_instructions: list[tuple[str, int, int]] = []
    86 self._current_instructions: list[tuple[str, int, int]] = []
    82 87
    83 88 # TODO: keeping track of what pieces of info not to show
    84 89 # show not be done at the processor level.
    85 90 # Maybe implement a 'get_pretty_print_state' at module
    86 91 # level?
  • 284 284 Also record the breakpoint that was reached.
    285 285 """
    286 286 self.breakpoint_reached = False
    287 for _, bp in self.breakpoints.items():
    287 for _, bp in self._breakpoints.items():
    288 288 # TODO: Can make this more efficient by only checking enabled
    289 289 # breakpoints
  • Martin Högstedt approved this merge request

    approved this merge request

  • Johannes Kung mentioned in commit 76fb5f77

    mentioned in commit 76fb5f77

  • Please register or sign in to reply
    Loading