|
发表于 2009-10-23 11:36:38
|
显示全部楼层
想用FPGA制作一个32位的计数器,以测量脉冲的频率,——————完全可以,,而且很“适合”!!
——————————————非常容易实现——————————
—————“脉冲”——应该是重复的??有稳定周期的??——才能谈得上“频率”吧!?
做 32位 计数器————可以参考————C1,R1 是12位的计数器,T1是8位的。。。。改成“31”就成了32位计数器了。
entity My_Lhx is
port (clk_1M,I1,I2,I6,I4,I3,SL,SY:IN Std_Logic;
O1,O2,O6,Ot4,O3:Out Std_Logic);
end My_Lhx;
architecture inference of My_Lhx is
signal C1:Std_Logic_Vector(11 Downto 0);
signal R1:Std_Logic_Vector(11 Downto 0);
signal T1:Std_Logic_Vector(7 Downto 0);
process (clk_1M)
begin
if (clk_1M'EVENT and clk_1M='1') then
if (I1 = '0') then
T1 <= T1 + '1';
if (T1 = Conv_Std_Logic_Vector(252,8) and C1 > Conv_Std_Logic_Vector(511,12)) then
Wr1 <= '1';
R1 <= C1;
else
Wr1 <= '0';
end if;
if (T1 > Conv_Std_Logic_Vector(254,8)) then
C1 <= "000000000000";
end if;
else
C1 <= C1 + '1';
T1 <= "00000000";
Wr1 <= '0';
end if; -- END Part Input 1#
end if;
end process;
end My_Lhx; |
|