From 486c76dbef776025ae327997cf602f6dc3236fac Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 18 Mar 2020 16:10:32 +0000 Subject: [PATCH] use function which reverses bit-order --- src/soc/decoder/power_fieldsn.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/soc/decoder/power_fieldsn.py b/src/soc/decoder/power_fieldsn.py index 8a12e40d..fdba7c05 100644 --- a/src/soc/decoder/power_fieldsn.py +++ b/src/soc/decoder/power_fieldsn.py @@ -9,9 +9,12 @@ class SignalBitRange(BitRange): BitRange.__init__(self) self.signal = signal + def _rev(self, k): + width = self.signal.shape()[0] + return width-1-k + def __getitem__(self, subs): # *sigh* field numberings are bit-inverted. PowerISA 3.0B section 1.3.2 - width = self.signal.shape()[0] print (dir(self)) print (self.items()) if isinstance(subs, slice): @@ -32,11 +35,11 @@ class SignalBitRange(BitRange): for t in range(start, stop, step): k = OrderedDict.__getitem__(self, t) print ("t", t, k) - res.append(self.signal[width-k-1]) # reverse-order here + res.append(self.signal[self._rev(k)]) # reverse-order here return Cat(*res) else: k = OrderedDict.__getitem__(self, subs) - return self.signal[width-k-1] # reverse-order here + return self.signal[self._rev(k)] # reverse-order here print ("translated", subs, translated) -- 2.30.2