From: Luke Kenneth Casson Leighton Date: Wed, 29 Sep 2021 18:35:23 +0000 (+0100) Subject: add use of PartitionedAssign in PartitionedSignal, behind __Assign__ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=58c9fe6d719842132dd18fc6264ee525f1fc7f88;p=ieee754fpu.git add use of PartitionedAssign in PartitionedSignal, behind __Assign__ move to separate module due to recursive import issues --- diff --git a/src/ieee754/part/partsig.py b/src/ieee754/part/partsig.py index d3518984..032749cf 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_ass.passign import PAssign from ieee754.part_cat.pcat import PCat from operator import or_, xor, and_, not_ @@ -99,6 +100,10 @@ class PartitionedSignal(UserValue): "val1 == %d, val2 == %d" % (len(val1), len(val2)) return PMux(self.m, self.partpoints, self, val1, val2) + def __Assign__(self, val): + # print ("partsig ass", self, val) + return PAssign(self.m, self.shape(), val, self.partpoints) + def __Cat__(self, *args, src_loc_at=0): args = [self] + list(args) for sig in args: diff --git a/src/ieee754/part_ass/assign.py b/src/ieee754/part_ass/assign.py index 1bc87c74..d6fdc6ce 100644 --- a/src/ieee754/part_ass/assign.py +++ b/src/ieee754/part_ass/assign.py @@ -22,15 +22,6 @@ from ieee754.part_mul_add.partpoints import PartitionPoints from ieee754.part.partsig import PartitionedSignal -modcount = 0 # global for now -def PAssign(m, arglist, mask): - global modcount - modcount += 1 - pc = PartitionedAssign(arglist, mask) - setattr(m.submodules, "pass%d" % modcount, pc) - return pc.output - - def get_runlengths(pbit, size): res = [] count = 1 diff --git a/src/ieee754/part_ass/passign.py b/src/ieee754/part_ass/passign.py new file mode 100644 index 00000000..00de7390 --- /dev/null +++ b/src/ieee754/part_ass/passign.py @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# See Notices.txt for copyright information + +""" +Copyright (C) 2021 Luke Kenneth Casson Leighton + +dynamically-partitionable "assign" class, directly equivalent +to nmigen Assign + +See: + +* http://libre-riscv.org/3d_gpu/architecture/dynamic_simd/assign +* http://bugs.libre-riscv.org/show_bug.cgi?id=709 + +""" + + + +modcount = 0 # global for now +def PAssign(m, shape, assign, mask): + from ieee754.part_ass.assign import PartitionedAssign # recursion issue + global modcount + modcount += 1 + pc = PartitionedAssign(shape, assign, mask) + setattr(m.submodules, "pass%d" % modcount, pc) + return pc.output + + diff --git a/src/ieee754/part_cat/cat.py b/src/ieee754/part_cat/cat.py index 6fdfb66b..27abb19a 100644 --- a/src/ieee754/part_cat/cat.py +++ b/src/ieee754/part_cat/cat.py @@ -38,15 +38,6 @@ from ieee754.part.partsig import PartitionedSignal from ieee754.part.test.test_partsig import create_simulator -modcount = 0 # global for now -def PCat(m, arglist, mask): - global modcount - modcount += 1 - pc = PartitionedCat(arglist, mask) - setattr(m.submodules, "pcat%d" % modcount, pc) - return pc.output - - def get_runlengths(pbit, size): res = [] count = 1