From: Luke Kenneth Casson Leighton Date: Mon, 17 Aug 2020 11:11:05 +0000 (+0100) Subject: allow byterev to accept a scalar int X-Git-Tag: 24jan2021_ls180~28 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=43e728ffbc5679ccf25ce88fba61c75c7c1b5703;p=nmutil.git allow byterev to accept a scalar int --- diff --git a/src/nmutil/byterev.py b/src/nmutil/byterev.py index c38f694..2e5c41a 100644 --- a/src/nmutil/byterev.py +++ b/src/nmutil/byterev.py @@ -9,6 +9,15 @@ def byte_reverse(m, name, data, length): """ comb = m.d.comb data_r = Signal.like(data, name=name) + + if isinstance(length, int): + j = length + for i in range(j): + dest = data_r.word_select(i, 8) + src = data.word_select(j-1-i, 8) + comb += dest.eq(src) + return data_r + with m.Switch(length): for j in [1,2,4,8]: with m.Case(j):