forked from mithro/HDMI2USB-litex-firmware-old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopsis_video.py
executable file
·97 lines (83 loc) · 3.9 KB
/
opsis_video.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env python3
from opsis_base import *
from litevideo.input import HDMIIn
from litevideo.output import VideoOut
from gateware.freq_measurement import FrequencyMeasurement
base_cls = MiniSoC
class VideoMixerSoC(base_cls):
csr_peripherals = (
"hdmi_out0",
"hdmi_out1",
"hdmi_in0",
"hdmi_in0_freq",
"hdmi_in0_edid_mem",
"hdmi_in1",
"hdmi_in1_freq",
"hdmi_in1_edid_mem",
)
csr_map_update(base_cls.csr_map, csr_peripherals)
interrupt_map = {
"hdmi_in0": 3,
"hdmi_in1": 4,
}
interrupt_map.update(base_cls.interrupt_map)
def __init__(self, platform, **kwargs):
base_cls.__init__(self, platform, **kwargs)
# hdmi in 0
self.submodules.hdmi_in0 = HDMIIn(platform.request("hdmi_in", 0),
self.sdram.crossbar.get_port(mode="write"),
fifo_depth=512)
self.submodules.hdmi_in0_freq = FrequencyMeasurement(self.hdmi_in0.clocking._cd_pix.clk,
self.clk_freq)
# hdmi in 1
self.submodules.hdmi_in1 = HDMIIn(platform.request("hdmi_in", 1),
self.sdram.crossbar.get_port(mode="write"),
fifo_depth=512)
self.submodules.hdmi_in1_freq = FrequencyMeasurement(self.hdmi_in1.clocking._cd_pix.clk,
self.clk_freq)
# hdmi out 0
self.submodules.hdmi_out0 = VideoOut(platform.device,
platform.request("hdmi_out", 0),
self.sdram.crossbar.get_port(mode="read", dw=16, cd="hdmi_out0_pix", reverse=True),
mode="ycbcr422",
fifo_depth=4096)
# hdmi out 1 : Share clocking with hdmi_out0 since no PLL_ADV left.
self.submodules.hdmi_out1 = VideoOut(platform.device,
platform.request("hdmi_out", 1),
self.sdram.crossbar.get_port(mode="read", dw=16, cd="hdmi_out1_pix", reverse=True),
mode="ycbcr422",
fifo_depth=4096,
external_clocking=self.hdmi_out0.driver.clocking)
# all PLL_ADV are used: router needs help...
platform.add_platform_command("""INST PLL_ADV LOC=PLL_ADV_X0Y0;""")
# FIXME: Fix the HDMI out so this can be removed.
platform.add_platform_command(
"""PIN "hdmi_out_pix_bufg.O" CLOCK_DEDICATED_ROUTE = FALSE;""")
platform.add_platform_command(
"""PIN "hdmi_out_pix_bufg_1.O" CLOCK_DEDICATED_ROUTE = FALSE;""")
platform.add_platform_command(
"""
NET "{pix0_clk}" TNM_NET = "GRPpix0_clk";
NET "{pix1_clk}" TNM_NET = "GRPpix1_clk";
""",
pix0_clk=self.hdmi_out0.driver.clocking.cd_pix.clk,
pix1_clk=self.hdmi_out1.driver.clocking.cd_pix.clk,
)
self.platform.add_false_path_constraints(
self.crg.cd_sys.clk,
self.hdmi_out0.driver.clocking.cd_pix.clk,
self.hdmi_out1.driver.clocking.cd_pix.clk)
def main():
parser = argparse.ArgumentParser(description="Opsis LiteX SoC")
builder_args(parser)
soc_sdram_args(parser)
parser.add_argument("--nocompile-gateware", action="store_true")
args = parser.parse_args()
platform = opsis_platform.Platform()
soc = VideoMixerSoC(platform, **soc_sdram_argdict(args))
builder = Builder(soc, output_dir="build",
compile_gateware=not args.nocompile_gateware,
csr_csv="test/csr.csv")
vns = builder.build()
if __name__ == "__main__":
main()