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(...)
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
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):