From 58fe2311806ea13320844944b5abd01fe26a9f1a Mon Sep 17 00:00:00 2001 From: Kia <kia@special-circumstanc.es> Date: Sun, 4 Apr 2021 20:14:13 -0600 Subject: [PATCH] this is the best way to do a synthesizable cutting-off of the top K bits, i believe. --- rtl_lib/shift_testing.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 rtl_lib/shift_testing.py diff --git a/rtl_lib/shift_testing.py b/rtl_lib/shift_testing.py new file mode 100644 index 0000000..76f5f2c --- /dev/null +++ b/rtl_lib/shift_testing.py @@ -0,0 +1,30 @@ +from enum import Enum +from nmigen import * +from nmigen.hdl.rec import * +from nmigen.asserts import * +from nmigen.cli import main + +class DummyPlug(Elaboratable): + + #def __init__(self): + + + + def elaborate(self, platform): + m = Module() + egg = Signal(8, reset=219) + foo = Signal(8) + # the "constant mask" idea lets us use a constant compile-time bitmask while still letting us lop off a variable number of bits + + counter = Signal(8) + m.d.sync += counter.eq(counter+1) + m.d.sync += foo.eq(((egg<<counter)&0xff)>>counter) + + return m + + + +if __name__ == '__main__': + baka =DummyPlug() + main(baka) + #platform.build(DummyPlug()) -- GitLab