




已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
可编程器件Xlinx指导书xx 1实验一三为上课必做内容,实验四可以选做。 实验一四位拨码开关控制显示数字0000FFFF说明当拨码开关为0001,四位数码管显示为1111,当拨码开关为0010,四位数码管显示为2222,以此类推,当拨码开关为1111时,四位数码管显示为FFFF。 module seg7ment_sub(input wire3:0num,output reg6:0a_to_g);always(*)case(num)0:a_to_g=7b0000001;1:a_to_g=7b1001111;2:a_to_g=7b0010010;3:a_to_g=7b0000110;4:a_to_g=7b1001100;5:a_to_g=7b0100100;6:a_to_g=7b0100000;7:a_to_g=7b0001111;8:a_to_g=7b0000000;9:a_to_g=7b0000100;hA:a_to_g=7b0001000;hB:a_to_g=7b1100000;hC:a_to_g=7b0110001;hD:a_to_g=7b1000010;hE:a_to_g=7b0110000;hF:a_to_g=7b0111000;default:a_to_g=7b0000001;endcase endmodulemodule seg7ment_top(input wire3:0sw,output wire6:0a_to_g,output wire3:0an);assign an=4b0000;seg7ment_sub A1(.num(sw),.a_to_g(a_to_g);endmodule2实验二拨码开关控制数字0F循环显示说明clk做计数时钟输入,BTN0做复位,无进位,四个拨码开关决定对应的数码管循环显示数字0F(当四个拨码开关为0001时,对应的一个数码管循环显示数字0F,当四个拨码开关为0011时,对应的二个数码管同时循环显示数字0F,以此类推,当四个拨码开关为1111时,对应的四个数码管同时循环显示数字0F)module clk_sw_7seg_sub(input3:0NUM,input3:0SW,output reg3:0an,output reg6:0a_to_g);always(*)an=SW;always(*)case(NUM)0:a_to_g=7b0000001;1:a_to_g=7b1001111;2:a_to_g=7b0010010;3:a_to_g=7b0000110;4:a_to_g=7b1001100;5:a_to_g=7b0100100;6:a_to_g=7b0100000;7:a_to_g=7b0001111;8:a_to_g=7b0000000;9:a_to_g=7b0000100;hA:a_to_g=7b0001000;hB:a_to_g=7b1100000;hC:a_to_g=7b0110001;hD:a_to_g=7b1000010;hE:a_to_g=7b0110000;hF:a_to_g=7b0111000;default:a_to_g=7b0000001;endcase endmodule3module clk_sw_7seg_top(input clk,input clr,input3:0SW,output3:0an,output6:0a_to_g);reg28:0clk_t;/clock countreg3:0NUM;/number printedon thesegment LEDsalways(posedge clkor posedge clr)/deal theclock andclear eventsbegin if(clr)clk_t=0;/if clearbutton pressed,clear theclock countelse begin clk_t=clk_t+1;/if clockflip,count clockif(clk_t28:2515)/可以不写,无意义clk_t=0;end end always(*)NUM=clk_t28:25;/take thehigher fourbits asnumber forprinting clk_sw_7seg_sub A1(.NUM(NUM),.SW(SW),.an(an),.a_to_g(a_to_g);/call thesub displaymodule endmodule4实验三二位数码管循环显示数字00FF说明clk做计数时钟输入,BTN0做复位,数字00FF在数码管右二位循环显示。 module clk_7segff_sub(input3:0NUM,output reg6:0a_to_g);always(*)case(NUM)0:a_to_g=7b0000001;1:a_to_g=7b1001111;2:a_to_g=7b0010010;3:a_to_g=7b0000110;4:a_to_g=7b1001100;5:a_to_g=7b0100100;6:a_to_g=7b0100000;7:a_to_g=7b0001111;8:a_to_g=7b0000000;9:a_to_g=7b0000100;hA:a_to_g=7b0001000;hB:a_to_g=7b1100000;hC:a_to_g=7b0110001;hD:a_to_g=7b1000010;hE:a_to_g=7b0110000;hF:a_to_g=7b0111000;default:a_to_g=7b0000001;endcase endmodule5module clk_7segff_top(input clk,input clr,output3:0an,output6:0a_to_g);reg32:0clk_t;/clock countreg3:0NUM;/number printedon thesegment LEDswire s;always(posedge clkor posedgeclr)/deal theclock andclear eventsbegin if(clr)clk_t=0;/if clearbutton pressed,clear theclock countelse begin clk_t=clk_t+1;/if clockflip,count clockif(clk_t32:2915)/可以不写clk_t=0;end endassign s=clk_t15;/决定两个数码管交替显示assign an1=s;assign an0=s;assign an3:2=2b11;always(*)case(s)/take thehigher fourbits asnumber forprinting1:NUM=clk_t32:29;0:NUM=clk_t28:25;endcase clk_7segff_sub A1(.NUM(NUM),.a_to_g(a_to_g);/call thesub displaymodule endmodule6实验四二位数码管循环显示数字0099(选做)说明clk做计数时钟输入,BTN0做复位,BTN3做暂停,数字0099在数码管右二位循环显示。 第一种算法module CLK_SW_7seg_sub(input3:0NUM,output reg6:0a_to_g);always(*)case(NUM)0:a_to_g=7b0000001;1:a_to_g=7b1001111;2:a_to_g=7b0010010;3:a_to_g=7b0000110;4:a_to_g=7b1001100;5:a_to_g=7b0100100;6:a_to_g=7b0100000;7:a_to_g=7b0001111;8:a_to_g=7b0000000;9:a_to_g=7b0000100;hA:a_to_g=7b0001000;hB:a_to_g=7b1100000;hC:a_to_g=7b0110001;hD:a_to_g=7b1000010;hE:a_to_g=7b0110000;hF:a_to_g=7b0111000;default:a_to_g=7b0000001;endcase endmodule7module CLK_SW_7seg_top(input clk,input clr,input pause,/暂停output3:0an,/数码管使能output6:0a_to_g);reg23:0clk_t;/保存分频时钟reg3:0NUM;/保存显示数字reg16:0s;/数码管复用计数(交替显示)reg p_flag;/暂停标识位wire temp_a;/十进制计数时钟reg3:0temp_b;/保存个位数reg3:0temp_c;/保存十位数always(posedge clkor posedgeclr)/处理时钟或清零事件begin if(clr)clk_t=0;/如果清零键按下,分频时钟回零else if(!p_flag)/如果分频时钟沿来临且非暂停状态,计时begin clk_t=clk_t+1;end endassign temp_a=clk_t23;/取分频后的时钟作为十进制计数时钟always(posedge temp_a or posedgeclr)/处理十进制计数和清零事件begin if(clr)/如果清零键按下,个位和十位回零begin temp_b=0;temp_c=0;end elseBegin/如果十进制计时时钟来临,个位计数temp_b=temp_b+1;if(temp_b=10)/如果个位超9,十位加1,个位回零begin temp_b=0;temp_c=temp_c+1;if(temp_c=10)/如果十位超9,十位回零temp_c=0;end end8end always(posedge clk)/数码管复用切换实现begin s=s+1;if(s16)/检测最高位,然后清零s=0;endalways(posedge pause)/暂停事件处理,翻转暂停标志位p_flag=p_flag;assign an0=s15;/个位数码管使能assign an1=s15;/十位数码管使能assign an3:2=2b11;/禁止另外两个数码管always(*)case(s15)/配合复用使能,交替更换显示数字1:NUM=temp_c;/显示十位数字0:NUM=temp_b;/显示个位数字endcase CLK_SW_7seg_sub A1(.NUM(NUM),.a_to_g(a_to_g);/调用数码管显示子模块endmodule9第二种算法module clk_7seg99_sub(input3:0NUM,output reg6:0a_to_g);always(*)case(NUM)0:a_to_g=7b0000001;1:a_to_g=7b1001111;2:a_to_g=7b0010010;3:a_to_g=7b0000110;4:a_to_g=7b1001100;5:a_to_g=7b0100100;6:a_to_g=7b0100000;7:a_to_g=7b0001111;8:a_to_g=7b0000000;9:a_to_g=7b0000100;hA:a_to_g=7b0001000;hB:a_to_g=7b1100000;hC:a_to_g=7b0110001;hD:a_to_g=7b1000010;hE:a_to_g=7b0110000;hF:a_to_g=7b0111000;default:a_to_g=7b0000001;endcase endmodule10module B8_to_D2(/8位二进制转为2位二进制input7:0B_8,output7:0D_2);reg3:0c;reg7:0q;assign D_2=c,q3:0;always(*)begin c=B_87:0/16;/8位进行4次除法运算q=(B_87:0%16)+(B_87:0/16)*6;if(q/16)begin c=c+q/16;q=q%16+(q/16)*6;end if(q/16)begin c=c+q/16;q=q%16+(q/16)*6;end if(q/16)beginc=c+q/16;q=q%16+(q/16)*6;end else if(q=10)beginc=c+1;q=q-10;end end endmodule11module clk_7seg99_top(input clk,input clr,input pause,output3:0an,output6:0a_to_g);reg30:0clk_t;/时钟计数reg3:0NUM;/显示的数字reg16:0s;/控制显示的两位数码管切换reg p_flag;/暂停标示位wire7:0temp;wire7:0temp_1;always(posedge clkorposedgeclr)begin if(clr)clk_t=0;elseif(!p_flag)begin clk_t=clk_t+1;if(clk_t30:2399)/可以不写clk_t=0;end endalways(posedge pause)/暂停键按下p_f
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 安徽安全员要求考试试题及答案
- 药品法律法规-采购环节培训试题测试题库含答案
- 护士企业编制面试题库含完整答案详解【易错题】
- 2025年绿色建筑示范项目资金申请条件与标准研究报告
- 押题宝典执业药师资格证之《西药学专业二》模考模拟试题及答案详解【网校专用】
- 2025年直播电商主播影响力与品牌形象研究报告
- 2025至2030年中国非金属矿市场规模现状及投资规划建议报告
- 押题宝典高校教师资格证之《高等教育心理学》考试题库含答案详解(综合题)
- 2025年度高端医疗器械实物抵押融资租赁合同
- 2025版同居伴侣财产共有及共同生活协议书
- 《智慧供应链管理》课件
- 2025-2030吉林省生活垃圾清运和处理行业市场发展分析及发展前景与投资研究报告
- 《蔚来汽车的SWOT分析》课件
- 山香教育协议班合同
- 部编版语文四年级上册第一单元大单元教学设计
- 老年慢性病的中药调理方法
- 典当黄金合同标准文本
- 旧厂房改造施工安全措施
- 内镜中心标本遗失警示教育
- 高中数学(沪教版)知识点梳理
- 食堂服务礼仪培训
评论
0/150
提交评论