EDA课程设计(交通灯)答辩
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
process(q) --1s信号 begin if (q'event and q='0') then s<='0'; if(tmp="110001") then tmp<="000000"; s<='1'; else tmp<=tmp+'1'; end if; end if; end process;
状态转换逻辑: 以 present_state,sensor为进 程敏感信号。描述状态转换图 process(present_state,sensor) __状态逻辑 begin case present_state is when green=> red_light1<='0' ; green_light1<='1' ; yellow_light1<= '0' ; red_light2<='1' ; green_light2<='0' ; yellow_light2<= '0' ; if (sensor = '1') then next_state <= yellow; else next_state <= green; end if;
process(yl2) --支干道低位译码 begin case yl2 is when"0000"=>Ql2(6 downto 0)<="1111110"; when"0001"=>Ql2(6 downto 0)<="0110000"; when"0010"=>Ql2(6 downto 0)<="1101101"; when"0011"=>Ql2(6 downto 0)<="1111001"; when"0100"=>Ql2(6 downto 0)<="0110011"; when"0101"=>Ql2(6 downto 0)<="1011011"; when"0110"=>Ql2(6 downto 0)<="1011111"; when"0111"=>Ql2(6 downto 0)<="1110000"; when"1000"=>Ql2(6 downto 0)<="1111111"; when"1001"=>Ql2(6 downto 0)<="1111011"; when others=>Ql2(6 downto 0)<="00000000"; end case; end process;
另外两个状态程序结构与之一致,只在计时时间上有所不同。
状态装换:
以当前状态计时到0信号f为触 发信号,转到下一亮灯状态
process(f) begin WAIT UNTIL f'event and f ='0' ; present_state<=next_state ; end process ;
if(tmpl2=“0000”)then --支干道倒计时 tmpl2<="1001"; tmph2<=tmph2-'1'; if(tmph2="0000")then tmph2<="0010"; --十位 if(tmpl2="0000")then tmpl2<="0100"; --个位 end if; end if; elsif(tmpl2<"1001"or tmpl2="1001")then tmpl2<=tmpl2-'1'; end if; yh1<=tmph1; yl1<=tmpl1; 主干道倒计时BCD码 yh2<=tmph2; yl2<=tmpl2; 支干道倒计时BCD码
红灯
黄灯 5s
绿灯 25s
红灯 25s
50s
Vhdl程序设计流程图
Process(clk)分 频器F%,q
Process(q)计 数器(1s)
Process(p_s,sen) 状态转换逻辑
Process(s)倒 计时f
Process(f) 状态转换
显示译码
process(clk) --分频 begin if (clk'event and clk='0') then IF(counter="01100011") then 分频模块: counter<="00000000"; 10000HZ时钟信号进行分频, q<=not q; clk一百个上升沿 ,Q取一次反。 再对Q的上升沿计数50次就得 else 到1s信号, counter<=counter+'1'; end if; end if; end process;
EDA课程设计—交通灯
任务要求:
(1) 由一条主干道和一条支干道汇合成十字路口, 在每 一个入口处设置红、绿、黄三色信号灯,红灯亮禁止通 行,绿灯亮允许通行,黄灯亮则给行驶中的车辆有时间 停在禁行线外。
(2) 主干道处于常允许通行的状态,支干道有车来时才允 许通行。主干道亮绿灯时,支干道亮红灯;支干道亮绿 灯时,主干道亮红灯。
(3)主、支干道均有车时,两者交替允许通行,主干道每 次放行45秒,支干道每次放行25秒,设立45秒、25秒计 时、显示电路。
(4)在每次由绿灯亮到红灯亮的转换过程中,要亮5秒黄 灯作为过渡,使行驶中的车辆有时间停到禁行线外,设 立5秒计时,显示电路。
任务分析
主干道 支干道放行25s
绿灯 45s
when yellow=>red_light1<= '0' ; green_light1<='0' ; yellow_light1<='1' ; red_light2<='1' ; green_light2<='0' ; yellow_light2<= '0' ; next_state <= red ; when red=>red_light1<='1' ; green_light1<='0' ; yellow_light1<='0' ; red_light2<='0' ; green_light2<='1' ; yellow_light2<= '0' ; next_state <= green ; end case; end process;
process(yl1) --主干道低位译码 begin case yl1 is when"0000"=>Ql1(6 downto 0)<="1111110"; when"0001"=>Ql1(6 downto 0)<="0110000"; when"0010"=>Ql1(6 downto 0)<="1101101"; when"0011"=>Ql1(6 downto 0)<="1111001"; when"0100"=>Ql1(6 downto 0)<="0110011"; when"0101"=>Ql1(6 downto 0)<="1011011"; when"0110"=>Ql1(6 downto 0)<="1011111"; when"0111"=>Ql1(6 downto 0)<="1110000"; when"1000"=>Ql1(6 downto 0)<="1111111"; when"1001"=>Ql1(6 downto 0)<="1111011"; when others=>Ql1(6 downto 0)<="00000000"; end case; end process;
process(yh2) --支干道高位译码 begin case yh2 is when"0000"=>Qh2(6 downto 0)<="1111110"; when"0001"=>Qh2(6 downto 0)<="0110000"; when"0010"=>Qh2(6 downto 0)<="1101101"; when"0011"=>Qh2(6 downto 0)<="1111001"; when"0100"=>Qh2(6 downto 0)<="0110011"; when"0101"=>Qh2(6 downto 0)<="1011011"; when"0110"=>Qh2(6 downto 0)<="1011111"; when"0111"=>Qh2(6 downto 0)<="1110000"; when"1000"=>Qh2(6 downto 0)<="1111111"; when"1001"=>Qh2(6 downto 0)<="1111011"; when others=>Qh2(6 downto 0)<="00000000"; end case; end process;
Fra Baidu bibliotek 亮灯状态倒计时:
同时对主干道和支干道当前 亮灯状态倒计时;
process(s) --状态计时 begin if (s'event and s='1') then case present_state is when yellow=>f<='0'; if(tmpl1=“0000”)then --主干道倒计时 tmpl1<="1001"; tmph1<=tmph1-'1'; if(tmph1="0000")then tmph1<="0010"; --十位 f<=„1‟; --倒计时到0的标志 if(tmpl1="0000")then tmpl1<="0100"; --个位 end if; end if; elsif(tmpl1<"1001"or tmpl1="1001")then tmpl1<=tmpl1-'1'; end if;
Vhdl 程序仿真波形
红绿 灯灯 灭亮
绿 黄 灯 灯 灭 亮
黄红 灯灯 灭亮
译码显示部分:
分主干道和支干道译码显示,
process(yh1) --主干道高位译码 begin case yh1 is when"0000"=>Qh1(6 downto 0)<="1111110"; when"0001"=>Qh1(6 downto 0)<="0110000"; when"0010"=>Qh1(6 downto 0)<="1101101"; when"0011"=>Qh1(6 downto 0)<="1111001"; when"0100"=>Qh1(6 downto 0)<="0110011"; when"0101"=>Qh1(6 downto 0)<="1011011"; when"0110"=>Qh1(6 downto 0)<="1011111"; when"0111"=>Qh1(6 downto 0)<="1110000"; when"1000"=>Qh1(6 downto 0)<="1111111"; when"1001"=>Qh1(6 downto 0)<="1111011"; when others=>Qh1(6 downto 0)<="00000000"; end case; end process;