From: Luke Kenneth Casson Leighton Date: Tue, 28 Sep 2021 18:41:20 +0000 (+0100) Subject: add PartitionedSignal.__Cat__ override X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=56c40b033c2276503ae7b1021ed6ac6ed871e2ef;p=ieee754fpu.git add PartitionedSignal.__Cat__ override calls and creates PartitionedCat module --- diff --git a/src/ieee754/part/partsig.py b/src/ieee754/part/partsig.py index ba172aab..69f9734f 100644 --- a/src/ieee754/part/partsig.py +++ b/src/ieee754/part/partsig.py @@ -23,6 +23,7 @@ from ieee754.part_shift.part_shift_dynamic import PartitionedDynamicShift from ieee754.part_shift.part_shift_scalar import PartitionedScalarShift from ieee754.part_mul_add.partpoints import make_partition2, PartitionPoints from ieee754.part_mux.part_mux import PMux +from ieee754.part_cat.cat import PartitionedCat from operator import or_, xor, and_, not_ from nmigen import (Signal, Const) @@ -47,7 +48,7 @@ global modnames modnames = {} # for sub-modules to be created on-demand. Mux is done slightly # differently (has its own global) -for name in ['add', 'eq', 'gt', 'ge', 'ls', 'xor']: +for name in ['add', 'eq', 'gt', 'ge', 'ls', 'xor', 'cat']: modnames[name] = 0 @@ -93,6 +94,15 @@ class PartitionedSignal(UserValue): "val1 == %d, val2 == %d" % (len(val1), len(val2)) return PMux(self.m, self.partpoints, self, val1, val2) + def __Cat__(self, *args, src_loc_at=0): + args = [self] + list(args) + for sig in args: + assert isinstance(sig, PartitionedSignal), \ + "All PartitionedSignal.__Cat__ arguments must be " \ + "a PartitionedSignal. %s is not." % repr(sig) + pc = PartitionedCat(args, self.partpoints) + setattr(self.m.submodules, self.get_modname('cat'), pc) + # unary ops that do not require partitioning def __invert__(self):