return "%s_%s" % (pname, field)
+class PatternOpcode(str):
+ pass
+
+
+def parse_opcode(opcode, opint=True):
+ assert opint
+ if isinstance(opcode, (int, PatternOpcode)):
+ return opcode
+ assert isinstance(opcode, str)
+ assert opcode.startswith('0b')
+ if '-' not in opcode:
+ opcode = int(opcode, 0)
+ else:
+ opcode = PatternOpcode(opcode[2:])
+ return opcode
+
+
class PowerOp:
"""PowerOp - a dynamic class that stores (subsets of) CSV rows of data
about a PowerISA instruction. this is a "micro-code" expanded format
mask = self.suffix_mask(d)
print("mask", hex(mask))
for row in d.opcodes:
- opcode = row['opcode']
- if d.opint and '-' not in opcode:
- opcode = int(opcode, 0)
+ opcode = parse_opcode(row['opcode'], d.opint)
key = opcode & mask
opcode = opcode >> d.suffix
if key not in divided:
bitsel = (d.suffix+d.bitsel[0], d.bitsel[1])
sd = Subdecoder(pattern=None, opcodes=row,
bitsel=bitsel, suffix=None,
- opint=False, subdecoders=[])
+ opint=True, subdecoders=[])
mname = get_pname("dec_sub%d" % key, self.pname)
subdecoder = PowerDecoder(width=32, dec=sd,
name=mname,
case_does_something = True
eq += seqs
for row in d.opcodes:
- opcode = row['opcode']
- if d.opint:
- assert opcode.startswith('0b')
- if '-' not in opcode:
- opcode = int(opcode, 0)
- else:
- opcode = opcode[2:]
+ opcode = parse_opcode(row['opcode'], d.opint)
if not row['unit']:
continue
if self.row_subsetfn:
dec.append(Subdecoder(pattern=None, opint=True, opcodes=opcodes,
bitsel=(26, 32), suffix=None, subdecoders=pminor))
opcodes = get_csv("extra.csv")
- dec.append(Subdecoder(pattern=None, opint=False, opcodes=opcodes,
+ dec.append(Subdecoder(pattern=None, opint=True, opcodes=opcodes,
bitsel=(0, 32), suffix=None, subdecoders=[]))
return TopPowerDecoder(32, dec, name=name, col_subset=col_subset,
# # self.run_tst(10, "minor_31.csv", suffix=(5, 10))
# def test_extra(self):
- # self.run_tst(32, "extra.csv", opint=False)
- # self.generate_ilang(32, "extra.csv", opint=False)
+ # self.run_tst(32, "extra.csv", opint=True)
+ # self.generate_ilang(32, "extra.csv", opint=True)
if __name__ == "__main__":