From 6527ad3925da72eb0485a6ef970352ac104554e8 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 13 Feb 2020 11:55:22 +0000 Subject: [PATCH] limit matrix output width and limit shift amount --- src/ieee754/part_shift/part_shift_dynamic.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ieee754/part_shift/part_shift_dynamic.py b/src/ieee754/part_shift/part_shift_dynamic.py index 776030da..1b941d26 100644 --- a/src/ieee754/part_shift/part_shift_dynamic.py +++ b/src/ieee754/part_shift/part_shift_dynamic.py @@ -13,7 +13,7 @@ See: * http://libre-riscv.org/3d_gpu/architecture/dynamic_simd/shift/ * http://bugs.libre-riscv.org/show_bug.cgi?id=173 """ -from nmigen import Signal, Module, Elaboratable, Cat, Mux +from nmigen import Signal, Module, Elaboratable, Cat, Mux, C from ieee754.part_mul_add.partpoints import PartitionPoints import math @@ -51,6 +51,7 @@ class PartitionedDynamicShift(Elaboratable): end = keys[j] row.append(Signal(width - start, name="matrix[%d][%d]" % (i, j))) + start = end matrix.append(row) # break out both the input and output into partition-stratified blocks @@ -74,8 +75,15 @@ class PartitionedDynamicShift(Elaboratable): a = a_intervals[j] end = keys[i] result_width = matrix[i][j].width - bwidth = math.ceil(math.log2(result_width + 1)) - comb += matrix[i][j].eq(a << b[:bwidth]) + rw = math.ceil(math.log2(result_width + 1)) + # XXX! + bw = math.ceil(math.log2(self.output.width + 1)) + tshift = Signal(bw, name="ts%d_%d" % (i, j), reset_less=True) + with m.If(b[:bw] < 1<