⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctrl.vhd

📁 用PLC程序编写十字路口的交通灯
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity ctrl is
port(clk,spe:in std_logic;
     en:out std_logic);
end;
architecture behave of ctrl is
type states is(s3,s2,s1,s0);
signal current_state,next_state:states;
begin
com:process(spe,current_state)
begin
case current_state is
when s0=> en <='0';
if spe='1' then next_state<=s0;
else next_state<=s1;
end if;
when s1=> en <='1';
if spe='1' then next_state<=s2;
else next_state<=s1;
end if;
when s2=> en <='1';
if spe='1' then next_state<=s2;
else next_state<=s3;
end if;
when s3=> en <='0';
if spe='1' then next_state<=s0;
else next_state<=s3;
end if;
end case;
end process;
synch: process(clk)
begin
if clk'event and clk='1' then
current_state<=next_state;
end if;
end process;
end behave;





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -