用VHDL编写交通灯的程序 急救!

mefjy 2003-05-10 08:39:45
要求及技术指标:
假设道路交叉口,有红绿黄三色交通控制灯,且要求:
1)。绿灯亮是,车辆可潜行,过30秒,绿灯熄灭,黄灯亮;
2)。黄灯亮5秒后,熄灭,红灯亮,车辆停止前行。红灯亮30秒之后熄灭,黄灯亮;
3)黄灯亮5秒之后,熄灭,绿灯又亮,车辆可通行,如此循环。

需要用VHDL编写。这是我毕业设计的一部分。
希望高手们相助。
...全文
405 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
mefjy 2003-05-12
  • 打赏
  • 举报
回复
非常的感谢,我已经运行通过了。
resound 2003-05-11
  • 打赏
  • 举报
回复
在第三行加入这个语句:
use ieee.std_logic_unsigned.all;
zhanmei 2003-05-11
  • 打赏
  • 举报
回复
建议用清楚的ASM(Algorism State Machine)来写,将各种状态列出。
mefjy 2003-05-11
  • 打赏
  • 举报
回复
老兄,我运行了一下结果还有一个错误
是在cnt<=cnt+1;这里
它的错误提示是 subprogram error: can't interpret subprogram call.
还望在看一下。
resound 2003-05-11
  • 打赏
  • 举报
回复
在线写一个,你试试.

library ieee;
use ieee.std_logic_1164.all;
--the system CLOCK is 5秒
entity abc is
port(
CLOCK:IN STD_LOGIC;-- 输入时钟
RESET:INSTD_LOGIC;-- 复位信号
r,g,y:OUT STD_LOGIC);-- 红绿黄信号
END abc;

architecture imp of abc is
signal cnt:STD_LOGIC_VECTOR(3 downto 0); -- 计数器;
begin
p1:process (RESET,clock)
begin
if RESET = '1' then -- Initilaize all the signals;
r<='0';
g<='0';
y<='0';
cnt<="0000";
elsif (clock'event and clock='1') then
if(cnt<"1110") then
cnt<=cnt+1;
else
cnt<="0000";
end if;
if(cnt="0000") then
r<='0';
g<='0';
y<='1';--黄亮
elsif(cnt="0001") then
r<='0';
g<='1';--绿亮
y<='0';
elsif(cnt="0111") then
r<='0';
g<='0';
y<='1';--黄亮
elsif(cnt="1000") then
r<='1';--红亮
g<='0';
y<='0';
end if;
end if;
end process p1;
end imp;

你自己验证一下.

6,125

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 硬件设计
社区管理员
  • 硬件设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧