FPGA程序乘法器.doc_第1页
FPGA程序乘法器.doc_第2页
FPGA程序乘法器.doc_第3页
FPGA程序乘法器.doc_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

乘法器:by leasualmodule mui44(a,b,rst,out,bai,shi,ge);input rst;input3:0a,b; output out,bai,shi,ge;reg3:0bai,shi,ge;wire7:0out1,out2,out3,out4;reg7:0out;always (*) if(!rst) begin out=0; bai=0; shi=0; ge=0; end else begin out=out1+out2+out3+out4; bai=out/100; shi=out%100/10; ge=out%10; endassign out1=(b0=1)?a:0;assign out2=(b1=1)?(a1):0;assign out3=(b2=1)?(a2):0;assign out4=(b3=1)?(a3):0;endmodule奇数分频:by leasualmodule jishufenp(rst,clk,clkout); parameter N=3;/计数器的位数 N的最大计数值要大于或等于M parameter M=7; /要分频的模,取奇数 input rst; input clk; output clkout; reg tempp,tempn; reg N-1:0 count; always (negedge rst or posedge clk) if(!rst) begin count=0; tempp=0; end else begin count=count+1; if(count=M/2) tempp=1; else if(count=M-1) begin tempp=0; count=0; end end always (negedge rst or negedge clk) if(!rst) tempn=0; else tempn=tempp; assign clkout=tempp|tempn; endmodule状态机:/*gongneng: jian ce xulie 1011 chengxuby leasual2010.11.29*/module ztj2(a,rst,clk,q);input clk,a,rst;output q;reg q;reg7:0 cur_state;parameter s1=8b0000_0001,s2=8b0000_0010,s3=8b0000_0100,s4=8b0000_1000,s5=8b0001_0000,s6=8b0010_0000,s7=8b0100_0000,s8=8b1000_0000;always(posedge clk or negedge rst)if(rst)begincur_state=s1;end elsecase(cur_state)s1:begincur_state=(a=1)?s2:s1);q=0;ends2:begincur_state=(a=0)?s3:s2);q=0;ends3:begincur_state=(a=1)?s4:s1);q=0;ends4:begincur_state=(a=1)?s5:s3);q=0;ends5:begincur_state=(a=0)?s6:s2);q=0;ends6:begincur_state=(a=1)?s7:s1);q=0;ends7:begincur_state=(a=0)?s8:s5);q=0;ends8:if(a=1)begincur_state=s1;q=1;en

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论