From 941156a34b3d02f8571b28fc6d54efb5bca6f666 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 15 Feb 2020 14:30:38 +0000 Subject: [PATCH] clip shift amount --- src/ieee754/part_shift/part_shift_dynamic.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/ieee754/part_shift/part_shift_dynamic.py b/src/ieee754/part_shift/part_shift_dynamic.py index d991e5f8..ccfc5d04 100644 --- a/src/ieee754/part_shift/part_shift_dynamic.py +++ b/src/ieee754/part_shift/part_shift_dynamic.py @@ -120,13 +120,16 @@ class PartitionedDynamicShift(Elaboratable): # the partition mask, this calculates that with a mux # chain - # This computes the partial results table + # This computes the partial results table. note that + # the shift amount is truncated because there's no point + # trying to shift data by 64 bits if the result width + # is only 8. shifter = Signal(shiftbits, name="shifter%d" % i, reset_less=True) - #with m.If(element > shiftbits): - # comb += shifter.eq(shiftbits) - #with m.Else(): - # comb += shifter.eq(element) + with m.If(element > shiftbits): + comb += shifter.eq(shiftbits) + with m.Else(): + comb += shifter.eq(element) comb += shifter.eq(element) partial = Signal(reswid, name="partial%d" % i, reset_less=True) comb += partial.eq(a_intervals[i] << shifter) -- 2.30.2