名称:基于FPGA的红绿灯时间可调交通灯设计Verilog代码ISE仿真
软件:ISE
语言:Verilog
代码功能:
红绿灯时间可调交通灯设计
1、十字路口交通灯,交通灯时间可调。
2、具体紧急(夜间)按键,在紧急(夜间)模式下亮黄灯。
FPGA代码Verilog/VHDL代码资源下载:www.hdlcode.com
演示视频:
设计文档:
1. 工程文件
2. 程序文件
3. 程序编译
4. RTL图
5. Testbench(仿真文件)
6. 仿真图
整体仿真图
时钟电路(分频模块)
计时电路调节(绿灯)
绿灯时间从20 调整到26
计时电路调节(黄灯)
黄灯从3调整到6
控制模块
部分代码展示:
//交通灯 module traffic_light( input clk,//50Mhz input lock_key,//为1夜间模块 input main_green_add,//主路绿灯加 input main_green_sub,//主路绿灯减 input branch_green_add,//支路绿灯加 input branch_green_sub,//支路绿灯减 input main_yellow_add,//主路黄灯加 input main_yellow_sub,//主路黄灯减 input branch_yellow_add,//支路黄灯加 input branch_yellow_sub,//支路黄灯减 output main_red,//主路灯 output main_green,//主路灯 output main_yellow,//主路灯 output branch_red,//支路灯 output branch_green,//支路灯 output branch_yellow,//支路灯 output [3:0] main_ten_bcd,//主路十位接CD4511 output [3:0] main_one_bcd,//主路个位接CD4511 output [3:0] branch_ten_bcd,//支路十位接CD4511 output [3:0] branch_one_bcd //支路个位接CD4511 ); wire clk_1Hz; wire [7:0] main_green_BCD; wire [7:0] main_yellow_BCD; wire [7:0] main_red_BCD; wire [7:0] branch_green_BCD; wire [7:0] branch_yellow_BCD; wire [7:0] branch_red_BCD; wire [7:0] main_data_out; wire [7:0] branch_data_out; //分频模块 fengping i_fengping ( . clk(clk), . clk_out(clk_1Hz)//1Hz ); //按键调整时间 wire [7:0]main_green_time;//由外部控制 wire [7:0]main_yellow_time; wire [7:0]branch_green_time;//由外部控制 wire [7:0]branch_yellow_time; //绿灯时间调节 green_time_ctrl igreen_time_ctrl( . clk(clk),//50MMhz . main_green_add(main_green_add),//主路绿灯加 . main_green_sub(main_green_sub),//主路绿灯减 . branch_green_add(branch_green_add),//支路绿灯加 . branch_green_sub(branch_green_sub),//支路绿灯减 . main_green_time(main_green_time),//主路绿灯时间 . branch_green_time(branch_green_time)//支路绿灯时间 ); //黄灯时间调节 yellow_time_ctrl iyellow_time_ctrl( . clk(clk),//50MMhz . main_green_add(main_yellow_add),//主路黄灯加 . main_green_sub(main_yellow_sub),//主路黄灯减 . branch_green_add(branch_yellow_add),//支路黄灯加 . branch_green_sub(branch_yellow_sub),//支路黄灯减 . main_green_time(main_yellow_time),//主路黄灯时间 . branch_green_time(branch_yellow_time)//支路黄灯时间 ); reg [7:0] display_main; reg [7:0] display_branch; //交通灯控制模块 control i_control( . clk(clk), . clk_1Hz(clk_1Hz), .
点击链接获取代码文件:http://www.hdlcode.com/index.php?m=home&c=View&a=index&aid=828
阅读全文
810