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

📄 jiandan01.vhd

📁 交通灯控制程序.实现十字路口的交通灯控制.使用vhdl编写,使用方便.
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity jiandan01 is
port(clk1: in std_logic;
    reset: in std_logic;
      led: out std_logic_vector(6 downto 0);
     pout: out std_logic_vector(12 downto 1));
end jiandan01;
architecture traffic of jiandan01 is
signal er,ey,eg: std_logic;
signal sr,sy,sg: std_logic;
signal wr,wy,wg: std_logic;
signal nr,ny,ng: std_logic;
signal count: integer range 0 to 11;
signal state: integer range 0 to 4;

begin
process(clk1,reset,count)
begin
if reset='1' then
count<=0;
state<=0;
else
if(clk1' event and clk1='1') then
count<=count+1;
if(count=11) then
state<=state+1;
end if;
if(state>4) then 
state<=1 ;
count<=0;
end if;
end if;
end if;
case state is
when 0=>ey<='1'; wy<='1'; sy<='1'; ny<='1';
        eg<='0'; wg<='0'; sg<='0'; ng<='0';
        er<='0'; wr<='0'; sr<='0'; nr<='0';

when 1=>ey<='0'; wy<='0'; sy<='0'; ny<='0';
        eg<='1'; wg<='1'; sg<='0'; ng<='0';
        er<='0'; wr<='0'; sr<='1'; nr<='1';

when 2=>ey<='1'; wy<='1'; sy<='0'; ny<='0';
        eg<='1'; wg<='1'; sg<='0'; ng<='0';
        er<='0'; wr<='0'; sr<='1'; nr<='1';

when 3=>ey<='0'; wy<='0'; sy<='0'; ny<='0';
        eg<='0'; wg<='0'; sg<='1'; ng<='1';
        er<='1'; wr<='1'; sr<='0'; nr<='0';

when 4=>ey<='0'; wy<='0'; sy<='1'; ny<='1';
        eg<='0'; wg<='0'; sg<='1'; ng<='1';
        er<='1'; wr<='1'; sr<='0'; nr<='0';
when others=>null;
end case;
end process;
pout(1)<=er; pout(2)<=eg; pout(3)<=ey;
pout(4)<=sr; pout(5)<=sg; pout(6)<=sy;
pout(7)<=wr; pout(8)<=wg; pout(9)<=wy;
pout(10)<=nr; pout(11)<=ng; pout(12)<=ny;
process(count)
begin
case count is
when 0=>led<="0111111"; 
when 1=>led<="0000110";
when 2=>led<="1011011";
when 3=>led<="1001111";
when 4=>led<="0100110";
when 5=>led<="1101101";
when 6=>led<="1111101";
when 7=>led<="0000111";
when 8=>led<="1111111";
when 9=>led<="1101111";
when 10=>led<="1110111";
when 11=>led<="1111100";
when others=>null;
end case;
end process;
end traffic;

⌨️ 快捷键说明

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