Verilog交通灯控制系统.doc
文本预览下载声明
摘 要
Verilog HDL作为一种规范的硬件描述语言,被广泛应用于电路的设计中。它的设计描述可被不同的工具所支持,可用不同器件来实现。利用Verilog HDL语言自顶向下的设计方法设计交通灯控制系统,使其实现道路交通的正常运转,突出了其作为硬件描述语言的良好的可读性、可移植性和易理解等优点,并通过Quartus5.0完成综合、仿真。此程序通过下载到FPGA芯片后,可应用于实际的交通灯控制系统中。
关键词:Verilog HDL;硬件描述语言;状态;FPGA
Abstract
As a common language for the description of hardware, Verilog HDL is widely applied in circuit designing. The design description can be supportted by differenttools and implemented by different devices.In this paper, the process of design ing traffic light controller system by the Verilog HDL topdown design method is presented, which has made the road traffic work well, the design of t his system has shown the readability, portability and easily understanding of Verilog HDL as a hard description language Circuit synthesis and simulation are pe rformed by Quartus5.0. The program can be used in the truly traffic light controller system by downloading to the FPGA chipKeywords:Verilog HDL; hardware description language; state; FPGAHDL(Hardware Description Language,硬件描述语言)是一种描述硬件所做工作的语HDL在这种形势下显示出了巨大的优HDL在硬件设计领域的地位将与C和C++在软件设计领域地位一样,在大 Verilog HDL是工业和学术界的硬件设计者所使用的两种主要的HDL之一,另一种是VHDL。IEEE标准。两者各有特点,但Verilog HDL拥有更悠久的历,资源也远比VHDL丰富,且非常容易学习掌握。
状态图如下:
2.系统设计方案:
根据设计要求和系统所具有功能,并参考相关的文献资料经行方案设计画出如下所示的十字路口交通灯控制器系统框图,及为设计的总体方案,框图如下图所示:
四、程序设计
1.verilog源程序:
module traffic(en,clk,rst,num1,num2,light1,light2,out1,out2,out3,out4,in1,in2);
input en,clk,rst,in1,in2; //en为使能端。in1,in2控制绿灯和红灯亮时间
output [7:0] num1,num2;
output [2:0] light1,light2;
output [6:0]out1,out2,out3,out4;//输出四个数码管
reg [6:0]out1,out2,out3,out4;
reg tim1,tim2;
reg [1:0]state1,state2;
reg [2:0]light1,light2;
reg [7:0] num1,num2;
reg [7:0] red1,red2,green1,green2,yellow1,yellow2;
parameter s0=2b00,s1=2b01,s2=2b10,s3=2b11;//四个循环状态
reg[25:0]count;reg div;
always @(en )
if(en)
begin //设置计数初值
if (!in1)begin green1=8red2=8 end//30H,即30秒
else begin green1=8red2=8end//60s
if (!in2)begin red1=8green2=8 end//20s
显示全部