Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

edid.py: sample SCL only every 64 clock cycles, to avoid bouncing

Possibly due to SCL rising fairly slowly (in the 0.5-1 us range),
bouncing has been observed while crossing the "forbidden" region
between Vil(max) and Vih(min).

By lowering the sample rate from once per system clock to once
every 64 clock cycles, we make sure we sample at most once during
the bounce interval and thus never see a false edge. (Although we
may see a rising edge one sample time late, which is perfectly
harmless.)
  • Loading branch information...
commit 7a6e56492cd5d446007d6bfe851d14ee3a850aa7 1 parent 950d3a4
Werner Almesberger authored April 12, 2013 sbourdeauducq committed April 12, 2013

Showing 1 changed file with 9 additions and 8 deletions. Show diff stats Hide diff stats

  1. 17  milkymist/dvisampler/edid.py
17  milkymist/dvisampler/edid.py
@@ -23,24 +23,25 @@ def __init__(self, pads, default=_default_edid):
23 23
 
24 24
 		###
25 25
 
26  
-		scl_i = Signal()
  26
+		scl_raw = Signal()
27 27
 		sda_i = Signal()
28 28
 		sda_drv = Signal()
29 29
 		_sda_drv_reg = Signal()
30 30
 		_sda_i_async = Signal()
31 31
 		self.sync += _sda_drv_reg.eq(sda_drv)
32 32
 		self.specials += [
33  
-			MultiReg(pads.scl, scl_i),
  33
+			MultiReg(pads.scl, scl_raw),
34 34
 			Tristate(pads.sda, 0, _sda_drv_reg, _sda_i_async),
35 35
 			MultiReg(_sda_i_async, sda_i)
36 36
 		]
37 37
 
38  
-		# FIXME: understand what is really going on here and get rid of that workaround
39  
-		for x in range(20):
40  
-			new_scl = Signal()
41  
-			self.sync += new_scl.eq(scl_i)
42  
-			scl_i = new_scl
43  
-		#
  38
+		scl_i = Signal()
  39
+		samp_count = Signal(6)
  40
+		samp_carry = Signal()
  41
+		self.sync += [
  42
+			Cat(samp_count, samp_carry).eq(samp_count + 1),
  43
+			If(samp_carry, scl_i.eq(scl_raw))
  44
+		]
44 45
 
45 46
 		scl_r = Signal()
46 47
 		sda_r = Signal()

0 notes on commit 7a6e564

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