Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework code in SBLED so LED information is in the platform #20

Open
mithro opened this issue Jul 9, 2019 · 5 comments
Open

Rework code in SBLED so LED information is in the platform #20

mithro opened this issue Jul 9, 2019 · 5 comments

Comments

@mithro
Copy link
Member

mithro commented Jul 9, 2019

Currently the SBLED has the following horrible hack;

if revision == "pvt" or revision == "evt" or revision == "dvt":
self.comb += [
If(self.ctrl.storage[3], rgba_pwm[1].eq(self.raw.storage[0])).Else(rgba_pwm[1].eq(ledd_value[0])),
If(self.ctrl.storage[4], rgba_pwm[0].eq(self.raw.storage[1])).Else(rgba_pwm[0].eq(ledd_value[1])),
If(self.ctrl.storage[5], rgba_pwm[2].eq(self.raw.storage[2])).Else(rgba_pwm[2].eq(ledd_value[2])),
]
elif revision == "hacker":
self.comb += [
If(self.ctrl.storage[3], rgba_pwm[2].eq(self.raw.storage[0])).Else(rgba_pwm[2].eq(ledd_value[0])),
If(self.ctrl.storage[4], rgba_pwm[1].eq(self.raw.storage[1])).Else(rgba_pwm[1].eq(ledd_value[1])),
If(self.ctrl.storage[5], rgba_pwm[0].eq(self.raw.storage[2])).Else(rgba_pwm[0].eq(ledd_value[2])),
]
else:
self.comb += [
If(self.ctrl.storage[3], rgba_pwm[0].eq(self.raw.storage[0])).Else(rgba_pwm[0].eq(ledd_value[0])),
If(self.ctrl.storage[4], rgba_pwm[1].eq(self.raw.storage[1])).Else(rgba_pwm[1].eq(ledd_value[1])),
If(self.ctrl.storage[5], rgba_pwm[2].eq(self.raw.storage[2])).Else(rgba_pwm[2].eq(ledd_value[2])),
]

What should be done is that the "platform" should define the RGB and rgb0/rgb1/rgb2 relationship and the SBLED should just ask which one is the red/green/blue.

@mithro
Copy link
Member Author

mithro commented Jul 9, 2019

Important information seems to be....

    rgb_write(r, LEDDPWRG); // Red
    rgb_write(g, LEDDPWRB); // Green
    rgb_write(b, LEDDPWRR); // Blue
            o_PWMOUT0 = ledd_value[0],
            o_PWMOUT1 = ledd_value[1],
            o_PWMOUT2 = ledd_value[2],

image

RGB0
Open-drain output of the RGB Driver connected to the device pin for RED LED
RGB1
Open-drain output of the RGB Driver connected to the device pin for GREEN LED
RGB2
Open-drain output of the RGB Driver connected to the device pin for BLUE LED
0001 LEDDPWRR LED Driver Pulse Width Register for RED W
0010 LEDDPWRG LED Driver Pulse Width Register for GREEN W
0011 LEDDPWRB LED Driver Pulse Width Register for BLUE W

@xobs
Copy link
Member

xobs commented Jul 9, 2019

It's slightly more complicated than that because of how the SB_RGBA_DRV is implimented. The blackbox has three outputs: RGB0, RGB1, and RGB2. These cannot be remapped, so unlike other implementations where we can just refer to them with platform.request() we actually have to manually place muxes in front of them.

@mithro
Copy link
Member Author

mithro commented Jul 9, 2019

Your doing the remapping between the SB_LEDDA_IP PWM outputs and the SB_RGBA_DRV inputs if I understand correctly?

@xobs
Copy link
Member

xobs commented Jul 9, 2019

It's remapping both the SB_LEDDA_IP PWM outputs and some optional bit-banged outputs. The raw registers allow for letting C code directly control the registers by disengaging the SB_LEDDA_IP.

@mithro
Copy link
Member Author

mithro commented Jul 9, 2019

Something like;

rgba_drv_pins = {
 'pin 1': 'RGB0',
 'pin 2': 'RGB1',
 'pin 3': 'RGB2',
}

r_led = platform.request('user_led_r')
self.comb += [
  If(csr.storage[RED], platform.get_pin(rgba_drv_pins[r_led.pin]).eq(ledda_ip.pwmout0), ...)
]
g_led = platform.request('user_led_g')
self.comb += [
  platform.get_pin(rgba_drv_pins[g_led.pin]).eq(ledda_ip.pwmout1),
]

b_led = platform.request('user_led_b')
self.comb += [
  platform.get_pin(rgba_drv_pins[b_led.pin]).eq(ledda_ip.pwmout1),
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants