?? cam3.tdf
字號:
TITLE "CCD shutter controller";
% Vertion 1.20
Copyright GoldWay Its Co;Ltd. 2001-2002
Description
This EPLD is designed to control flash and electro-shutter speed.
Edit History
-05.16 Realize the main function.
By WangGuoqiang
-07.01 Add 4 time slots to change shutter speed more exact;
By Alix
-07.08 reduce system complexity.
By Chen
-07.09: rst[].clk=clk change to rst[].clk=xsg1
-8.16 changed again
-11.5 changed again :control flash
%
CONSTANT speed_cnt_max=255;
constant speed_cnt_flash=253;
constant speed_cnt_ss=250;
constant nature_1=1;
constant nature_2=2;
constant nature_3=3;
constant nature_4=4;
constant nature_8=8;
constant nature_16=16;
constant nature_32=32;
constant h_cnt_max=500;
constant h_even=313;
constant h_odd=312;
constant h_even_1=312;
constant h_odd_1=311;
constant xsub1_cnt_max =700;
SUBDESIGN CAM3
(
xv2,xv3 : INPUT;
xsg1,clk : INPUT;
xsub_in : INPUT;
ctrl1 : INPUT;
ctrl2 : INPUT;
xsub_out : OUTPUT;
flash1 : OUTPUT;
flash2 : OUTPUT;
)
VARIABLE
xsub_1 : NODE; --, xsub_2 xsub_1:every row drain charge pulse; xsub_2:last drain charge pulse
judge_field : NODE;
even_odd : DFF; -- hign odd , low even
ctrl_cnt[2..0] : DFF;
h_count[8..0] : DFF;
xsub1_cnt[9..0] : DFF;
--xsub2_cnt[9..0] : DFF;
judge_f[6..0] : DFF;
ctrl : NODE;
speed_cnt[7..0] : DFF;
-- nature_light capture shutter control 2002.5.13
nature[8..0] :node;-- dff;
flash_flag : DFF;
fast_shutt_f : DFF;
ss[3..0] : dff; --,sx[1..0]: dff; --,
ctrl14 :node; --add
clk_250 :node; --add
rst[2..0] :dff;
rest :node;
-- f_speed[8..0] :node; --flash use
BEGIN
-----------------------------------------
ctrl14=ctrl_cnt[]==1 or ctrl_cnt[]==4;
-- reset=ctrl1 and ctrl2;
rst[].clk=xsg1;--clk;
if rst[]<6 then
rst[]=rst[]+1;
else
rst[]=rst[];
end if;
if rst[]>=2 and rst[]<=4 then --8.16
rest=gnd; ------|__|---
else
rest=vcc;
end if;
-----------------------------------------
ctrl=ctrl1 or ctrl2;
-- create sample clock
speed_cnt[].clk=clk;
speed_cnt[].clrn=ctrl;
IF speed_cnt[]<speed_cnt_max THEN
speed_cnt[]=speed_cnt[]+1;
ELSE
speed_cnt[]=speed_cnt[];
END IF;
-- judge flash or no
flash_flag.clk=!(speed_cnt[]==speed_cnt_flash); -- -------|_|-----
-------------------------------------
-- nature capture field shutter control 2002.5.13
clk_250=!(speed_cnt[]==speed_cnt_ss);
ss[].clk=clk_250;
if ss[]>=11 then
flash_flag=vcc;
else
flash_flag=gnd;
end if;
if (rest==gnd) or (ss[]==0) or (nature[]==0) then
ss[]=9;--9;
nature[]=16;
else
IF ctrl1 and !ctrl2 THEN -- ctrl1 __|~~~~~|__
if ss[]<14 then
ss[]=ss[]+1;
else
ss[]=ss[];
end if;
ELSIF !ctrl1 and ctrl2 THEN -- ctrl1 ___________
if ss[]>1 then
ss[]=ss[]-1;
else
ss[]=ss[];
end if;
ELSE
ss[]=ss[];
end if;
case ss[] is
when 1=> nature[]=nature_1;
when 2=> nature[]=nature_1 ;
when 3=> nature[]=nature_1;
when 4=> nature[]=nature_2 ;
when 5=> nature[]=nature_2;
when 6=> nature[]=nature_3;
when 7=> nature[]=nature_4;
when 8=> nature[]=nature_8;
when 9=> nature[]=nature_16;
when 10=> nature[]=nature_32;
when 11=> nature[]=nature_32; --changed on 02/11/5
-- f_speed[]=33; -- f_speed[]=33;
when 12=> nature[]=nature_32;
-- f_speed[]=32; -- f_speed[]=33;
when 13=> nature[]=nature_32;
-- f_speed[]=31; -- f_speed[]=32;
when 14=> nature[]=nature_32;
--f_speed[]=30; --f_speed[]=31;
when others =>nature[]=nature_16;
end case;
END IF;
-- in these fields, control drain charge pulse
ctrl_cnt[].clk =xsg1;
ctrl_cnt[].clrn =!ctrl;
IF ctrl_cnt[]<6 THEN
ctrl_cnt[]=ctrl_cnt[]+1;
-- ctrl_cnt[]=4;--*********
ELSE
ctrl_cnt[]=ctrl_cnt[];
END IF;
-- judge even field or odd field
judge_f[].clk =clk;
judge_f[].clrn =xsg1;
IF judge_f[]<126 THEN
judge_f[]=judge_f[]+1;
ELSE
judge_f[]=judge_f[];
END IF;
IF judge_f[]>=26 and judge_f[]<=124 THEN --add :----|_____|----judee_field generated
judge_field=gnd;
ELSE
judge_field=vcc;
END IF;
even_odd.clk =judge_field;
even_odd =xv2;
-- find field end
h_count[].clk = xv3; --
h_count[].clrn =judge_field; --judge_field_dff; --add clear h_count[]
IF h_count[]<h_cnt_max THEN
h_count[]=h_count[]+1;
else
h_count[]=h_count[];
END IF;
------------------------------
------------------------------
-- 2002.5.16
fast_shutt_f.clk=xv3;
fast_shutt_f=(ctrl_cnt[]>=2 and ctrl_cnt[]<=3); --add 2 or 3 __xv3__|--fast_shutt_f<='1'
-- even field
IF even_odd THEN
IF fast_shutt_f THEN
IF h_count[]>0 and h_count[]<314 THEN
xsub_out= xsub_1;
ELSE
-- xsub_out= xsub_2;
xsub_out=vcc;
END IF;
--(ctrl_cnt[]==1 or ctrl_cnt[]==4)
ELSIF ctrl14 THEN
IF h_count[]>0 and h_count[]<(314-nature[]) THEN
xsub_out=xsub_1 or judge_f[]<28 ;
elsif h_count[]==(314-nature[]) then
--del-----------xsg1---------------------------|__|------
---xsub--|___|----------|___|-------------|_____|----
xsub_out =xsub_1 or judge_f[]<28 or !xv3 ;
ELSE
xsub_out =vcc;
END IF;
ELSE
xsub_out =xsub_in;
END IF;
-- odd field
--
ELSE
IF fast_shutt_f THEN
IF h_count[]>0 and h_count[]<313 THEN
xsub_out =xsub_1;
ELSE
xsub_out =vcc;
END IF;
ELSIF ctrl14 THEN
IF h_count[]>0 and h_count[]<(313-nature[]) THEN
xsub_out =xsub_1 ;
elsif h_count[]==(313-nature[]) then
xsub_out=xsub_1 or !xv3 ;
ELSE
xsub_out =vcc;
END IF;
ELSE
xsub_out =xsub_in;
END IF;
END IF;
--control flash light changed on 02/11/5
IF ctrl_cnt[]==1 and flash_flag THEN
if even_odd THEN
if ss[]==11 then
flash2=(h_count[]==281);-- and ( xsub1_cnt[]>=350));
elsif ss[]==12 then
flash2=((h_count[]==281) and ( xsub1_cnt[]>=250));
elsif ss[]==13 then
flash2=((h_count[]==281)and ( xsub1_cnt[]>=450));
elsif ss[]==14 then
flash2=(h_count[]==282);
else
flash2=gnd;
end if;
else
if ss[]==11 then
flash2=(h_count[]==280);
elsif ss[]==12 then
flash2=((h_count[]==280) and ( xsub1_cnt[]>=250));
elsif ss[]==13 then
flash2=((h_count[]==280)and ( xsub1_cnt[]>=450));
elsif ss[]==14 then
flash2=(h_count[]==281);
else
flash2=gnd;
end if;
end if;
ELSE
flash2=gnd;
END IF;
IF ctrl_cnt[]==2 THEN
IF even_odd THEN
flash1=(h_count[]==h_even);--313);
ELSE
flash1=(h_count[]==h_odd);--312);
END IF;
END IF;
-- drain charge pulse every row
xsub1_cnt[].clk =clk;
xsub1_cnt[].clrn =xv3;
IF xsub1_cnt[]<xsub1_cnt_max THEN --add:xsub_1:_____|--------
xsub1_cnt[]=xsub1_cnt[]+1;
ELSE
xsub1_cnt[]=xsub1_cnt[];
END IF;
if xsub1_cnt[]<27 then
xsub_1=gnd ;
elsif ctrl14 then
if xsub1_cnt[]>=200 and xsub1_cnt[]<=282 and ss[]==2 then --sx[]==1 then --and ctrl14
if even_odd then
-- then last hang +1:--312--|____|-313------|_313___|-----313 to 312
xsub_1=gnd or !(h_count[]==h_even );
else
xsub_1= gnd or !(h_count[]==h_odd);
end if;
elsif xsub1_cnt[]>367 and xsub1_cnt[]<=450 and ss[]==4 then--ss[]==1 then--and ctrl14
if even_odd then
xsub_1=gnd or !(h_count[]==h_even_1 );--313 to 312======
else
xsub_1= gnd or !(h_count[]==h_odd_1);
end if;
elsif xsub1_cnt[]>334 and xsub1_cnt[]<418 and ss[]==1 then --sx[]==2 then --and ctrl14
if even_odd then
xsub_1=gnd or !(h_count[]==h_even); --313 to 312
else
xsub_1=gnd or !(h_count[]==h_odd);
end if;
else
xsub_1=vcc ;
end if;
else
xsub_1=vcc ;
end if;
END;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -