From 74b34919e7dea7dd1f9ecd4a238c6244ee8dbe02 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 29 Sep 2021 19:10:48 +0100 Subject: [PATCH] add PartitionedAssign class for use in PartitionedSignal --- src/ieee754/part_ass/assign.py | 152 +++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 src/ieee754/part_ass/assign.py diff --git a/src/ieee754/part_ass/assign.py b/src/ieee754/part_ass/assign.py new file mode 100644 index 00000000..34472b40 --- /dev/null +++ b/src/ieee754/part_ass/assign.py @@ -0,0 +1,152 @@ +# 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 + +""" + +from nmigen import Signal, Module, Elaboratable, Cat, Const, signed +from nmigen.back.pysim import Simulator, Settle +from nmutil.extend import ext + +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 + # identify where the 1s are, which indicates "start of a new partition" + # we want a list of the lengths of all partitions + for i in range(size): + if pbit & (1<