From c346d214c2d0380c2a0ac5121d6733437bc93fc4 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Fri, 19 Aug 2022 11:01:08 +0300 Subject: [PATCH] power_fields: move BitRange to selectable_int --- src/openpower/decoder/power_fields.py | 17 ++++------------- src/openpower/decoder/power_fieldsn.py | 4 +++- src/openpower/decoder/selectable_int.py | 13 ++++++++++++- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/openpower/decoder/power_fields.py b/src/openpower/decoder/power_fields.py index 8f8d5544..7e21d3a1 100644 --- a/src/openpower/decoder/power_fields.py +++ b/src/openpower/decoder/power_fields.py @@ -1,16 +1,7 @@ -from collections import OrderedDict, namedtuple -from openpower.decoder.power_enums import find_wiki_file +from collections import namedtuple - -class BitRange(OrderedDict): - """BitRange: remaps from straight indices (0,1,2..) to bit numbers - """ - - def __getitem__(self, subscript): - if isinstance(subscript, slice): - return list(self.values())[subscript] - else: - return OrderedDict.__getitem__(self, subscript) +from openpower.decoder.power_enums import find_wiki_file as _find_wiki_file +from openpower.decoder.selectable_int import BitRange as _BitRange def decode_instructions(form): @@ -116,7 +107,7 @@ class DecodeFields: assert name_on_wiki is None fname = "fields.txt" name_on_wiki = "fields.text" - self.fname = find_wiki_file(name_on_wiki) + self.fname = _find_wiki_file(name_on_wiki) @property def form_names(self): diff --git a/src/openpower/decoder/power_fieldsn.py b/src/openpower/decoder/power_fieldsn.py index e0a02bae..982bd645 100644 --- a/src/openpower/decoder/power_fieldsn.py +++ b/src/openpower/decoder/power_fieldsn.py @@ -1,9 +1,11 @@ from collections import OrderedDict -from openpower.decoder.power_fields import DecodeFields, BitRange +from openpower.decoder.power_fields import DecodeFields from nmigen import Module, Elaboratable, Signal, Cat from nmigen.cli import rtlil from copy import deepcopy +from openpower.decoder.selectable_int import BitRange + class SignalBitRange(BitRange): def __init__(self, signal): diff --git a/src/openpower/decoder/selectable_int.py b/src/openpower/decoder/selectable_int.py index 22fb8311..ce9ad0a4 100644 --- a/src/openpower/decoder/selectable_int.py +++ b/src/openpower/decoder/selectable_int.py @@ -2,7 +2,7 @@ import unittest import struct from copy import copy import functools -from openpower.decoder.power_fields import BitRange +from collections import OrderedDict from operator import (add, sub, mul, floordiv, truediv, mod, or_, and_, xor, neg, inv, lshift, rshift, lt, eq) from openpower.util import log @@ -18,6 +18,17 @@ def check_extsign(a, b): return SelectableInt(b.value, a.bits) +class BitRange(OrderedDict): + """BitRange: remaps from straight indices (0,1,2..) to bit numbers + """ + + def __getitem__(self, subscript): + if isinstance(subscript, slice): + return list(self.values())[subscript] + else: + return OrderedDict.__getitem__(self, subscript) + + @functools.total_ordering class FieldSelectableInt: """FieldSelectableInt: allows bit-range selection onto another target -- 2.30.2