Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
framebuffer: video timing generator
  • Loading branch information
Sebastien Bourdeauducq committed Jul 1, 2012
1 parent 16c6e4f commit 3091247
Showing 1 changed file with 55 additions and 3 deletions.
58 changes: 55 additions & 3 deletions milkymist/framebuffer/__init__.py
Expand Up @@ -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)),
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3091247

Please sign in to comment.