Forum Discussion
Altera_Forum
Honored Contributor
9 years ago --- Quote Start --- So, what about you give more details, like the code, target device, clock rate, etc...? --- Quote End --- thank you for your answer. i attached my code. but just simple code for all 1's pixel count. actually i want to count only linked 1's pixel count. but i can't. ================================= library ieee; library cycloneive; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.numeric_std.all; use cycloneive.all; entity img_processor is port( CLK10KHz : in std_logic; line_scan_data : in std_logic_vector(4 downto 0); qty_1_pixel : out std_logic_vector(7 downto 0) ) end entity; architecture rtl of img_processor is type img_array is array(0 to 4) of std_logic_vector(4 downto 0); signal img : img_array; begin process(CLK10KHz) begin if CLK10KHz'event and CLK10KHz = '1' then img(0) <= line_scan_data; for i in 0 to 3 loop img(i+1) <= img(i); end loop; qty_1_pixel <= ((("0000000"&img( 0)(0) + img( 0)(1) + img( 0)(2)) + ("0000000"&img( 0)(3) + img( 0)(4))) + (( "0000000"&img( 1)(0) + img( 1)(1) + img( 1)(2)) + ("0000000"&img( 1)(3) + img( 1)(4))) + (( "0000000"&img( 2)(0) + img( 2)(1) + img( 2)(2)) + ("0000000"&img( 2)(3) + img( 2)(4)))) + ((("0000000"&img( 3)(0) + img( 3)(1) + img( 3)(2)) + ("0000000"&img( 3)(3) + img( 3)(4))) + (( "0000000"&img( 4)(0) + img( 4)(1) + img( 4)(2)) + ("0000000"&img( 4)(3) + img( 4)(4)))); end process; end rtl;