Skip to content

Commit

Permalink
targets/analog_pocket: Add --video-colorbars/video-terminal/video-fra…
Browse files Browse the repository at this point in the history
…mebuffer arguments.
  • Loading branch information
enjoy-digital committed Oct 9, 2023
1 parent dec25b7 commit 6386f29
Showing 1 changed file with 57 additions and 41 deletions.
98 changes: 57 additions & 41 deletions litex_boards/targets/analog_pocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ def __init__(self, platform, sys_clk_freq, sdram_rate="1:1"):
# BaseSoC ------------------------------------------------------------------------------------------

class BaseSoC(SoCCore):
def __init__(self, sys_clk_freq=50e6, sdram_rate="1:1", **kwargs):
def __init__(self, sys_clk_freq=50e6, sdram_rate="1:1",
with_video_terminal = False,
with_video_framebuffer = False,
with_video_colorbars = False,
**kwargs):
platform = analog_pocket.Platform()

# CRG --------------------------------------------------------------------------------------
Expand All @@ -87,46 +91,51 @@ def __init__(self, sys_clk_freq=50e6, sdram_rate="1:1", **kwargs):

# Video ------------------------------------------------------------------------------------

from litex.soc.interconnect import stream
from litex.soc.cores.video import video_data_layout
from litex.build.io import SDROutput, DDROutput

class VideoDDRPHY(Module):
def __init__(self, pads, clock_domain="sys"):
self.sink = sink = stream.Endpoint(video_data_layout)

# # #

# Always ack Sink, no backpressure.
self.comb += sink.ready.eq(1)

# Drive Clk.
self.specials += DDROutput(i1=1, i2=0, o=pads.clk, clk=ClockSignal(clock_domain+"_90"))

# Drive Controls.
self.specials += SDROutput(i=sink.de, o=pads.de, clk=ClockSignal(clock_domain))
self.specials += SDROutput(i=sink.hsync, o=pads.hsync, clk=ClockSignal(clock_domain))
self.specials += SDROutput(i=sink.vsync, o=pads.vsync, clk=ClockSignal(clock_domain))
self.specials += SDROutput(i=Constant(0), o=pads.skip, clk=ClockSignal(clock_domain))

# Drive Datas.
data = Signal(24)
for i in range(8):
self.comb += data[ 0+i].eq(sink.b[i] & sink.de)
self.comb += data[ 8+i].eq(sink.g[i] & sink.de)
self.comb += data[16+i].eq(sink.r[i] & sink.de)
for i in range(12):
self.specials += DDROutput(
i1 = data[12 + i],
i2 = data[ 0 + i],
o = pads.data[i],
clk = ClockSignal(clock_domain)
)
if with_video_colorbars or with_video_framebuffer or with_video_terminal:

from litex.soc.interconnect import stream
from litex.soc.cores.video import video_data_layout
from litex.build.io import SDROutput, DDROutput

class VideoDDRPHY(Module):
def __init__(self, pads, clock_domain="sys"):
self.sink = sink = stream.Endpoint(video_data_layout)

# # #

# Always ack Sink, no backpressure.
self.comb += sink.ready.eq(1)

# Drive Clk.
self.specials += DDROutput(i1=1, i2=0, o=pads.clk, clk=ClockSignal(clock_domain+"_90"))

# Drive Controls.
self.specials += SDROutput(i=sink.de, o=pads.de, clk=ClockSignal(clock_domain))
self.specials += SDROutput(i=sink.hsync, o=pads.hsync, clk=ClockSignal(clock_domain))
self.specials += SDROutput(i=sink.vsync, o=pads.vsync, clk=ClockSignal(clock_domain))
self.specials += SDROutput(i=Constant(0), o=pads.skip, clk=ClockSignal(clock_domain))

# Drive Datas.
data = Signal(24)
for i in range(8):
self.comb += data[ 0+i].eq(sink.b[i] & sink.de)
self.comb += data[ 8+i].eq(sink.g[i] & sink.de)
self.comb += data[16+i].eq(sink.r[i] & sink.de)
for i in range(12):
self.specials += DDROutput(
i1 = data[12 + i],
i2 = data[ 0 + i],
o = pads.data[i],
clk = ClockSignal(clock_domain)
)

self.videophy = VideoDDRPHY(platform.request("video"), clock_domain="video")
#self.add_video_colorbars(phy=self.videophy, timings="640x480@60Hz", clock_domain="video")
self.add_video_terminal(phy=self.videophy, timings="640x480@60Hz", clock_domain="video")
#self.add_video_framebuffer(phy=self.videophy, timings="640x480@60Hz", clock_domain="video")
if with_video_colorbars:
self.add_video_colorbars(phy=self.videophy, timings="640x480@60Hz", clock_domain="video")
if with_video_terminal:
self.add_video_terminal(phy=self.videophy, timings="640x480@60Hz", clock_domain="video")
if with_video_framebuffer:
self.add_video_framebuffer(phy=self.videophy, timings="640x480@60Hz", clock_domain="video")

# Build --------------------------------------------------------------------------------------------

Expand All @@ -135,11 +144,18 @@ def main():
parser = LiteXArgumentParser(platform=analog_pocket.Platform, description="LiteX SoC on Analog Pocket.")
parser.add_target_argument("--sys-clk-freq", default=50e6, type=float, help="System clock frequency.")
parser.add_target_argument("--sdram-rate", default="1:1", help="SDRAM Rate (1:1 Full Rate or 1:2 Half Rate).")
viopts = parser.target_group.add_mutually_exclusive_group()
viopts.add_argument("--with-video-terminal", action="store_true", help="Enable Video Terminal.")
viopts.add_argument("--with-video-framebuffer", action="store_true", help="Enable Video Framebuffer.")
viopts.add_argument("--with-video-colorbars", action="store_true", help="Enable Video Colorbars.")
args = parser.parse_args()

soc = BaseSoC(
sys_clk_freq = args.sys_clk_freq,
sdram_rate = args.sdram_rate,
sys_clk_freq = args.sys_clk_freq,
sdram_rate = args.sdram_rate,
with_video_terminal = args.with_video_terminal,
with_video_framebuffer = args.with_video_framebuffer,
with_video_colorbars = args.with_video_colorbars,
**parser.soc_argdict
)
builder = Builder(soc, **parser.builder_argdict)
Expand Down

0 comments on commit 6386f29

Please sign in to comment.