1 <!DOCTYPE rgb3sx8_to_ycbcr_3DSP>
2 <block_impl ref_name="rgb3sx8_to_ycbcr_3DSP.xml" ref_md5="">
4 <author lastname="" mail="" firstname=""/>
5 <log creation="2018-05-02">
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_cr : std_logic;
37 signal do_out_cb : std_logic;
38 signal do_out_y : std_logic;
39 signal count_y : unsigned (2 downto 0);
40 signal count_cr : unsigned (2 downto 0);
41 signal count_cb : unsigned (2 downto 0);
42 signal y : signed(8 downto 0);
43 signal y_dly1 : signed(8 downto 0);
44 signal y_dly2 : signed(8 downto 0);
45 signal cb : signed(8 downto 0);
46 signal cb_dly1 : signed(8 downto 0);
47 signal cr : signed(8 downto 0);
48 signal cst_y_r : signed(17 downto 0);
49 signal cst_y_g : signed(17 downto 0);
50 signal cst_y_b : signed(17 downto 0);
51 signal cst_cb_r : signed(17 downto 0);
52 signal cst_cb_g : signed(17 downto 0);
53 signal cst_cb_b : signed(17 downto 0);
54 signal cst_cr_r : signed(17 downto 0);
55 signal cst_cr_g : signed(17 downto 0);
56 signal cst_cr_b : signed(17 downto 0);
58 signal bypass_y : std_logic;
59 signal a_y : std_logic_vector(17 downto 0);
60 signal b_y : std_logic_vector(17 downto 0);
61 signal s_y : std_logic_vector(47 downto 0);
62 signal bypass_cr : std_logic;
63 signal a_cr : std_logic_vector(17 downto 0);
64 signal b_cr : std_logic_vector(17 downto 0);
65 signal s_cr : std_logic_vector(47 downto 0);
66 signal bypass_cb : std_logic;
67 signal a_cb : std_logic_vector(17 downto 0);
68 signal b_cb : std_logic_vector(17 downto 0);
69 signal s_cb : std_logic_vector(47 downto 0);
73 y_multiplier : mult_accum
83 cr_multiplier : mult_accum
93 cb_multiplier : mult_accum
105 cst_y_r <= to_signed(33658, 18);
106 cst_y_g <= to_signed(66077, 18);
107 cst_y_b <= to_signed(12833, 18);
108 cst_cb_r <= to_signed(-19428, 18);
109 cst_cb_g <= to_signed(-38141, 18);
110 cst_cb_b <= to_signed(57569, 18);
111 cst_cr_r <= to_signed(57569, 18);
112 cst_cr_g <= to_signed(-48207, 18);
113 cst_cr_b <= to_signed(-9362, 18);
115 multy_process : process (@{clk}, @{reset})
117 if @{reset} = '1' then
118 a_y <= (others => '0');
119 b_y <= (others => '0');
121 count_y <= to_unsigned(0, 3);
124 elsif rising_edge(@{clk}) then
128 a_y <= (others => '0');
129 b_y <= (others => '0');
131 if @{rgb_in_enb} = '1' then
133 a_y <= "0000000000" & @{rgb_in};
136 b_y <= std_logic_vector(cst_y_b);
138 count_y <= to_unsigned(1, 3);
140 elsif count_y = 1 then
141 b_y <= std_logic_vector(cst_y_g);
142 count_y <= to_unsigned(2, 3);
144 elsif count_y = 2 then
145 b_y <= std_logic_vector(cst_y_r);
146 count_y <= to_unsigned(0, 3);
151 end process multy_process;
153 sumy_process : process (@{clk}, @{reset})
155 if @{reset} = '1' then
157 do_sum_y_dly <= '0';
158 y <= to_signed(0, 9);
159 y_dly1 <= to_signed(0, 9);
160 y_dly2 <= to_signed(0, 9);
162 elsif rising_edge(@{clk}) then
163 bypass_y <= do_sum_y;
164 do_sum_y_dly <= do_sum_y;
168 if do_sum_y_dly = '1' then
169 y <= to_signed(16, 9) + signed(s_y(25 downto 17));
173 end process sumy_process;
175 multcb_process : process (@{clk}, @{reset})
177 if @{reset} = '1' then
178 a_cb <= (others => '0');
179 b_cb <= (others => '0');
181 count_cb <= to_unsigned(0, 3);
184 elsif rising_edge(@{clk}) then
188 a_cb <= (others => '0');
189 b_cb <= (others => '0');
191 if @{rgb_in_enb} = '1' then
193 a_cb <= "0000000000" & @{rgb_in};
196 b_cb <= std_logic_vector(cst_cb_b);
198 count_cb <= to_unsigned(1, 3);
200 elsif count_cb = 1 then
201 b_cb <= std_logic_vector(cst_cb_g);
202 count_cb <= to_unsigned(2, 3);
204 elsif count_cb = 2 then
205 b_cb <= std_logic_vector(cst_cb_r);
206 count_cb <= to_unsigned(0, 3);
211 end process multcb_process;
213 sumcb_process : process (@{clk}, @{reset})
215 if @{reset} = '1' then
217 do_sum_cb_dly <= '0';
218 cb <= to_signed(0, 9);
219 cb_dly1 <= to_signed(0, 9);
220 elsif rising_edge(@{clk}) then
221 bypass_cb <= do_sum_cb;
222 do_sum_cb_dly <= do_sum_cb;
225 if do_sum_cb_dly = '1' then
226 cb <= to_signed(128, 9) + signed(s_cb(25 downto 17));
230 end process sumcb_process;
232 multcr_process : process (@{clk}, @{reset})
234 if @{reset} = '1' then
235 a_cr <= (others => '0');
236 b_cr <= (others => '0');
238 count_cr <= to_unsigned(0, 3);
241 elsif rising_edge(@{clk}) then
245 a_cr <= (others => '0');
246 b_cr <= (others => '0');
248 if @{rgb_in_enb} = '1' then
250 a_cr <= "0000000000" & @{rgb_in};
253 b_cr <= std_logic_vector(cst_cr_b);
255 count_cr <= to_unsigned(1, 3);
257 elsif count_cr = 1 then
258 b_cr <= std_logic_vector(cst_cr_g);
259 count_cr <= to_unsigned(2, 3);
261 elsif count_cr = 2 then
262 b_cr <= std_logic_vector(cst_cr_r);
263 count_cr <= to_unsigned(0, 3);
268 end process multcr_process;
270 sumcr_process : process (@{clk}, @{reset})
272 if @{reset} = '1' then
274 do_sum_cr_dly <= '0';
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"/>