Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

framebuffer: video timing generator

  • Loading branch information...
commit 309124711fad64b0e6d8881bff44fe10fb4dc938 1 parent 16c6e4f
Sébastien Bourdeauducq sbourdeauducq authored
Showing with 55 additions and 3 deletions.
  1. +55 −3 milkymist/framebuffer/__init__.py
58 milkymist/framebuffer/__init__.py
View
@@ -44,7 +44,7 @@ def __init__(self, asmi_bits, length_bits, alignment_bits):
self._vscan = RegisterField("vscan", _vbits, reset=524)
self._base = RegisterField("base", asmi_bits + self._alignment_bits)
- self._length = RegisterField("length", length_bits + self._alignment_bits)
+ self._length = RegisterField("length", length_bits + self._alignment_bits, reset=640*480*4)
layout = [
("hres", BV(_hbits)),
@@ -102,7 +102,59 @@ def __init__(self):
)
def get_fragment(self):
- return Fragment() # TODO
+ hactive = Signal()
+ vactive = Signal()
+ active = Signal()
+
+ generate_en = Signal()
+ hcounter = Signal(BV(_hbits))
+ vcounter = Signal(BV(_vbits))
+ hsync = Signal()
+ vsync = Signal()
+
+ comb = [
+ active.eq(hactive & vactive),
+ If(active,
+ self.token("dac").r.eq(self.token("pixels").r[:_bpc_dac]),
+ self.token("dac").g.eq(self.token("pixels").g[:_bpc_dac]),
+ self.token("dac").b.eq(self.token("pixels").b[:_bpc_dac])
+ ),
+
+ generate_en.eq(self.endpoints["timing"].stb & self.endpoints["dac"].ack \
+ & (~active | self.endpoints["pixels"].stb)),
+ self.endpoints["pixels"].ack.eq(self.endpoints["dac"].ack & active),
+ self.endpoints["dac"].stb.eq(generate_en)
+ ]
+ tp = self.token("timing")
+ sync = [
+ self.endpoints["timing"].ack.eq(0),
+ If(generate_en,
+ hcounter.eq(hcounter + 1),
+
+ If(hcounter == 0, hactive.eq(1)),
+ If(hcounter == tp.hres, hactive.eq(0)),
+ If(hcounter == tp.hsync_start, hsync.eq(1)),
+ If(hcounter == tp.hsync_end, hsync.eq(0)),
+ If(hcounter == tp.hscan,
+ hcounter.eq(0),
+ If(vcounter == tp.vscan,
+ vcounter.eq(0)
+ ).Else(
+ vcounter.eq(vcounter + 1)
+ )
+ ),
+
+ If(vcounter == 0, vactive.eq(1)),
+ If(vcounter == tp.vres, vactive.eq(0)),
+ If(vcounter == tp.vsync_start, vsync.eq(1)),
+ If(vcounter == tp.vsync_end,
+ vsync.eq(0),
+ self.endpoints["timing"].ack.eq(1)
+ )
+ )
+ ]
+
+ return Fragment(comb, sync)
class FIFO(Actor):
def __init__(self):
@@ -153,7 +205,7 @@ def get_fragment(self):
class Framebuffer:
def __init__(self, address, asmiport):
asmi_bits = asmiport.hub.aw
- alignment_bits = asmiport.hub.dw//8
+ alignment_bits = bits_for(asmiport.hub.dw//8)
length_bits = _hbits + _vbits + 2 - alignment_bits
pack_factor = asmiport.hub.dw//_bpp
packed_pixels = structuring.pack_layout(_pixel_layout, pack_factor)
Please sign in to comment.
Something went wrong with that request. Please try again.