- added conversion functions unsigned <=> color_t
git-svn-id: http://moon:8086/svn/vhdl/trunk@103 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -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,6 +214,27 @@ 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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user