Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

framebuffer: video timing generator

  • Loading branch information...
commit 309124711fad64b0e6d8881bff44fe10fb4dc938 1 parent 16c6e4f
Sébastien Bourdeauducq authored

Showing 1 changed file with 55 additions and 3 deletions. Show diff stats Hide diff stats

  1. 58  milkymist/framebuffer/__init__.py
58  milkymist/framebuffer/__init__.py
@@ -44,7 +44,7 @@ def __init__(self, asmi_bits, length_bits, alignment_bits):
44 44
 		self._vscan = RegisterField("vscan", _vbits, reset=524)
45 45
 		
46 46
 		self._base = RegisterField("base", asmi_bits + self._alignment_bits)
47  
-		self._length = RegisterField("length", length_bits + self._alignment_bits)
  47
+		self._length = RegisterField("length", length_bits + self._alignment_bits, reset=640*480*4)
48 48
 		
49 49
 		layout = [
50 50
 			("hres", BV(_hbits)),
@@ -102,7 +102,59 @@ def __init__(self):
102 102
 		)
103 103
 	
104 104
 	def get_fragment(self):
105  
-		return Fragment() # TODO
  105
+		hactive = Signal()
  106
+		vactive = Signal()
  107
+		active = Signal()
  108
+		
  109
+		generate_en = Signal()
  110
+		hcounter = Signal(BV(_hbits))
  111
+		vcounter = Signal(BV(_vbits))
  112
+		hsync = Signal()
  113
+		vsync = Signal()
  114
+		
  115
+		comb = [
  116
+			active.eq(hactive & vactive),
  117
+			If(active,
  118
+				self.token("dac").r.eq(self.token("pixels").r[:_bpc_dac]),
  119
+				self.token("dac").g.eq(self.token("pixels").g[:_bpc_dac]),
  120
+				self.token("dac").b.eq(self.token("pixels").b[:_bpc_dac])
  121
+			),
  122
+			
  123
+			generate_en.eq(self.endpoints["timing"].stb & self.endpoints["dac"].ack \
  124
+				& (~active | self.endpoints["pixels"].stb)),
  125
+			self.endpoints["pixels"].ack.eq(self.endpoints["dac"].ack & active),
  126
+			self.endpoints["dac"].stb.eq(generate_en)
  127
+		]
  128
+		tp = self.token("timing")
  129
+		sync = [
  130
+			self.endpoints["timing"].ack.eq(0),
  131
+			If(generate_en,
  132
+				hcounter.eq(hcounter + 1),
  133
+			
  134
+				If(hcounter == 0, hactive.eq(1)),
  135
+				If(hcounter == tp.hres, hactive.eq(0)),
  136
+				If(hcounter == tp.hsync_start, hsync.eq(1)),
  137
+				If(hcounter == tp.hsync_end, hsync.eq(0)),
  138
+				If(hcounter == tp.hscan,
  139
+					hcounter.eq(0),
  140
+					If(vcounter == tp.vscan,
  141
+						vcounter.eq(0)
  142
+					).Else(
  143
+						vcounter.eq(vcounter + 1)
  144
+					)
  145
+				),
  146
+				
  147
+				If(vcounter == 0, vactive.eq(1)),
  148
+				If(vcounter == tp.vres, vactive.eq(0)),
  149
+				If(vcounter == tp.vsync_start, vsync.eq(1)),
  150
+				If(vcounter == tp.vsync_end,
  151
+					vsync.eq(0),
  152
+					self.endpoints["timing"].ack.eq(1)
  153
+				)
  154
+			)
  155
+		]
  156
+		
  157
+		return Fragment(comb, sync)
106 158
 
107 159
 class FIFO(Actor):
108 160
 	def __init__(self):
@@ -153,7 +205,7 @@ def get_fragment(self):
153 205
 class Framebuffer:
154 206
 	def __init__(self, address, asmiport):
155 207
 		asmi_bits = asmiport.hub.aw
156  
-		alignment_bits = asmiport.hub.dw//8
  208
+		alignment_bits = bits_for(asmiport.hub.dw//8)
157 209
 		length_bits = _hbits + _vbits + 2 - alignment_bits
158 210
 		pack_factor = asmiport.hub.dw//_bpp
159 211
 		packed_pixels = structuring.pack_layout(_pixel_layout, pack_factor)

0 notes on commit 3091247

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