If anyone's interested, a while ago I ported (and slightly modified I think) a very simple test project for the Upduino 2.0 (RGB controller) for Radiant using VHDL. Maybe that could get some people started.
Top (VHDL):
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
library iCE40UP;
use iCE40UP.Components.all;
--******************************************************************************
entity TestRGB is
generic
(
nPWMCounterBits : integer := 13
);
port
(
RESETn : in std_logic;
LED_REDn : out std_logic;
LED_GREENn : out std_logic;
LED_BLUEn : out std_logic
);
end TestRGB;
--******************************************************************************
architecture Behavioral of TestRGB is
signal LF_Clock : std_logic;
signal nPWM_Cnt : unsigned((nPWMCounterBits - 1) downto 0);
signal PWM_Red, PWM_Green, PWM_Blue : std_logic;
begin
-- On-Chip Oscillator (LSOSC): Low Frequency Oscillator, 10 kHz.
LSOSC_1: LSOSC
port map (CLKLFEN => '1', CLKLF => LF_Clock, CLKLFPU => '1');
-- RGB Driver.
RGB_Driver_1 : RGB
generic map
(
CURRENT_MODE => "0",
RGB0_CURRENT => "0b000001",
RGB1_CURRENT => "0b000001",
RGB2_CURRENT => "0b000001"
)
port map
(
RGBLEDEN => RESETn, CURREN => RESETn,
RGB0PWM => PWM_Red, RGB1PWM => PWM_Green, RGB2PWM => PWM_Blue,
RGB0 => LED_REDn, RGB1 => LED_GREENn, RGB2 => LED_BLUEn
);
-- PWM Counter.
PWM_Counter: process (RESETn, LF_Clock)
begin
if RESETn = '0' then
nPWM_Cnt <= (others => '0');
elsif rising_edge(LF_Clock) then
nPWM_Cnt <= nPWM_Cnt + 1;
end if;
end process PWM_Counter;
-- PWM Control.
PWM_Red <= nPWM_Cnt(nPWMCounterBits - 1) and nPWM_Cnt(nPWMCounterBits - 2);
PWM_Green <= nPWM_Cnt(nPWMCounterBits - 1) and (not nPWM_Cnt(nPWMCounterBits - 2));
PWM_Blue <= (not nPWM_Cnt(nPWMCounterBits - 1)) and nPWM_Cnt(nPWMCounterBits - 2);
end Behavioral;
--******************************************************************************
.pdc file:
ldc_set_location -site {37} [get_ports RESETn]
ldc_set_location -site {39} [get_ports LED_REDn]
ldc_set_location -site {40} [get_ports LED_GREENn]
ldc_set_location -site {41} [get_ports LED_BLUEn]
ldc_set_port -iobuf {IO_TYPE=LVCMOS33 PULLMODE=100K} [get_ports RESETn]