fix silly errors in power_fieldsn.py
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 19 Mar 2020 06:53:36 +0000 (06:53 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 19 Mar 2020 06:53:36 +0000 (06:53 +0000)
src/soc/decoder/power_fieldsn.py
src/soc/decoder/test/test_decoder_gas.py

index 19d371029a51c81f91012544c12d794d28b575c6..819c40deac9c9b4f00dc2cdd859bc0e8ff3df4a3 100644 (file)
@@ -15,8 +15,7 @@ class SignalBitRange(BitRange):
 
     def __getitem__(self, subs):
         # *sigh* field numberings are bit-inverted.  PowerISA 3.0B section 1.3.2
-        print (dir(self))
-        print (self.items())
+        print ("SignalBitRange", subs, len(self), self.items())
         if isinstance(subs, slice):
             res = []
             print (subs)
@@ -28,9 +27,9 @@ class SignalBitRange(BitRange):
             if stop is None:
                 stop = -1
             if start < 0:
-                start = len(self) + start
+                start = len(self) + start + 1
             if stop < 0:
-                stop = len(self) + stop
+                stop = len(self) + stop + 1
             print ("range", start, stop, step)
             for t in range(start, stop, step):
                 t = len(self) - 1 - t # invert field back
@@ -40,7 +39,7 @@ class SignalBitRange(BitRange):
             return Cat(*res)
         else:
             if subs < 0:
-                subs = len(self) + sub
+                subs = len(self) + subs
             subs = len(self) - 1 - subs # invert field back
             k = OrderedDict.__getitem__(self, subs)
             return self.signal[self._rev(k)] # reverse-order here
index 865192e9bab79d22cf00adbcb1f2334d347b06fb..d575f9b15ca8574e436c7364bcd79cae7991b861 100644 (file)
@@ -80,8 +80,9 @@ class DecoderTestCase(FHDLTestCase):
                 r3 = Register(random.randrange(32))
 
                 instruction_str = self.generate_opcode_string(opcode, r1, r2, r3)
-                print(instruction_str)
+                print("instr", instruction_str.strip())
                 instruction_bin = self.get_assembled_instruction(instruction_str)
+                print("code", hex(instruction_bin), bin(instruction_bin))
 
                 yield instruction.eq(instruction_bin)
                 yield Delay(1e-6)