- 9
- 0
- 约6.81千字
- 约 9页
- 2016-11-23 发布于北京
- 举报
2014交通灯实验报告参考
5.6 交通灯控制器程序设计与仿真实验用基本的寄存器和门电路搭成的电路corna(corna.vhd),信号灯模块corna源程序如下:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity corna is
Port ( clk : in std_logic;
r : out std_logic;
g : out std_logic;
y : out std_logic;
timh : out std_logic_vector(3 downto 0);
timl : out std_logic_vector(3 downto 0));
end corna;
architecture Behavioral of corna is
type rgy is (yellow,green,red); --初态为黄灯
begin
process(clk)
variable a:std_logic:=0;
variable th,tl:std_logic_vector(3 downto 0); --计数高低位
variable state:rgy;
begin
if clkevent and clk=1 then
case state is --状态机开始
when green =
if a=0 then
th:=0010;
tl:=0100;
a:=1;
g=0;
r=1;
else
if not(th=0000 and tl=0001) then -- if语句处理显示时间
if tl=0000 then
tl:=1001;
th:=th-1;
else
tl:=tl-1;
end if;
else
th:=0000;
tl:=0000;
a:=0;
state:=yellow;
end if;
end if;
when red=
if a=0 then
th:=0001;
tl:=1001;
a:=1;
r=0;
y=1;
else
if not(th=0000 and tl=0001) then
if tl=0000 then
tl:=1001;
th:=th-1;
else
tl:=tl-1;
end if;
else
th:=0000;
tl:=0000;
a:=0;
state:=green;
end if;
end if;
when yellow =
if a=0 then
th:=0000;
tl:=0100;
a:=1;
g=1; --初始态的设置,黄灯亮,绿灯,红灯熄。
y=0;
r=1;
else
if not(th=0000 and tl=0001) then
if tl=0000 then
tl:=1001;
th:=th-1;
您可能关注的文档
- 2014上海市建筑装饰施工合同家装.doc
- 2014上海市房屋租赁合同范本版.doc
- 2014上海海洋大学学院辩论队章程.doc
- 2014上海旅行三天参考页.doc
- 2014上电子放箱服务使用协议.doc
- 2014上申请国家励志奖学金助学金 操作过程.doc
- 2014下半广西教师资格考试综合素质材料分析写作命中分析.doc
- 2014下派人员发言稿.doc
- 2014不发工资条合法.doc
- 2014上选课系统报告参考模板.doc
- 广东省广州省实验中学教育集团2025-2026学年八年级上学期期中考试物理试题(解析版).docx
- 广东省广州大学附属中学2025-2026学年八年级上学期奥班期中物理试题(解析版).docx
- 广东省广州市第八十六中学2025-2026学年八年级上学期期中物理试题(含答案).docx
- 广东省广州市第八十九中学2025-2026学年八年级上学期期中考试物理试题(解析版).docx
- 广东省广州市第二中学2025-2026学年八年级上学期期中考试物理试题(含答案).docx
- 广东省广州市第八十六中学2025-2026学年八年级上学期期中物理试题(解析版).docx
- 广东省广州市第八十九中学2025-2026学年八年级上学期期中考试物理试题(含答案).docx
- 广东省广州市第二中学2025-2026学年八年级上学期期中考试物理试题(解析版).docx
- 2026《中国人寿上海分公司营销员培训体系优化研究》18000字.docx
- 《生物探究性实验教学》中小学教师资格模拟试题.docx
原创力文档

文档评论(0)