From 43e728ffbc5679ccf25ce88fba61c75c7c1b5703 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 17 Aug 2020 12:11:05 +0100 Subject: [PATCH] allow byterev to accept a scalar int --- src/nmutil/byterev.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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): -- 2.30.2