EIE4-FYP/modules/testRGB.py

36 lines
1.1 KiB
Python
Raw Normal View History

from migen import *
from litex.soc.interconnect.csr import *
from litex.soc.integration.doc import ModuleDoc
# Test RGB Module ----------------------------------------------------------------------------------
class TestRgb(Module, AutoCSR, ModuleDoc):
"""
RGB LED Test Module
Set an RGB value and this SystemVerilog block will handle PWM pulse generation to set the on-board LED to that colour.
"""
def __init__(self, platform, pads):
self.pads = pads
2023-03-04 14:54:09 +00:00
self._out = CSRStorage(size = 24, description="Led Output(s) Value (24-bit RGB)",
fields = [
CSRField("ledb", size = 8, description = "LED Blue Brightness"),
CSRField("ledg", size = 8, description = "LED Green Brightness"),
CSRField("ledr", size = 8, description = "LED Red Brightness"),
])
# # #
leds = Signal(3)
self.comb += pads.eq(~leds)
self.specials += Instance("ledPwm",
i_clk = ClockSignal(),
i_rgb = self._out.storage,
o_ledr = leds[0],
o_ledg = leds[1],
o_ledb = leds[2]
)
platform.add_source("rtl/ledPwm.sv")