cores/video/VideoTimingGenerator: Allow passing custom dict as default_video_timings.

Allow only listing the classical video timings in the core and let user provide the timings
specific to other configurations.
This commit is contained in:
Florent Kermarrec 2021-04-28 16:55:27 +02:00
parent da1092d9c0
commit c4e8e44cd9
1 changed files with 11 additions and 8 deletions

View File

@ -152,7 +152,8 @@ video_data_layout = [
class VideoTimingGenerator(Module, AutoCSR): class VideoTimingGenerator(Module, AutoCSR):
def __init__(self, default_video_timings="800x600@60Hz"): def __init__(self, default_video_timings="800x600@60Hz"):
# Check / Get Video Timings. # Check / Get Video Timings (can be str or dict)
if isinstance(default_video_timings, str):
try: try:
self.video_timings = vt = video_timings[default_video_timings] self.video_timings = vt = video_timings[default_video_timings]
except KeyError: except KeyError:
@ -160,6 +161,8 @@ class VideoTimingGenerator(Module, AutoCSR):
for video_timing in video_timings.keys(): for video_timing in video_timings.keys():
msg.append(f" - {video_timing} / {video_timings[video_timing]['pix_clk']/1e6:3.2f}MHz.") msg.append(f" - {video_timing} / {video_timings[video_timing]['pix_clk']/1e6:3.2f}MHz.")
raise ValueError("\n".join(msg)) raise ValueError("\n".join(msg))
else:
self.video_timings = vt = default_video_timings
# MMAP Control/Status Registers. # MMAP Control/Status Registers.
self._enable = CSRStorage(reset=1) self._enable = CSRStorage(reset=1)