From: Luke Kenneth Casson Leighton Date: Sat, 30 Oct 2021 10:26:31 +0000 (+0100) Subject: add setmodule function to SimdScope X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ea6f170475dc460d8ba49b512270fddf17ae4ec2;p=ieee754fpu.git add setmodule function to SimdScope --- diff --git a/src/ieee754/part/simd_scope.py b/src/ieee754/part/simd_scope.py index 290c83e6..680fea32 100644 --- a/src/ieee754/part/simd_scope.py +++ b/src/ieee754/part/simd_scope.py @@ -50,18 +50,22 @@ class SimdScope: def __init__(self, module, elwid, vec_el_counts, scalar=False): + self.elwid = elwid + self.vec_el_counts = vec_el_counts + self.scalar = scalar + self.set_module(module) + + def set_module(self, module): # in SIMD mode, must establish module as part of context and inform # the module to operate under "SIMD" Type 1 (AST) casting rules, # not the # default "Value.cast" rules. - if not scalar: - self.module = module - from ieee754.part.partsig import SimdSignal + if self.scalar: + return + self.module = module + from ieee754.part.partsig import SimdSignal + if module is not None: module._setAstTypeCastFn(SimdSignal.cast) - self.elwid = elwid - self.vec_el_counts = vec_el_counts - self.scalar = scalar - def __repr__(self): return (f"SimdScope(\n" f" elwid={self.elwid},\n"