From: Luke Kenneth Casson Leighton Date: Mon, 1 Feb 2021 14:49:01 +0000 (+0000) Subject: sort out SelectableInt bit-ordering for identifying SVP64 fields X-Git-Tag: convert-csv-opcode-to-binary~268 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6fff2d13f15a7507a7894668e1b117a13148cea6;p=soc.git sort out SelectableInt bit-ordering for identifying SVP64 fields --- diff --git a/src/soc/decoder/isa/caller.py b/src/soc/decoder/isa/caller.py index 38a439f0..c58ad248 100644 --- a/src/soc/decoder/isa/caller.py +++ b/src/soc/decoder/isa/caller.py @@ -214,7 +214,6 @@ class PC: # Simple-V: see https://libre-soc.org/openpower/sv -# also soc.sv.svstate SVSTATEREC class SVP64State: def __init__(self, init=0): self.spr = SelectableInt(init, 32) @@ -614,7 +613,9 @@ class ISACaller: pfx = SVP64PrefixFields() pfx.insn.value = opcode major = pfx.major.asint(msb0=True) # MSB0 inversion - print ("prefix test: opcode:", major, bin(major)) + print ("prefix test: opcode:", major, bin(major), + pfx.insn[7] == 0b1, pfx.insn[9] == 0b1, + bin(pfx.rm.asint(msb0=True))) def execute_one(self): """execute one instruction diff --git a/src/soc/decoder/selectable_int.py b/src/soc/decoder/selectable_int.py index 53e85036..7f60f5e4 100644 --- a/src/soc/decoder/selectable_int.py +++ b/src/soc/decoder/selectable_int.py @@ -117,8 +117,10 @@ class FieldSelectableInt: def asint(self, msb0=False): res = 0 brlen = len(self.br) - for i, key in enumerate(self.br): - res |= self.si[key].value << ((brlen-i-1) if msb0 else i) + for i, key in self.br.items(): + bit = self.si[key].value + #print("asint", i, key, bit) + res |= bit << ((brlen-i-1) if msb0 else i) return res @@ -277,7 +279,6 @@ class SelectableInt: def __getitem__(self, key): if isinstance(key, SelectableInt): key = key.value - print("getitem", key, self.bits, hex(self.value)) if isinstance(key, int): assert key < self.bits, "key %d accessing %d" % (key, self.bits) assert key >= 0 @@ -286,6 +287,7 @@ class SelectableInt: key = self.bits - (key + 1) value = (self.value >> key) & 1 + print("getitem", key, self.bits, hex(self.value), value) return SelectableInt(value, 1) elif isinstance(key, slice): assert key.step is None or key.step == 1 @@ -300,6 +302,7 @@ class SelectableInt: #print ("__getitem__ slice num bits", start, stop, bits) mask = (1 << bits) - 1 value = (self.value >> start) & mask + print("getitem", key, self.bits, hex(self.value), value) return SelectableInt(value, bits) def __setitem__(self, key, value):