Actually forward the field width to field_slice()
authorCesar Strauss <cestrauss@gmail.com>
Sat, 20 Feb 2021 21:12:03 +0000 (18:12 -0300)
committerCesar Strauss <cestrauss@gmail.com>
Sat, 20 Feb 2021 21:21:52 +0000 (18:21 -0300)
This means that field extraction of multi-bit subfields, for field sizes
other than 64 bits, was buggy up to now.

Fortunately, there were no users of non-default field sizes so far.

src/soc/consts.py

index d555e55b4824deec060581afc5cdf1b5961849e3..108a730d5db8d47d7c7267104af3167b4a9efc24 100644 (file)
@@ -77,7 +77,7 @@ def field(r, msb0_start, msb0_end=None, field_width=64):
     if msb0_end is None:
         return r[(field_width - 1) - msb0_start]
     else:
-        return r[field_slice(msb0_start, msb0_end)]
+        return r[field_slice(msb0_start, msb0_end, field_width)]
 
 
 def sel(r, sel_bits, field_width=None):