From: Luke Kenneth Casson Leighton Date: Mon, 25 Oct 2021 17:30:53 +0000 (+0100) Subject: add two new functions to PartType: get_num_elements and get_el_range X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6d4768761c73582467ab684d87c5d8094639e1c9;p=ieee754fpu.git add two new functions to PartType: get_num_elements and get_el_range --- diff --git a/src/ieee754/part/partsig.py b/src/ieee754/part/partsig.py index 61b64e66..cf1e6678 100644 --- a/src/ieee754/part/partsig.py +++ b/src/ieee754/part/partsig.py @@ -59,6 +59,24 @@ for name in ['add', 'eq', 'gt', 'ge', 'ls', 'xor', 'bool', 'all']: modnames[name] = 0 +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<