?? sy3.vhd
字號(hào):
library ieee;
use ieee.std_logic_1164.all;
-------------------------------------------------------------------
entity sy3 is
port(x,clk : in std_logic;
z : out std_logic);
end sy3;
--------------------------------------------------------------------
architecture bev of sy3 is
type state_type is (s0,s1,s2); --定義枚舉類型state_type
signal state : state_type; --初值為s0
begin
process(x,clk)
begin
if (clk'event and clk='1') then --時(shí)鐘信號(hào)上升沿觸發(fā)
case state is
when s0=> --狀態(tài)為s0,輸出0
z<='0';
if (x='0') then --輸入為0,狀態(tài)變?yōu)閟1
--輸入為1,狀態(tài)不變
state<=s1;
end if;
when s1=> --狀態(tài)為s1,輸出0
z<='0';
if (x='1') then --輸入為1,狀態(tài)變?yōu)閟2
--輸入為0,狀態(tài)不變
state<=s2;
end if;
when s2=> --狀態(tài)為s2
if (x='0') then --輸入為0,輸出為1,狀態(tài)變?yōu)閟1
z<='1';
state<=s1;
else --輸入為1,輸出為0,狀態(tài)變?yōu)閟0
z<='0';
state<=s0;
end if;
end case;
end if;
end process;
end bev;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -