# 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)
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
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
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
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
#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):