|
楼主 |
发表于 2010-6-10 09:31:13
|
显示全部楼层
楼上的大哥什么是gated clock还有什么是 enable 呀,小弟新手不明白呀
要不我把程序贴上吧,之前写得更复杂大程序都没问题,这个不知道咋回事
LIBRARY ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
ENTITY tongbu IS
PORT(
CLK : IN std_logic; --晶振时钟
clks : IN std_logic; --秒脉冲输入
reset : IN std_logic;
clk_tb : OUT STD_LOGIC ;--同步信号输出
right : OUT STD_LOGIC ;
fault : OUT STD_LOGIC );
END tongbu ;
ARCHITECTURE a OF tongbu IS
SIGNAL s0 : STD_LOGIC ;
SIGNAL s1 : STD_LOGIC ;
SIGNAL s2 : STD_LOGIC ;
signal count :integer range 0 to 255;
signal pps_count :integer range 0 to 8;
signal low_count :integer range 0 to 8;
BEGIN
process(clks,s0)
begin
if(clks'event and clks='1')then
s1<='1';
end if;
if(s0='1')then
s1<='0';
end if;
end process;
process(CLK,clks,s1,count,reset)
begin
if(s1='1')then
if(CLK'event and CLK='1')then
if(count=255 or (clks='1' and count>25)or reset='0')then
count<=0;
else count<=count+1;
end if;
end if;
end if;
end process;
process(clks,count)
begin
if(clks'event and clks='0')then
if(count<25 and s2='0')then
low_count<=low_count+1;
end if;
end if;
end process;
process(low_count)
begin
if(low_count>1)then
s0<='1';
else s2<='1';
end if;
end process;
process(clks,count,pps_count)
begin
if(count>248 and count<252 and pps_count<4)then
if(clks'event and clks='1')then
pps_count<=pps_count+1;
end if;
end if;
end process;
process(pps_count)
begin
if(pps_count>2)then
right<='1';
fault<='0';
elsif(pps_count<3)then
fault<='1';
right<='0';
end if;
end process;
END a; |
|