整个程序分三个模块:u1,u2,u3,其中u1是分频模块,用4输出计数器对输入的62M主时钟(mclk)进行2分频,u2是图像数据产生模块,用8位的计数器来产生灰度图象数据。u3模块是利用13位的计数器来产生控制信号,严格按照要求的时序关系,分别产生像元时钟(DCLK)、行同步信号(LVAL)、外触发信号(DTRG)。部分源程序如下:
begin
u1:fenpin port map(mclk,clr0,set,clk);? //引用分频模块
u2:count8 port map(clk,clr1,set,countout8);//引用8位计数器
u3:count13 port map (clk,clr2,set,countout13);//引用13位计数器
set<='1';
clr1<='0';
dclk<=clk;
process(clk)
begin
if(clk'event and clk='1')then
if (countout13>=4096 and countout13<=4099)then
lval<='1';
data<=countout8;
else
lval<='0';
end if;
if(countout13=4099)then
dtrg<='1';
clr2<='1';
else
dtrg<='0';
clr2<='0';
end if;
if(countout13>=0 and countout13<=3071)then
data<=countout8;//输出有效像元
end if;
if (countout13>=3072 and countout13<=4095)then
data<=0;//输出零像元
end if;
end if;
end process;
end rtl;
时序仿真图如下图所示:

5总结
编译仿真通过后,在顶层用原理图进行综合实现,然后烧入芯片进行实验,并根据实际运行情况,对设计进行改进。如根据实际器件的延时特性,在设计中某些地方插入适当的延迟单元以保证各时延一致。
根据本文介绍的设计方案,采用CPLD技术设计的多路CCD图像信号模拟器结构简单,实现方便,易于修改。在图像采集卡的测试过程中,发挥了重要作用。