remove SimdScope.get() and friends
authorJacob Lifshay <programmerjake@gmail.com>
Thu, 28 Oct 2021 03:41:34 +0000 (20:41 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Thu, 28 Oct 2021 03:41:34 +0000 (20:41 -0700)
src/ieee754/part/simd_scope.py
src/ieee754/part/test/test_partsig_scope.py

index 6741cf201c085f4190fb503c3748a6fc83012fd5..290c83e6c20f0c06ff7c8acd847dcda8eb03ab7b 100644 (file)
@@ -10,8 +10,8 @@ Copyright (C) 2021 Luke Kenneth Casson Leighton
 use as:
 
     m = Module()
-    with SimdScope(m, elwid) as s:
-        a = s.Signal(width=64, ....)
+    s = SimdScope(m, elwid)
+    a = s.Signal(width=64, ....)
 
     m.d.comb += a.eq(...)
 
@@ -48,32 +48,6 @@ class SimdScope:
         or Signal(IntElWid)
     """
 
-    __SCOPE_STACK = []
-
-    # XXX REMOVE THIS FUNCTION.  ITS USE IS DANGEROUS.
-    @classmethod
-    def get(cls):
-        """get the current SimdScope. raises a ValueError outside of any
-        SimdScope.
-
-        Example:
-        with SimdScope(...) as s:
-            assert SimdScope.get() is s
-        """
-        if len(cls.__SCOPE_STACK) > 0:
-            retval = cls.__SCOPE_STACK[-1]
-            assert isinstance(retval, SimdScope), "inconsistent scope stack"
-            return retval
-        raise ValueError("not in a `with SimdScope()` statement")
-
-    def __enter__(self):
-        self.__SCOPE_STACK.append(self)
-        return self
-
-    def __exit__(self, exc_type, exc_value, traceback):
-        assert self.__SCOPE_STACK.pop() is self, "inconsistent scope stack"
-        return False
-
     def __init__(self, module, elwid, vec_el_counts, scalar=False):
 
         # in SIMD mode, must establish module as part of context and inform
index 81bd7d0c1c7972e8624389a48afa45085bb15024..1da4e3720f40bf1096526702103e2ca9590bed19 100644 (file)
@@ -29,13 +29,13 @@ def create_simulator(module, traces, test_name):
 class TestCatMod(Elaboratable):
     def __init__(self, width, elwid, vec_el_counts):
         self.m = Module()
-        with SimdScope(self.m, elwid, vec_el_counts) as s:
-            shape = SimdShape(s, fixed_width=width)
-            shape2 = SimdShape(s, fixed_width=width*2)
-            shape3 = SimdShape(s, fixed_width=width*3)
-            self.a = s.Signal(shape)
-            self.b = s.Signal(shape2)  # TODO: shape*2
-            self.o = s.Signal(shape3)  # TODO: shape*3
+        s = SimdScope(self.m, elwid, vec_el_counts)
+        shape = SimdShape(s, fixed_width=width)
+        shape2 = SimdShape(s, fixed_width=width*2)
+        shape3 = SimdShape(s, fixed_width=width*3)
+        self.a = s.Signal(shape)
+        self.b = s.Signal(shape2)  # TODO: shape*2
+        self.o = s.Signal(shape3)  # TODO: shape*3
         self.cat_out = self.o.sig
 
     def elaborate(self, platform):