?? simple_fsm.vhd
字號:
------------整個設計包括兩個狀態(a,b),每次當發現d='1'時,他都會從當前狀態
-------------跳變到另一個狀態,當狀態機處于state a時,輸出端口x=a,當狀態機處于state b時,輸出端口x=b
------------------------------------------------
entity simple_fsm is
port(a,b,d,clk,rst : in bit;
x: out bit);
end simple_fsm;
----------------------------
architecture simple_fsm of simple_fsm is
type state is (statea,stateb);
signal temp: bit;
signal pr_state,nx_state : state;
begin
-----------------lower section-------------------------------
process( rst,clk)
begin
if (rst = '1')then
pr_state <= statea;
elsif (clk 'event and clk = '1')then
x<= temp;
pr_state <= nx_state;
end if;
end process;
-----------------upper section-------------------
process (a,b,d,pr_state)
begin
case pr_state is
when statea =>
temp <= a;
if (d = '1')then nx_state <= stateb;
else nx_state <= statea;
end if;
when stateb =>
temp <= b;
if (d = '1')then nx_state <= statea;
else nx_state <= stateb;
end if;
end case;
end process;
end simple_fsm;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -