版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、精选优质文档-倾情为你奉上精选优质文档-倾情为你奉上专心-专注-专业专心-专注-专业精选优质文档-倾情为你奉上专心-专注-专业EDA程序设计实验报告 学院:信息学院 专业:电子信息工程 班级:电信1001班 姓名:celestialfox 学号:celestialfox 实验题目: 交通灯控制器设计实验目的: 1、熟练掌握VHDL基本语句、语法的使用 2、掌握状态机的设计方法 3、学习使用模块化设计4、加深对VHDL编程思想的理解设计任务: (1)显示十字路口A,B两个方向的红、黄、绿指示灯状态 (2)根据外部设定时间实现正常的倒计时功能,用两组数码管分别作为A,B两方向的倒计时显示,规定东西
2、和南北方向的车流量大致相同,因此红黄绿灯亮的时间也相同,定为红灯45s,黄灯5s,绿灯40s (3)设计一个特殊状态,此时A,B方向都禁止通行,指示红灯,计时器停止计数并保持原来的状态。特殊状态解除后,在原来状态的基础上继续计数 (4)能实现总体清零功能,按下RES键后,系统实现总清零,计数器由初始状态计数,对应状态的指示灯亮设计分析: (1)交通灯的4种可能亮灯状态:状态东西方向红 黄 绿 南北方向绿 黄 红 11 0 01 0 0 21 0 0 0 1 0 30 0 10 0 1 40 1 00 0 1(2)根据交通灯不同状态的亮灯时间得到交通灯的工作过程:方向ARARAGAYARARA方
3、向BGBYBRBRBGBYB时间t40s5s40s5s40s5s状态SS0S1S2S3S0S1 (3)对于特殊情况,只需设计一个异步时序电路即可解决。程序中还应判断东西方向和南北方向的计数值是否超出范围。此电路仅在电路启动运行时有效,因为一旦两个方向的计数值正确后,就不能在计数到非法状态。 (4)系统组成 根据交通灯工作原理及要实现的功能将其分为4个部分。主控逻辑单元、置数器、计数器、BCD码转换器、七段字型译码器。主控制器七段译码器置数器计数器BCD码转换器 (5)系统工作原理上 电 复 位 S0 状态A红B绿 RES=0 Time=0 S1状态A红B黄 RES=0 Time=0 RES=0
4、 Time=0 S3状态A黄B红Res=0Time=0 N Y Y Y N S2状态A绿B红 Y Y N Y Y NY程序设计:-the program head -系统描述LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE WORK.ALL;ENTITY head IS PORT(color_a:buffer std_logic_vector(2 downto 0); color_b:buffer std_logic_vector(2 downto 0); acode_out_high,acode_out_low:out std_logic_vector
5、(6 downto 0); bcode_out_high,bcode_out_low:out std_logic_vector(6 downto 0); res,clk,key:in std_logic);end head;architecture main_str of head is signal put_a,put_b,flag_a,flag_b,load_a,load_b:std_logic; signal data_a,data_b,value_cou_a,value_cou_b:std_logic_vector(7 downto 0); signal acode_in_high,a
6、code_in_low,bcode_in_high,bcode_in_low:std_logic_vector(3 downto 0); signal data_bcd_a,data_bcd_b:std_logic_vector(7 downto 0);component put_numb is -定义置数器 port(res_s,put_a,put_b,clk_s:in std_logic; out_sto_a:buffer std_logic_vector(7 downto 0); out_sto_b:buffer std_logic_vector(7 downto 0);end comp
7、onent;component counter is -定义计数器 port(res_c,clk_h,com_load,hold:in std_logic; in_data:in std_logic_vector(7 downto 0); vec_out:buffer std_logic_vector(7 downto 0); flag:out std_logic);end component;component mux_bcd is -定义bcd码转换器 port(data_1:in std_logic_vector(7 downto 0); res_m,hold_s,clk_m:in st
8、d_logic; data_bcd:out std_logic_vector(7 downto 0);end component;component main_col is -定义主控制器 port(hold_l,clk_r,flag_froma,flag_fromb,res_r:in std_logic; color_vec_a:buffer std_logic_vector(2 downto 0); color_vec_b:buffer std_logic_vector(2 downto 0); puta,putb,loada,loadb:buffer std_logic);end com
9、ponent;component code_sev is -定义七段字型译码器 port(code_in:in std_logic_vector(3 downto 0); code_out:out std_logic_vector(6 downto 0);end component;begin u1:put_numb port map(res,put_a,put_b,clk,data_a,data_b); u2:counter port map(res,clk,load_a,key,data_a,value_cou_a,flag_a); u3:counter port map(res,clk,
10、load_b,key,data_b,value_cou_b,flag_b); u4:mux_bcd port map(value_cou_a,res,key,clk,data_bcd_a); u5:mux_bcd port map(value_cou_b,res,key,clk,data_bcd_b); u6:main_col port map(key,clk,flag_a,flag_b,res,color_a,color_b,put_a,put_b, load_a,load_b); u7:code_sev port map(acode_in_high,acode_out_high); u8:
11、code_sev port map(acode_in_low,acode_out_low); u9:code_sev port map(bcode_in_high,bcode_out_high); u10:code_sev port map(bcode_in_low,bcode_out_low); acode_in_high=data_bcd_a(7 downto 4);-将BCD码转换器输出的八位码拆分为高低各四位 acode_in_low=data_bcd_a(3 downto 0); bcode_in_high=data_bcd_b(7 downto 4); bcode_in_low=d
12、ata_bcd_b(3 downto 0);end main_str;-the program of main_col -主控制器library ieee;use ieee.std_logic_1164.all;entity main_col is port(hold_l,clk_r,flag_froma,flag_fromb,res_r:in std_logic; color_vec_a:buffer std_logic_vector(2 downto 0); color_vec_b:buffer std_logic_vector(2 downto 0); puta,putb,loada,l
13、oadb:buffer std_logic);end main_col;architecture rtl of main_col issignal color_vec:std_logic_vector(5 downto 0); -将两组灯颜色信号矢量并为一组signal color_vec_out:std_logic_vector(5 downto 0);-高三位为a组,低三位为b组begin puta=flag_froma; -来自a组计数器0秒信号送a组置数器 putb=flag_fromb; -来自b组计数器0秒信号送b组置数器 color_vec_a=color_vec_out(5 d
14、ownto 3); color_vec_b=color_vec_out(2 downto 0); process(clk_r) begin if(clk_revent and clk_r=0)then loada=flag_froma; -来自计数器的0秒信号延迟半个节拍后再送回计数器 loadb=flag_fromb; -加载已在半个节前置数器放置在其端口上的初始数据确保数据无误 end if; end process; process(clk_r,res_r,loada,loadb) variable temp:std_logic; variable temp_vec:std_logic_
15、vector(5 downto 0); begin temp_vec:=color_vec; if(res_r=0)then color_veccolor_veccolor_veccolor_veccolor_veccolor_vec=XXXXXX; end case; end if; end if; end process; process(hold_l,clk_r) -对特殊状态时红灯全亮的处理 variable temp:std_logic_vector(5 downto 0); begin if(hold_l=1)then temp:=color_vec; else temp:=; e
16、nd if; color_vec_out=temp; end process;end rtl;-the program of put_numb -置数器library ieee;use ieee.std_logic_1164.all;entity put_numb is port(res_s,put_a,put_b,clk_s:in std_logic; out_sto_a:buffer std_logic_vector(7 downto 0); out_sto_b:buffer std_logic_vector(7 downto 0);end put_numb;architecture rt
17、l_sto of put_numb isbegin process(res_s,put_a,clk_s) -a组计时时间状态机 variable in_var:std_logic_vector(7 downto 0); begin in_var:=out_sto_a; if(res_s=0)then out_sto_aout_sto_aout_sto_aout_sto_aout_sto_a=XXXXXXXX; end case; end if; end if; end process; process(res_s,put_b,clk_s) -b组计时时间状态机 variable in_var:
18、std_logic_vector(7 downto 0); begin in_var:=out_sto_b; if(res_s=0)then out_sto_bout_sto_bout_sto_bout_sto_bout_sto_b=XXXXXXXX; end case; end if; end if; end process;end rtl_sto;-the program of counter -计时器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsign
19、ed.all;entity counter is port(res_c,clk_h,com_load,hold:in std_logic; in_data:in std_logic_vector(7 downto 0); vec_out:buffer std_logic_vector(7 downto 0); flag:out std_logic);end counter;architecture rtl of counter is signal clk_c:std_logic;begin clk_c=hold and clk_h; process(clk_c) begin if(clk_ce
20、vent and clk_c=1)then flag=(not vec_out(0) or vec_out(1) or vec_out(2) or vec_out(3) or vec_out(4) or vec_out(5) or vec_out(6) or vec_out(7); -计时时间到信号的获取,在0秒输出宽1秒的富脉冲 end if; end process; process(res_c,clk_c) variable count:integer range 0 to 255; begin if(res_c=0)then -复位时计数器重新加载端口计时初值 count:=conv_
21、integer(in_data); elsif(clk_cevent and clk_c=1)then if(com_load=0)then -load命令让计数器加载端口计时初值 count:=conv_integer(in_data); else count:=count-1; -减1计数 end if; end if; vec_out=conv_std_logic_vector(count,8); -将整数值转换为8位宽的矢量信号 end process;end rtl;-the program of mux_bcd -BCD码转换器library ieee;use ieee.std_l
22、ogic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity mux_bcd is port(data_1:in std_logic_vector(7 downto 0); res_m,hold_s,clk_m:in std_logic; data_bcd:out std_logic_vector(7 downto 0);end mux_bcd;architecture mu of mux_bcd issignal data_in:std_logic_vector(7 downto 0);si
23、gnal data_2:std_logic_vector(7 downto 0);signal sel:std_logic;begin data_2=; -此码用作关断数码管 process(sel,res_m,data_1,data_2) begin if(res_m=0)then data_in=; -复位时将能显示的最大值给数码管,99秒 elsif(sel=1)then -二选一信号sel data_in=data_1; else data_intemp:=temp; when 10 to 19=temp:=temp+6; when 20 to 29=temp:=temp+12; when 30 to 39=temp:=temp+18; when 40 to 49=temp:=temp+24; when 50 to 59=temp:=temp+30; when 60 to 69=temp:=temp+36; when 70 to 79=temp:=temp+4
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 茶双11宣传及营销方案
- 2026年化学工程专业知识技能大赛
- 2026年中国糖画3D镂空造型师考试重点预测解析
- 2026年无人机安防监控测试题
- 2026年会计实务操作能力测试题
- 2026年应急通信保障中心招聘笔试高频考点
- 2026年财务会计考试题及答案
- 2026年国家电投巴西公司招聘笔试模拟题
- 2026年形态设计基础知识
- 2026年出版物发行员资格考试仿真题集
- 2026年辽宁锦州海通实业有限公司度校园招聘28人笔试备考题库及答案详解
- 2026年巨量本地推初级题库
- 2025年四川省自贡市地理生物会考真题试卷+答案
- 摩根士丹利-中国消费:当前消费趋势走向何方?-China Consumer:Where is consumption trending now-20260601
- GB 26396-2026洗涤用品安全技术规范
- 2026年上海市宝山区中考一模化学试卷
- 东南大学2024综评数学试卷
- CB/T 3136-1995船体建造精度标准
- 设备运行分析报告(模板02)
- 二次函数求最值动轴定区间动区间定轴课件
- 浙江省衢州市各县区乡镇行政村村庄村名居民村民委员会明细及行政区划代码
评论
0/150
提交评论