欢迎来到天天文库
浏览记录
ID:48315145
大小:485.22 KB
页数:7页
时间:2020-01-13
《FPGA实验计数器设计实验》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、哈尔滨理工大学软件学院实验报告课程FPGA题目实验二计数器设计实验班级集成12-2班专业集成电路设计与集成系统学生学号12140202272014年10月15日实验二计数器设计实验实验目的:学习计数器的设计、仿真和硬件测试方法。实验内容及步骤:1.使用VerilogHDL设计2位16进制计数器,由DE2的KEY0输入计数值,在HEX1,HEX0上显示计数值。2.使用嵌入式逻辑分析仪进行仿真;3.将实验程序下载到DE2运行。实验注意事项:去抖动DE2按键电路图实验程序:modulecounting(clk,reset,k,
2、h1,h2);inputk,reset,clk;output[6:0]h1,h2;reg[7:0]count;regkey;reg[6:0]h1,h2;reg[10:0]clock=11'b0;always@(posedgeclk)beginif(k)//kistheinputKey0beginkey<=1;clock<=0;endelsebeginclock<=clock+1;//ifclockstillisn't2000,thenthenextalldon,texcutiveif(clock==1000)//soco
3、ntinuecamebackuntilupto2000beginclock<=11'b0;key=0;//toproduceanegadgeasasenstivepinendendendalways@(negedgekeyornegedgereset)beginif(reset==0)count=0;elsecount=count+1'b1;endalways@(count)begincase(count[3:0])4'b0000:h1<=7'b1000000;4'b0001:h1<=7'b1111001;4'b0010
4、:h1<=7'b0100100;4'b0011:h1<=7'b0110000;4'b0100:h1<=7'b0011001;4'b0101:h1<=7'b0010010;4'b0110:h1<=7'b0000010;4'b0111:h1<=7'b1111000;4'b1000:h1<=7'b0000000;4'b1001:h1<=7'b0010000;4'b1010:h1<=7'b0001000;4'b1011:h1<=7'b0000011;4'b1100:h1<=7'b1000110;4'b1101:h1<=7'b01
5、00001;4'b1110:h1<=7'b0000110;4'b1111:h1<=7'b0001110;default:h1<=7'b1000000;endcasecase(count[7:4])4'b0000:h2<=7'b1000000;4'b0001:h2<=7'b1111001;4'b0010:h2<=7'b0100100;4'b0011:h2<=7'b0110000;4'b0100:h2<=7'b0011001;4'b0101:h2<=7'b0010010;4'b0110:h2<=7'b0000010;4'b0
6、111:h2<=7'b1111000;4'b1000:h2<=7'b0000000;4'b1001:h2<=7'b0010000;4'b1010:h2<=7'b0001000;4'b1011:h2<=7'b0000011;4'b1100:h2<=7'b1000110;4'b1101:h2<=7'b0100001;4'b1110:h2<=7'b0000110;4'b1111:h2<=7'b0001110;default:h2<=7'b0000001;endcaseendendmodule实验结果:当计数值为4时
此文档下载收益归作者所有