X-Git-Url: https://git.libre-soc.org/?p=ieee754fpu.git;a=blobdiff_plain;f=src%2Fieee754%2Fpart%2Fpartsig.py;h=d5acb6c42adcd68e39db151cd9ee736c78d43844;hp=baf7f6300eee4000d22e5abae4a7d3ca67e985b6;hb=417f7f93bf3baf576e537cde32f118b2a50eab46;hpb=201cb485c0075d0744ca1142604931199e38d10a diff --git a/src/ieee754/part/partsig.py b/src/ieee754/part/partsig.py index baf7f630..d5acb6c4 100644 --- a/src/ieee754/part/partsig.py +++ b/src/ieee754/part/partsig.py @@ -224,12 +224,50 @@ class SimdShape(Shape): # wheww, got everything. return SimdShape(self.scope, # same scope width=lane_shapes, # widths_at_elwid - signed=self.signed, # same sign + signed=self.signed, # same sign? hmmm XXX fixed_width=fixed_width) # overall width else: raise NotImplementedError( f"Multiplying a SimdShape by {type(other)} isn't implemented") + # TODO (and go over examples, sigh). this is deliberately *after* + # the raise NotImplementedError because it needs review. + + # also probably TODO: potentially the other argument could be + # a Shape() not a SimdShape(). sigh. + + # for SimdShape-to-SimdShape multiply, the rules are slightly + # different: both sides have to be PRIORITY_FIXED for a + # PRIORITY_FIXED result to be returned. if either (or both) + # of the LHS and RHS were given elwidths (lane_shapes != None) + # then tough luck: the return result is still PRIORITY_ELWID. + # TODO: review that. it *might* be the case (again, due to + # a coincidence of multiply, that when PRIORITY_BOTH is set + # it is possible to return a PRIORITY_BOTH result. but.. + # it is unlikely) + + fixed_width = None + lane_shapes = None + + # first, check if this is fixed_width mode. this is *only* + # possible if *both* LHS *and* RHS are PRIORITY_FIXED. + if (self.mode_flag == PRIORITY_FIXED and + other.mode_flag == PRIORITY_FIXED): + fixed_width = self.width * other.width + else: + # (XXX assume other is SimdShape) - when PRIORITY_ELWID + # the result *has* to be a PRIORITY_ELWID (FIXED is *IGNORED*) + # use *either* the computed *or* the given lane_shapes + lane_shapes = {k: v * other.lane_shapes[k] \ + for k, v in self.lane_shapes} + + # wheww, got everything. + return SimdShape(self.scope, # same scope + width=lane_shapes, # widths_at_elwid + signed=self.signed, # same sign? hmmm XXX + fixed_width=fixed_width) # overall width + + def __rmul__(self, other): return self.__mul__(other)