From 6060226db6ffc01a2c1dd0497796d42223455895 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Wed, 27 Oct 2021 20:41:34 -0700 Subject: [PATCH] remove SimdScope.get() and friends --- src/ieee754/part/simd_scope.py | 30 ++------------------- src/ieee754/part/test/test_partsig_scope.py | 14 +++++----- 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/src/ieee754/part/simd_scope.py b/src/ieee754/part/simd_scope.py index 6741cf20..290c83e6 100644 --- a/src/ieee754/part/simd_scope.py +++ b/src/ieee754/part/simd_scope.py @@ -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 diff --git a/src/ieee754/part/test/test_partsig_scope.py b/src/ieee754/part/test/test_partsig_scope.py index 81bd7d0c..1da4e372 100644 --- a/src/ieee754/part/test/test_partsig_scope.py +++ b/src/ieee754/part/test/test_partsig_scope.py @@ -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): -- 2.30.2