Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

memtest/MemtestWriter: fix 'busy status stuck' bug

  • Loading branch information...
commit 9ab22fe3b179d1ca5c756e72ed2782cb3b0bef47 1 parent 3d899f0
Sébastien Bourdeauducq authored July 13, 2013

Showing 1 changed file with 18 additions and 5 deletions. Show diff stats Hide diff stats

  1. 23  milkymist/memtest/__init__.py
23  milkymist/memtest/__init__.py
@@ -2,7 +2,7 @@
2 2
 from migen.genlib.misc import optree
3 3
 from migen.bank.description import *
4 4
 from migen.actorlib import dma_lasmi
5  
-from migen.actorlib.spi import MODE_SINGLE_SHOT, DMAReadController, DMAWriteController
  5
+from migen.actorlib.spi import *
6 6
 
7 7
 class LFSR(Module):
8 8
 	def __init__(self, n_out, n_state=31, taps=[27, 30]):
@@ -53,7 +53,8 @@ class MemtestWriter(Module):
53 53
 	def __init__(self, lasmim):
54 54
 		self._r_magic = CSRStatus(16)
55 55
 		self._r_reset = CSR()
56  
-		self.submodules._dma = DMAWriteController(dma_lasmi.Writer(lasmim), MODE_SINGLE_SHOT)
  56
+		self._r_shoot = CSR()
  57
+		self.submodules._dma = DMAWriteController(dma_lasmi.Writer(lasmim), MODE_EXTERNAL)
57 58
 
58 59
 		###
59 60
 
@@ -63,14 +64,26 @@ def __init__(self, lasmim):
63 64
 		self.submodules += lfsr
64 65
 		self.comb += lfsr.reset.eq(self._r_reset.re)
65 66
 
  67
+		en = Signal()
  68
+		en_counter = Signal(lasmim.aw)
  69
+		self.comb += en.eq(en_counter != 0)
  70
+		self.sync += [
  71
+			If(self._r_shoot.re,
  72
+				en_counter.eq(self._dma.length)
  73
+			).Elif(lfsr.ce,
  74
+				en_counter.eq(en_counter - 1)
  75
+			)
  76
+		]
  77
+
66 78
 		self.comb += [
67  
-			self._dma.data.stb.eq(1),
68  
-			lfsr.ce.eq(self._dma.data.ack),
  79
+			self._dma.trigger.eq(self._r_shoot.re),
  80
+			self._dma.data.stb.eq(en),
  81
+			lfsr.ce.eq(en & self._dma.data.ack),
69 82
 			self._dma.data.payload.d.eq(lfsr.o)
70 83
 		]
71 84
 
72 85
 	def get_csrs(self):
73  
-		return [self._r_magic, self._r_reset] + self._dma.get_csrs()
  86
+		return [self._r_magic, self._r_reset, self._r_shoot] + self._dma.get_csrs()
74 87
 
75 88
 class MemtestReader(Module):
76 89
 	def __init__(self, lasmim):

0 notes on commit 9ab22fe

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