作者mouein (Dennis)
站内Electronics
标题Re: [问题] VHDL之计数器问题
时间Tue May 15 15:07:12 2007
entity counter is
port(
rst,clk : in std_logic;
c : out std_logic_vector(3 downto 0));
end counter;
architecture Behavioral of counter is
signal tc: std_logic_vector(3 downto 0);
begin
process(clk)
begin
if rst='1' then
tc <= "0000";
else
tc <= tc + 1;
end if;
c <= tc;
end process;
end Behavioral;
Xilinx ISE8.2跑的结果是可以的~ 你跑跑看吧!!!
process里面放clk,只要clk有变化就动作 其他上缘下缘都不管他
小弟愚见~~ 有误请板上前辈指教 谢谢!!
※ 引述《CuckooBoy (阿书)》之铭言:
: 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;
--
得益网 (大陆网站)
http://0rz.tw/6f2DH
有积分制度的电子书网站,每天登入一次加一分
工程 电子 经济 企管 休闲 相关电子书免费下载
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.122.79.143
※ 编辑: mouein 来自: 140.122.79.143 (05/15 15:09)
1F:推 SILee:哇!! 你签名档的那个网站好赞啊 05/15 15:40
2F:→ SILee:资料很齐 应有尽有 05/15 15:40
3F:推 CuckooBoy:嗯?不明白你贴了一个计数器的程式目地? 05/15 21:41
4F:→ CuckooBoy:为什麽你没有用CLK上缘触发,LIST怮o有CLK? 05/15 21:42
5F:推 CuckooBoy:你的+1是不是少'' 两点? 05/15 22:10