framebuffer: reset VTG
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 15 Nov 2013 10:25:07 +0000 (11:25 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 15 Nov 2013 10:25:07 +0000 (11:25 +0100)
misoclib/framebuffer/__init__.py
misoclib/framebuffer/format.py

index ec49dba283bffbd699d6208dfd4c86c10591c14e..7399e40381eaa47d979c7f0a4ccebd5d0a358e94 100644 (file)
@@ -32,6 +32,7 @@ class Framebuffer(Module, AutoCSR):
                self.comb += [
                        self.fi.trigger.eq(self._enable.storage),
                        self.dma.generator.trigger.eq(self._enable.storage),
+                       vtg.enable.eq(self._enable.storage)
                ]
 
 class Blender(PipelinedActor, AutoCSR):
@@ -104,6 +105,7 @@ class MixFramebuffer(Module, AutoCSR):
                        setattr(self, "dma"+str(n), dma)
 
                vtg = VTG()
+               self.comb += vtg.enable.eq(self._enable.storage)
                g.add_connection(self.fi, vtg, sink_ep="timing")
                g.add_connection(self.blender, vtg, sink_ep="pixels")
                g.add_connection(vtg, self.driver)
index 7e4224533e6539c7682bc7b719a56a5b4feb66dc..fdfc643316a35b3122c8e2e17aba023d6b45f2d2 100644 (file)
@@ -50,6 +50,7 @@ class FrameInitiator(spi.SingleGenerator):
 
 class VTG(Module):
        def __init__(self):
+               self.enable = Signal()
                self.timing = Sink([
                                ("hres", _hbits),
                                ("hsync_start", _hbits),
@@ -63,6 +64,8 @@ class VTG(Module):
                self.phy = Source(phy_layout)
                self.busy = Signal()
 
+               ###
+
                hactive = Signal()
                vactive = Signal()
                active = Signal()
@@ -81,33 +84,39 @@ class VTG(Module):
                        ),
                        
                        generate_en.eq(self.timing.stb & (~active | self.pixels.stb)),
-                       self.pixels.ack.eq(self.phy.ack & active),
+                       self.pixels.ack.eq(~self.enable | (self.phy.ack & active)),
                        self.phy.stb.eq(generate_en),
                        self.busy.eq(generate_en)
                ]
                tp = self.timing.payload
                self.sync += [
-                       self.timing.ack.eq(0),
-                       If(generate_en & self.phy.ack,
-                               hcounter.eq(hcounter + 1),
-                       
-                               If(hcounter == 0, hactive.eq(1)),
-                               If(hcounter == tp.hres, hactive.eq(0)),
-                               If(hcounter == tp.hsync_start, self.phy.payload.hsync.eq(1)),
-                               If(hcounter == tp.hsync_end, self.phy.payload.hsync.eq(0)),
-                               If(hcounter == tp.hscan,
-                                       hcounter.eq(0),
-                                       If(vcounter == tp.vscan,
-                                               vcounter.eq(0),
-                                               self.timing.ack.eq(1)
-                                       ).Else(
-                                               vcounter.eq(vcounter + 1)
-                                       )
-                               ),
+                       If(self.enable,
+                               self.timing.ack.eq(0),
+                               If(generate_en & self.phy.ack,
+                                       hcounter.eq(hcounter + 1),
                                
-                               If(vcounter == 0, vactive.eq(1)),
-                               If(vcounter == tp.vres, vactive.eq(0)),
-                               If(vcounter == tp.vsync_start, self.phy.payload.vsync.eq(1)),
-                               If(vcounter == tp.vsync_end, self.phy.payload.vsync.eq(0))
+                                       If(hcounter == 0, hactive.eq(1)),
+                                       If(hcounter == tp.hres, hactive.eq(0)),
+                                       If(hcounter == tp.hsync_start, self.phy.payload.hsync.eq(1)),
+                                       If(hcounter == tp.hsync_end, self.phy.payload.hsync.eq(0)),
+                                       If(hcounter == tp.hscan,
+                                               hcounter.eq(0),
+                                               If(vcounter == tp.vscan,
+                                                       vcounter.eq(0),
+                                                       self.timing.ack.eq(1)
+                                               ).Else(
+                                                       vcounter.eq(vcounter + 1)
+                                               )
+                                       ),
+                                       
+                                       If(vcounter == 0, vactive.eq(1)),
+                                       If(vcounter == tp.vres, vactive.eq(0)),
+                                       If(vcounter == tp.vsync_start, self.phy.payload.vsync.eq(1)),
+                                       If(vcounter == tp.vsync_end, self.phy.payload.vsync.eq(0))
+                               )
+                       ).Else(
+                               self.timing.ack.eq(1),
+                               hcounter.eq(0),
+                               vcounter.eq(0)
                        )
                ]