標題:
基于fsm 0-9計數(shù)器源程序
[打印本頁]
作者:
BruderLung
時間:
2019-5-28 13:17
標題:
基于fsm 0-9計數(shù)器源程序
備注:
輸出信號使用燈泡來顯示“0000”表示1,“1001”表示9。
原理:
該電路的輸入為一個時鐘脈沖CLK和異步復(fù)位信號reset每段clk上升沿到達時計數(shù)器加一,直到九,下一個上升沿到達后計數(shù)結(jié)果為0,然后再周而復(fù)始的計數(shù)下去。reset高電平時正常技術(shù),當(dāng)reset為低電平時,計數(shù)從0開始,計數(shù)結(jié)果要接入LED燈泡顯示。
實現(xiàn)思路:
根據(jù)計數(shù)原理設(shè)置10個狀態(tài),分別表示為S0-S9,S0的狀態(tài)對應(yīng)0,驅(qū)動燈泡顯示為“0000”,下一個時鐘脈沖到達后,無條件從S0轉(zhuǎn)到S1,S1狀態(tài)對應(yīng)1,驅(qū)動燈泡顯示為“0001”,以此類推,直到S9狀態(tài)。在此狀態(tài)下,當(dāng)時鐘到達后,直接轉(zhuǎn)到S0。
狀態(tài)轉(zhuǎn)化圖:
VFXBK@3WNDZ_K@`HI8PB{CC.png
(11.87 KB, 下載次數(shù): 76)
下載附件
2019-5-28 13:10 上傳
部分程序代碼:
library ieee;
use ieee.std_logic_1164.all;
entity fsm_jishu is
port(clk,reset :in std_logic;
q:out std_logic_vector(3 downto 0));
end fsm_jishu;
architecture wang of fsm_jishu is
type state is (s0,s1,s2,s3,s4,s5,s6,s7,s8,s9);
signal currentstate,nextstate:state;
begin
--jincheng
with currentstate select
nextstate<=s1 when s0,
s2 when s1,
s3 when s2,
s4 when s3,
s5 when s4,
s6 when s5,
s7 when s6,
s8 when s7,
s9 when s8,
s0 when others;
--suochunjincheng
state_latch : process(clk,reset)
begin
if reset='0'then
currentstate<=s0;
elsif clk'event and clk='1'then
currentstate<=nextstate;
end if;
end process
復(fù)制代碼
詳細程序在附件
0-9計數(shù)器.docx
(12.66 KB, 下載次數(shù): 5)
2019-5-28 14:31 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1