名称:交通灯控制器设计Verilog代码VIVADO仿真(文末获取)
软件:VIVADO
语言:Verilog
代码功能:
交通灯控制器
1、实现一个十字路口交通灯,每条路有红绿黄三色信号灯
2、使用数码管显示倒计时
3、可通过代码修改通行时间
1. 工程文件
2. 程序文件
3. 程序编译
4. RTL图
5. Testbech
6. 仿真图
整体仿真图
分频模块仿真
控制模块仿真
计数模块
数码管动态扫描模块仿真
部分代码展示:
/* 红->绿 绿->黄 黄->红 1、红--计时main_red_times------------------------绿--计时main_green_times---main_yellow_times黄灯---------------红 2、绿--计时branch_green_times---branch_yellow_times黄灯--------------------红--计时branch_reg_times-------------------绿 */ module traffic_light( input clk,//50Mhz //led 1亮0灭 output main_red,//主路灯 output main_green,//主路灯 output main_yellow,//主路灯 output branch_red,//支路灯 output branch_green,//支路灯 output branch_yellow,//支路灯 output [3:0] weixuan,//数码管位选 output [7:0] duanxian//数码管段选 ); 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; wire main_red_led;//主路灯 wire main_green_led;//主路灯 wire main_yellow_led;//主路灯 wire branch_red_led;//支路灯 wire branch_green_led;//支路灯 wire branch_yellow_led;//支路灯 //led 0亮1灭 assign main_red=main_red_led;//主路灯 assign main_green=main_green_led;//主路灯 assign main_yellow=main_yellow_led ;//主路灯 assign branch_red=branch_red_led;//支路灯 assign branch_green=branch_green_led;//支路灯 assign branch_yellow=branch_yellow_led ;//支路灯 //分频模块 div div100 ( . clk(clk), . clk_out(clk_1Hz) );
源代码
扫描文章末尾的公众号二维码