• 沒有找到結果。

控制器

N/A
N/A
Protected

Academic year: 2022

Share "控制器"

Copied!
2
0
0

加載中.... (立即查看全文)

全文

(1)

控制器(FSM) library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

use IEEE.STD_LOGIC_ARITH.ALL;

use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity controller is

Port ( Reset : in std_logic;

Clk : in std_logic;

start : in std_logic;

Pb1 : in std_logic;

Pb2 : in std_logic;

Winer : out std_logic_vector(3 downto 0)); --贏家 end controller;

architecture Behavioral of controller is type State_type is (s0,s11,s12,s21,s22);

signal State,Next_State : State_type;

begin

process(Reset,Clk,start,Pb1,Pb2) begin

if (Reset = '0') then Winer <= "0000";

State <= s0;

elsif (Clk'event and Clk='1') then

State <= Next_State; --切換狀態 end if;

case State is

when s0 => --初始狀態

Winer <= "0000"; --Moore Model if (Pb1='0' and start='0') then --1 號偷跑 Next_State <= s11;

elsif (Pb2='0' and start='0') then

Next_State <= s21; --2 號偷跑

elsif (Pb1='0' and start='1' and State /= s22) then --時間己到,1號 有按且 2 號尚未贏

Next_State <= s12;

(2)

elsif (Pb2='0' and start='1' and State /= s12) then Next_State <= s22;

else

Next_State <= s0;

end if;

when s11 => --1 號偷跑狀態

Winer <= "0000";

if (Pb1='1' and start = '0') then --1 號又放開 Next_State <= s0;

elsif (Pb2 = '0' and start = '1') then --2 號先按 Next_State <= s22;

else

Next_State <= s11; ----1 號持續按住 end if;

when s21 => --2 號偷跑狀態

Winer <= "0000";

if (Pb2='1' and start='0') then Next_State <= s0;

elsif (Pb1 = '0' and start = '1') then --1號先按 Next_State <= s12;

else

Next_State <= s21;

end if;

when s12 => --1 號贏狀態

Winer <= "0001";

Next_State <= s12;

when s22 => --2 號贏狀態

Winer <= "0010";

Next_State <= s22;

end case;

end process;

end Behavioral;

參考文獻

相關文件

More than 2.0 grams per kilogram of body weight for athlete who is consuming a vegan diet or a low-calorie diet (Earle, Baechle et al.,

 積熱電驛(Thermal relay, TH-RY),又稱為積熱過載 電驛(Thermal over-load relay, OL).  電磁開關(Magnetic

政策標的團體 學術參照團體 資訊傳播媒體 利益整合團體

在工業上,例如:產業自動化控制、化工程序控 制、機器人定位控制、CNC工具機之數值控制等;在 軍事上的用途,例如:飛機之導航系統、飛彈之射控

[r]

EtherCAT ® 為德國 Beckhoff Automation GmbH 取得許可證之專利技術,亦為註冊商標。. EtherNet/IP™為

專案導向應用程式開發 階梯程式編輯畫面 狀態的監視與控制 階梯程式助憶碼輔助顯示 階梯程式註解功能

ADtek assumes no responsibility for any inaccuracies that may be contained in this document, and make no commitment to update or to keep current the information contained in