From 692bedeadeb89dbc6f7d818be091c75807cb88e0 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 24 Jul 2020 10:25:59 +0100 Subject: [PATCH] made it clear what is meant by the slice numbering being inverted see https://bugs.libre-soc.org/show_bug.cgi?id=325#c126 --- src/soc/consts.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/soc/consts.py b/src/soc/consts.py index fe29743e..8ed63eab 100644 --- a/src/soc/consts.py +++ b/src/soc/consts.py @@ -13,12 +13,15 @@ def field_slice(start, end): where the start and end bits use IBM conventions. start < end. The range specified is inclusive on both ends. """ + start = 63 - start + end = 63 - end + # XXX must do the endian-reversing BEFORE doing the comparison + # if done after, that instead asserts that (after modification) + # start *MUST* be greater than end! if start >= end: raise ValueError( "start ({}) must be less than end ({})".format(start, end) ) - start = 63 - start - end = 63 - end return slice(end, start + 1) -- 2.30.2