Skip to content
Snippets Groups Projects
Commit 58fe2311 authored by Kia's avatar Kia
Browse files

this is the best way to do a synthesizable cutting-off of the top K bits, i believe.

parent bb6141f3
No related branches found
No related tags found
No related merge requests found
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())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment