From 9b7e045448550924e985ccd3d0a53698f33784c9 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 14 Dec 2018 13:50:19 +0000 Subject: [PATCH] back.pysim: show more legible names for processes in errors. --- nmigen/back/pysim.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/nmigen/back/pysim.py b/nmigen/back/pysim.py index 53cb91e..a174ec8 100644 --- a/nmigen/back/pysim.py +++ b/nmigen/back/pysim.py @@ -435,6 +435,10 @@ class Simulator: # Otherwise, do one more round of updates. def _run_process(self, process): + def format_process(process): + frame = process.gi_frame + return "{}:{}".format(inspect.getfile(frame), inspect.getlineno(frame)) + try: cmd = process.send(None) while True: @@ -462,14 +466,14 @@ class Simulator: lhs_signals = cmd.lhs._lhs_signals() for signal in lhs_signals: if not signal in self._signals: - raise ValueError("Process {!r} sent a request to set signal '{!r}', " + raise ValueError("Process '{}' sent a request to set signal '{!r}', " "which is not a part of simulation" - .format(process, signal)) + .format(format_process(process), signal)) if signal in self._comb_signals: - raise ValueError("Process {!r} sent a request to set signal '{!r}', " + raise ValueError("Process '{}' sent a request to set signal '{!r}', " "which is a part of combinatorial assignment in " "simulation" - .format(process, signal)) + .format(format_process(process), signal)) funclet = _StatementCompiler()(cmd) funclet(self._state) @@ -480,8 +484,8 @@ class Simulator: self._commit_sync_signals(domains) else: - raise TypeError("Received unsupported command '{!r}' from process {!r}" - .format(cmd, process)) + raise TypeError("Received unsupported command '{!r}' from process '{}'" + .format(cmd, format_process(process))) break -- 2.30.2