当前位置:文档之家› EDA彩灯控制器

EDA彩灯控制器

EDA 课程设计

——彩灯控制器

摘要:

循环彩灯的电路很多,循环方式更是五花八门,而且有专门的可编程彩灯集成电路。绝大多数的彩灯控制电路都是用数字电路来实现

的,本次设计的循环彩灯控制器是用译码器来实现,本彩灯控制器能实现六种不同的花型,在呈现出不同花型的同时发出声音。

关键字:彩灯 Verilog HDL 控制

一.设计目的

学习EDA开发软件Quarters Ⅱ的使用方法,熟悉可编程逻辑器件的使用,通过制作来了解彩灯控制系统。本次课程设计的主要目的是通过电子设计自动化的设计,掌握FPGA应用系统的开发过程,进一步理解FPGA应用系统的工作原理。本课程设计设计了一个多路彩灯控制器,六种彩灯能循环变化,按照FPGA的开发流程和Verilog HDL 语言建模、仿真、综合、下载、适配,用EDA开发板上的FPGA系统实现了相应的功能。通过这次课程设计更清楚的理解了Verilog HDL 程序的描述语言,能进行简单程序的编写和仿真。

二、设计题目描述和要求

设计一个彩灯控制器,使彩灯(8个LED)能连续发出三种以上不同的花型(自拟)。

扩展功能:

随着彩灯显示图案的变化,发出不同的音响声。

三、设计流程

1、此次实验要求我们通过学习的EDA课程来编制Verilog程序以及使用这些程序代码来显示我们所要求的结果。流水灯设计是由八

只LED显示灯来实现的通过程序代码来控制这八只灯的亮灭。在实验初期我们首先得编程序,通过我们上课所学的基础知识再结合近段时间去图书馆查阅的有关参考书籍以及网上所搜索的相关知识我们小组共同完成了程序的编制,程序代码在下面有介绍。

2、其次我们需要掌握Quartus II的用法,因为要求的现象是通过这个软件实现的,在EDA实验课程中老师有详细介绍Quartus II 的使用方法,所以在这一阶段对我们来说也比较得心应手,安装调试然后将编好的程序输入,在此过程中我们遇到了点小困难显示程序有错误,但是通过我们集体的努力终于发现是因为在操作时我们应该先创建自己的文件夹然后统一存放在一起,而我们存放的地方有误所以显示不出我们所输入的代码。

3、当所有的程序输入无误后我们要为每个器件设置管脚,因为这些在实验课上老师有说过而且管脚号也已告诉我们只需查询便可,所以这一阶段应该说也挺简单的。

4、当所有的这一切准备工作做完后就是该演示现象了,这是最关键的一步,8只LED显示灯能被控制其亮灭会显示不同的花型。四、系统设计图:

五、管脚分配图:

六、时序仿真图:

七、实验结果图:

八、心得体会

这次的EDA 课程设计我们学到得东西很多,明白了理论与实践之间的差距,而且对DEA 课程有了更深入的理解,尤其是知道了怎么去应用所学的知识,怎么去利用网络实现自己的要求,具体体会如下:

(1)要想完成编程就要对DEA 知识很熟悉,这样才能加快编程的速度,另外在编程时一定要小心,稍微有一点粗心都会有很多的错误出现,在出现错误后要学会寻找错误原因如名称前后不一、数据类型不同、符号写错等等。

(2)拿道题目后要注意分析,要学会总体把握,然后再一一一

细化、学会将复杂的问题简单化,分析时一定要有一个明确的目标。

(3)要学会理论联系实际,在程序导入到实验箱后,居然不显示结果,认真的检查看看操作是否有错误、试验箱中该短路的是否已用短路帽短路、又重新检查了一下程序,结果发现是短路帽接错了,所以看似很简单的操作自己操作起来可能会有很大的漏洞,所以亲自动手是很重要的。

(4)当自己的只是有限时,要注意运用网络等一切资源,要学会知识的灵活运用在查阅的过程中学到了很多在书本所没有学到的知识,通过查阅相关资料进一步加深了对EDA的了解。

总的来说,通过这次课程设计不仅锻炼了我们的动手和动脑能力,也使我懂得了理论与实际相结合的重要性,只有理论知识是远远不够的,要把所学的理论知识与实践相结合起来,才能提高自己的实际动手能力和独立思考的能力。还有最重要的一点就是要有一丝不苟的精神和端正认真的态度,遇到困难后要学会积极的面对。

程序附录:

module beyond(clk,beep,led);

input clk;

output beep;

output [7:0] led;

reg beep;

reg [22:0]i;

reg clk_4hz;

reg [7:0]led;

reg [7:0]mod;

reg[24:0] count1;

reg [16:0] count,div_num;//

reg [6:0] music;//just for a test; always @(posedge clk)

if(count1[24] == 1)

count1 <= 0;

else

count1 <= count1 + 1'b1; always @(posedge clk)

if(count1[24] == 1)

if( mod[7] == 1 )

mod <= 0;

else

mod <= mod + 1'b1;

always @(posedge clk)//4hz

begin

if(i==23'h47868c)

begin

i<=0;

clk_4hz=~clk_4hz;

end

else

i=i+1'b1;

end

always @(posedge clk_4hz)

begin

if(music==7'd90)///////////////// ///notice

music<=0;

else

music<=music+1'b1; end

always @(posedge clk)

begin

if(count==div_num)

begin

count<=0;

beep=~beep;

end

else

count<=count+1'b1;

end

parameter

L1=17'h1754e,

L2=17'h14c81,

L3=17'h1284a,

L4=17'h117A8,

L5=17'h14e70,

L6=17'h0ddf2,

L7=17'h0c5ba,

M1=17'h0ba9e,

M2=17'h0a648,

M3=17'h0941f,

M4=17'h08bcf,

M5=17'h07c90,

M6=17'h06ef9,

M7=17'h062dd,

H1=17'h05d68,

H2=17'h05322,

H3=17'h04a11,

H4=17'h045e9,

H5=17'h3e48,

H6=17'h377d,

H7=17'h316f;

always @(posedge clk_4hz)

begin

case(music)

7'd0 : div_num=M7;

7'd1 : div_num=M7;

7'd2 : div_num=H1;

7'd3 : div_num=H1;

7'd4 : div_num=H2;

7'd5 : div_num=H2;

7'd6 : div_num=H2;

7'd7 : div_num=H3; 7'd8 : div_num=H3; 7'd9 : div_num=H3; 7'd10 : div_num=H3; 7'd11 : div_num=H2; 7'd12 : div_num=H2; 7'd13 : div_num=H2; 7'd14 : div_num=H2; 7'd15 : div_num=H2; 7'd16 : div_num=H1; 7'd17 : div_num=M7; 7'd18 : div_num=M5; 7'd19 : div_num=M6; 7'd20 : div_num=M6; 7'd21 : div_num=M6; 7'd22 : div_num=M3; 7'd23 : div_num=M2; 7'd24 : div_num=M3; 7'd25 : div_num=M3; 7'd26 : div_num=M3; 7'd27 : div_num=M3; 7'd28 : div_num=M5; 7'd29 : div_num=M5; 7'd30 : div_num=M5; 7'd31 : div_num=M6; 7'd32 : div_num=M6; 7'd33 : div_num=M6; 7'd34 : div_num=H1; 7'd35 : div_num=M7; 7'd36 : div_num=H1; 7'd37 : div_num=H1; 7'd38 : div_num=H7; 7'd39 : div_num=H7; 7'd40 : div_num=H1; 7'd41 : div_num=H1; 7'd42 : div_num=H1; 7'd43 : div_num=H1; //repeat

7'd44 : div_num=M7; 7'd45 : div_num=M7; 7'd46 : div_num=H1; 7'd47 : div_num=H1; 7'd48 : div_num=H2; 7'd49 : div_num=H2;

7'd50 : div_num=H2;

7'd51 : div_num=H3;

7'd52 : div_num=H3;

7'd53 : div_num=H3;

7'd54 : div_num=H3;

7'd55 : div_num=H2;

7'd56 : div_num=H2;

7'd57 : div_num=H2;

7'd58 : div_num=H2;

7'd59 : div_num=H2;

7'd60 : div_num=H1;

7'd61 : div_num=M7;

7'd62 : div_num=H1;

7'd63 : div_num=H1;

7'd64 : div_num=M7;

7'd65 : div_num=M7;

7'd66 : div_num=M7;

7'd67 : div_num=M7;

7'd68 : div_num=M3;

7'd69 : div_num=M2;

7'd70 : div_num=M3;

7'd71 : div_num=M3;

7'd72 : div_num=M3;

7'd73 : div_num=M3;

7'd74 : div_num=M5;

7'd75 : div_num=M5;

7'd76 : div_num=M5;

7'd77 : div_num=M6;

7'd78 : div_num=M6;

7'd79 : div_num=M6;

7'd80 : div_num=L5;

7'd81 : div_num=L6;

7'd82 : div_num=M1;

7'd83 : div_num=M2;

7'd84 : div_num=M3;

7'd85 : div_num=M5;

7'd86 : div_num=H1;

7'd87 : div_num=H1;

7'd88 : div_num=H1;

7'd89 : div_num=H1;

endcase

end

always @(posedge clk)

begin

case (mod)

8'h08: led <= 8'b11111111;

8'h09: led <= 8'b00000000;

8'h0a: led <= 8'b00000011;

8'h0b: led <= 8'b00001100;

8'h0c: led <= 8'b00110000;

8'h0d: led <= 8'b11000000;

8'h0e: led <= 8'b11000000;

8'h0f: led <= 8'b00110000;

8'h10: led <= 8'b00011000;

8'h11: led <= 8'b00000110;

8'h12: led <= 8'b00000000;

8'h13: led <= 8'b11111111;

8'h00: led <= 8'b00011000; 8'h01: led <= 8'b00111100;

8'h02: led <= 8'b01111110;

8'h03: led <= 8'b11111111;

8'h04: led <= 8'b01111110;

8'h05: led <= 8'b00111100;

8'h06: led <= 8'b00011000;

8'h07: led <= 8'b00000000;

8'h14: led <= 8'b00000000;

8'h15: led <= 8'b00000001;

8'h16: led <= 8'b00000011;

8'h17: led <= 8'b00000111;

8'h18: led <= 8'b00001111;

8'h19: led <= 8'b00011111;

8'h1a: led <= 8'b00111111;

8'h1b: led <= 8'b01111111;

8'h1c: led <= 8'b11111111;

8'h1d: led <= 8'b11111111;

8'h1e: led <= 8'b01111111;

8'h1f: led <= 8'b00111111;

8'h20: led <= 8'b00011111;

8'h21: led <= 8'b00001111;

8'h22: led <= 8'b00000111;

8'h23: led <= 8'b00000011;

8'h24: led <= 8'b00000001;

8'h25: led <= 8'b00000000;

8'h26: led <= 8'b11111111;

8'h27: led <= 8'b11111111;

8'h28: led <= 8'b11111110;

8'h29: led <= 8'b11111110;

8'h2a: led <= 8'b11111100; 8'h2b: led <= 8'b11111100; 8'h2c: led <= 8'b11111000; 8'h2d: led <= 8'b11111000; 8'h2e: led <= 8'b11110000; 8'h2f: led <= 8'b11110000; 8'h30: led <= 8'b11100000; 8'h31: led <= 8'b11100000; 8'h32: led <= 8'b11000000; 8'h33: led <= 8'b11000000; 8'h34: led <= 8'b10000000; 8'h35: led <= 8'b10000000; 8'h36: led <= 8'b00000000; 8'h37: led <= 8'b00000000; 8'h38: led <= 8'b10000000; 8'h39: led <= 8'b10000000; 8'h3a: led <= 8'b11000000; 8'h3b: led <= 8'b11000000; 8'h3c: led <= 8'b11100000; 8'h3d: led <= 8'b11100000; 8'h3e: led <= 8'b11110000; 8'h3f: led <= 8'b11110000; 8'h40: led <= 8'b11111000; 8'h41: led <= 8'b11111000; 8'h42: led <= 8'b11111100; 8'h43: led <= 8'b11111100; 8'h44: led <= 8'b11111110; 8'h45: led <= 8'b11111110; 8'h46: led <= 8'b11111111; 8'h47: led <= 8'b01111110; 8'h48: led <= 8'b10111101; 8'h49: led <= 8'b11011011; 8'h4a: led <= 8'b11100111; 8'h4b: led <= 8'b11100111; 8'h4c: led <= 8'b11011011; 8'h4d: led <= 8'b10111101; 8'h4e: led <= 8'b01111110; 8'h4f: led <= 8'b00000000; 8'h50: led <= 8'b11111111; 8'h51: led <= 8'b01111110; 8'h52: led <= 8'b00111100; 8'h53: led <= 8'b00011000; 8'h54: led <= 8'b00000000; 8'h55: led <= 8'b00011000; 8'h56: led <= 8'b00111100;

8'h57: led <= 8'b01111110;

8'h58: led <= 8'b11111111; 8'h59: led <= 8'b00000011;

8'h5a: led <= 8'b00000011;

8'h5b: led <= 8'b11000000;

8'h5c: led <= 8'b11000000;

8'h5d: led <= 8'b11000000;

8'h5e: led <= 8'b11000000;

8'h5f: led <= 8'b11000000;

8'h60: led <= 8'b11000000;

8'h61: led <= 8'b11000000;

8'h62: led <= 8'b11000000;

8'h63: led <= 8'b01100000;

8'h64: led <= 8'b01100000;

8'h65: led <= 8'b01100000;

8'h66: led <= 8'b01100000;

8'h67: led <= 8'b01100000;

8'h68: led <= 8'b01100000;

8'h69: led <= 8'b01100000;

8'h6a: led <= 8'b01100000;

8'h6b: led <= 8'b00110000;

8'h6c: led <= 8'b00110000;

8'h6d: led <= 8'b00110000;

8'h6e: led <= 8'b00110000;

8'h6f: led <= 8'b00110000;

8'h70: led <= 8'b00110000;

8'h71: led <= 8'b00110000;

8'h72: led <= 8'b00110000;

8'h73: led <= 8'b00011000;

8'h74: led <= 8'b00011000;

8'h75: led <= 8'b00011000;

8'h76: led <= 8'b00011000;

8'h77: led <= 8'b00011000;

8'h78: led <= 8'b00011000;

8'h79: led <= 8'b00011000;

8'h7a: led <= 8'b00011000;

8'h7b: led <= 8'b00001100;

8'h7c: led <= 8'b00001100;

8'h7d: led <= 8'b00001100;

8'h7e: led <= 8'b00001100;

8'h7f: led <= 8'b00001100;

8'h80: led <= 8'b00001100; default: led <= 8'h00;

endcase end

endmodule2

相关主题
文本预览
相关文档 最新文档