11import logging
22from amaranth import *
3- from amaranth .lib import data
3+ from amaranth .lib import data , io
44
55from ....gateware .pll import *
66from ... import *
77
88
99class VGAOutput (Elaboratable ):
10- def __init__ (self , pads ):
11- self .pads = pads
10+ def __init__ (self , ports ):
11+ self .ports = ports
1212
1313 self .hs = Signal ()
1414 self .vs = Signal ()
@@ -19,25 +19,26 @@ def __init__(self, pads):
1919 def elaborate (self , platform ):
2020 m = Module ()
2121
22+ m .submodules .hs_buffer = hs_buffer = io .Buffer ("o" , self .ports .hs )
23+ m .submodules .vs_buffer = vs_buffer = io .Buffer ("o" , self .ports .vs )
24+ m .submodules .r_buffer = r_buffer = io .Buffer ("o" , self .ports .r )
25+ m .submodules .g_buffer = g_buffer = io .Buffer ("o" , self .ports .g )
26+ m .submodules .b_buffer = b_buffer = io .Buffer ("o" , self .ports .b )
27+
2228 m .d .comb += [
23- self .pads .hs_t .oe .eq (1 ),
24- self .pads .hs_t .o .eq (self .hs ),
25- self .pads .vs_t .oe .eq (1 ),
26- self .pads .vs_t .o .eq (self .vs ),
27- self .pads .r_t .oe .eq (1 ),
28- self .pads .r_t .o .eq (self .r ),
29- self .pads .g_t .oe .eq (1 ),
30- self .pads .g_t .o .eq (self .g ),
31- self .pads .b_t .oe .eq (1 ),
32- self .pads .b_t .o .eq (self .b ),
29+ hs_buffer .o .eq (self .hs ),
30+ vs_buffer .o .eq (self .vs ),
31+ r_buffer .o .eq (self .r ),
32+ g_buffer .o .eq (self .g ),
33+ b_buffer .o .eq (self .b )
3334 ]
3435
3536 return m
3637
3738
3839class VGAOutputSubtarget (Elaboratable ):
39- def __init__ (self , pads , h_front , h_sync , h_back , h_active , v_front , v_sync , v_back , v_active , pix_clk_freq ):
40- self .pads = pads
40+ def __init__ (self , ports , h_front , h_sync , h_back , h_active , v_front , v_sync , v_back , v_active , pix_clk_freq ):
41+ self .ports = ports
4142 self .h_front = h_front
4243 self .h_sync = h_sync
4344 self .h_back = h_back
@@ -51,7 +52,7 @@ def __init__(self, pads, h_front, h_sync, h_back, h_active, v_front, v_sync, v_b
5152 def elaborate (self , platform ):
5253 m = Module ()
5354
54- m .submodules .output = output = VGAOutput (self .pads )
55+ m .submodules .output = output = VGAOutput (self .ports )
5556
5657 m .domains .pix = cd_pix = ClockDomain ()
5758 m .submodules += PLL (f_in = platform .default_clk_frequency , f_out = self .pix_clk_freq , odomain = "pix" )
@@ -139,14 +140,15 @@ class VGAOutputApplet(GlasgowApplet):
139140 * b ---[ 350R ]-- BLUE
140141 """
141142
142- __pins = ("hs" , "vs" , "r" , "g" , "b" )
143-
144143 @classmethod
145144 def add_build_arguments (cls , parser , access ):
146145 super ().add_build_arguments (parser , access )
147146
148- for pin in cls .__pins :
149- access .add_pin_argument (parser , pin , default = True )
147+ access .add_pin_argument (parser , "hs" , default = True )
148+ access .add_pin_argument (parser , "vs" , default = True )
149+ access .add_pin_argument (parser , "r" , default = True )
150+ access .add_pin_argument (parser , "g" , default = True )
151+ access .add_pin_argument (parser , "b" , default = True )
150152
151153 parser .add_argument (
152154 "-p" , "--pix-clk-freq" , metavar = "FREQ" , type = float , default = 25.175 ,
@@ -181,7 +183,13 @@ def add_build_arguments(cls, parser, access):
181183 def build (self , target , args , test_pattern = True ):
182184 self .mux_interface = iface = target .multiplexer .claim_interface (self , args )
183185 subtarget = iface .add_subtarget (VGAOutputSubtarget (
184- pads = iface .get_deprecated_pads (args , pins = self .__pins ),
186+ ports = iface .get_port_group (
187+ hs = args .pin_hs ,
188+ vs = args .pin_vs ,
189+ r = args .pin_r ,
190+ g = args .pin_g ,
191+ b = args .pin_b
192+ ),
185193 h_front = args .h_front ,
186194 h_sync = args .h_sync ,
187195 h_back = args .h_back ,
0 commit comments