Exemple #1
0
    def __init__(self, pads_vga, pads_dvi, lasmim):
        pack_factor = lasmim.dw // bpp

        g = DataFlowGraph()

        self.fi = FrameInitiator(lasmim.aw, pack_factor)

        intseq = misc.IntSequence(lasmim.aw, lasmim.aw)
        dma_out = AbstractActor(plumbing.Buffer)
        g.add_connection(self.fi, intseq, source_subr=self.fi.dma_subr())
        g.add_pipeline(intseq, AbstractActor(plumbing.Buffer),
                       dma_lasmi.Reader(lasmim), dma_out)

        cast = structuring.Cast(lasmim.dw,
                                pixel_layout(pack_factor),
                                reverse_to=True)
        vtg = VTG(pack_factor)
        self.driver = Driver(pack_factor, pads_vga, pads_dvi)

        g.add_connection(self.fi,
                         vtg,
                         source_subr=self.fi.timing_subr,
                         sink_ep="timing")
        g.add_connection(dma_out, cast)
        g.add_connection(cast, vtg, sink_ep="pixels")
        g.add_connection(vtg, self.driver)
        self.submodules += CompositeActor(g)
Exemple #2
0
    def __init__(self, lasmim):
        self._magic = CSRStatus(16)
        self._reset = CSR()
        self._error_count = CSRStatus(lasmim.aw)
        self.submodules._dma = DMAReadController(dma_lasmi.Reader(lasmim),
                                                 MODE_SINGLE_SHOT)

        ###

        self.comb += self._magic.status.eq(memtest_magic)

        lfsr = LFSR(lasmim.dw)
        self.submodules += lfsr
        self.comb += lfsr.reset.eq(self._reset.re)

        self.comb += [lfsr.ce.eq(self._dma.data.stb), self._dma.data.ack.eq(1)]
        err_cnt = self._error_count.status
        self.sync += [
            If(self._reset.re, err_cnt.eq(0)).Elif(
                self._dma.data.stb,
                If(self._dma.data.d != lfsr.o, err_cnt.eq(err_cnt + 1)))
        ]
Exemple #3
0
    def __init__(self, lasmim, tag):
        self.source = source = Source(user_description(8))

        reader = dma_lasmi.Reader(lasmim)
        self.dma = spi.DMAReadController(reader, mode=spi.MODE_SINGLE_SHOT)

        pack_factor = lasmim.dw // 8
        packed_dat = structuring.pack_layout(8, pack_factor)
        cast = structuring.Cast(lasmim.dw, packed_dat)
        unpack = structuring.Unpack(pack_factor,
                                    phy_description(8),
                                    reverse=True)

        # Graph
        cnt = Signal(32)
        self.sync += \
            If(self.dma.generator._shoot.re,
                cnt.eq(0)
            ).Elif(source.stb & source.ack,
                cnt.eq(cnt + 1)
            )
        g = DataFlowGraph()
        g.add_pipeline(self.dma, cast, unpack)
        self.submodules += CompositeActor(g)
        self.comb += [
            source.stb.eq(unpack.source.stb),
            source.sop.eq(cnt == 0),
            source.eop.eq(cnt == (self.dma.length * pack_factor - 1)),
            source.length.eq(self.dma.length * pack_factor),
            source.data.eq(unpack.source.data),
            source.dst.eq(tag),
            unpack.source.ack.eq(source.ack)
        ]

        # IRQ
        self.submodules.ev = EventManager()
        self.ev.done = EventSourcePulse()
        self.ev.finalize()
        self.comb += self.ev.done.trigger.eq(source.stb & source.eop)
Exemple #4
0
    def __init__(self, lasmim):
        self.source = source = Source(EndpointDescription([("data", 128)]))
        self.base = CSRStorage(32)
        self.h_width = CSRStorage(16)
        self.v_width = CSRStorage(16)
        self.start = CSR()
        self.done = CSRStatus()

        # # #

        pixel_bits = 16  # ycbcr 4:2:2
        burst_pixels = lasmim.dw // pixel_bits
        alignment_bits = bits_for(lasmim.dw // 8) - 1

        self.submodules.reader = reader = dma_lasmi.Reader(lasmim)
        self.submodules.converter = structuring.Converter(EndpointDescription([
            ("data", lasmim.dw)
        ]),
                                                          EndpointDescription([
                                                              ("data", 128)
                                                          ]),
                                                          reverse=True)
        self.comb += [
            Record.connect(reader.data,
                           self.converter.sink,
                           leave_out=set(["d"])),
            self.converter.sink.data.eq(reader.data.d),
            Record.connect(self.converter.source, source)
        ]

        base = Signal(32)
        h_width = self.h_width.storage
        v_width = self.v_width.storage
        start = self.start.r & self.start.re
        done = self.done.status
        self.sync += If(start, base.eq(self.base.storage))

        h_clr = Signal()
        h_clr_lsb = Signal()
        h_inc = Signal()
        h = Signal(16)
        h_next = Signal(16)
        self.comb += h_next.eq(h + burst_pixels)
        self.sync += \
            If(h_clr,
                h.eq(0)
            ).Elif(h_clr_lsb,
                h[:3].eq(0),
                h[3:].eq(h[3:])
            ).Elif(h_inc,
                h.eq(h_next)
            )

        v_clr = Signal()
        v_inc = Signal()
        v_dec7 = Signal()
        v = Signal(16)
        self.sync += \
            If(v_clr,
                v.eq(0)
            ).Elif(v_inc,
                v.eq(v + 1)
            ).Elif(v_dec7,
                v.eq(v - 7)
            )

        self.submodules.fsm = fsm = FSM(reset_state="IDLE")
        fsm.act("IDLE", h_clr.eq(1), v_clr.eq(1),
                If(start, NextState("READ")).Else(done.eq(1)))
        fsm.act(
            "READ",
            reader.address.stb.eq(1),
            If(
                reader.address.ack,
                # last burst of 8 pixels
                If(
                    h_next[:3] == 0,
                    # last line of a block of 8 pixels
                    If(
                        v[:3] == 7,
                        # last block of a line
                        If(
                            h >= h_width - burst_pixels,
                            h_clr.eq(1),
                            v_inc.eq(1),
                            # last line
                            If(v >= v_width - 1, NextState("IDLE"))).Else(
                                h_inc.eq(1), v_dec7.eq(1))).Else(
                                    h_clr_lsb.eq(1),
                                    v_inc.eq(1))).Else(h_inc.eq(1))))

        read_address = Signal(lasmim.aw + alignment_bits)
        self.comb += [
            read_address.eq(v * h_width + h),
            reader.address.a.eq(base[alignment_bits:] +
                                read_address[alignment_bits -
                                             log2_int(pixel_bits // 8):])
        ]