Re: [問題] VHDL之計數器問題

看板Electronics作者 (Dennis)時間18年前 (2007/05/15 15:07), 編輯推噓3(302)
留言5則, 2人參與, 最新討論串2/4 (看更多)
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)

05/15 15:40, , 1F
哇!! 你簽名檔的那個網站好讚啊
05/15 15:40, 1F

05/15 15:40, , 2F
資料很齊 應有盡有
05/15 15:40, 2F

05/15 21:41, , 3F
嗯?不明白你貼了一個計數器的程式目地?
05/15 21:41, 3F

05/15 21:42, , 4F
為什麼你沒有用CLK上緣觸發,LIST怮o有CLK?
05/15 21:42, 4F

05/15 22:10, , 5F
你的+1是不是少'' 兩點?
05/15 22:10, 5F
文章代碼(AID): #16ILmYye (Electronics)
文章代碼(AID): #16ILmYye (Electronics)