From b0f94a3f110435ac8c4f5e8a25998b2977b97545 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 4 Apr 2020 21:53:03 +0100 Subject: [PATCH] import EXTS which over-extends to 256 bits --- src/soc/decoder/helpers.py | 15 ++++++++++++--- src/soc/decoder/pseudo/pywriter.py | 5 +++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/soc/decoder/helpers.py b/src/soc/decoder/helpers.py index 941bcbc8..98b3e672 100644 --- a/src/soc/decoder/helpers.py +++ b/src/soc/decoder/helpers.py @@ -7,17 +7,26 @@ def exts(value, bits): return (value & (sign - 1)) - (value & sign) +def EXTS(value): + """ extends sign bit out from current MSB to all 256 bits + """ + assert isinstance(value, SelectableInt) + return SelectableInt(exts(value.value, value.bits) & ((1 << 256)-1), 256) + def EXTS64(value): - if isinstance(value, SelectableInt): - value = value.value - return SelectableInt(exts(value, 32) & ((1 << 64)-1), 64) + """ extends sign bit out from current MSB to 64 bits + """ + assert isinstance(value, SelectableInt) + return SelectableInt(exts(value.value, value.bits) & ((1 << 64)-1), 64) +# XXX should this explicitly extend from 32 to 64? def EXTZ64(value): if isinstance(value, SelectableInt): value = value.value return SelectableInt(value & ((1<<32)-1), 64) + def rotl(value, bits, wordlen): mask = (1 << wordlen) - 1 bits = bits & (wordlen - 1) diff --git a/src/soc/decoder/pseudo/pywriter.py b/src/soc/decoder/pseudo/pywriter.py index 049a1f39..40d10e8c 100644 --- a/src/soc/decoder/pseudo/pywriter.py +++ b/src/soc/decoder/pseudo/pywriter.py @@ -16,7 +16,7 @@ header = """\ # auto-generated by pywriter.py, do not edit or commit from soc.decoder.isa.caller import ISACaller, inject -from soc.decoder.helpers import (EXTS64, EXTZ64, ROTL64, ROTL32, MASK,) +from soc.decoder.helpers import (EXTS, EXTS64, EXTZ64, ROTL64, ROTL32, MASK,) from soc.decoder.selectable_int import SelectableInt from soc.decoder.selectable_int import selectconcat as concat from soc.decoder.orderedset import OrderedSet @@ -72,8 +72,9 @@ class PyISAWriter(ISA): if __name__ == '__main__': isa = PyISAWriter() - isa.write_pysource('fixedlogical') + isa.write_pysource('branch') exit(0) + isa.write_pysource('fixedlogical') isa.write_pysource('fixedstore') isa.write_pysource('fixedload') isa.write_pysource('comparefixed') -- 2.30.2