1 <!DOCTYPE rgb3sx8_to_ycbcr_3DSP>
2 <block_impl ref_name="rgb3sx8_to_ycbcr_3DSP.xml" ref_md5="">
4 <author lastname="" mail="" firstname=""/>
5 <date creation="2018-01-10"/>
6 <related_files list=""/>
7 <description>fez</description>
12 <package name="std_logic_1164" use="all"/>
13 <package name="numeric_std" use="all"/>
16 <architecture comp_list="mult_accum">
19 @{clk} : in std_logic;
22 bypass : in std_logic;
23 a : in std_logic_vector(17 downto 0);
24 b : in std_logic_vector(17 downto 0);
25 s : out std_logic_vector(47 downto 0)
30 signal do_sum_y : std_logic;
31 signal do_sum_y_dly : std_logic;
32 signal do_sum_cr : std_logic;
33 signal do_sum_cr_dly : std_logic;
34 signal do_sum_cb : std_logic;
35 signal do_sum_cb_dly : std_logic;
36 signal do_out : std_logic;
37 signal do_out_cr : std_logic;
38 signal do_out_cb : std_logic;
39 signal do_out_y : std_logic;
40 signal count_y : unsigned (2 downto 0);
41 signal count_cr : unsigned (2 downto 0);
42 signal count_cb : unsigned (2 downto 0);
43 signal y : signed(8 downto 0);
44 signal y_dly1 : signed(8 downto 0);
45 signal y_dly2 : signed(8 downto 0);
46 signal cb : signed(8 downto 0);
47 signal cb_dly1 : signed(8 downto 0);
48 signal cr : signed(8 downto 0);
49 signal cst_y_r : signed(17 downto 0);
50 signal cst_y_g : signed(17 downto 0);
51 signal cst_y_b : signed(17 downto 0);
52 signal cst_cb_r : signed(17 downto 0);
53 signal cst_cb_g : signed(17 downto 0);
54 signal cst_cb_b : signed(17 downto 0);
55 signal cst_cr_r : signed(17 downto 0);
56 signal cst_cr_g : signed(17 downto 0);
57 signal cst_cr_b : signed(17 downto 0);
59 signal bypass_y : std_logic;
60 signal a_y : std_logic_vector(17 downto 0);
61 signal b_y : std_logic_vector(17 downto 0);
62 signal s_y : std_logic_vector(47 downto 0);
63 signal bypass_cr : std_logic;
64 signal a_cr : std_logic_vector(17 downto 0);
65 signal b_cr : std_logic_vector(17 downto 0);
66 signal s_cr : std_logic_vector(47 downto 0);
67 signal bypass_cb : std_logic;
68 signal a_cb : std_logic_vector(17 downto 0);
69 signal b_cb : std_logic_vector(17 downto 0);
70 signal s_cb : std_logic_vector(47 downto 0);
72 signal compo_out : std_logic_vector(7 downto 0);
76 y_multiplier : mult_accum
86 cr_multiplier : mult_accum
96 cb_multiplier : mult_accum
108 cst_y_r <= to_signed(33658, 18);
109 cst_y_g <= to_signed(66077, 18);
110 cst_y_b <= to_signed(12833, 18);
111 cst_cb_r <= to_signed(-19428, 18);
112 cst_cb_g <= to_signed(-38141, 18);
113 cst_cb_b <= to_signed(57569, 18);
114 cst_cr_r <= to_signed(57569, 18);
115 cst_cr_g <= to_signed(-48207, 18);
116 cst_cr_b <= to_signed(-9362, 18);
118 multy_process : process (@{clk}, @{reset})
120 if @{reset} = '1' then
121 a_y <= (others => '0');
122 b_y <= (others => '0');
124 count_y <= to_unsigned(0, 3);
127 elsif rising_edge(@{clk}) then
131 a_y <= (others => '0');
132 b_y <= (others => '0');
134 if @{rgb_in_enb} = '1' then
136 a_y <= "0000000000" & @{rgb_in};
139 b_y <= std_logic_vector(cst_y_b);
141 count_y <= to_unsigned(1, 3);
143 elsif count_y = 1 then
144 b_y <= std_logic_vector(cst_y_g);
145 count_y <= to_unsigned(2, 3);
147 elsif count_y = 2 then
148 b_y <= std_logic_vector(cst_y_r);
149 count_y <= to_unsigned(0, 3);
154 end process multy_process;
156 sumy_process : process (@{clk}, @{reset})
158 if @{reset} = '1' then
160 y <= to_signed(0, 9);
161 y_dly1 <= to_signed(0, 9);
162 y_dly2 <= to_signed(0, 9);
164 elsif rising_edge(@{clk}) then
165 bypass_y <= do_sum_y;
166 do_sum_y_dly <= do_sum_y;
170 if do_sum_y_dly = '1' then
171 y <= to_signed(16, 9) + signed(s_y(25 downto 17));
175 end process sumy_process;
177 multcb_process : process (@{clk}, @{reset})
179 if @{reset} = '1' then
180 a_cb <= (others => '0');
181 b_cb <= (others => '0');
183 count_cb <= to_unsigned(0, 3);
186 elsif rising_edge(@{clk}) then
190 a_cb <= (others => '0');
191 b_cb <= (others => '0');
193 if @{rgb_in_enb} = '1' then
195 a_cb <= "0000000000" & @{rgb_in};
198 b_cb <= std_logic_vector(cst_cb_b);
200 count_cb <= to_unsigned(1, 3);
202 elsif count_cb = 1 then
203 b_cb <= std_logic_vector(cst_cb_g);
204 count_cb <= to_unsigned(2, 3);
206 elsif count_cb = 2 then
207 b_cb <= std_logic_vector(cst_cb_r);
208 count_cb <= to_unsigned(0, 3);
213 end process multcb_process;
215 sumcb_process : process (@{clk}, @{reset})
217 if @{reset} = '1' then
219 cb <= to_signed(0, 9);
220 cb_dly1 <= to_signed(0, 9);
221 elsif rising_edge(@{clk}) then
222 bypass_cb <= do_sum_cb;
223 do_sum_cb_dly <= do_sum_cb;
226 if do_sum_cb_dly = '1' then
227 cb <= to_signed(128, 9) + signed(s_cb(25 downto 17));
231 end process sumcb_process;
233 multcr_process : process (@{clk}, @{reset})
235 if @{reset} = '1' then
236 a_cr <= (others => '0');
237 b_cr <= (others => '0');
239 count_cr <= to_unsigned(0, 3);
242 elsif rising_edge(@{clk}) then
246 a_cr <= (others => '0');
247 b_cr <= (others => '0');
249 if @{rgb_in_enb} = '1' then
251 a_cr <= "0000000000" & @{rgb_in};
254 b_cr <= std_logic_vector(cst_cr_b);
256 count_cr <= to_unsigned(1, 3);
258 elsif count_cr = 1 then
259 b_cr <= std_logic_vector(cst_cr_g);
260 count_cr <= to_unsigned(2, 3);
262 elsif count_cr = 2 then
263 b_cr <= std_logic_vector(cst_cr_r);
264 count_cr <= to_unsigned(0, 3);
269 end process multcr_process;
271 sumcr_process : process (@{clk}, @{reset})
273 if @{reset} = '1' then
275 cr <= to_signed(0, 9);
278 elsif rising_edge(@{clk}) then
279 bypass_cr <= do_sum_cr;
280 do_sum_cr_dly <= do_sum_cr;
283 if do_sum_cr_dly = '1' then
285 cr <= to_signed(128, 9) + signed(s_cr(25 downto 17));
288 end process sumcr_process;
290 out_process : process (@{clk}, @{reset})
292 if @{reset} = '1' then
295 elsif rising_edge(@{clk}) then
296 do_out_cb <= do_out_cr;
297 do_out_y <= do_out_cb;
299 end process out_process;
302 @{ycbcr_out} <= std_logic_vector(y_dly2(7 downto 0)) when do_out_y = '1' else
303 std_logic_vector(cb_dly1(7 downto 0)) when do_out_cb = '1' else
304 std_logic_vector(cr(7 downto 0)) when do_out_cr = '1' else
306 @{ycbcr_out_enb} <= do_out_y or do_out_cb or do_out_cr;
311 <input pattern="111" name="rgb_in_enb"/>
313 <production counter="3,3,3">
314 <output pattern="00000111" name="ycbcr_out_enb"/>