allow byterev to accept a scalar int
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 17 Aug 2020 11:11:05 +0000 (12:11 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 17 Aug 2020 11:11:05 +0000 (12:11 +0100)
src/nmutil/byterev.py

index c38f694f1a7a6df38d0f7e44a5daa4e059ec63ac..2e5c41ab26be17c37642a372af9516f4207e02a5 100644 (file)
@@ -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):