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

📄 light.vhd

📁 软件开发环境:ISE 7.1i 仿真环境:ModelSim SE 6.0 1. 用VHDL语言仿真交通灯
💻 VHD
字号:
----------红绿灯设计-------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
---------------------------------
entity light is
port(clk,rst:in std_logic;
	cout:out std_logic_vector(2 downto 0));
end;
---------------------------------
architecture one of light is
constant timered:integer:=9;
constant timegreen:integer:=9;
constant timeyellow:integer:=4;
type states is(red,green,yellow);
signal current_state,next_state:states;
signal time,delaytime:integer range 0 to 20;
signal temp:std_logic_vector(2 downto 0);
begin
----------时序逻辑电路-----------
REG:process(clk,rst)
	begin
	if rst='1' then current_state<=red;time<=0;
	elsif clk'event and clk='1' then
		if time=delaytime then current_state<=next_state;time<=0;
		else time<=time+1;
		end if;
	end if;
	end process REG;
----------组合逻辑电路-----------
COM:process(current_state)
	begin
	case current_state is
	when red=>temp<="100";next_state<=green;delaytime<=timegreen;
	when green=>temp<="010";next_state<=yellow;delaytime<=timeyellow;
	when yellow=>temp<="001";next_state<=red;delaytime<=timered;
	when others=>null;
	end case;
	cout<=temp;
	end process COM;
end;
---------------------------------

⌨️ 快捷键说明

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