Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

memtest/LFSR: use module decorators

  • Loading branch information...
commit 8e04de524bf4ec77cd131076c9a8de181f83c8bc 1 parent 764e7c0
@sbourdeauducq sbourdeauducq authored
Showing with 7 additions and 10 deletions.
  1. +7 −10 milkymist/memtest/__init__.py
View
17 milkymist/memtest/__init__.py
@@ -4,10 +4,10 @@
from migen.actorlib import dma_lasmi
from migen.actorlib.spi import *
+@DecorateModule(InsertReset)
+@DecorateModule(InsertCE)
class LFSR(Module):
def __init__(self, n_out, n_state=31, taps=[27, 30]):
- self.ce = Signal()
- self.reset = Signal()
self.o = Signal(n_out)
###
@@ -20,18 +20,15 @@ def __init__(self, n_out, n_state=31, taps=[27, 30]):
curval.insert(0, nv)
curval.pop()
- self.sync += If(self.reset,
- state.eq(0),
- self.o.eq(0)
- ).Elif(self.ce,
- state.eq(Cat(*curval[:n_state])),
- self.o.eq(Cat(*curval))
- )
+ self.sync += [
+ state.eq(Cat(*curval[:n_state])),
+ self.o.eq(Cat(*curval))
+ ]
def _print_lfsr_code():
from migen.fhdl import verilog
dut = LFSR(3, 4, [3, 2])
- print(verilog.convert(dut, ios={dut.ce, dut.o}))
+ print(verilog.convert(dut, ios={dut.ce, dut.reset, dut.o}))
class _LFSRTB(Module):
def __init__(self, *args, **kwargs):
Please sign in to comment.
Something went wrong with that request. Please try again.