From: Luke Kenneth Casson Leighton Date: Wed, 29 Sep 2021 16:12:51 +0000 (+0100) Subject: add assert to check partition jump point size X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=91236094c321b06c82ac31013b0775e4cb0c1ae7;p=ieee754fpu.git add assert to check partition jump point size --- diff --git a/src/ieee754/part_mul_add/partpoints.py b/src/ieee754/part_mul_add/partpoints.py index 8ae23810..88da9ae9 100644 --- a/src/ieee754/part_mul_add/partpoints.py +++ b/src/ieee754/part_mul_add/partpoints.py @@ -37,14 +37,15 @@ def make_partition2(mask, width): mask len = 7, width == 64 will return: {8: mask[0], 16: mask[1], 24: mask[2], .... 56: mask[6]} """ + if isinstance(mask, dict): # convert dict/partpoints to sequential list + mask = list(mask.values()) mlen = len(mask) + 1 # ONE MORE partitions than break-points jumpsize = width // mlen # amount to jump by (size of each partition) ppoints = {} ppos = jumpsize + print ("make_partition2", width, mask, len(mask), mlen, jumpsize) + assert jumpsize > 0, "incorrect width // mlen (%d // %d)" % (width, mlen) midx = 0 - if isinstance(mask, dict): # convert dict/partpoints to sequential list - mask = list(mask.values()) - print ("make_partition2", width, mask, mlen, jumpsize) while ppos < width and midx < mlen: # -1, ignore last bit print (" make_partition2", ppos, width, midx, mlen) ppoints[ppos] = mask[midx]