EDA交通灯控制器+函数信号发生器+乐曲演奏电路.docx

上传人:时光煮雨 文档编号:15004568 上传时间:2022-03-03 格式:DOCX 页数:28 大小:213.86KB
返回 下载 相关 举报
EDA交通灯控制器+函数信号发生器+乐曲演奏电路.docx_第1页
第1页 / 共28页
EDA交通灯控制器+函数信号发生器+乐曲演奏电路.docx_第2页
第2页 / 共28页
EDA交通灯控制器+函数信号发生器+乐曲演奏电路.docx_第3页
第3页 / 共28页
EDA交通灯控制器+函数信号发生器+乐曲演奏电路.docx_第4页
第4页 / 共28页
EDA交通灯控制器+函数信号发生器+乐曲演奏电路.docx_第5页
第5页 / 共28页
点击查看更多>>
资源描述

《EDA交通灯控制器+函数信号发生器+乐曲演奏电路.docx》由会员分享,可在线阅读,更多相关《EDA交通灯控制器+函数信号发生器+乐曲演奏电路.docx(28页珍藏版)》请在三一文库上搜索。

1、EDA课程设计题目一:交通灯控制器VHDL的设计题目二:智能函数发生器题目三:乐曲硬件演奏电路的VHDL设计专业:通信工程班级:通信084班一、设计题目:交通灯控制器VHDL的设计二、设计目标1、 设计一个交通信号灯控制器,由一条主干道和一条支干道汇合成十字路口,在每个入口处设置红、绿、黄三色信号灯,红灯亮禁止通行,绿灯亮允许通行,黄灯亮则给行驶中的车辆有时间停在禁行线外。2、 红、绿、黄发光二极管作信号灯,。3、 主干道处于常允许通行的状态,支干道有车来时才允许通行。主干道亮绿灯时,支干道亮红灯;支干道亮绿灯时,主干道亮红灯。4、 主、支干道均有车时,两者交替允许通行,主干道每次放行45秒,

2、支干道每次放行25秒,设立45秒、25秒计时、显示电路。5、 在每次由绿灯亮到红灯亮的转换过程中,要亮5秒黄灯作为过渡,使行驶中的车辆有时间停到禁行线外,设立5秒计时、显示电路。三、设计原理 主系统由三个模块组成,jtd.vhd为顶层文件,其内部包含三个功能模块模块:信号灯主控模块(moore.vhd)、减法计数器模块(jishu.vhd)、译码器模块(led7s.vhd)。1、 选择1HZ时钟脉冲作为系统时钟。2、 45秒、25秒、5秒定时信号用倒计时,计时起始信号由主控电路给出,每当计满所需时间,即向主控电路输出“时间到”信号,转换信号灯状态,由主控电路启、闭三色信号灯显示结果:十字路口的

3、交通灯控制信号由主控电路给出,能显示十字路口东西、南北两个方向的红、黄、绿灯的指示状态。用两组红、黄、绿三种颜色的灯分别作为东西、南北两个方向的红、黄、绿灯,变化规律为:东西绿灯亮,南北红灯亮东西黄灯亮,南北红灯亮东西红灯亮、南北绿灯亮东西红灯亮,南北黄灯亮东西绿灯亮,南北红灯亮.,这样依次循环。东西方向是主干道车道,南北方向是支干道车道,要求两条交叉道路上的车辆交替运行,主干道每次通行时间都设为45秒,支干道每次通行时间都设为25秒。在绿灯转为红灯时,要求黄灯先亮5秒钟,才能变换运行车道。要求交通灯控制器有复位功能,在复位信号使能的情况下能够实现交通灯的自动复位,并且要求所有交通灯的状态变化

4、,包括复位信号引起的均发生时钟脉冲的上升沿处。四、设计内容1.信号灯主控模块moore.vhd设计一个Morre型状态机,是一个4状态的状态机,输出ld0控制减法计数器,在减法计数器减计数到6或1时,计数器输出1,将计数器的输出输入到Moore型状态机c0中来实现状态机的输入控制,再通过状态机的输出来控制计数器的计数值。即原理相同于S0为东西方向的绿灯控制及南北方向的红灯控制,计数时间为45秒;S1为东西方向黄灯控制及南北方向的红灯控制,计数时间为5秒;S2为南北方向的绿灯控制及东西方向的红灯控制,计数时间为25秒;S3为南北方向的黄灯及东西方向的红灯控制,计数时间为5秒。状态图如下:clk0

5、:1Hz时钟输入rst0:复位端c0:状态机输入控制信号ld0输出计数控制信号dinh0,dinl0:输出高低位计数值red_east1等:红黄绿灯控制信号2.减法计数器的设计jishu.vhdclk1:1Hz时钟输入ld1:计数控制信号dinh1,dinl1:输入高低位计数值qh1,ql1:输出高低位计数值c1:输出状态机控制信号 减法计数器设计,用dinh1和dinl1来设置所需要的计数数值,ld1为初始化计数数值,当减法计数器减到设置的6或1时,C1输出为1,其他时间均为0。Qh1和ql1为计数器的计数输出。3.译码器的设计led7s.vhd译码器是一个简单的LED的显示的译码,为47译

6、码器。a:译码输入信号led7s:译码输出信号五、仿真结果一、设计题目:智能函数发生器二、设计目标设计一个智能函数发生器,能够以稳定的频率发生递增斜波、递减斜波、三角波、梯形波,正弦波和方波。设置一个波形选择输入信号,通过此改变该信号可以选择以上各种不同种类的输出函数波形,系统具有复位功能。三、设计原理主系统由7个模块组成,singt.vhd为顶层设计文件,其内部有七个功能模块:波形选择模块(wavsel.vhd)、递增斜波模块(zengxie.vhd)、递减斜波模块(jianxie.vhd)、三角波模块(rect.vhd)、梯形模块(trap.vhd)、方波模块(reta.vhd)、正弦波模

7、块(sindata.vhd)。递减模块递增模块三角波模块梯形波模块方波模块正弦波模块选 择 模 块输出信号智能函数发生器原理图四、设计内容1.递减模块的设计jianxie.vhd递减模块的设计,递减模块是用VHDL程序描述的递增函数,它的实体部分部分说明三个端口,其中两个输入端口时钟信号clk3、复位信号rst3和一个输出端口jout3。结构体部分定义一个8位二进制变量,然后使用进程语句,设定敏感信号clk3和 rst3,通过设计一个中间变量从00000101到00000000的递减赋值给输出信号jout3,编译无误后,即额可以创建递减元件符号。2.递增模块的设计zengxie.vhd递增模块

8、的设计与递减模块相似,其中两个输入端口时钟信号clk2、复位信号rst2和一个输出端口zout2。结构体部分定义一个8位二进制变量,然后使用进程语句,设定敏感信号clk2和 rst2,通过设计一个中间变量从00000000到00000101的递增赋值给输出信号zout2,编译无误后,即额可以创建递增元件符号。3三角波模块的设计rect.vhd三角波模的设计完成功能异步复位和三角波的形成,程序定义两个中间变量,一个中间变量即为输出赋值,另一个完成三角波分段,当p为 0时,完成三角波的前段从00000000到00000101递增;当p为1时,完成后段的从00000101到00000000的递减,形

9、成一个完整的三角波。4.梯形波模块的设计trap.vhd 梯形波模块的设计通过运用case语句,设计三个状态,使信号在“00”状态时从00000000到00000101递增,在“01”状态时保持00000101,在“10”状态时从00000101到00000000递减,形成一个完整的梯形波。5.方波模块的设计reta.vhd 方波模块即是完成方波输出地设计,以及有异步复位的功能,该程序采用了两个进程语句,第一个进程是完成在时钟上升沿同步时,rclk,rst0=rst,c0=c,ld0=ld,dinl0=dinl,dinh0=dinh,red_east1=red_east,yellow_east

10、1=yellow_east,green_east1=green_east,red_north1=red_north,yellow_north1=yellow_north,green_north1=green_north); u2:jishu port map (clk1=clk,ld1=ld,dinl1=dinl,dinh1=dinh,qh1=led7sh,ql1=led7sl,c1=c); u3: led7s port map(a=led7sh,led7s=ten_east); u4: led7s port map(a=led7sl,led7s=one_east); u5: led7s po

11、rt map(a=led7sh,led7s=ten_north); u6: led7s port map(a=led7sl,led7s=one_north);end;2.Morre型状态机的设计moore.vhdlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity moore is port(clk0,rst0,c0 :in std_logic; ld0 :out std_logic; red_east1,green_east1,yellow_east1,red_north1,green_

12、north1,yellow_north1:out std_logic; dinl0,dinh0 :out std_logic_vector(3 downto 0);end;architecture one of moore is type st_type is(s0,s1,s2,s3); signal c_st:st_type; signal clk2:std_logic; begin process(clk0,rst0) begin if rst0=0 then c_st=s0;dinh0=0100;dinl0=0101;ld0=0;red_east1=0;yellow_east1=0;gr

13、een_east1=1;red_north1=1;yellow_north1=0;green_north1if c0=1 then c_st=s1;dinh0=0000;dinl0=0101;ld0=0; else c_st=s0;ld0=1; endif; red_east1=0;yellow_east1=0;green_east1=1;red_north1=1;yellow_north1=0;green_north1if c0=1 then c_st=s2;dinh0=0010;dinl0=0101;ld0=0; else c_st=s1;ld0=1; end if; red_east1=

14、0;yellow_east1=1;green_east1=0;red_north1=1;yellow_north1=0;green_north1if c0=1 then c_st=s3;dinh0=0000;dinl0=0101;ld0=0; else c_st=s2;ld0=1;end if; red_east1=1;yellow_east1=0;green_east1=0;red_north1=0;yellow_north1=0;green_north1if c0=1 then c_st=s0;dinh0=0100;dinl0=0101;ld0=0; else c_st=s3;ld0=1;

15、end if; red_east1=1;yellow_east1=0;green_east1=0;red_north1=0;yellow_north1=1;green_north1red_east1=0;yellow_east1=0;green_east1=1;red_north1=1;yellow_north1=0;green_north1=0;ld0=0; end case; end if; end process;end;3.减法计数器的设计jishu.vhdlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsig

16、ned.all;entity jishu is port(clk1:in std_logic; ld1:in std_logic; dinl1:in std_logic_vector(3 downto 0); dinh1:in std_logic_vector(3 downto 0); ql1:out std_logic_vector(3 downto 0); qh1:out std_logic_vector(3 downto 0); c1:out std_logic);end;architecture one of jishu is signal qa,qat:std_logic_vecto

17、r(3 downto 0); signal qb,qbt:std_logic_vector(3 downto 0); signal ca,cb :std_logic; begin qh1=qb; ql1=qa; process(clk1) begin qat=dinl1; if clk1event and clk1=1 then if ld1=0 then qa=qat;ca=0; elsif(qa=0000) then qa=1001;ca=0; elsif(qa=0001) then ca=1;qa=0000; else qa=qa-1;ca=0; end if; end if; end

18、process; process(ca,clk1) begin qbt=dinh1; if clk1event and clk1=1 then if ld1=0 then qb=qbt;cb=0;c1=0; elsif(qb=0000 and qa=0001) then c1=0; elsif(qb=0000 and qa=0010) then c1=1; elsif(qb=0000 and qa=1000) then c1=1; elsif(qb=0000 and qa=0111) then c1=0; elsif(ca=1) then qbled7sled7sled7sled7sled7s

19、led7sled7sled7sled7sled7sled7sled7sled7sled7sled7sled7snull; end case; end process; end;(二)智能函数发生器1.顶层文件singt.vhdlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity singt isport(clk,rst:in std_logic; key1,key2,key3:in std_logic; douts:out std_logic_vector(7 downto 0);end;

20、architecture one of singt iscomponent sindataport(address:in std_logic_vector(5 downto 0); inclock:in std_logic; q:out std_logic_vector(7 downto 0);end component;component retaport(clk1,rst1:in std_logic; rout1:out std_logic_vector(7 downto 0);end component;component trapport(clk5,rst5:in std_logic;

21、 tout5:out std_logic_vector(7 downto 0);end component;component jianxie port(clk3,rst3:in std_logic; jout3:out std_logic_vector(7 downto 0);end component;component zengxieport(clk2,rst2:in std_logic; zout2:out std_logic_vector(7 downto 0);end component;component rectport(clk4,rst4:in std_logic; sout

22、4:out std_logic_vector(7 downto 0);end component;component wavselport (key11,key22,key33:in std_logic; zin0,jin0,rin0,tin0,sin0,sinin0:in std_logic_vector(7 downto 0); dout:out std_logic_vector(7 downto 0);end component;signal q1:std_logic_vector(5 downto 0);signal a0,a1,a2,a3,a4,a5:std_logic_vector

23、(7 downto 0);beginprocess(clk)beginif clkevent and clk=1 then q1q1,q=a0,inclock=clk);u2:reta port map(clk1=clk,rst1=rst,rout1=a1);u3:zengxie port map(clk2=clk,rst2=rst,zout2=a2);u4:jianxie port map(clk3=clk,rst3=rst,jout3=a3);u5:rect port map(clk4=clk,rst4=rst,sout4=a4);u6:trap port map(clk5=clk,rst

24、5=rst,tout5=a5);u7:wavsel port map (key11=key1,key22=key2,key33=key3,sinin0=a0,rin0=a1,zin0=a2,jin0=a3,sin0=a4,tin0=a5,dout=douts);end;2.递增斜波程序zengxie.vhdlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity zengxie isport(clk2,rst2:in std_logic; zout2:out std_logic_vector(

25、7 downto 0);end;architecture one of zengxie isbegin process(clk2)variable r:std_logic_vector(7 downto 0);beginif rst2=1 then r:=(others=0);elsif clk2event and clk2=1 thenif r0);end if;end if;zout20 then r:=r-1;else r:=00000101;end if;end if;jout3=r;end process;end;4.方波程序reta.vhdlibrary ieee;use ieee

26、.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity reta isport(clk1,rst1:in std_logic; rout1:out std_logic_vector(7 downto 0);end;architecture one of reta issignal r:std_logic_vector(7 downto 0);begin process(r)beginif r6 then rout1=00000110;else rout10);end if;end process;process(clk1,rst1,

27、r)beginif rst1=1 then r0);elsif clk1event and clk1=1 thenif r11 then r=r+1;else r0);end if;end if;end process;end;5.梯形波程序trap.vhdlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity trap isport(clk5,rst5:in std_logic; tout5:out std_logic_vector(7 downto 0);end;architecture

28、 one of trap issignal r:std_logic_vector(7 downto 0);beginprocess(clk5,rst5)variable p:std_logic_vector(1 downto 0);beginif rst5=1 then r0);tout50);p:=00;elsif clk5event and clk5=1 thencase p iswhen 00 =if r6 then r=r+1;tout5if r9 then r=r+1;tout5=00000101;else p:=10;rif r0 then r=r-1;tout5=r;else p

29、:=00;r=00000001;tout5NULL;end case;end if;end process;end;6.三角波程序rect.vhdlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity rect isport(clk4,rst4:in std_logic; sout4:out std_logic_vector(7 downto 0);end;architecture one of rect issignal r:std_logic_vector(7 downto 0);beg

30、inprocess(clk4,rst4,r)variable p:std_logic;beginif rst4=1 then r0);sout40);p:=0;elseif clk4event and clk4=1 then if p=0 then if r5 then r=r+1; else p:=1;r0 then r=r-1; else p:=0;r=r+1; end if; end if;end if;end if;sout4=r;end process;end;7.正弦波程序sindata.vhdlibrary ieee;use ieee.std_logic_1164.all;library lpm;use lpm.lpm_components.all;entity sindata isport(address: in std_lo

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1