作者CuckooBoy (阿书)
看板comm_and_RF
标题[问题] VHDL之计数器问题
时间Mon May 14 21:27:43 2007
http://ilook.tw/7e6a
这是一个,上/下缘皆累加的计数器
但是发现有一个问题
如图中, 框/圈起来的地方...
也就是cnt_r跟cnt_f都为3後归0的那段会出问题
不知道如何解决呢?小弟一直想不出什麽办法!
此模拟的程式如下,请大大指点...感谢~~
===========================================================
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity test is
Port ( Clock : in std_logic;
Led : out std_logic_vector(3 downto 0));
end test;
architecture Behavioral of test is
signal cnt : std_logic_vector(3 downto 0);
signal cnt_r:std_logic_vector(3 downto 0);
signal cnt_f:std_logic_vector(3 downto 0);
begin
process(Clock)
begin
if rising_edge(Clock) then
if cnt_r<3 then
cnt_r<=cnt_r+'1';
end if;
end if;
end process;
process(Clock)
begin
if falling_edge(Clock) then
if cnt_f<3 then
cnt_f <= cnt_f + '1';
end if;
end if;
end process;
cnt <= cnt_r + cnt_f;
Led<=cnt;
end Behavioral;
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 123.195.6.78
1F:→ zerocustom00:+/-源触发都一起用可能也会无法合成. 220.130.19.220 05/15 10:22
2F:→ zerocustom00:何不倍频再做计数器. 220.130.19.220 05/15 10:23