From 740a02e64970937e68a04dbe3a71e4111868ddb7 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 21 Feb 2021 15:27:40 +0000 Subject: [PATCH] extra comments in byte_reverse function --- src/nmutil/byterev.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/nmutil/byterev.py b/src/nmutil/byterev.py index a6cb4fa..7dad450 100644 --- a/src/nmutil/byterev.py +++ b/src/nmutil/byterev.py @@ -6,7 +6,7 @@ from nmigen import Signal, Cat -# TODO: turn this into a module +# TODO: turn this into a module? def byte_reverse(m, name, data, length): """byte_reverse: unlike nmigen word_select this takes a dynamic length @@ -16,6 +16,7 @@ def byte_reverse(m, name, data, length): comb = m.d.comb data_r = Signal.like(data, name=name) + # if length is a static integer, we do not require a Case statement if isinstance(length, int): j = length rev = [] @@ -25,6 +26,7 @@ def byte_reverse(m, name, data, length): comb += data_r.eq(Cat(*rev)) return data_r + # Switch statement needed: dynamic length had better be = 1,2,4 or 8 with m.Switch(length): for j in [1,2,4,8]: with m.Case(j): @@ -34,4 +36,3 @@ def byte_reverse(m, name, data, length): comb += data_r.eq(Cat(*rev)) return data_r - -- 2.30.2