LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY PSGtraffic is
port(clk:in std_logic;
people:in std_logic;
cnttime: out std_logic_vector(7 downto 0);
carled: out std_logic_vector(3 downto 0);
peopleled: out std_logic(3 downto 0));
end PSGtraffic;
ARCHITECTURE behave OF PSGtraffic IS
type statetype is (CGPR,CYPR,CRPG);
SIGNAL STATE: statetype := CGPR;
SIGNAL cnt :std_logic_vector(7 downto 0);
begin
process(clk,people,cnt)
begin
if (clk'event and clk='1')then
if clk/=0 then
if cnt(3 downto 0)=x"0"then
cnt(7 downto 4)<=cnt(7 downto 4)-1;
cnt(3 downto 0)<=x"9";
else
cnt(3 downto 0)<=cnt(3 downto 0)-1;
end if;
end if;
case state is
when CGPR =>
carled<="0010";
peopleled<="0100";
if people ="1"and cnt=0 then
state <= CYPR;
cnt <=x"3"AFTER 30s;
end if;
when CYPR =>
carled<="0001";
peopleled<="0100";
if cnt = 0 then
state <= CRPG;
cnt <=x"15";
end if;
when CRPG =>
carled<="0100";
peopleled<="0010";
if cnt = 0 then
if people ="0" and cnt=0 then
state <= CGPR;
cnt <=x"30";
end if;
when others => NULL;
end case;
end if;
cnttime<=cnt;
end process;
end behave;
打赏帖 | |
---|---|
汽车+汽车地线之间连接处理被打赏20分 | |
【Zephyr】使用Zephyr外设初始化过程解析被打赏30分 | |
【S32K146】S32DS watchdog 配置使用被打赏20分 | |
【Zephyr】使用 IAR 调试 Zephyr 镜像被打赏20分 | |
赚取电动螺丝刀+电源电路理论知识分享1被打赏5分 | |
我想要一部加热台+分享常见运算放大器电路的应用被打赏5分 | |
【Zephyr】MCXN947 Zephyr 开发入门适配shell被打赏20分 | |
我想要一部加热台+常见的MOS管驱动电路被打赏5分 | |
【我要开发板】6.联合MATLAB记录数据被打赏50分 | |
【换取手持数字示波器】MicrochipMPLABHarmony框架下串口调试printf输出记录被打赏29分 |