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;
我要赚赏金打赏帖 |
|
|---|---|
| 基于ArduinoUNO开发板的AT24C02读写测试被打赏¥16元 | |
| TCS3472S传感器及其色彩检测被打赏¥19元 | |
| 【S32DS】S32K3 RTD7.0.1 HSE 组件配置报错问题解决被打赏¥27元 | |
| 【S32K3XX】MCME 启动 CORE1被打赏¥23元 | |
| AG32VH407下温度大气压传感器及其检测被打赏¥20元 | |
| AG32VH407下光照强度传感器BH1750及其检测被打赏¥22元 | |
| AT32VH407下使用温湿度传感器DHT22进行检测被打赏¥20元 | |
| DIY一个婴儿澡盆温度计被打赏¥34元 | |
| 【FreeRtos】FreeRtos+MPU region 配置规则被打赏¥23元 | |
| 【分享开发笔记,赚取电动螺丝刀】三分钟快速上手驱动墨水屏(ArduinoIDE)被打赏¥28元 | |
我要赚赏金
