欢迎来到课桌文档! | 帮助中心 课桌文档-建筑工程资料库
课桌文档
全部分类
  • 党建之窗>
  • 感悟体会>
  • 百家争鸣>
  • 教育整顿>
  • 文笔提升>
  • 热门分类>
  • 计划总结>
  • 致辞演讲>
  • 在线阅读>
  • ImageVerifierCode 换一换
    首页 课桌文档 > 资源分类 > DOCX文档下载  

    数字集成电路设计课程作业--实验十一红绿交通灯控制系统设计.docx

    • 资源ID:957244       资源大小:430.87KB        全文页数:26页
    • 资源格式: DOCX        下载积分:5金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要5金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    数字集成电路设计课程作业--实验十一红绿交通灯控制系统设计.docx

    数字集成电路设计课程作业题目:红绿交通灯控制系统设计目录一、实验目的3二、实验原理3三、实验内容6四、实验步骤61 .实验代码62 .实验优化与仿真21五、实验总结24一、实验目的:1、初步学会用EDA进行系统设计2、理解电路模块化设计概念二、实验原理:1 .红绿交通灯控制系统如图1所示。硬件电路包括:两组红绿灯(配合十字路口的双向指挥控制)、两组七段数码管(配合红灯时倒计时的显示)、一组手动与自动控制开关(针对交通警察指挥交通控制使用)。图I红绿灯交通信号系统2 .实验电路安排如图2所示。其中,TRAFFIC_SIGN模块是用VHDL语言设计的。TRAFFIC_SIGN模块由4个子模块构成,如图3所示。(1) clgen:时钟脉冲发生电路(即分频电路)在红绿灯交通控制系统中,大多数的情况是通过自动控制的方式指挥交通的。因此,为了避免意外事件的发生,电路必须给一个稳定的时钟才能让系统正常运作。但为了配合高峰时段,防止交通拥挤,有时必须使用手动控制,即让交警能顺利地指挥交通。clk.gen电路最主要的功能就是产生一些额外的输出信号,并将其用做后续几个电路的使能控制与同步信号处理。clk,gen电路系统输入信号:elk:由外接信号发生器提供IKHZ的时钟信号;reset:系统内部自复位信号;clk_gen电路系统输出信号:enascan:将外部的elk信号进行分频(此电路设计除4)处理;ena_lhz:产生每秒一个脉冲的信号;图2实验电路图SESUS SH,-. :SkGi)- SEG73;SeG 1 2SEG7IISH.7iu,SH,tV “HG 飞IUSfcICLK.GENEKA SCASEKA IHZSBC77 SBOT6S«j75 、Ss4SEC7J SEO72 桃7|Vhdl SMV)MflaXk CLK REStfr UMD111 ENASCAN RFKMNT MCI、WUElI :0) TRAFFIC MlrX< SAD < CFAD < CFAD < CPAD <>a:) ,(>A J V "AD < CFAD ViPAI) 4C,AD <f CMD < CPA <:C PAD < CPAD (PAD << CPADVbdlcodeKfcCOUNI RESET KJM STATEll OjSlGN STATF1:0R£D|1 叫ItEDtBNASCANENAIIiZFLASH IIIZ1STATL IHG£¢"16:0 RFSFTRECoVXT LoADn 刈 COCNLDOWZREI<IGRcM 9KASH IHZYLiXOWI I O AMSl WJlTNO(TSTATrTRFC NMREDOGREENLOlGREENl GREENOYHKwlYEUX)WO 一YCLLOW IJ<CPAD 1VePAD IJAD)I,AD>图3红绿灯交通信号系统的VHDL模块图(2) traffijmux:计数秒表选择电路当过马路的时候,绿灯的一方有时会附加一个显示器告诉行人,目前还剩下几秒信号灯变成红灯。因此,traffijmux电路的主要功能就是负责输出显示器需要的值(即倒数的秒数值),作为倒数显示器电路(countdowncircuit)的计数秒表。traffic_mux电路的系统输入信号:elk:由外接信号发生器提供IKHZ的时钟信号;reset:系统内部自复位信号;ena_scan:接收由clgen电路提供的25OHZ的时钟脉冲信号;recount:接收由traffiJfSm电路产生的重新计数的使能控制信号;sign_state:接收由trafficjsm电路产生的状态信号(共2b,4种状态)系统输出宿号;traffic_mux电路的系统输出信号:load:负责产生计数器所需的计数数值(共8b,可输入数值范围。255);(3) countdown:倒计时控制电路当过马路的前候,绿灯的一方有时会附加一个显示器告诉行人,目前还剩下几秒信号灯变成红灯。因此,countdown电路的主要功能就是负责接收traffijmux电路输出的值(即倒数的秒数超),然后将其转换成BCD码,利用七段显示器显示出来,让行人能清楚地知道在过多久就会变成红灯。countdown电路的系统输入信号:elk:由外接信号发生器提供IKHZ的时钟信号;reset:系统内部自复位信号;ena_lHZ:接收由clk_gen电路提供的IHZ的脉冲信号;recount:重新计数的使能控制信号;load:负责接收计数器所需的计数数值CoUnjdOWn电路的系统输出信号:seg7:负责将计数数值转换成BCD码,并利用七段显示器显示;next_state:当计数器计时完毕时,负责产生一个脉冲信号,作为转态触发信号。(4) traffic_fsm:红绿灯信号控制电路在红绿交通行控制系统中,大多数的情况是通过自动控制的方式指挥交通的。但为了配合高峰时段,防止交通拥挤,有时必须使用手动控制,即让交警自行指挥交通。因此,trafficjsm电路除了负责监控路口红绿灯之外,最主要的功能就是能够利用开关来切毓手动与自动的模式,让交警能够通过外部输入的方式来控制红绿灯交通信号系统的运作。trafficjsm电路的系统输入信号:elk:由外接信号发生器提供IKHZ的时钟信号;reset:系统内部自复位信号;ena_scan:接收由clk_gen电路提供的250HZ的时钟脉冲信号;ena_lHZ:接收由clk_gen电路提供的IHZ的脉冲信号;flash_lHZ:接收由clk,gen电路提供的IHZ的脉冲信号;a_m:年动与自动的切换按钮(1:自动,0:手动);SJbUtt:红绿灯状态切换键(在手动模式下,每按一次就切换一个状态)nexjstate:接收由countdown电路提供的转态触发信号(在自动模式下)trafficjsm电路的系统输出信号:sign_state:产生的输出状态信号(共2b,4种状态);red:负责红灯的显示(共2b,4种状态);green:负责绿灯的显示(共2b,4种状态);yellow:负责黄灯的显示(共2b,4种状态);三、实验内容:用VHDL语言实现clk_gen时钟发生电路(即分频电路);traffijmux:计数秒表选择电路;countdown:倒计时控制电路;traffiJfSm:红绿灯信号控制电路;用上述电路构成红绿交通灯控制系统。四、实验步骤1 .编写红绿交通灯控制系统各个模块的VHDL程序,进行语法检查,直到语法检查正确。(1) clk_gen:分频到IHZ的电路clk_gen.vhd:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.stdJogic_unsigned.all;entityclk_genisport(elk:inStdJogic;ena_lhz:outStdJogic);-Ihzoutputendentity;architecturebehavofclk_genissignalreg_clk:std_logic:='O'beginena_lhz<=reg_clk;div50m:process(clk)variabletmp:integerrange0to25000000:=0;-50MHz(25000000*2)=lHzbeginifclk,eventandelk=,1,thentmp:=tmp+1;iftmp=25000000thentmp:=0;reg-clk<=notreg_clk;endif;endif;endprocess;endbehave;(2) clk_div:分频到IKHz的电路clk_div.vhd:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.stdJogic_unsigned.all;entityclk_divisport(elk:inStdJogic;clkout:outStdJogic);-elkdivtoIKHzendentity;architecturebehvofclk_divissignalreg_clk:std_logic:='O'beginclkout<=reg-clk;process(clk)variabletmp:integerrangeOto25000:=0;-50MHz/(25000*2)=100OHzbeginifclk,eventandelk=,1,thentmp:=tmp+1;endif;iftmp=25000thenreg-clk<=notreg_clk;endif;endprocess;endarchitecture;(3) traffiJmUX:计数秒表选择电路traffic_mux.vhd:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entitytraffic_muxisport(elk:inStdJogic;-IKHzCLKinreset:inStdJogic;ena_lhz:inStdJogic;-IHzCLKinrecount:inStdJogic;sign_state:instd_logic_vector(ldowntoO);-zzOOwredzz01,yellowzz10,reen"11"greenflashload:outstd_logic_vector(7downtoO);-abinarycountoutputst_butt:inStdJogic;-manualcontrolnext_state:outStdJogic);-outputtofsm(finitestatemachine)endentity;architecturebehavoftraffic_muxissignalcount:std_logic_vector(7downtoO);signalstate:StdJogic:=,0,;signaltmpr:integerrangeOto30:=30;signaltmpg:integerrangeOto25:=25;signaltmpy:integerrangeOto5:=5;signaltmpgflash:integerrangeOto4:=4;beginprocess(ena_lhz,sign_state)beginif(sign_state="00")then-rif(rising_edge(ena_lhz)thenif(recount='1'orreset='1'ortmpr=Oorst_butt='O,)thentmpr<=30;elsetmpr<=tmpr-1;endif;endif;endif;if(sign_state="01")then-yif(rising_edge(ena_lhz)thenif(recount=,1,orreset='1'ortmpy=0orst_butt='0,)thentmpy<=5;elsetmpy<=tmpy-1;endif;endif;endif;if(sign_state="10")then-gif(rising_edge(ena_lhz)thenif(recount=,1'orreset='1,ortmpg=5orst_butt='0')thentmpg<=25;elsetmpg<=tmpg-1;endif;endif;endif;if(sign_state="11")then-gflashif(rising_edge(ena_lhz)thenif(recount=,1,orreset='1,ortmpgflash=0orst_butt='01)thentmpgflash<=4;elsetmpgflash<=tmpgflash-1;endif;endif;endif;casesign_stateis-convertthecountfromintegertostd_logic_vectorwhen"00"=>count<=CONV_STD_LOGIC_VECTOR(tmpr,8);when"01"=>count<=CONV_STD_LOGIC_VECTOR(tmpy,8);when"10"=>count<=CONV_STD_LOGIC_VECTOR(tmpg,8);when"1=>count<=CONV_STD_LOGIC_VECTOR(tmpgflashz8);whenothers=>count<="00000000"endcase;endprocess;process(tmpg,tmpgflashztmpr,tmpy)beginstate<='0,;if(tmpg=5ortmpr=0ortmpy=0ortmpgflash=0)thenstate<='1'endif;endprocess;process(clk,reset)beginif(rising_edge(clk)thennext_state<=state;load<=count;endif;endprocess;endbehav;(4) traffiJmUX2与1相同,只是输出用来控制另外一个方向的倒数traffic-mu×2.vhd:libraryieee;useieee.std_logic_1164.all;useieee.stdJogic_unsigned.all;useieee.std_logic_arith.all;entitytraffic_mux2isport(elk:inStdJogic;输出时钟reset:inStdJogic;一异步重置ena_scan:inStdJogic;一计数时钟(25OhZ)recount:inStdJogic;-同步重置倒计时Sign_state:instd_logic_vector(ldownto0);00“绿“01”黄uIOna"l,gflashload:outstd_logic_vector(7downto0);st_butt:inStdJogic;next_state:outStdJogic);endentity;architecturebehavoftraffic_mux2issignalcount:std_logic_vector(7downto0);signalstate:StdJogic:=,0,;signaltmpr:integerrange0to30:=30;signaltmpg:integerrange0to25:=25;signaltmpy:integerrange0to5:=5;signaltmpgflash:integerrangeOto4:=4;beginprocess(ena_scan,sign_state)beginif(sign_state="00")then-rif(rising_edge(ena_scan)thenif(recount='1'orreset='1'ortmpr=0orst_butt='0')thentmpr<=30;elsetmpr<=tmpr-1;endif;endif;endif;if(sign_state="01")then-yif(rising_edge(ena_scan)thenif(recount=,1,orreset='1'ortmpy=0orst_butt='0,)thentmpy<=5;elsetmpy<=tmpy-1;endif;endif;endif;if(sign_state="10")then-gif(rising_edge(ena_scan)thenif(recount=,1'orreset='1,ortmpg=5orst_butt='0')thentmpg<=25;elsetmpg<=tmpg-1;endif;endif;endif;if(sign_state="11")then-gflashif(rising_edge(ena_scan)thenif(recount=,1,orreset='1,ortmpgflash=0orst_butt=,0')thentmpgflash<=4;elsetmpgflash<=tmpgflash-1;endif;endif;endif;casesign_stateiswhen"00"=>count<=CONV_STD_LOGIC_VECTOR(tmprz8);when"01"=>count<=CONV-STD-LOGIC-VECTOR(tmp¼8);when"10"=>count<=CoNV_STD_LOGQVEcTOR(tmpg,8);when"1=>count<=CONV-STD-LOGIC-VECTOR(tmpgflashz8);whenothers=>count<="00000000"endcase;endprocess;process(tmpg,tmpgflashztmpGtmpy)beginstate<='0,;if(tmpg=5ortmpr=0ortmpy=0ortmpgflash=0)thenstate<='1'endif;endprocess;process(clkzreset)-输出给下一个模块beginif(rising_edge(clk)thennext_state<=state;load<=count;endif;endprocess;endbehav;(5) countdown:接收来自traffiJmUX的倒计时数字,并驱动数码管显示。count_down.vhd:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entitycountdownisPrt(ena_lhz:inStdJogic;load:instd_logic_vector(7downtoO);Ioad2:instd_logic_vector(7downtoO);seglshi:outstd_logic_vector(7downtoO);一输出十位seglge:outstd_logic_vector(7downtoO);“输出个位seg2shi:outstd_logic_vector(7downtoO);一输出十位seg2ge:outstd_logic_vector(7downto0);endcountdown;architecturebehavofcountdownisbeginprocess(ena_lhz)beginif(rising_edge(ena_lhz)thencaseloadiswhen"00011110"=>seglshi<="10110000"seglge<="11000000"when"00011101"=>seglshi<="10100100"seglge<="10010000"-29when"00011100"=>seglshi<="10100100"seglge<="10000000"-28when"00011011=>seglshi<="10100100"seglge<="11111000"-27when"00011010"=>seglshi<="10100100"seglge<="10000010"-26when"00011001"=>seglshi<="10100100"seglge<="10010010"-25when"00011000"=>seglshi<="10100100"seglge<="10011001"-24when"00010111"=>seglshi<="10100100"seglge<="10110000"-23when"00010110"=>seglshi<="10100100"seglge<="10100100"-22when"00010101"=>seglshi<="10100100"seglge<="11111001"-21when"00010100"=>seglshi<="10100100"seglge<="11000000"-20when"00010011"=>seglshi<="11111001"seglge<="10010000"when"00010010"=>seglshi<="11111001"seglge<="10000000"when"00010001,=>seglshi<="11111001"seglge<="11111000"-17when"00010000"=>seglshi<="11111001"seglge<="10000010"when"00001111"=>seglshi<="11111001"seglge<="10010010"when"00001110"=>seglshi<="11111001"seglge<="10011001"when"00001101"=>seglshi<="11111001"seglge<="10110000"when"00001100"=>seglshi<="11111001"seglge<="10100100"-12when"00001011"=>seglshi<="11111001"seglge<="11111001"when"00001010"=>seglshi<="11111001"seglge<="11000000"when"00001001"=>seglshi<="llllllll"seglge<="10010000"when"00001000"=>seglshi<="llllllll"seglge<="10000000"when"00000111"=>seglshi<="llllllll"seglge<="11111000"-7when"00000110"=>seglshi<="llllllll"seglge<="10000010"when"00000101"=>seglshi<="llllllll"seglge<="10010010"-5when"00000100"=>seglshi<="llllllll"seglge<="10011001"when"00000011"=>seglshi<="llllllll"seglge<="10110000"when"00000010"=>seglshi<="llllllll"seglge<="10100100"-2when"00000001"=>seglshi<="llllllll"seglge<="11111001"when"00000000"=>seglshi<="llllllll"seglge<="11000000"whenothers=>seglshi<="llllllll"seglge<=,1111111;endcase;endif;endprocess;process(ena_lhz)beginif(rising_edge(ena_lhz)thencaseIoad2iswhen"00011110"=>seg2shi<="10110000"seg2ge<="11000000"when"00011101"=>seg2shi<="10100100"seg2ge<="10010000"-29when"00011100"=>seg2shi<="10100100"seg2ge<="10000000"-28when"00011011=>seg2shi<="10100100"seg2ge<="11111000"-27when"00011010"=>seg2shi<="10100100"seg2ge<="10000010"-26when"00011001"=>seg2shi<="10100100"seg2ge<="10010010"-25when"00011000"=>seg2shi<="10100100"seg2ge<="10011001"-24when"00010111"=>seg2shi<="10100100"seg2ge<="10110000"-23when"00010110"=>seg2shi<="10100100"seg2ge<="10100100"-22when"00010101"=>seg2shi<="10100100"seg2ge<="11111001"-21when"00010100"=>seg2shi<="10100100"seg2ge<="11000000"-20when"00010011"=>seg2shi<="11111001"seg2ge<="10010000"when"00010010"=>seg2shi<="11111001"seg2ge<="10000000"when"00010001,=>seg2shi<="11111001"seg2ge<="11111000"-17when"00010000"=>seg2shi<="11111001"seg2ge<="10000010"when"00001111"=>seg2shi<="11111001"seg2ge<="10010010"when"00001110"=>seg2shi<="11111001"seg2ge<="10011001"when"00001101"=>seg2shi<="11111001"seg2ge<="10110000"when"00001100"=>seg2shi<="11111001"seg2ge<="10100100"-12when"00001011"=>seg2shi<="11111001"seg2ge<="11111001"when"00001010"=>seg2shi<="11111001"seg2ge<="11000000"when"00001001"=>seg2shi<="llllllll"seg2ge<="10010000"when"00001000"=>seg2shi<="llllllll"seg2ge<="10000000"when"00000111"=>seg2shi<="llllllll"seg2ge<="11111000"-7when"00000110"=>seg2shi<="llllllll"seg2ge<="10000010"when"00000101"=>seg2shi<="llllllll"seg2ge<="10010010"-5when"00000100"=>seg2shi<="llllllll"seg2ge<="10011001"when"00000011"=>seg2shi<="llllllll"seg2ge<="10110000"when"00000010"=>seg2shi<="llllllll"seg2ge<="10100100"-2when"00000001"=>seg2shi<="llllllll"seg2ge<="11111001"when"00000000"=>seg2shi<="llllllll"seg2ge<="11000000"whenothers=>seg2shi<="llllllll"seg2ge<=,1111111;endcase;endif;endprocess;endbehav;(6) trafficjsm:红绿灯信号控制电路,采用有限状态机的方法写traffic-fsm.vhd:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.stdJogic_unsigned.all;entitytraffic_fsmisport(elk:inStdJogic;reset:instd_logic;ena_lhz:inStdJogic;flash_lhz:inStdJogic;a_m:inStdJogic;-'l,auto,0,manualst_butt:inStdJogic;st_buttl:inStdJogic;next_state:inStdJogic;sign_state:outstd_logic_vector(ldownto0);-"00"g"01"y"10"rred:outStdJogic;yellow:outstd_logic;green:outStdJogic);endentity;architecturebehavoftraffic_fsmisTYPEFSM_STIS(s,si,s2,s3);signalst×:FSM_ST:=s;beginstate_trans:process(ena_lhz,reset,a_m)beginif(a_m=,1,)thenifrising_edge(ena_lhz)thenif(reset=,1,)thenstx<=s;elsecasestxiswhens=>ifnext_state='1'thenstx<=sl;endif;whensi=>ifnext_state=,1,thenstx<=s2;endif;-gflashwhens2=>ifnext_state=,1,thenstx<=s3;endif;-ywhens3=>ifnext_state=,1,thenstx<=sO;endif;whenothers=>stx<=s;endcase;endif;endif;elseif(st_butt=,O,)then-rst×<=s3;endif;if(st_buttl=,O,)then-gst×<=s;endif;endif;endprocess;outputl:process(stx)begincasestxiswhens=>sign_state<="10"green<='l'red<=,0yellow<=,0,;-gwhensi=>sign_state<="ll"green<=flash_lhz;red<=,0yellow<='0,;-gflashwhens2=>sign_state<="01"green<='O'red<='0'yellow<=,1,;-ywhens3=>sign_state<="OO"green<='O'red<=,lyellow<=,0,;-rwhenothers=>sign_state<="01"green<=flash_lhz;red<=flash_lhz;yellow<=flash_lhz;endcase;endprocess;endbehav;(7) traffiJfSm2:同上,控制另一个方向的红绿灯traffic_fsm2.vhd:libraryieee;useieee.stdJogic_1164.all;useieee.std_logic_arith.all;useieee.std_logic_unsigned.all;entitytraffic_fsm2isport(elk:inStdJogic;reset:inStdJogic;ena_lhz:inStdJogic;flash_lhz:inStdJogic;a_m:inStdJogic;-,l,auto,0,manualst_butt:inStdJogic;st_buttl:inStdJogic;next_state:inStdJogic;sign_state:outstd_logic_vector(ldowntoO);-,'00"g"01',y"10"rred:outStdJogic;yellow:outStdJogic;green:outStdJogic);endentity;architecturebehavoftraffic_fsm2isTYPEFSM_STIS(s,si,s2,s3);signalst×:FSM_ST:=s;beginstate_trans:process)ena-lhz,rset,a-m)beginif(a_m=,1,)thenifrising_edge(ena_lhz)thenif(reset=,1,)thenstx<=s;elsecasestxiswhens=>ifnext_state='1'thenstx<=sl;endif;-rwhensi=>ifnext_state=,1,thenstx<=s2;endif;-gwhens2=>ifnext_state='1'thenstx<=s3;endif;-gflashwhens3=>ifnext_state='1'thens

    注意事项

    本文(数字集成电路设计课程作业--实验十一红绿交通灯控制系统设计.docx)为本站会员(夺命阿水)主动上传,课桌文档仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知课桌文档(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-1

    经营许可证:宁B2-20210002

    宁公网安备 64010402000986号

    课桌文档
    收起
    展开