flote21
Advanced Member level 1
- Joined
- Jan 22, 2014
- Messages
- 411
- Helped
- 1
- Reputation
- 2
- Reaction score
- 3
- Trophy points
- 1,298
- Activity points
- 5,595
Hello buddys!
I am working with a image sensor which delivers 4 pixels (12 bits/pixel) every system clock.
The pixel output of the sensor is 6 Lines x 2112 pixels. And I want to throw away some pixels per line according to the parameter SHIFT_COL.
For example,
- if SHIFT_COL = 1, the 1st pixel of every line should be skipped resulting 2111 pixels.
- if SHIFT_COL = 2, the 2 first pixels of every line should be skipped resulting 2110 pixels
- and so on...
Here is the code that I have already programmed. But I think that it could be a better coding for this issue. Any suggestion?
Thanks anyway!
I am working with a image sensor which delivers 4 pixels (12 bits/pixel) every system clock.
The pixel output of the sensor is 6 Lines x 2112 pixels. And I want to throw away some pixels per line according to the parameter SHIFT_COL.
For example,
- if SHIFT_COL = 1, the 1st pixel of every line should be skipped resulting 2111 pixels.
- if SHIFT_COL = 2, the 2 first pixels of every line should be skipped resulting 2110 pixels
- and so on...
Here is the code that I have already programmed. But I think that it could be a better coding for this issue. Any suggestion?
Code:
-- Valid Pixels Management:
-- Receiving 4 pixels on every clock cycle and skip some of them
-- according to the parameter SHIFT_COL
SHIFT_DAV <= '0';
if VID_I_DAV = '1' then -- New "4pixels"
VID_I_CNT <= VID_I_CNT + 4;
SHIFT_SEL <= SHIFT_SEL + 1;
-- Binning 6x6 => Max. 10 pixels to shift!
if FPGA_MODE_l = "100" then
case SHIFT_COLr is
when x"0000" => -- No shifting
if SHIFT_SEL = 0 then
SHIFT_DATA_REG <= VID_I_DATA;
SHIFT_DAV <= '1';
SHIFT_SEL <= (others=>'0');
SHIFT_CNT <= SHIFT_CNT + 4;
end if;
when x"0001" => -- Shifting 1 column
if SHIFT_SEL = 0 then
SHIFT_PIX_REG1 <= VID_I_DATA(23 downto 12);
SHIFT_PIX_REG2 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG3 <= VID_I_DATA(47 downto 36);
elsif SHIFT_SEL = 1 then
SHIFT_PIX_REG1 <= VID_I_DATA(23 downto 12);
SHIFT_PIX_REG2 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG3 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(11 downto 0) & SHIFT_PIX_REG3 & SHIFT_PIX_REG2 & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_CNT <= SHIFT_CNT + 4;
elsif SHIFT_SEL = 2 then
SHIFT_PIX_REG1 <= VID_I_DATA(23 downto 12);
SHIFT_PIX_REG2 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG3 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(11 downto 0) & SHIFT_PIX_REG3 & SHIFT_PIX_REG2 & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_SEL <= x"1";
SHIFT_CNT <= SHIFT_CNT + 4;
end if;
when x"0002" => -- Shifting 2 columns
if SHIFT_SEL = 0 then
SHIFT_PIX_REG1 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG2 <= VID_I_DATA(47 downto 36);
elsif SHIFT_SEL = 1 then
SHIFT_PIX_REG1 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG2 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(23 downto 0) & SHIFT_PIX_REG2 & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_CNT <= SHIFT_CNT + 4;
elsif SHIFT_SEL = 2 then
SHIFT_PIX_REG1 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG2 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(23 downto 0) & SHIFT_PIX_REG2 & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_SEL <= x"1";
SHIFT_CNT <= SHIFT_CNT + 4;
end if;
when x"0003" => -- Shifting 3 columns
if SHIFT_SEL = 0 then
SHIFT_PIX_REG1 <= VID_I_DATA(47 downto 36);
elsif SHIFT_SEL = 1 then
SHIFT_PIX_REG1 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(35 downto 0) & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_CNT <= SHIFT_CNT + 4;
elsif SHIFT_SEL = 2 then
SHIFT_PIX_REG1 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(35 downto 0) & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_SEL <= x"1";
SHIFT_CNT <= SHIFT_CNT + 4;
end if;
--
when x"0004" => -- Shifting 4 columns
if SHIFT_SEL = 1 then
SHIFT_DATA_REG <= VID_I_DATA;
SHIFT_DAV <= '1';
SHIFT_SEL <= x"1";
SHIFT_CNT <= SHIFT_CNT + 4;
end if;
when x"0005" => -- Shifting 5 columns
if SHIFT_SEL = 1 then
SHIFT_PIX_REG1 <= VID_I_DATA(23 downto 12);
SHIFT_PIX_REG2 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG3 <= VID_I_DATA(47 downto 36);
elsif SHIFT_SEL = 2 then
SHIFT_PIX_REG1 <= VID_I_DATA(23 downto 12);
SHIFT_PIX_REG2 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG3 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(11 downto 0) & SHIFT_PIX_REG3 & SHIFT_PIX_REG2 & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_CNT <= SHIFT_CNT + 4;
elsif SHIFT_SEL = 3 then
SHIFT_PIX_REG1 <= VID_I_DATA(23 downto 12);
SHIFT_PIX_REG2 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG3 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(11 downto 0) & SHIFT_PIX_REG3 & SHIFT_PIX_REG2 & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_SEL <= x"2";
SHIFT_CNT <= SHIFT_CNT + 4;
end if;
when x"0006" => -- Shifting 6 columns
if SHIFT_SEL = 1 then
SHIFT_PIX_REG1 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG2 <= VID_I_DATA(47 downto 36);
elsif SHIFT_SEL = 2 then
SHIFT_PIX_REG1 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG2 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(23 downto 0) & SHIFT_PIX_REG2 & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_CNT <= SHIFT_CNT + 4;
elsif SHIFT_SEL = 3 then
SHIFT_PIX_REG1 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG2 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(23 downto 0) & SHIFT_PIX_REG2 & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_SEL <= x"2";
SHIFT_CNT <= SHIFT_CNT + 4;
end if;
when x"0007" => -- Shifting 7 columns
if SHIFT_SEL = 1 then
SHIFT_PIX_REG1 <= VID_I_DATA(47 downto 36);
elsif SHIFT_SEL = 2 then
SHIFT_PIX_REG1 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(35 downto 0) & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_CNT <= SHIFT_CNT + 4;
elsif SHIFT_SEL = 3 then
SHIFT_PIX_REG1 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(35 downto 0) & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_SEL <= x"2";
SHIFT_CNT <= SHIFT_CNT + 4;
end if;
--
when x"0008" => -- Shifting 8 columns
if SHIFT_SEL = 2 then
SHIFT_DATA_REG <= VID_I_DATA;
SHIFT_DAV <= '1';
SHIFT_SEL <= x"2";
SHIFT_CNT <= SHIFT_CNT + 4;
end if;
when x"0009" => -- Shifting 9 column
if SHIFT_SEL = 2 then
SHIFT_PIX_REG1 <= VID_I_DATA(23 downto 12);
SHIFT_PIX_REG2 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG3 <= VID_I_DATA(47 downto 36);
elsif SHIFT_SEL = 3 then
SHIFT_PIX_REG1 <= VID_I_DATA(23 downto 12);
SHIFT_PIX_REG2 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG3 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(11 downto 0) & SHIFT_PIX_REG3 & SHIFT_PIX_REG2 & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_CNT <= SHIFT_CNT + 4;
elsif SHIFT_SEL = 4 then
SHIFT_PIX_REG1 <= VID_I_DATA(23 downto 12);
SHIFT_PIX_REG2 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG3 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(11 downto 0) & SHIFT_PIX_REG3 & SHIFT_PIX_REG2 & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_SEL <= x"3";
SHIFT_CNT <= SHIFT_CNT + 4;
end if;
when x"000A" => -- Shifting 10 columns
if SHIFT_SEL = 2 then
SHIFT_PIX_REG1 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG2 <= VID_I_DATA(47 downto 36);
elsif SHIFT_SEL = 3 then
SHIFT_PIX_REG1 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG2 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(23 downto 0) & SHIFT_PIX_REG2 & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_CNT <= SHIFT_CNT + 4;
elsif SHIFT_SEL = 4 then
SHIFT_PIX_REG1 <= VID_I_DATA(35 downto 24);
SHIFT_PIX_REG2 <= VID_I_DATA(47 downto 36);
SHIFT_DATA_REG <= VID_I_DATA(23 downto 0) & SHIFT_PIX_REG2 & SHIFT_PIX_REG1;
SHIFT_DAV <= '1';
SHIFT_SEL <= x"3";
SHIFT_CNT <= SHIFT_CNT + 4;
end if;
when others => null;
end case;
end if;
end if;
Thanks anyway!