diff --git a/lib/VGA_ctrl/src/vga_types.vhd b/lib/VGA_ctrl/src/vga_types.vhd index e778405..80667c2 100644 --- a/lib/VGA_ctrl/src/vga_types.vhd +++ b/lib/VGA_ctrl/src/vga_types.vhd @@ -131,6 +131,9 @@ package vga_types is function DCM_FREQ_M(f_sys_hz, f_vga_hz : natural) return natural; function DCM_FREQ_D(f_sys_hz, f_vga_hz : natural) return natural; + function to_color_t(x : unsigned) return color_t; + function to_unsigned(x : color_t) return unsigned; + end vga_types; @@ -211,7 +214,28 @@ package body vga_types is end DCM_PERIOD; + function to_color_t(x : unsigned) return color_t is + variable result : color_t; + begin + result(r) := x(x'right+7 downto x'right+0); + result(g) := x(x'right+15 downto x'right+8); + result(b) := x(x'right+23 downto x'right+16); + result(a) := x(x'right+31 downto x'right+24); + + return result; + end to_color_t; + function to_unsigned(x : color_t) return unsigned is + variable result : unsigned(31 downto 0); + begin + result(7 downto 0) := x(r); + result(15 downto 8) := x(g); + result(23 downto 16) := x(b); + result(31 downto 24) := x(a); + + return result; + end to_unsigned; + end vga_types;