?? videocpt.vhd
字號(hào):
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
USE ieee.std_logic_unsigned.all;
ENTITY videocpt IS
PORT
(
cdao : out std_logic_vector(7 downto 0); -- 驗(yàn)證視頻數(shù)據(jù)輸出口
cps : out std_logic; -- 視頻數(shù)據(jù)輸出像素 Pixel SYN Signal
cfs : out std_logic; -- 視頻數(shù)據(jù)輸出幀
caclk: out std_logic;
cclk : in std_logic; --主時(shí)鐘 24M
cdi : in std_logic_vector(7 downto 0); --視頻數(shù)據(jù)輸入口
pclk : in std_logic; -- 采集時(shí)鐘 4M
ccs : in std_logic; -- 視頻信號(hào)選擇
avf : in std_logic; --有效場(chǎng)同步幀
avh : in std_logic; --有效行同步幀
vd : in std_logic --場(chǎng)同步信號(hào)
);
END videocpt;
ARCHITECTURE a OF videocpt IS
constant StartWidPix : integer range 0 to 1023 := 0; --起始寬度像素常量
constant StartHiPix : integer range 0 to 288 := 0; --起始高度像素常量
constant EndWidPix : integer range 0 to 1023 := 704; --末端寬度像素常量
constant EndHiPix : integer range 0 to 288 := 287; --末端高度像素常量
signal pclk1 : std_logic := '0';
signal demodata : std_logic_vector(7 downto 0) := "01111001";
signal readline : std_logic := '0';
signal read : std_logic := '0';
signal done : std_logic := '0';
BEGIN
process (cclk)
variable ccount : integer range 0 to 3 :=0;
begin
if cclk='1' and cclk'event then
if ccount < 3 then
ccount := ccount+1; caclk <= '1';
else
ccount := 0; caclk <= '0';
end if;
end if;
end process;
process (cclk, ccs )
variable HPCnt : integer range 0 to 288 := 0;
variable WPCnt : integer range 0 to 1023 := 0;
variable avh1 : std_logic; -- avh延遲1個(gè)周期
variable vd1 : std_logic; -- vd延遲1個(gè)周期
variable frame : boolean; -- 搜索起始幀
begin
if ccs = '1' then
read <='0';
frame := FALSE;
HPCnt:=0;
WPCnt:=0;
done <='0';
elsif cclk='1' and cclk'event then
pclk1<=pclk;
if vd1='1' and vd='0' and done='0' then
done<='1';
frame :=TRUE;
HPCnt:=0;
WPCnt:=0;
end if;
if frame and avh1='0' and avh='1' then
if HPCnt < 288 then
HPCnt:=HPCnt+1;
end if;
WPCnt:=0;
end if;
if frame and avh='1' and avf='1' then
readline<='1';
else
readline<='0';
end if;
if(readline='1' and pclk='0'and pclk1='1')then
WPCnt:=WPCnt+1;
end if;
--此處如果用if frame and HPCnt>3-HiPix and HPCnt<=HiPix and avh='1' and avf = '1' then 就會(huì)出現(xiàn)毛刺
if frame and HPCnt>StartHiPix and HPCnt<=EndHiPix and WPCnt>=StartWidPix and WPCnt<EndWidPix then
if avh='1' and avf = '1' then
read <='1';
demodata<=cdi;
else
read<='0';
end if;
else
read <='0';
end if;
vd1:=vd;
avh1:=avh;
end if;
end process;
cdao <= demodata WHEN read = '1' ELSE (OTHERS=>'1') ;
cps <= not pclk1 WHEN read = '1' ELSE '1' ;
cfs <= '1';
END a;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -