模拟电视的行场扫描信号
| 发布日期:[2006/10/27] 共阅[3472]次 | --*********************************************
--模拟真实场和行信号--
-----------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity tongbu1 is
port( clk: in std_logic;
clk1: out std_logic;
k2 :out std_logic; --front
k3: out std_logic; --blance
k4: out std_logic; --back
k5: out std_logic_vector(13 downto 0); --half_front
k6: out std_logic; --half_back
h: out std_logic; --行时钟信号输出
v: out std_logic --场时钟信号输出
);
end tongbu1;
architecture a of tongbu1 is
--constant h_period : integer :=640;
--constant v_period : integer :=200000; --20ms
--constant h_positive : integer :=520;
--constant v_positive : integer :=18400;
--signal divi_clk : std_logic;
signal flagF : std_logic_vector(2 downto 0); --Front flag
signal flagB : std_logic_vector(2 downto 0); --Back flag
--signal flag1 : std_logic;
signal v_xylines: std_logic_vector(4 downto 0); --消隐时间的行数
--signal half_front: std_logic;
--signal half_back : std_logic;
signal half_Fcout : std_logic_vector(13 downto 0);----前半场计数
signal half_Bcout : std_logic_vector(13 downto 0);----后半场计数
signal clock: std_logic; ---记时时钟0.1us
signal v_syn: std_logic; --场同步脉冲
signal v_syn_cout: std_logic_vector(8 downto 0); --场同步脉冲计数
signal balance1: std_logic; --前均衡脉冲输出
signal balance2: std_logic; --后均衡脉冲输出
signal balan1_cout: std_logic_vector(8 downto 0);--前均衡脉冲计数
signal balan2_cout: std_logic_vector(8 downto 0);--后均衡脉冲计数
signal hh: std_logic; --行信号的复合结果
signal vv: std_logic; --场信号的复合结果
signal h_period: std_logic_vector(9 downto 0);--行周期64us
signal v_period: std_logic_vector(13 downto 0); --场周期,假设场周期为20ms
signal h_cout: std_logic_vector(9 downto 0);--行计数值最大计数值为625
--signal v_cout: std_logic_vector(13 downto 0);--场计数值
--输入的时钟频率假定为20M,分频后得到10M的时钟。
begin
process(clk)
begin
if(clk'event and clk='1') then
clock<= not clock; --0.1us
clk1<=clock;
end if;
end process;
--********************************************/
--行信号的产生,扫描行数为625行,行周期64us
--********************************************/
process(clock)
begin
if(clock'event and clock='1') then
if(h_period=640)then --行周期64us
h_period<=(others =>'0');
if(h_cout=625) then --奇数场扫描的行数,假设奇数场扫描312行
h_cout<=(others =>'0');
else
h_cout<=h_cout+1;
end if;
else
h_period<=h_period+1;
end if;
end if;
end process;
--***********************************************/
----产生行同步信号,脉冲宽度为4.7us
--***********************************************/
process(h_period)
begin
if(h_period>="1000001000" and h_period<"1000110111") then --同步信号的产生,52us---56.7us为同步信号宽度为4.7US
hh<='0'; --52us -- 56.7us
else
hh<='1';
end if;
end process;
--***********************************************/
----扫描前半行的记时
--***********************************************/
process(clock)
begin
if(clock'event and clock='1') then
if(h_cout>=287 and h_cout<=313) then
if(half_Fcout=16320) then --half line
half_Fcout<=(others =>'0');
else
half_Fcout<=half_Fcout+1;
--flag <='1';
end if;
end if;
end if;
end process;
--***********************************************/
----扫描后半行的记时
--***********************************************/
process(clock,h_cout)
begin
if(clock'event and clock='1') then
if(h_cout>=600 and h_cout<=625) then
if(half_Bcout=16000) then --half line
half_Bcout<=(others =>'0');
--flagB <='0';
else
half_Bcout<=half_Bcout+1;
--flag <='1';
end if;
end if;
end if;
end process;
--*****************************************************************************/
--场同步信号,在奇数场扫描完成后产生场同步信号,宽度为7.5H(480us低电平信号)
--当扫描行数为287时,开始产生场同步信号
--*****************************************************************************/
process(flagF,clock) --场信号的产生
begin
if(clock'event and clock='1') then
--------287.5-------------312------
if(half_Fcout>320 and half_Fcout<16320) then --奇数场结束,产生场同步信号,场消隐阶段
--时间从半行结束后开始到场消隐结束
if(v_period=16000) then --场消隐
v_period<=(others =>'0');
--flagF<='0';
--flagB<='0';
else
v_period<=v_period+1;
end if;
end if;
if(v_period>0 and v_period<=4800 ) then --480us
vv<='0';
else
vv<='1';
end if;
end if;
end process;
--***********************************************/
---前均衡脉冲,总时间为2.5H脉冲宽度为2.3us
--***********************************************/
process(clock,v_period)
begin
if(clock'event and clock='1') then
if(v_period>0 and v_period<=1600) then --前均衡脉冲从计数开始到2.5H
if(balan1_cout=320) then --32us,每个脉宽的周期时间
balan1_cout<=(others =>'0');
else
balan1_cout<=balan1_cout+1;
end if;
end if;
end if;
if(balan1_cout>0 and balan1_cout<=23) then
balance1<='0';
else
balance1<='1';
end if;
end process;
--********************************************************/
---场同步信号,总时间为2.5H,齿脉冲27.3us,开槽宽度4.7us
--********************************************************/
process(clock,v_period)
begin
if(clock'event and clock='1') then
if(v_period>1600 and v_period<=3200) then
if(v_syn_cout=320) then
v_syn_cout<=(others =>'0');
else
v_syn_cout<=v_syn_cout+1;
end if;
end if;
end if;
if(v_syn_cout>0 and v_syn_cout<=273) then
v_syn<='0';
else
v_syn<='1';
end if;
end process;
--********************************************************/
---后均衡脉冲信号,总时间为2.5H,脉冲宽度为2.3us;
--********************************************************/
process(clock,v_period)
begin
if(clock'event and clock='1') then
if(v_period>3200 and v_period<=4800) then
if(balan2_cout=320) then
balan2_cout<=(others =>'0');
else
balan2_cout<=balan2_cout+1;
end if;
end if;
end if;
if(balan2_cout>0 and balan2_cout<=23) then
balance2<='0';
else
balance2<='1';
end if;
end process;
---*****************************************/
--信号输出
--******************************************/
h<=hh; --行信号
v<=vv; --场信号
k2<=balance1; --前均衡脉冲
k3<=v_syn; --场同步信号
k4<=balance2; --后均衡脉冲
k5<=half_Fcout;
k6<=((balance1 and v_syn) and balance2) or vv; --场复合信号
end a;
|
|