超前进位加法器_第1页
超前进位加法器_第2页
超前进位加法器_第3页
超前进位加法器_第4页
超前进位加法器_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

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

文档简介

1、说明文档4到8 LED编码器4位超前进位加法器abcincout8段LED显示器8段LED显示器1.结构图:2.八段LED显示器的编码:假设8段LED显示器是共阴极的,DPGFEDCBA正好组成一个8位的数8seg,给这个数赋值,即可以显示相应的数字。编码:3.编码器子模块4到8位LED编码器module coder(in,out);input3:0 in;output7:0 out;wire3:0 in;reg7:0 out;always(in)begincase(in)4'h0: out=8'h3f;4'h1: out=8'h06;4'h2: out

2、=8'h5b;4'h3: out=8'h4f;4'h4: out=8'h66;4'h5: out=8'h6d;4'h6: out=8'h7d;4'h7: out=8'h07;4'h8: out=8'h7f;4'h9: out=8'h6f;4'ha: out=8'h77;4'hb: out=8'h7c;4'hc: out=8'h39;4'hd: out=8'h5e;4'he: out=8'h79;4

3、'hf: out=8'h71;endcaseendendmodule4. 超前进位加法器子模块对一个4位全加器,第i位的两加数分别是Ai和Bi,进位输入信号是Ci-1,这个位产生的进位输出是 Ci,则可以有得到:Ci=AiBi(AiBi)Ci-1令Gi= AiBi(进位产生函数) Pi= AiBi(进位传递函数)则:Ci=Gi+ PiCi-1所以有:C0=G0+P0C-1 C1=G1+P1C0 C2=G2+P2C1 C3=G3+P3C2将上式逐次代入则可以得到如下表达式(C-1是最低位的进位输入)COG0+P0C-1C1=G1+P1C0=G1+P1G0+P1P0C-1C2=G2

4、+P2C1=G2+P2G1+P2P1C0=G2+P2G1+P2P1G0+P2P1P0C-1C3=G3+P3C2 =G3+P3G2+P3P2C1 =G3+P3P2P3P2C1 =G3+P3P2P3P2G1P3P2P1C0 =G3+P3P2P3P2G1P3P2P1G0P3P2P1P0C-1上述表达式说明只要各位数据和最低位进位同时输入,各位之间的进位信号与和就能同时产生。要据这样的原理可以实现超前进位加法器,这种加法器运算速度显著提高,但是复杂度也提高了。module add4_head( a, b, cin, sum,cout);input3:0 a;input3:0 b;input cin;

5、output3:0 sum;output cout;wire3:0 p;wire3:0 g;wire3:0 t;wire2:0 c;assign p0 = a0 | b0;assign p1 = a1 | b1;assign p2 = a2 | b2;assign p3 = a3 | b3;assign t0 = a0 b0;assign t1 = a1 b1;assign t2 = a2 b2;assign t3 = a3 b3;assign g0 = a0 & b0;assign g1 = a1 & b1;assign g2 = a2 & b2;assign g3

6、= a3 & b3;assign c0 = (p0 & cin) | g0;assign c1 = (p1 & c0) | g1;assign c2 = (p2 & c1) | g2;assign cout = g3 | (p3 & (g2 | p2 & (g1 | p1 & (g0|(p0&cin);assign sum0 = t0 cin;assign sum1 = t1 c0;assign sum2 = t2 c1;assign sum3 = t3 c2; endmodule5.例化两个子模块把超前进位加法器和4到8位LED

7、编码器 两个模块例化放一起,完成本设计module add_display(a,b,cin,cout,out);input3:0 a;input3:0 b;input cin;output cout;output7:0 out;wire3:0 temp;add4_head add4_head(.a(a), .b(b), .cin(cin), .sum(temp), .cout(cout) );coder coder ( .in(temp), .out(out);endmodule6.对本设计进行测试/timescale 1ns / 1psmodule testbench;/ Inputsreg 3:0 a;reg 3:0 b;reg cin;/ Outputswire 7:0 out;wire cout; add_display add_display(.a(a),.b(b),.cin(cin),.cout(cout),.out(out);integer m,n,l;initial begin a = 4'b0000; b = 4'b0000;cin= 0;/ Add stimul

温馨提示

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

评论

0/150

提交评论