whoops asmcode length (number of instructions) went over 256, caused
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 8 Jul 2021 21:34:29 +0000 (22:34 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 8 Jul 2021 21:34:29 +0000 (22:34 +0100)
asmcode in simulator to "wrap" and get the wrong instruction name,
and then execute totally the wrong simulated instruction

src/openpower/decoder/decode2execute1.py
src/openpower/decoder/power_decoder.py
src/openpower/decoder/power_enums.py

index cd012f6fa58f6ba9012f54df84adea618fe6a437..1d4808383be8595580a5342793a52dba92828557 100644 (file)
@@ -10,9 +10,11 @@ from openpower.decoder.power_enums import (MicrOp, CryIn, Function,
 from openpower.consts import TT
 from openpower.exceptions import LDSTException
 from openpower.decoder.power_svp64_rm import sv_input_record_layout
+from openpower.decoder.power_enums import asmlen
 
 from openpower.util import log
 
+
 class Data(Record):
 
     def __init__(self, width, name):
@@ -102,7 +104,7 @@ class Decode2ToExecute1Type(RecordObject):
         RecordObject.__init__(self, name=name)
 
         if asmcode:
-            self.asmcode = Signal(8, reset_less=True) # only for simulator
+            self.asmcode = Signal(asmlen, reset_less=True) # only for simulator
         self.write_reg = Data(7, name="rego")
         self.write_ea = Data(7, name="ea") # for LD/ST in update mode
         self.read_reg1 = Data(7, name="reg1")
index 3bce7e8473b67d341aaccc438d6a04a2e2a7820e..024953a57ad98929ecad5c872bbe8f05b207f9f6 100644 (file)
@@ -96,7 +96,8 @@ from openpower.decoder.power_enums import (Function, Form, MicrOp,
                                      RC, LdstLen, LDSTMode, CryIn,
                                      single_bit_flags, CRInSel,
                                      CROutSel, get_signal_name,
-                                     default_values, insns, asmidx)
+                                     default_values, insns, asmidx,
+                                     asmlen)
 from openpower.decoder.power_fields import DecodeFields
 from openpower.decoder.power_fieldsn import SigDecode, SignalBitRange
 from openpower.decoder.power_svp64 import SVP64RM
@@ -120,7 +121,7 @@ Subdecoder = namedtuple(  # fix autoformatter
 power_op_types = {'function_unit': Function,
                   'internal_op': MicrOp,
                   'form': Form,
-                  'asmcode': 8,
+                  'asmcode': asmlen,
                   'SV_Etype': SVEtype,
                   'SV_Ptype': SVPtype,
                   'in1_sel': In1Sel,
index 67f81c3bc6b3265104bab56d9ab59ca24d96abd6..41d712e273b886a1e4e6fc148bc5b7420da8b3d9 100644 (file)
@@ -303,6 +303,9 @@ for i, insn in enumerate(_insns):
     insns[i] = insn
     asmidx[insn] = i
 
+# must be long enough to cover all instructions
+asmlen = len(_insns).bit_length()
+
 # Internal Operation numbering.  Add new opcodes here (FPADD, FPMUL etc.)