diff --git a/magma/circuit.py b/magma/circuit.py index 780d3025c..58ad78962 100644 --- a/magma/circuit.py +++ b/magma/circuit.py @@ -14,8 +14,7 @@ from .common import deprecated, setattrs, OrderedIdentitySet from .interface import * from .wire import * -from .config import get_debug_mode, set_debug_mode -from .debug import get_debug_info, debug_info +from .debug import get_debug_info from .is_definition import isdefinition from .placer import Placer, StagedPlacer from magma.syntax.combinational import combinational @@ -27,7 +26,7 @@ pass from magma.clock import is_clock_or_nested_clock, Clock, ClockTypes -from magma.config import get_debug_mode, set_debug_mode, config, RuntimeConfig +from magma.config import get_debug_mode, set_debug_mode, config, DebugConfig from magma.definition_context import ( DefinitionContext, definition_context_manager, @@ -63,7 +62,7 @@ _logger = root_logger() -config.register(use_namer_dict=RuntimeConfig(False)) +config.register(use_namer_dict=DebugConfig(False)) class _SyntaxStyle(enum.Enum): @@ -293,12 +292,9 @@ def __new__(metacls, name, bases, dct): # If in debug_mode is active and debug_info is not supplied, attach # callee stack info. dct.setdefault("debug_info", None) - if get_debug_mode() and not dct["debug_info"]: - callee_frame = inspect.getframeinfo( - inspect.currentframe().f_back.f_back) - module = inspect.getmodule(inspect.stack()[2][0]) - dct["debug_info"] = debug_info(callee_frame.filename, - callee_frame.lineno, module) + if not dct["debug_info"]: + # Don't use setdefault to avoid get_debug_info call if possible + dct["debug_info"] = get_debug_info(4) cls = type.__new__(metacls, name, bases, dct) diff --git a/magma/config.py b/magma/config.py index 9a5963d14..cffa21fde 100644 --- a/magma/config.py +++ b/magma/config.py @@ -55,8 +55,13 @@ def reset(self, default=None): self.set(value) +class DebugConfig(RuntimeConfig): + pass + + class ConfigManager: __entries = {} + __debug_entries = [] def __init__(self, **kwargs): self._register(**kwargs) @@ -66,6 +71,8 @@ def _register(self, **kwargs): if key in ConfigManager.__entries: raise RuntimeError(f"Config with key '{key}' already exists") ConfigManager.__entries[key] = value + if isinstance(value, DebugConfig): + ConfigManager.__debug_entries.append(key) def register(self, **kwargs): self._register(**kwargs) @@ -73,7 +80,13 @@ def register(self, **kwargs): def __get(self, key): return ConfigManager.__entries[key].get() + def __set_debug_mode(self, value): + for key in self.__debug_entries: + self.__set(key, value) + def __set(self, key, value): + if key == "debug_mode": + self.__set_debug_mode(value) ConfigManager.__entries[key].set(value) def __getattr__(self, key): diff --git a/magma/debug.py b/magma/debug.py index 5198ce0fd..9b6dbef0d 100644 --- a/magma/debug.py +++ b/magma/debug.py @@ -4,7 +4,7 @@ import uinspect from magma.common import Stack -from magma.config import config, RuntimeConfig +from magma.config import config, DebugConfig @dataclasses.dataclass @@ -17,7 +17,7 @@ class _DebugInfo: debug_info = _DebugInfo -config.register(use_uinspect=RuntimeConfig(True)) +config.register(use_uinspect=DebugConfig(True)) _extra_frames_to_skip_stack = Stack() diff --git a/magma/logging.py b/magma/logging.py index 031e4d75d..97e4a2ba7 100644 --- a/magma/logging.py +++ b/magma/logging.py @@ -35,6 +35,8 @@ def _get_source_line(filename, lineno): def _attach_debug_info(msg, debug_info): file = debug_info.filename + if file is None: + return msg line = debug_info.lineno line_info = _make_bold(f"{make_relative(file)}:{line}") msg = f"{line_info}: {msg}" diff --git a/magma/testing/utils.py b/magma/testing/utils.py index 3d6d3956d..646dd8fbf 100644 --- a/magma/testing/utils.py +++ b/magma/testing/utils.py @@ -44,12 +44,14 @@ def check_files_equal(callee_file, file1_name, file2_name): class _MagmaDebugSection: def __init__(self): self.__restore = get_debug_mode() + self.__restore_uinspect = config.use_uinspect def __enter__(self): set_debug_mode(True) def __exit__(self, typ, value, traceback): set_debug_mode(self.__restore) + config.use_uinspect = self.__restore_uinspect def magma_debug_section(): diff --git a/tests/test_circuit/gold/test_for_loop_def.json b/tests/test_circuit/gold/test_for_loop_def.json index 23454ddd0..69b39d35f 100644 --- a/tests/test_circuit/gold/test_for_loop_def.json +++ b/tests/test_circuit/gold/test_for_loop_def.json @@ -7,7 +7,8 @@ ["I0","BitIn"], ["I1","BitIn"], ["O","Bit"] - ]] + ]], + "metadata":{"filename":"tests/test_circuit/test_define.py","lineno":"8"} }, "main":{ "type":["Record",[ diff --git a/tests/test_circuit/gold/test_interleaved_instance_wiring.json b/tests/test_circuit/gold/test_interleaved_instance_wiring.json index 85622e98d..d6298687b 100644 --- a/tests/test_circuit/gold/test_interleaved_instance_wiring.json +++ b/tests/test_circuit/gold/test_interleaved_instance_wiring.json @@ -7,7 +7,8 @@ ["I0","BitIn"], ["I1","BitIn"], ["O","Bit"] - ]] + ]], + "metadata":{"filename":"tests/test_circuit/test_define.py","lineno":"8"} }, "main":{ "type":["Record",[ diff --git a/tests/test_circuit/gold/test_simple_def.json b/tests/test_circuit/gold/test_simple_def.json index ca2cc4ff4..5197b0d5d 100644 --- a/tests/test_circuit/gold/test_simple_def.json +++ b/tests/test_circuit/gold/test_simple_def.json @@ -7,7 +7,8 @@ ["I0","BitIn"], ["I1","BitIn"], ["O","Bit"] - ]] + ]], + "metadata":{"filename":"tests/test_circuit/test_define.py","lineno":"8"} }, "main":{ "type":["Record",[ diff --git a/tests/test_circuit/gold/test_simple_def_class.json b/tests/test_circuit/gold/test_simple_def_class.json index 13cdd76b9..0e2b7f7b6 100644 --- a/tests/test_circuit/gold/test_simple_def_class.json +++ b/tests/test_circuit/gold/test_simple_def_class.json @@ -7,7 +7,8 @@ ["I0","BitIn"], ["I1","BitIn"], ["O","Bit"] - ]] + ]], + "metadata":{"filename":"tests/test_circuit/test_define.py","lineno":"8"} }, "Main":{ "type":["Record",[ diff --git a/tests/test_circuit/test_debug_circuit.py b/tests/test_circuit/test_debug_circuit.py index 59178bc03..6625b8fa5 100644 --- a/tests/test_circuit/test_debug_circuit.py +++ b/tests/test_circuit/test_debug_circuit.py @@ -9,6 +9,7 @@ class Foo(m.DebugCircuit): io = m.IO(I=m.In(m.Bit)) assert m.config.get_debug_mode() is False + m.config.config.use_uinspect = True def test_debug_generator(): @@ -21,3 +22,4 @@ def __init__(self, n: int): Foo(4) assert m.config.get_debug_mode() is False + m.config.config.use_uinspect = True diff --git a/tests/test_circuit/test_define.py b/tests/test_circuit/test_define.py index 3af6e1c0c..4b04ed047 100644 --- a/tests/test_circuit/test_define.py +++ b/tests/test_circuit/test_define.py @@ -13,7 +13,7 @@ class And2(m.Circuit): @pytest.mark.parametrize("target,suffix", [("verilog", "v"), ("coreir", "json")]) def test_simple_def(target, suffix): - m.config.set_debug_mode(True) + m.config.config.use_namer_dict = True m.set_codegen_debug_info(True) class main(m.Circuit): @@ -42,7 +42,7 @@ class Main(m.Circuit): # Create a fresh context for second compilation. m.compile("build/test_simple_def_class", Main, output=target) m.set_codegen_debug_info(False) - m.config.set_debug_mode(False) + m.config.config.use_namer_dict = False assert check_files_equal(__file__, f"build/test_simple_def_class.{suffix}", f"gold/test_simple_def_class.{suffix}") @@ -50,7 +50,7 @@ class Main(m.Circuit): @pytest.mark.parametrize("target,suffix", [("verilog", "v"), ("coreir", "json")]) def test_for_loop_def(target, suffix): - m.config.set_debug_mode(True) + m.config.config.use_namer_dict = True m.set_codegen_debug_info(True) class main(m.Circuit): @@ -72,7 +72,7 @@ class main(m.Circuit): m.compile("build/test_for_loop_def", main, output=target) m.set_codegen_debug_info(False) - m.config.set_debug_mode(False) + m.config.config.use_namer_dict = False assert check_files_equal(__file__, f"build/test_for_loop_def.{suffix}", f"gold/test_for_loop_def.{suffix}") @@ -80,7 +80,7 @@ class main(m.Circuit): @pytest.mark.parametrize("target,suffix", [("verilog", "v"), ("coreir", "json")]) def test_interleaved_instance_wiring(target, suffix): - m.config.set_debug_mode(True) + m.config.config.use_namer_dict = True m.set_codegen_debug_info(True) class main(m.Circuit): @@ -102,7 +102,7 @@ class main(m.Circuit): m.compile("build/test_interleaved_instance_wiring", main, output=target) m.set_codegen_debug_info(False) - m.config.set_debug_mode(False) + m.config.config.use_namer_dict = False assert check_files_equal(__file__, f"build/test_interleaved_instance_wiring.{suffix}", f"gold/test_interleaved_instance_wiring.{suffix}") diff --git a/tests/test_circuit/test_new_style_syntax.py b/tests/test_circuit/test_new_style_syntax.py index 3cad531a6..718810653 100644 --- a/tests/test_circuit/test_new_style_syntax.py +++ b/tests/test_circuit/test_new_style_syntax.py @@ -55,7 +55,10 @@ class _Foo(m.Circuit): io = None # doesn't matter what the value of io is. _check_foo_interface(_Foo) - expected = "'IO' and 'io' should not both be specified, ignoring 'io'" + expected = """\ +tests/test_circuit/test_new_style_syntax.py:53: 'IO' and 'io' should not both be specified, ignoring 'io' +>> class _Foo(m.Circuit):\ +""" assert has_warning(caplog, expected) @@ -75,7 +78,10 @@ class _Foo(m.Circuit): io.x @= 0 assert m.isdefinition(_Foo) - assert has_error(caplog, "_Foo.O not driven") + assert has_error(caplog, """\ +tests/test_circuit/test_new_style_syntax.py:74: _Foo.O not driven +>> class _Foo(m.Circuit):\ +""") assert has_error(caplog, "_Foo.O") assert has_error(caplog, " _Foo.O[0]: Connected") assert has_error(caplog, " _Foo.O[1]: Unconnected") @@ -107,12 +113,12 @@ class _Foo(m.Circuit): assert not m.isdefinition(_Foo) assert has_error(caplog, """\ -tests/test_circuit/test_new_style_syntax.py:104: Cannot wire _Foo.I (Out(Bit)) to _Foo.O (Out(Bit)) +tests/test_circuit/test_new_style_syntax.py:110: Cannot wire _Foo.I (Out(Bit)) to _Foo.O (Out(Bit)) >> m.wire(io.I, io.O)\ """) assert has_error(caplog, """\ -tests/test_circuit/test_new_style_syntax.py:105: Cannot wire _Foo.I (Out(Bit)) to _Foo.O1 (In(Bits[1])) +tests/test_circuit/test_new_style_syntax.py:111: Cannot wire _Foo.I (Out(Bit)) to _Foo.O1 (In(Bits[1])) >> m.wire(io.I, io.O1)\ """) @@ -131,19 +137,22 @@ class _Foo(m.Circuit): assert has_error( caplog, """\ -tests/test_circuit/test_new_style_syntax.py:129: Cannot wire _Foo.I (Out(Bit)) to _Foo._Bar_inst0.I (In(Bits[1])) +tests/test_circuit/test_new_style_syntax.py:135: Cannot wire _Foo.I (Out(Bit)) to _Foo._Bar_inst0.I (In(Bits[1])) >> m.wire(io.I, bar.I)\ """) assert has_error( caplog, """\ -tests/test_circuit/test_new_style_syntax.py:130: Cannot wire _Foo._Bar_inst0.O (Out(Bits[1])) to _Foo.O (In(Bit)) +tests/test_circuit/test_new_style_syntax.py:136: Cannot wire _Foo._Bar_inst0.O (Out(Bits[1])) to _Foo.O (In(Bit)) >> m.wire(bar.O, io.O)\ """) - assert has_error(caplog, "_Foo.O not driven") + assert has_error(caplog, """\ +tests/test_circuit/test_new_style_syntax.py:131: _Foo.O not driven +>> class _Foo(m.Circuit):\ +""") assert has_error(caplog, "_Foo.O: Unconnected") assert has_error(caplog, """\ -tests/test_circuit/test_new_style_syntax.py:128: _Foo._Bar_inst0.I not driven +tests/test_circuit/test_new_style_syntax.py:134: _Foo._Bar_inst0.I not driven >> bar = _Bar()\ """) assert has_error(caplog, "_Foo._Bar_inst0.I: Unconnected") diff --git a/tests/test_config.py b/tests/test_config.py new file mode 100644 index 000000000..e90a02082 --- /dev/null +++ b/tests/test_config.py @@ -0,0 +1,14 @@ +import magma as m + + +def test_config_debug(): + def _check(val: bool): + m.config.config.debug_mode = val + for field in ["use_uinspect", "use_namer_dict", "debug_mode"]: + assert getattr(m.config.config, field) is val + + for val in [True, False]: + _check(val) + + # Reset default + m.config.config.use_uinspect = True diff --git a/tests/test_deprecated/test_old_io_syntax/gold/test_for_loop_def.json b/tests/test_deprecated/test_old_io_syntax/gold/test_for_loop_def.json index 902f1cac1..ab4b7e015 100644 --- a/tests/test_deprecated/test_old_io_syntax/gold/test_for_loop_def.json +++ b/tests/test_deprecated/test_old_io_syntax/gold/test_for_loop_def.json @@ -8,7 +8,7 @@ ["I1","BitIn"], ["O","Bit"] ]], - "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"62"} + "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"63"} }, "main":{ "type":["Record",[ @@ -18,33 +18,33 @@ "instances":{ "and2_0":{ "modref":"global.And2", - "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"69"} + "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"70"} }, "and2_1":{ "modref":"global.And2", - "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"69"} + "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"70"} }, "and2_2":{ "modref":"global.And2", - "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"69"} + "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"70"} }, "and2_3":{ "modref":"global.And2", - "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"69"} + "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"70"} } }, "connections":[ - ["self.I.0","and2_0.I0",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"71"}], - ["self.I.1","and2_0.I1",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"72"}], - ["and2_1.I0","and2_0.O",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"74"}], - ["self.I.1","and2_1.I1",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"75"}], - ["and2_2.I0","and2_1.O",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"74"}], - ["self.I.1","and2_2.I1",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"75"}], - ["and2_3.I0","and2_2.O",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"74"}], - ["self.I.1","and2_3.I1",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"75"}], - ["self.O","and2_3.O",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"78"}] + ["self.I.0","and2_0.I0",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"72"}], + ["self.I.1","and2_0.I1",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"73"}], + ["and2_1.I0","and2_0.O",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"75"}], + ["self.I.1","and2_1.I1",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"76"}], + ["and2_2.I0","and2_1.O",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"75"}], + ["self.I.1","and2_2.I1",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"76"}], + ["and2_3.I0","and2_2.O",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"75"}], + ["self.I.1","and2_3.I1",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"76"}], + ["self.O","and2_3.O",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"79"}] ], - "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"65"} + "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"66"} } } } diff --git a/tests/test_deprecated/test_old_io_syntax/gold/test_for_loop_def.v b/tests/test_deprecated/test_old_io_syntax/gold/test_for_loop_def.v index 85fc18034..0a191e825 100644 --- a/tests/test_deprecated/test_old_io_syntax/gold/test_for_loop_def.v +++ b/tests/test_deprecated/test_old_io_syntax/gold/test_for_loop_def.v @@ -1,30 +1,30 @@ -// Defined at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:65 +// Defined at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:66 module main (input [1:0] I, output O); wire and2_0_O; wire and2_1_O; wire and2_2_O; wire and2_3_O; -// Instanced at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:69 -// Argument I0(I[0]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:71 -// Argument I1(I[1]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:72 -// Argument O(and2_0_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:74 +// Instanced at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:70 +// Argument I0(I[0]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:72 +// Argument I1(I[1]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:73 +// Argument O(and2_0_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:75 And2 and2_0 (.I0(I[0]), .I1(I[1]), .O(and2_0_O)); -// Instanced at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:69 -// Argument I0(and2_0_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:74 -// Argument I1(I[1]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:75 -// Argument O(and2_1_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:74 +// Instanced at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:70 +// Argument I0(and2_0_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:75 +// Argument I1(I[1]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:76 +// Argument O(and2_1_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:75 And2 and2_1 (.I0(and2_0_O), .I1(I[1]), .O(and2_1_O)); -// Instanced at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:69 -// Argument I0(and2_1_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:74 -// Argument I1(I[1]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:75 -// Argument O(and2_2_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:74 +// Instanced at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:70 +// Argument I0(and2_1_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:75 +// Argument I1(I[1]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:76 +// Argument O(and2_2_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:75 And2 and2_2 (.I0(and2_1_O), .I1(I[1]), .O(and2_2_O)); -// Instanced at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:69 -// Argument I0(and2_2_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:74 -// Argument I1(I[1]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:75 -// Argument O(and2_3_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:78 +// Instanced at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:70 +// Argument I0(and2_2_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:75 +// Argument I1(I[1]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:76 +// Argument O(and2_3_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:79 And2 and2_3 (.I0(and2_2_O), .I1(I[1]), .O(and2_3_O)); -// Wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:78 +// Wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:79 assign O = and2_3_O; endmodule diff --git a/tests/test_deprecated/test_old_io_syntax/gold/test_interleaved_instance_wiring.json b/tests/test_deprecated/test_old_io_syntax/gold/test_interleaved_instance_wiring.json index 08a6664f0..314d50a45 100644 --- a/tests/test_deprecated/test_old_io_syntax/gold/test_interleaved_instance_wiring.json +++ b/tests/test_deprecated/test_old_io_syntax/gold/test_interleaved_instance_wiring.json @@ -8,7 +8,7 @@ ["I1","BitIn"], ["O","Bit"] ]], - "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"95"} + "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"97"} }, "main":{ "type":["Record",[ @@ -18,27 +18,27 @@ "instances":{ "and2_0":{ "modref":"global.And2", - "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"100"} + "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"102"} }, "and2_1":{ "modref":"global.And2", - "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"101"} + "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"103"} }, "and2_2":{ "modref":"global.And2", - "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"107"} + "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"109"} } }, "connections":[ - ["self.I.0","and2_0.I0",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"103"}], - ["self.I.1","and2_0.I1",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"104"}], - ["and2_1.I0","and2_0.O",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"105"}], - ["self.I.1","and2_1.I1",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"106"}], - ["and2_2.I0","and2_1.O",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"108"}], - ["self.I.0","and2_2.I1",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"109"}], - ["self.O","and2_2.O",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"111"}] + ["self.I.0","and2_0.I0",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"105"}], + ["self.I.1","and2_0.I1",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"106"}], + ["and2_1.I0","and2_0.O",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"107"}], + ["self.I.1","and2_1.I1",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"108"}], + ["and2_2.I0","and2_1.O",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"110"}], + ["self.I.0","and2_2.I1",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"111"}], + ["self.O","and2_2.O",{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"113"}] ], - "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"98"} + "metadata":{"filename":"tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py","lineno":"100"} } } } diff --git a/tests/test_deprecated/test_old_io_syntax/gold/test_interleaved_instance_wiring.v b/tests/test_deprecated/test_old_io_syntax/gold/test_interleaved_instance_wiring.v index 61a3f2503..0c8f0c2f9 100644 --- a/tests/test_deprecated/test_old_io_syntax/gold/test_interleaved_instance_wiring.v +++ b/tests/test_deprecated/test_old_io_syntax/gold/test_interleaved_instance_wiring.v @@ -1,24 +1,24 @@ -// Defined at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:98 +// Defined at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:100 module main (input [1:0] I, output O); wire and2_0_O; wire and2_1_O; wire and2_2_O; -// Instanced at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:100 -// Argument I0(I[0]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:103 -// Argument I1(I[1]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:104 -// Argument O(and2_0_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:105 -And2 and2_0 (.I0(I[0]), .I1(I[1]), .O(and2_0_O)); -// Instanced at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:101 -// Argument I0(and2_0_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:105 +// Instanced at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:102 +// Argument I0(I[0]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:105 // Argument I1(I[1]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:106 -// Argument O(and2_1_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:108 +// Argument O(and2_0_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:107 +And2 and2_0 (.I0(I[0]), .I1(I[1]), .O(and2_0_O)); +// Instanced at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:103 +// Argument I0(and2_0_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:107 +// Argument I1(I[1]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:108 +// Argument O(and2_1_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:110 And2 and2_1 (.I0(and2_0_O), .I1(I[1]), .O(and2_1_O)); -// Instanced at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:107 -// Argument I0(and2_1_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:108 -// Argument I1(I[0]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:109 -// Argument O(and2_2_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:111 +// Instanced at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:109 +// Argument I0(and2_1_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:110 +// Argument I1(I[0]) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:111 +// Argument O(and2_2_O) wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:113 And2 and2_2 (.I0(and2_1_O), .I1(I[0]), .O(and2_2_O)); -// Wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:111 +// Wired at tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py:113 assign O = and2_2_O; endmodule diff --git a/tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py b/tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py index 0d4634df1..2d791ce3d 100644 --- a/tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py +++ b/tests/test_deprecated/test_old_io_syntax/test_old_io_syntax_define.py @@ -49,6 +49,7 @@ def definition(io): m.compile("build/test_simple_def_class", Main, output=target) m.set_codegen_debug_info(False) m.config.set_debug_mode(False) + m.config.config.use_uinspect = True assert check_files_equal(__file__, f"build/test_simple_def_class.{suffix}", f"gold/test_simple_def_class.{suffix}") @@ -82,6 +83,7 @@ def test_for_loop_def(target, suffix): m.compile("build/test_for_loop_def", main, output=target) m.set_codegen_debug_info(False) m.config.set_debug_mode(False) + m.config.config.use_uinspect = True assert check_files_equal(__file__, f"build/test_for_loop_def.{suffix}", f"gold/test_for_loop_def.{suffix}") @@ -115,6 +117,7 @@ def test_interleaved_instance_wiring(target, suffix): m.compile("build/test_interleaved_instance_wiring", main, output=target) m.set_codegen_debug_info(False) m.config.set_debug_mode(False) + m.config.config.use_uinspect = True assert check_files_equal(__file__, f"build/test_interleaved_instance_wiring.{suffix}", f"gold/test_interleaved_instance_wiring.{suffix}") diff --git a/tests/test_dot/test_dot.py b/tests/test_dot/test_dot.py index e32a10c36..896f90937 100644 --- a/tests/test_dot/test_dot.py +++ b/tests/test_dot/test_dot.py @@ -16,6 +16,7 @@ class main(Circuit): compile("build/dot", main, output='dot') m.config.set_debug_mode(False) + m.config.config.use_uinspect = True # reset default # FIXME: Do equality check. # Let's not check for equality / check in gold until we've finalized this format. # assert magma_check_files_equal(__file__, "build/dot.dot", "gold/dot.dot") diff --git a/tests/test_errors/test_array_errors.py b/tests/test_errors/test_array_errors.py index 067ec980b..cc34fe598 100644 --- a/tests/test_errors/test_array_errors.py +++ b/tests/test_errors/test_array_errors.py @@ -15,7 +15,7 @@ class Foo(m.Circuit): with pytest.raises(Exception) as e: m.compile("build/Foo", Foo) - assert caplog.messages[0] == "Foo.A not driven" + assert "Foo.A not driven" in caplog.messages[0] assert caplog.messages[1] == "Foo.A" assert caplog.messages[2] == " Foo.A[0]: Connected" assert caplog.messages[3] == " Foo.A[1]: Unconnected" @@ -30,7 +30,7 @@ class Foo(m.Circuit): with pytest.raises(Exception) as e: m.compile("build/Foo", Foo) - assert caplog.messages[0] == "Foo.A not driven" + assert "Foo.A not driven" in caplog.messages[0] assert caplog.messages[1] == "Foo.A" assert caplog.messages[2] == " Foo.A[0]: Connected" assert caplog.messages[3] == " Foo.A[1]: Unconnected" @@ -46,7 +46,7 @@ class Foo(m.Circuit): with pytest.raises(Exception) as e: m.compile("build/Foo", Foo) - assert caplog.messages[0] == "Foo.A not driven" + assert "Foo.A not driven" in caplog.messages[0] assert caplog.messages[1] == "Foo.A" assert caplog.messages[2] == " Foo.A[0]: Connected" assert caplog.messages[3] == " Foo.A[1]" diff --git a/tests/test_errors/test_tuple_errors.py b/tests/test_errors/test_tuple_errors.py index cfe89ef08..10955cb1c 100644 --- a/tests/test_errors/test_tuple_errors.py +++ b/tests/test_errors/test_tuple_errors.py @@ -19,7 +19,7 @@ class Foo(m.Circuit): with pytest.raises(Exception) as e: m.compile("build/Foo", Foo) - assert caplog.messages[0] == "Foo.A not driven" + assert "Foo.A not driven" in caplog.messages[0] assert caplog.messages[1] == "Foo.A" assert caplog.messages[2] == " Foo.A.x: Connected" assert caplog.messages[3] == " Foo.A.y: Unconnected" @@ -42,7 +42,7 @@ class Foo(m.Circuit): with pytest.raises(Exception) as e: m.compile("build/Foo", Foo) - assert caplog.messages[0] == "Foo.A not driven" + assert "Foo.A not driven" in caplog.messages[0] assert caplog.messages[1] == "Foo.A" assert caplog.messages[2] == " Foo.A.x: Connected" assert caplog.messages[3] == " Foo.A.y: Unconnected" @@ -66,7 +66,7 @@ class Foo(m.Circuit): with pytest.raises(Exception) as e: m.compile("build/Foo", Foo) - assert caplog.messages[0] == "Foo.A not driven" + assert "Foo.A not driven" in caplog.messages[0] assert caplog.messages[1] == "Foo.A" assert caplog.messages[2] == " Foo.A.x: Connected" assert caplog.messages[3] == " Foo.A.y" @@ -88,7 +88,7 @@ class Foo(m.Circuit): with pytest.raises(Exception) as e: m.compile("build/Foo", Foo) - assert caplog.messages[0] == "Foo.A not driven" + assert "Foo.A not driven" in caplog.messages[0] assert caplog.messages[1] == "Foo.A" assert caplog.messages[2] == " Foo.A[0]" assert caplog.messages[3] == " Foo.A[0].x: Connected" @@ -125,7 +125,7 @@ class Foo(m.Circuit): tests/test_errors/test_tuple_errors.py:110: Cannot wire Bits[3](2) (Out(Bits[3])) to Foo.A.y (In(Bits[4])) >> io.A.y @= m.bits(2, 3)\ """) - assert caplog.messages[2] == "Foo.A not driven" + assert "Foo.A not driven" in caplog.messages[2] assert caplog.messages[3] == "Foo.A: Unconnected" @@ -164,7 +164,8 @@ class Foo(m.Circuit): m.compile("build/Foo", Foo) assert str(e.value) == "Found circuit with errors: Foo" expected = """\ -Foo.A.y not driven +\x1b[1mtests/test_errors/test_tuple_errors.py:157\x1b[0m: Foo.A.y not driven +>> class Foo(m.Circuit): Foo.A.y Foo.A.y[0]: Connected Foo.A.y[1]: Unconnected\ @@ -188,10 +189,10 @@ class Bar(m.Circuit): foo.I @= io.I io.O @= foo.z.x - assert caplog.messages[0] == "Bar.z.x not driven" + assert "Bar.z.x not driven" in caplog.messages[0] assert caplog.messages[1] == "Bar.z.x: Unconnected" assert has_error(caplog, """\ -tests/test_errors/test_tuple_errors.py:187: Foo_inst0.z.y not driven +tests/test_errors/test_tuple_errors.py:188: Foo_inst0.z.y not driven >> foo = Foo()\ """) diff --git a/tests/test_simulator/test_mdb.py b/tests/test_simulator/test_mdb.py index 55f5d2e41..1500c3a3c 100644 --- a/tests/test_simulator/test_mdb.py +++ b/tests/test_simulator/test_mdb.py @@ -16,7 +16,7 @@ def get_out(capsys): def FFs(n): return [PRIM_FF() for i in range(n)] - + def Register(n): args = ["I", In(Array[n, Bit]), "O", Out(Array[n, Bit])] + ClockInterface(False, False, False) @@ -26,23 +26,23 @@ class RegCircuit(m.Circuit): ffs = join(FFs(n)) wire(io.I, ffs.D) wire(ffs.Q, io.O) - + return RegCircuit() - + def IncOne(n): def sim_inc_one(self, value_store, state_store): I = value_store.get_value(self.I) n = len(I) val = seq2int(I) + 1 - + cout = val > ((1 << n) - 1) val = val % (1 << n) - + seq = int2seq(val, len(I)) seq = [bool(s) for s in seq] value_store.set_value(self.O, seq) value_store.set_value(self.COUT, cout) - + args = ["I", In(Array[n, Bit]), "O", Out(Array[n, Bit]), "COUT", Out(Bit)] class _Circuit(Circuit): name = 'IncOne' + str(n) @@ -52,36 +52,36 @@ class _Circuit(Circuit): simulate = sim_inc_one return _Circuit() - + def TestCounter(n): args = [] - + args += ["O", Array[n, Out(Bit)]] args += ["COUT", Out(Bit)] - + args += ClockInterface(False, False, False) - + class Counter(m.Circuit): name = 'Counter' + str(n) io = m.IO(**dict(zip(args[::2], args[1::2]))) - + inc = IncOne(n) reg = Register(n) reg.name = "reg" - + wire(reg.O, inc.I) wire(inc.O, reg.I) wire(reg.O, io.O) - + wire(inc.COUT, io.COUT) - + drive_undriven_other_clock_types_in_inst(Counter, Counter.reg) - + return Counter() - + args = ['O', Array[5, Out(Bit)], 'COUT', Out(Bit)] args += ClockInterface(False, False, False) - + class testcircuit(Circuit): name = "Test" io = IO(**dict(zip(args[::2], args[1::2]))) @@ -124,3 +124,4 @@ class testcircuit(Circuit): console.runcmd("p self.counter.reg.O") assert get_out(capsys) == "2" m.config.set_debug_mode(False) + m.config.config.use_uinspect = True diff --git a/tests/test_type/test_type_errors.py b/tests/test_type/test_type_errors.py index bb1e0891c..cba64ef48 100644 --- a/tests/test_type/test_type_errors.py +++ b/tests/test_type/test_type_errors.py @@ -4,7 +4,7 @@ def test_array_lengths(caplog): - m.config.set_debug_mode(True) + m.config.config.use_namer_dict = True class Buf(Circuit): name = "Buf" io = IO(I=In(Array[8, Bit]), O=Out(Array[8, Bit])) @@ -18,11 +18,11 @@ class main(Circuit): \033[1mtests/test_type/test_type_errors.py:16\033[0m: Cannot wire main.O (Array[(7, In(Bit))]) to main.buf.I (Array[(8, In(Bit))]) >> wire(io.O, buf.I)""" assert has_error(caplog, msg) - m.config.set_debug_mode(False) + m.config.config.use_namer_dict = False def test_array_to_bit(caplog): - m.config.set_debug_mode(True) + m.config.config.use_namer_dict = True class Buf(Circuit): name = "Buf" io = IO(I=In(Array[8, Bit]), O=Out(Array[8, Bit])) @@ -36,11 +36,11 @@ class main(Circuit): \033[1mtests/test_type/test_type_errors.py:34\033[0m: Cannot wire main.O (In(Bit)) to main.buf.I (Array[(8, In(Bit))]) >> wire(io.O, buf.I)""" assert has_error(caplog, msg) - m.config.set_debug_mode(False) + m.config.config.use_namer_dict = False def test_bit_to_array(caplog): - m.config.set_debug_mode(True) + m.config.config.use_namer_dict = True class Buf(Circuit): name = "Buf" io = IO(I=In(Bit), O=Out(Array[8, Bit])) @@ -54,7 +54,7 @@ class main(Circuit): \033[1mtests/test_type/test_type_errors.py:51\033[0m: Cannot wire main.buf.I (type=In(Bit)) to main.O (type=Array[7, In(Bit)]) because main.buf.I is not an Array >> wire(buf.I, main.O)""" assert has_error(caplog, msg) - m.config.set_debug_mode(False) + m.config.config.use_namer_dict = False class I(m.Product): @@ -63,7 +63,7 @@ class I(m.Product): def test_tuple_to_array(caplog): - m.config.set_debug_mode(True) + m.config.config.use_namer_dict = True class Buf(Circuit): name = "Buf" io = IO(I=In(I), O=Out(Array[8, Bit])) @@ -77,11 +77,11 @@ class main(Circuit): \033[1mtests/test_type/test_type_errors.py:75\033[0m: Cannot wire main.O (In(Bit)) to main.buf.I (Tuple(a=In(Bit),b=In(Bit))) >> wire(io.O, buf.I)""" assert has_error(caplog, msg) - m.config.set_debug_mode(False) + m.config.config.use_namer_dict = False def test_bad_tuples(caplog): - m.config.set_debug_mode(True) + m.config.config.use_namer_dict = True class O(m.Product): c = m.In(m.Bit) d = m.In(m.Bit) @@ -99,11 +99,11 @@ class main(Circuit): \033[1mtests/test_type/test_type_errors.py:97\033[0m: Cannot wire main.O (Tuple(c=In(Bit),d=In(Bit))) to main.buf.I (Tuple(a=In(Bit),b=In(Bit))) >> wire(io.O, buf.I)""" assert has_error(caplog, msg) - m.config.set_debug_mode(False) + m.config.config.use_namer_dict = False def test_bit_to_array(caplog): - m.config.set_debug_mode(True) + m.config.config.use_namer_dict = True class Buf(Circuit): name = "Buf" io = IO(I=In(Array[8, Bit]), O=Out(Array[8, Bit])) @@ -117,4 +117,4 @@ class main(Circuit): \033[1mtests/test_type/test_type_errors.py:115\033[0m: Cannot wire main.buf.I (Array[(8, In(Bit))]) to main.O (In(Bit)) >> wire(buf.I, io.O)""" assert has_error(caplog, msg) - m.config.set_debug_mode(False) + m.config.config.use_namer_dict = False diff --git a/tests/test_wire/test_errors.py b/tests/test_wire/test_errors.py index 937dd7d0d..27637d121 100644 --- a/tests/test_wire/test_errors.py +++ b/tests/test_wire/test_errors.py @@ -9,7 +9,7 @@ def test_input_as_output(caplog): - magma.config.set_debug_mode(True) + magma.config.config.use_namer_dict = True class Buf(Circuit): name = "Buf" io = IO(I=In(Bit), O=Out(Bit)) @@ -23,11 +23,11 @@ class main(Circuit): \033[1mtests/test_wire/test_errors.py:21\033[0m: Cannot wire main.O (In(Bit)) to main.buf.I (In(Bit)) >> wire(io.O, buf.I)""" assert has_error(caplog, msg) - magma.config.set_debug_mode(False) + magma.config.config.use_namer_dict = False def test_output_as_input(caplog): - magma.config.set_debug_mode(True) + magma.config.config.use_namer_dict = True class A(Circuit): name = "A" io = IO(I=In(Bit), O=Out(Bit)) @@ -41,11 +41,11 @@ class main(Circuit): \033[1mtests/test_wire/test_errors.py:39\033[0m: Cannot wire main.I (Out(Bit)) to main.a.O (Out(Bit)) >> wire(io.I, a.O)""" assert has_error(caplog, msg) - magma.config.set_debug_mode(False) + magma.config.config.use_namer_dict = False def test_multiple_outputs_to_input_warning(caplog): - magma.config.set_debug_mode(True) + magma.config.config.use_namer_dict = True class A(Circuit): name = "A" io = IO(I=In(Bit), O=Out(Bit)) @@ -60,11 +60,11 @@ class main(Circuit): \033[1mtests/test_wire/test_errors.py:58\033[0m: Wiring multiple outputs to same wire, using last connection. Input: main.a.I, Old Output: main.I[0], New Output: main.I[1] >> wire(io.I[1], a.I)""" assert has_warning(caplog, msg) - magma.config.set_debug_mode(False) + magma.config.config.use_namer_dict = False def test_multiple_outputs_circuit(caplog): - magma.config.set_debug_mode(True) + magma.config.config.use_namer_dict = True class A(Circuit): name = "A" io = IO(I=In(Bit), O=Out(Bit), U=Out(Bit)) @@ -78,11 +78,11 @@ class main(Circuit): \033[1mtests/test_wire/test_errors.py:76\033[0m: Can only wire circuits with one output; circuit `main.a` has outputs ['O', 'U'] >> wire(a, io.I)""" assert has_error(caplog, msg) - magma.config.set_debug_mode(False) + magma.config.config.use_namer_dict = False def test_mismatch_outputs_circuit(caplog): - magma.config.set_debug_mode(True) + magma.config.config.use_namer_dict = True class A(Circuit): name = "A" io = IO(I=In(Bit), J=In(Bit), O=Out(Bit), U=Out(Bit)) @@ -99,11 +99,11 @@ class Foo(Circuit): \033[1mtests/test_wire/test_errors.py:97\033[0m: Number of inputs is not equal to the number of outputs, expected 2 inputs, got 1. Only 1 will be wired. >> a(main)""" assert has_warning(caplog, msg) - magma.config.set_debug_mode(False) + magma.config.config.use_namer_dict = False def test_no_inputs_circuit(caplog): - magma.config.set_debug_mode(True) + magma.config.config.use_namer_dict = True class A(Circuit): name = "A" io = IO(O=Out(Bit), U=Out(Bit)) @@ -117,11 +117,11 @@ class main(Circuit): \033[1mtests/test_wire/test_errors.py:115\033[0m: Wiring an output to a circuit with no input arguments, skipping >> wire(io.I, a)""" assert has_warning(caplog, msg) - magma.config.set_debug_mode(False) + magma.config.config.use_namer_dict = False def test_multiple_inputs_circuit(caplog): - magma.config.set_debug_mode(True) + magma.config.config.use_namer_dict = True class A(Circuit): name = "A" io = IO(I=In(Bit), J=In(Bit), O=Out(Bit), U=Out(Bit)) @@ -135,11 +135,11 @@ class main(Circuit): \033[1mtests/test_wire/test_errors.py:133\033[0m: Wiring an output to a circuit with more than one input argument, using the first input main.a.I >> wire(io.I, a)""" assert has_warning(caplog, msg) - magma.config.set_debug_mode(False) + magma.config.config.use_namer_dict = False def test_no_key(caplog): - magma.config.set_debug_mode(True) + magma.config.config.use_namer_dict = True class A(Circuit): name = "A" io = IO(I=In(Bit), J=In(Bit), O=Out(Bit), U=Out(Bit)) @@ -154,11 +154,11 @@ class main(Circuit): >> a(K=io.I)""" assert has_warning(caplog, msg) - magma.config.set_debug_mode(False) + magma.config.config.use_namer_dict = False def test_const_array_error(caplog): - magma.config.set_debug_mode(True) + magma.config.config.use_namer_dict = True class Buf(Circuit): name = "Buf" io = IO(I=In(Array[1, Bit]), O=Out(Array[1, Bit])) @@ -176,7 +176,7 @@ class main(Circuit): >> wire(1, buf.I)""" assert caplog.records[0].msg == msg assert has_error(caplog, msg) - magma.config.set_debug_mode(False) + magma.config.config.use_namer_dict = False @wrap_with_context_manager(logging_level("DEBUG")) diff --git a/tests/test_wire/test_unwire.py b/tests/test_wire/test_unwire.py index ee4f3474c..fe575804e 100644 --- a/tests/test_wire/test_unwire.py +++ b/tests/test_wire/test_unwire.py @@ -29,10 +29,8 @@ def test_unwire_basic(T, func, caplog): @pytest.mark.parametrize('T', Ts) @pytest.mark.parametrize('func', funcs[2:4]) def test_unwire_undriven(T, func, caplog): - m.config.set_debug_mode(True) x, y = T(name="Foo"), T() func(x, y) - m.config.set_debug_mode(False) def make_expcted_log(value_str): return f"""\