From 56c40b033c2276503ae7b1021ed6ac6ed871e2ef Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 28 Sep 2021 19:41:20 +0100 Subject: [PATCH] add PartitionedSignal.__Cat__ override calls and creates PartitionedCat module --- src/ieee754/part/partsig.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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): -- 2.30.2