版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、东西方向秒表的低位东西方向秒表的高位南北方向秒表的低位南北方向秒表的高位利用状态机,定义四种状态sti,st2,st3,st4定义秒表为30秒交通灯设计总结报告一方案设计与论证使用vhdl语言编程,在结构体屮制造一个单进程状态机,此状态机只 进行单纯的状态转换,每个状态中不涉及控制交通灯的亮灭,交通灯的 亮灭在单独的一个进程中进行控制。时钟由20mhz的晶体分频形成1hz 的秒信号。二.vhdl编程设计library ieee;use ieee.std_logic_1164.all;使用库函数use ieee.std logic unsigned.all;use ieee.std logic
2、arith.all;entity traffic isport(clk:instd_logic;rst: in std_logic;ew_t1 : out std_l0gic_vect0r(3 downto 0);ew_t2: out std_l0gic_vect0r(3 downto 0); ew r : out std logic;ew g : out std logic;ew_y : out std_logic;ns_t1 :out std_l0gic_vect0r(3 downto 0);ns_t2: out std_l0gic_vect0r(3 downto 0); ns r: ou
3、t std logic;ns g : out std logic;mbmm夕ns_y : out std_logic;);end entity traffic;architecture func of traffic istype state 1 is (st1,st2,st3,st4);signal state :state1;signal clk 1hz : std logic;signal count1 : integer range 0 to 30;signal count2 : integer range 0 to 30;beginpo:process(clk)variable a
4、: std_logic_vector(23 downto 0);beginif(clk*event and clk二t) theniffa'loolloooloololloolllllll'hhenclk_1hz<=not clk_1hz; a:=(others=>'0');elsea:=a+1;end if;end if;end process po;p:process(clk_1hz)beginif(rst='1')thenstate<=st1;count1<=30;count2<=30;ew_r<=
5、9;0'ew g<='1'ew_y<='0'ns_r<='1'ns_g<=,0,;ns_y<='o'elsif(clk_1hz'event and clk_1hz='1,)then case state iswhen sti => ew_r<='0'ew_g<='1'ew_y<='0'ns_r<=,1,;ns_g<=*0'ns_y<='o*;if(count1=5)then
6、state<=st2;elsestate<=st1;end if;count1<=count1-1;count2<=count2-1;when st2 =>ew_r<='0'ew_g<='0*;ew_y<='1'ns_r<='1,;ns g<='o'ns_y<='0,;if(count2=1)then分频东西绿灯,南北红灯东西黄灯,南北红灯state<=st3;count1<=25;count2<=25;elsestate<=st2;
7、end if;count2<=count2-1;count1<=count1-1; when st3 =>ew_r<='1'ew_g<='0'ew_y<='0'ns_r<=,0,;ns_g<=,1,;ns_y<='0,;if(count2=5)thenstate<=st4;elsestate<=st3;end if;count2<=count2-1;count1<=count1-1; when st4 => ew_r<='1,;ew_g<
8、;='0'ew_y<='0'ns_r<=,0,;ns_g<='0'ns_y<='1,;if(count1=1)thenstate<=st1;elsestate<=st4; end if;count2<=count2-1;count1<=count1-1;when others => state <= sti;end case;end if;end process p;p1:process(clk_1hz)begincase c0unt1 iswhen 0 =>ew_tl&l
9、t;="0000"东西红灯,南北绿灯东西红灯,南北黄灯高低位都用四位二进制表示when2=>when 3 =>when4=>when 5 =>when 6=>when 7=>when8=>when9=>when 10 =>when 11 =>when 12 =>when 13 =>when 14 =>when 15 =>when 16 =>when 17 =>when 18 =>when 19 =>when 20 =>when 21 =>when 22 =
10、>ew_tlv二 ”0011"ew_t2<=',0000n;ew_tl<="0100,'ew_t2<="0000n;ew_tl<="0101"ew_t2<="0000n;ew_tl<="0110"ew_t2<=',0000n;ew_tl<="0111"ew_t2<="0000n;ew_tl<="1000"ew t2<="0000u;ew_tl<="
11、;1001"ew_t2<="0000n;ew_tl<=h0000"ew_t2<="0001"ew tl<=,0001h;ew_t2<="0001,'ew_tl<=h0010h;ew_t2<="0001"ew_tl<=,0011h;ew_t2<=,0001,1;ew_tl<="0100,'ew_t2<="0001h;ew_tl<=h0101h;ew_t2<="0001"ew_tk=,0
12、110"ew_t2<=',0001n;ew_tl<=h0111h;ew_t2<=,0001"ew_tl<=h1000h;ew t2<="0001n;ew_tl<="1001h;ew_t2<="0001n;ew_tl<=h0000"ew_t2<="0010h;ew tl<=,0001h;ew_t2<="0010,'ew_tl<=,0010h;when 24 =>when 25 =>when 26 =>when 2
13、7 =>when 28 =>when 29 =>when 30 =>ew_tl<="0101"ew_t2<=”0010“;ew_tl<=,0110h;ew_t2<=,0010"ew_tl<=,0111h;ew_t2<=,0010n;ew_tl<="1000"ew_t2<=”0010“;ew_tl<=,1001h;ew_t2<=,0010"ew_tl<=h0000h;ew t2<="0011n;when others => n
14、ull;end case;case count2 iswhen0=>when 1=>when2=>when 3 =>when4=>when5=>when 6=>when7=>when8=>when9=>when 10 =>when 11 =>ns_tl<=,0000n;ns_t2<="0000"ns_tl<="0001"ns_t2<="0000,'ns_tl<="0010h;ns_t2<="0000"
15、ns_tl<=,0011h;ns_t2<="0000h;ns_tl<=,0100n;ns_t2<="0000"ns_tl<=,0101n;ns_t2<=,0000n;ns_tl<=,0110n;ns_t2<="0000"ns_tl<=m0111"ns t2<="0000h;ns_tl<=,1000n;ns_t2<="0000"ns_tl<="1001"ns_t2<="0000"ns
16、tl<="0000"ns_t2<="0001"ns_tl<=,0001,1;when 13 =>when 14 =>when 15 =>when 16 =>when 17 =>when 18 =>when 19 =>when 20 =>when 21 =>when 22 =>when 23 =>when 24 =>when 25 =>when 26 =>when 27 =>when 28 =>when 29 =>when 30 =>
17、;ns_tl<="0100"ns_t2<=,0001"ns_tl<="0101"ns_t2<="0001"ns_tl<="0110"ns_t2<="0001"ns_tl<=,0111"ns_t2<=,0001"ns_tl<=,1000,;ns_t2<="0001"ns_tl<="1001" ns t2<="0001h;ns_tl<=&quo
18、t;0000"ns_t2<="0010"ns_tl<="0001,;ns_t2<="0010"ns tl<="0010"ns_t2<="0010"nstlv-'ooir;ns_t2<="0010"nstivoioo”;ns_t2<="0010"ns_tl<="0101"ns_t2<="0010"ns_tl<=,0110"ns_t2<=
19、"0010"ns_tl<=,0111"ns_t2<=,0010n;ns_tl<="1000"ns_t2<="0010"ns_tl<="1001" ns t2<="0010"ns_tl<="0000"ns_t2<=,0011,'when others => null;end case;end process pl;end architecture func;三.仿真波形 和锁定引脚node namedirectionlocationreservedgroup:1 okinputpin612° ew.goutputpinj143u ew.routputpin.4244一。ewj13outputpin."ewjl3.o453ew.tl outputpin.48ewjl3.o46o ew.t11outputpin.4947ewj1(o)o
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 学生情感分析研究-洞察分析
- 护理三新项目申报
- 品牌节庆调研报告范文
- 四川省宜宾市2025届高三数学第一次诊断性试题含解析
- 企业返聘报告范文
- 学校消防安全管理承包合同
- 幼儿园疫情期间食堂卫生方案
- 吊装行业研究报告范文
- 新村调研报告范文
- 申请买桌子的报告范文
- 2021LNG加气站质量手册
- 医师执业、变更执业、多机构备案申请审核表(范本 )(医师备案:多执业机构备案)
- 济南大学模拟电子技术(135202)期末复习题
- 苏教版科学2023四年级下册全册教案教学设计及反思
- 牦牛骨深加工项目可行性研究报告书
- 桥梁工程质量保证体系样本
- 科研失信行为调查结论、调查报告、处理决定书(模板)、调查保密协议、回避声明
- 八年级数学《从分数到分式》教学设计
- 小学道德与法治-《诚实守信》教学设计学情分析教材分析课后反思
- 头位难产(精)课件
- YY/T 0793.4-2022血液透析和相关治疗用液体的制备和质量管理第4部分:血液透析和相关治疗用透析液质量
评论
0/150
提交评论