From: Luke Kenneth Casson Leighton Date: Fri, 24 Jul 2020 09:25:59 +0000 (+0100) Subject: made it clear what is meant by the slice numbering being inverted X-Git-Tag: semi_working_ecp5~590 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=692bedeadeb89dbc6f7d818be091c75807cb88e0;p=soc.git made it clear what is meant by the slice numbering being inverted see https://bugs.libre-soc.org/show_bug.cgi?id=325#c126 --- 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)