Skip to content

Commit

Permalink
WIP: relocate pixel generation out of VGAOutputSubtarget
Browse files Browse the repository at this point in the history
  • Loading branch information
attie-argentum committed Nov 13, 2020
1 parent a66fe3a commit da8f559
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions software/glasgow/applet/video/vga_output/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def elaborate(self, platform):


class VGAOutputSubtarget(Elaboratable):
def __init__(self, pads, h_front, h_sync, h_back, h_active, v_front, v_sync, v_back, v_active, pix_clk_freq):
def __init__(self, pads, h_front, h_sync, h_back, h_active, v_front, v_sync, v_back, v_active, pix_clk_freq, pix_gen):
self.pads = pads
self.h_front = h_front
self.h_sync = h_sync
Expand All @@ -49,6 +49,7 @@ def __init__(self, pads, h_front, h_sync, h_back, h_active, v_front, v_sync, v_b
self.v_back = v_back
self.v_active, = v_active,
self.pix_clk_freq = pix_clk_freq
self.pix_gen = pix_gen

self.h_total = self.h_front + self.h_sync + self.h_back + self.h_active
self.v_total = self.v_front + self.v_sync + self.v_back + self.v_active
Expand Down Expand Up @@ -121,10 +122,7 @@ def elaborate(self, platform):
output.b.eq(0),
]

# TODO: relocate out of the module
m.d.comb += \
Cat(self.pix.r, self.pix.g, self.pix.b) \
.eq(self.h_ctr[5:] + self.v_ctr[5:])
self.pix_gen(self, m)

return m

Expand Down Expand Up @@ -188,6 +186,11 @@ def add_build_arguments(cls, parser, access):
help="set vertical resolution to N line clocks (default: %(default)s)")

def build(self, target, args, test_pattern=True):
# TODO: is a callback like this okay, or would a sub-class of VGAOutputSubtarget be preferred?
def pix_gen(t, m):
m.d.comb += Cat(t.pix.r, t.pix.g, t.pix.b) \
.eq(t.h_ctr[5:] + t.v_ctr[5:])

self.mux_interface = iface = target.multiplexer.claim_interface(self, args)
subtarget = iface.add_subtarget(VGAOutputSubtarget(
pads=iface.get_pads(args, pins=self.__pins),
Expand All @@ -200,6 +203,7 @@ def build(self, target, args, test_pattern=True):
v_back=args.v_back,
v_active=args.v_active,
pix_clk_freq=args.pix_clk_freq * 1e6,
pix_gen=pix_gen,
))
return subtarget

Expand Down

0 comments on commit da8f559

Please sign in to comment.