From 5a1c91609c64eace13bbb46902dba277e318aa9e Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 9 Oct 2021 17:22:36 +0100 Subject: [PATCH] convert PartitionedRepl over to new "PartType" format --- src/ieee754/part/partsig.py | 21 +++++++++++++++--- src/ieee754/part/test/test_partsig.py | 1 - src/ieee754/part_repl/prepl.py | 4 ++-- src/ieee754/part_repl/repl.py | 32 +++++++++++++++++++-------- 4 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/ieee754/part/partsig.py b/src/ieee754/part/partsig.py index 880ea18b..d02dac4a 100644 --- a/src/ieee754/part/partsig.py +++ b/src/ieee754/part/partsig.py @@ -30,7 +30,7 @@ from ieee754.part_cat.pcat import PCat from ieee754.part_repl.prepl import PRepl from operator import or_, xor, and_, not_ -from nmigen import (Signal, Const) +from nmigen import (Signal, Const, Cat) from nmigen.hdl.ast import UserValue, Shape @@ -56,6 +56,21 @@ for name in ['add', 'eq', 'gt', 'ge', 'ls', 'xor', 'bool', 'all']: modnames[name] = 0 + +class PartType: # TODO decide name + def __init__(self, psig): + self.psig = psig + def get_mask(self): + return list(self.psig.partpoints.values()) + def get_switch(self): + return Cat(self.get_mask()) + def get_cases(self): + return range(1<