Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

memtest/LFSR: use module decorators

  • Loading branch information...
commit 8e04de524bf4ec77cd131076c9a8de181f83c8bc 1 parent 764e7c0
Sébastien Bourdeauducq authored

Showing 1 changed file with 7 additions and 10 deletions. Show diff stats Hide diff stats

  1. 17  milkymist/memtest/__init__.py
17  milkymist/memtest/__init__.py
@@ -4,10 +4,10 @@
4 4
 from migen.actorlib import dma_lasmi
5 5
 from migen.actorlib.spi import *
6 6
 
  7
+@DecorateModule(InsertReset)
  8
+@DecorateModule(InsertCE)
7 9
 class LFSR(Module):
8 10
 	def __init__(self, n_out, n_state=31, taps=[27, 30]):
9  
-		self.ce = Signal()
10  
-		self.reset = Signal()
11 11
 		self.o = Signal(n_out)
12 12
 
13 13
 		###
@@ -20,18 +20,15 @@ def __init__(self, n_out, n_state=31, taps=[27, 30]):
20 20
 			curval.insert(0, nv)
21 21
 			curval.pop()
22 22
 
23  
-		self.sync += If(self.reset,
24  
-				state.eq(0),
25  
-				self.o.eq(0)
26  
-			).Elif(self.ce,
27  
-				state.eq(Cat(*curval[:n_state])),
28  
-				self.o.eq(Cat(*curval))
29  
-			)
  23
+		self.sync += [
  24
+			state.eq(Cat(*curval[:n_state])),
  25
+			self.o.eq(Cat(*curval))
  26
+		]
30 27
 
31 28
 def _print_lfsr_code():
32 29
 	from migen.fhdl import verilog
33 30
 	dut = LFSR(3, 4, [3, 2])
34  
-	print(verilog.convert(dut, ios={dut.ce, dut.o}))
  31
+	print(verilog.convert(dut, ios={dut.ce, dut.reset, dut.o}))
35 32
 
36 33
 class _LFSRTB(Module):
37 34
 	def __init__(self, *args, **kwargs):

0 notes on commit 8e04de5

Please sign in to comment.
Something went wrong with that request. Please try again.