资源描述:
《实验四 4 位计数器设计.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验四4位计数器设计1.实验目的学习quartusii和modelsim的使用方法;学习原理图和veriloghdl混合输入设计方法;掌握4位计数器设计的设计及仿真方法。2.实验原理根据下面FPGA内部电路,设计4位计数器,并在在kx3c10F+开发板上实现该电路,并作仿真。设计其中的计数器模块CNT4B和数码管译码驱动模块DECL7S的verilogHDL代码,并作出整个系统仿真。2.14位计数器模块代码moduleCNT4B(out,CLK,RST);//定义模块名和各个端口outputout;//定义输出端口inputCLK,R
2、ST;//定义输入时钟和复位reg[3:0]out;//定义四位计数器always@(posedgeCLKornegedgeRST)//上升沿时钟和下降沿复位beginif(!RST)//低电平复位out<=4'd0;elseout<=out+1;//每一个clk计数endendmodule效果图:82.2七段数码管代码modulesegled(out1,a);//定义模块名和输入输出端口input[3:0]a;//输入一个3位矢量output[6:0]out1;//输出一个6位矢量reg[6:0]out1;//reg型变量用于alw
3、ays语句always@(a)//敏感信号abegincase(a)//case语句用于选择输出4'b0000:out1<=7'b0111111;4'b0001:out1<=7'b0000110;4'b0010:out1<=7'b1011011;4'b0011:out1<=7'b1001111;4'b0100:out1<=7'b1100110;4'b0101:out1<=7'b1101101;4'b0110:out1<=7'b1111101;4'b0111:out1<=7'b0000111;4'b1000:out1<=7'b11111
4、11;4'b1001:out1<=7'b1101111;4'b1010:out1<=7'b1110111;4'b1011:out1<=7'b1111100;4'b1100:out1<=7'b0111001;4'b1101:out1<=7'b1011110;4'b1110:out1<=7'b1111001;4'b1111:out1<=7'b1110001;endcaseendendmodule//模块结束效果图:82.3综合模块代码//Copyright(C)1991-2013AlteraCorporation//YouruseofAl
5、teraCorporation'sdesigntools,logicfunctions//andothersoftwareandtools,anditsAMPPpartnerlogic//functions,andanyoutputfilesfromanyoftheforegoing//(includingdeviceprogrammingorsimulationfiles),andany//associateddocumentationorinformationareexpresslysubject//tothetermsandco
6、nditionsoftheAlteraProgramLicense//SubscriptionAgreement,AlteraMegaCoreFunctionLicense//Agreement,orotherapplicablelicenseagreement,including,//withoutlimitation,thatyouruseisforthesolepurposeof//programminglogicdevicesmanufacturedbyAlteraandsoldby//Alteraoritsauthorize
7、ddistributors.Pleaserefertothe//applicableagreementforfurtherdetails.//PROGRAM"QuartusII64-Bit"//VERSION"Version13.1.0Build16210/23/2013SJWebEdition"//CREATED"TueApr1122:35:092017"modulecou(CLK,RST,8Q);inputwireCLK;inputwireRST;outputwire[6:0]Q;wire[3:0]SYNTHESIZED_WIRE
8、_0;CNT4Bb2v_inst(.CLK(CLK),.RST(RST),.out(SYNTHESIZED_WIRE_0));segledb2v_inst1(.a(SYNTHESIZED_WIRE_0),.out1(Q)