OpenCores
URL https://opencores.org/ocsvn/graphiti/graphiti/trunk

Subversion Repositories graphiti

[/] [graphiti/] [trunk/] [xilinx/] [rgb2yuv.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 pototschni
-------------------------------------------------------------------------------
2
--      MiniGA
3
--  Author: Thomas Pototschnig (thomas.pototschnig@gmx.de)
4
--
5
--  License: Creative Commons Attribution-NonCommercial-ShareAlike 2.0 License
6
--           http://creativecommons.org/licenses/by-nc-sa/2.0/de/
7
--
8
--  If you want to use MiniGA for commercial purposes please contact the author
9
-------------------------------------------------------------------------------
10
library IEEE;
11
use IEEE.STD_LOGIC_1164.ALL;
12
use IEEE.STD_LOGIC_ARITH.ALL;
13
use IEEE.STD_LOGIC_UNSIGNED.ALL;
14
 
15
entity rgb2yuv is
16
    Port ( clk : in std_logic;
17
           reset : in std_logic;
18
                          in_r, in_g, in_b : in std_logic_vector (4 downto 0); -- signed
19
                          out_y, out_u, out_v : out std_logic_vector (11 downto 0)); -- unsigned
20
end rgb2yuv;
21
 
22
architecture Behavioral of rgb2yuv is
23
begin
24
        process (clk, reset)
25
                variable multu : signed (11 downto 0) := conv_signed (517,12);
26
                variable multv : signed (11 downto 0) := conv_signed (929,12);
27
                variable var_y : signed (11 downto 0);
28
                variable in_rs : signed (11 downto 0);
29
                variable in_gs : signed (11 downto 0);
30
                variable in_bs : signed (11 downto 0);
31
 
32
                variable worku24 : signed (23 downto 0);
33
                variable workv24 : signed (23 downto 0);
34
 
35
                variable rsigned : signed (11 downto 0) := conv_signed(0,12);
36
                variable bsigned : signed (11 downto 0) := conv_signed(0,12);
37
 
38
        begin
39
                if reset='0' then
40
                        out_u <= (others => '0');
41
                        out_v <= (others => '0');
42
                        out_y <= (others => '0');
43
                elsif clk='1' and clk'event then
44
                        case in_r is
45
                                when "00000" => in_rs := "000000000000"; -- 0.0000
46
                                when "00001" => in_rs := "000000001001"; -- 0.0094
47
                                when "00010" => in_rs := "000000010011"; -- 0.0187
48
                                when "00011" => in_rs := "000000011100"; -- 0.0281
49
                                when "00100" => in_rs := "000000100110"; -- 0.0375
50
                                when "00101" => in_rs := "000000110000"; -- 0.0469
51
                                when "00110" => in_rs := "000000111001"; -- 0.0562
52
                                when "00111" => in_rs := "000001000011"; -- 0.0656
53
                                when "01000" => in_rs := "000001001100"; -- 0.0750
54
                                when "01001" => in_rs := "000001010110"; -- 0.0844
55
                                when "01010" => in_rs := "000001100000"; -- 0.0938
56
                                when "01011" => in_rs := "000001101001"; -- 0.1031
57
                                when "01100" => in_rs := "000001110011"; -- 0.1125
58
                                when "01101" => in_rs := "000001111100"; -- 0.1219
59
                                when "01110" => in_rs := "000010000110"; -- 0.1313
60
                                when "01111" => in_rs := "000010010000"; -- 0.1406
61
                                when "10000" => in_rs := "000010011001"; -- 0.1500
62
                                when "10001" => in_rs := "000010100011"; -- 0.1594
63
                                when "10010" => in_rs := "000010101100"; -- 0.1687
64
                                when "10011" => in_rs := "000010110110"; -- 0.1781
65
                                when "10100" => in_rs := "000011000000"; -- 0.1875
66
                                when "10101" => in_rs := "000011001001"; -- 0.1969
67
                                when "10110" => in_rs := "000011010011"; -- 0.2062
68
                                when "10111" => in_rs := "000011011100"; -- 0.2156
69
                                when "11000" => in_rs := "000011100110"; -- 0.2250
70
                                when "11001" => in_rs := "000011110000"; -- 0.2344
71
                                when "11010" => in_rs := "000011111001"; -- 0.2437
72
                                when "11011" => in_rs := "000100000011"; -- 0.2531
73
                                when "11100" => in_rs := "000100001100"; -- 0.2625
74
                                when "11101" => in_rs := "000100010110"; -- 0.2719
75
                                when "11110" => in_rs := "000100100000"; -- 0.2813
76
                                when "11111" => in_rs := "000100101001"; -- 0.2906
77
                                when others => in_rs := (others => '0');
78
                        end case;
79
 
80
                        case in_g is
81
                                when "00000" => in_gs := "000000000000"; -- 0.0000
82
                                when "00001" => in_gs := "000000010010"; -- 0.0184
83
                                when "00010" => in_gs := "000000100101"; -- 0.0369
84
                                when "00011" => in_gs := "000000111000"; -- 0.0553
85
                                when "00100" => in_gs := "000001001011"; -- 0.0737
86
                                when "00101" => in_gs := "000001011110"; -- 0.0922
87
                                when "00110" => in_gs := "000001110001"; -- 0.1106
88
                                when "00111" => in_gs := "000010000100"; -- 0.1291
89
                                when "01000" => in_gs := "000010010111"; -- 0.1475
90
                                when "01001" => in_gs := "000010101001"; -- 0.1659
91
                                when "01010" => in_gs := "000010111100"; -- 0.1844
92
                                when "01011" => in_gs := "000011001111"; -- 0.2028
93
                                when "01100" => in_gs := "000011100010"; -- 0.2213
94
                                when "01101" => in_gs := "000011110101"; -- 0.2397
95
                                when "01110" => in_gs := "000100001000"; -- 0.2581
96
                                when "01111" => in_gs := "000100011011"; -- 0.2766
97
                                when "10000" => in_gs := "000100101110"; -- 0.2950
98
                                when "10001" => in_gs := "000101000000"; -- 0.3134
99
                                when "10010" => in_gs := "000101010011"; -- 0.3319
100
                                when "10011" => in_gs := "000101100110"; -- 0.3503
101
                                when "10100" => in_gs := "000101111001"; -- 0.3687
102
                                when "10101" => in_gs := "000110001100"; -- 0.3872
103
                                when "10110" => in_gs := "000110011111"; -- 0.4056
104
                                when "10111" => in_gs := "000110110010"; -- 0.4241
105
                                when "11000" => in_gs := "000111000101"; -- 0.4425
106
                                when "11001" => in_gs := "000111011000"; -- 0.4609
107
                                when "11010" => in_gs := "000111101010"; -- 0.4794
108
                                when "11011" => in_gs := "000111111101"; -- 0.4978
109
                                when "11100" => in_gs := "001000010000"; -- 0.5162
110
                                when "11101" => in_gs := "001000100011"; -- 0.5347
111
                                when "11110" => in_gs := "001000110110"; -- 0.5531
112
                                when "11111" => in_gs := "001001001001"; -- 0.5716
113
                                when others => in_gs := (others => '0');
114
                        end case;
115
 
116
                        case in_b is
117
                                when "00000" => in_bs := "000000000000"; -- 0.0000
118
                                when "00001" => in_bs := "000000000011"; -- 0.0034
119
                                when "00010" => in_bs := "000000000111"; -- 0.0069
120
                                when "00011" => in_bs := "000000001010"; -- 0.0103
121
                                when "00100" => in_bs := "000000001110"; -- 0.0138
122
                                when "00101" => in_bs := "000000010001"; -- 0.0172
123
                                when "00110" => in_bs := "000000010101"; -- 0.0206
124
                                when "00111" => in_bs := "000000011000"; -- 0.0241
125
                                when "01000" => in_bs := "000000011100"; -- 0.0275
126
                                when "01001" => in_bs := "000000011111"; -- 0.0309
127
                                when "01010" => in_bs := "000000100011"; -- 0.0344
128
                                when "01011" => in_bs := "000000100110"; -- 0.0378
129
                                when "01100" => in_bs := "000000101010"; -- 0.0413
130
                                when "01101" => in_bs := "000000101101"; -- 0.0447
131
                                when "01110" => in_bs := "000000110001"; -- 0.0481
132
                                when "01111" => in_bs := "000000110100"; -- 0.0516
133
                                when "10000" => in_bs := "000000111000"; -- 0.0550
134
                                when "10001" => in_bs := "000000111011"; -- 0.0584
135
                                when "10010" => in_bs := "000000111111"; -- 0.0619
136
                                when "10011" => in_bs := "000001000010"; -- 0.0653
137
                                when "10100" => in_bs := "000001000110"; -- 0.0688
138
                                when "10101" => in_bs := "000001001001"; -- 0.0722
139
                                when "10110" => in_bs := "000001001101"; -- 0.0756
140
                                when "10111" => in_bs := "000001010000"; -- 0.0791
141
                                when "11000" => in_bs := "000001010100"; -- 0.0825
142
                                when "11001" => in_bs := "000001011000"; -- 0.0859
143
                                when "11010" => in_bs := "000001011011"; -- 0.0894
144
                                when "11011" => in_bs := "000001011111"; -- 0.0928
145
                                when "11100" => in_bs := "000001100010"; -- 0.0963
146
                                when "11101" => in_bs := "000001100110"; -- 0.0997
147
                                when "11110" => in_bs := "000001101001"; -- 0.1031
148
                                when "11111" => in_bs := "000001101101"; -- 0.1066
149
                                when others => in_bs := (others => '0');
150
                        end case;
151
 
152
                        rsigned := (others => '0');
153
                        bsigned := (others => '0');
154
 
155
                        rsigned (9 downto 5) := signed(in_r);
156
                        bsigned (9 downto 5) := signed(in_b);
157
 
158
                        var_y := signed(in_rs) + signed(in_gs) + signed(in_bs);
159
 
160
                        worku24 := (bsigned-signed(var_y))* multu;
161
                        workv24 := (rsigned-signed(var_y))* multv;
162
 
163
                        out_u <= conv_std_logic_vector(worku24 (21 downto 10),12);
164
                        out_v <= conv_std_logic_vector(workv24 (21 downto 10),12);
165
                        out_y <= conv_std_logic_vector (var_y, var_y'length);
166
                end if;
167
        end process;
168
 
169
end Behavioral;

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.