From 423050fa77d75b84d0281f91a58764a688a3b3cb Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 5 Oct 2021 18:25:27 +0100 Subject: [PATCH] add PartitionedRepl into PartitionedSignal.__Repl__ uses same auto-module-creation as PCat, PMux and PAssign --- src/ieee754/part/partsig.py | 5 ++++- src/ieee754/part_repl/prepl.py | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/ieee754/part_repl/prepl.py diff --git a/src/ieee754/part/partsig.py b/src/ieee754/part/partsig.py index a3365d31..880ea18b 100644 --- a/src/ieee754/part/partsig.py +++ b/src/ieee754/part/partsig.py @@ -27,6 +27,7 @@ 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 ieee754.part_repl.prepl import PRepl from operator import or_, xor, and_, not_ from nmigen import (Signal, Const) @@ -93,7 +94,9 @@ class PartitionedSignal(UserValue): # TODO, http://bugs.libre-riscv.org/show_bug.cgi?id=458 #def __Part__(self, offset, width, stride=1, *, src_loc_at=0): - #def __Repl__(self, count, *, src_loc_at=0): + + def __Repl__(self, count, *, src_loc_at=0): + return PRepl(self.m, self, count, self.partpoints) def __Cat__(self, *args, src_loc_at=0): args = [self] + list(args) diff --git a/src/ieee754/part_repl/prepl.py b/src/ieee754/part_repl/prepl.py new file mode 100644 index 00000000..b2b64954 --- /dev/null +++ b/src/ieee754/part_repl/prepl.py @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# See Notices.txt for copyright information + +""" +Copyright (C) 2021 Luke Kenneth Casson Leighton + +dynamically-partitionable "repl" class, directly equivalent +to nmigen Repl + +See: + +* http://libre-riscv.org/3d_gpu/architecture/dynamic_simd/repl +* http://bugs.libre-riscv.org/show_bug.cgi?id=709 + +""" + + + +modcount = 0 # global for now +def PRepl(m, repl, qty, mask): + from ieee754.part_repl.repl import PartitionedRepl # recursion issue + global modcount + modcount += 1 + pc = PartitionedRepl(repl, qty, mask) + setattr(m.submodules, "repl%d" % modcount, pc) + return pc.output + -- 2.30.2