From 545379c99db2591de19213c87e8e8dbb7f554a79 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Sat, 25 Oct 2008 00:15:29 +0000 Subject: [PATCH] - added conversion functions unsigned <=> color_t git-svn-id: http://moon:8086/svn/vhdl/trunk@103 cc03376c-175c-47c8-b038-4cd826a8556b --- lib/VGA_ctrl/src/vga_types.vhd | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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;