Verilog实现4-bit行波进位加法器和超前进位加法器
1. 行波进位实现方式:
module adder4_ripple
(input wire [3:0] a, b,input wire Cin0,output wire [3:0] y,output wire Cout
);wire Cin1, Cin2, Cin3;full_adder1 a1(a[0], b[0], Cin0, y[0], Cin1);
full_adder1 a2(a[1], b[1], Cin1, y[1], Cin2);
full_adder1 a3(a[2], b[2], Cin2, y[2], Cin3);
full_adder1 a4(a[3], b[3], Cin3, y[3], Cout);endmodulemodule full_adder1
(input wire a, b,input wire Cin,output wire y, Cout
);assign y = a ^ b ^ Cin;
assign Cout = (a & b) + (a & Cin) + (b & Cin);endmodule
module tb_adder4();
reg [3:0] a,b;
reg Cin0;wire [3:0] y;
wire Cout;initial begina = 4'd5;Cin0 = 1'b1;b = 4'd8;#50 a = 4'd1;#50 a = 4'd3;#50 b = 4'd7;#50 a = 4'd10;
endadder4_ripple adder4_ripple_inst
(.a ( a ), .b ( b ),.Cin0 ( Cin0 ),.y ( y ),.Cout ( Cout )
);
endmodule
仿真结果:
2. 超前进位实现方式:
module adder4_CLA
(input wire [3:0] a , input wire [3:0] b ,input wire Cin0,output wire Gm ,output wire Pm ,output wire [3:0] y ,output wire Cout
);wire [3:0] G,P;
wire [4:1] C;full_adder_1bit a1(a[0], b[0], Cin0, y[0], G[0], P[0]);
full_adder_1bit a2(a[1], b[1], C[1], y[1], G[1], P[1]);
full_adder_1bit a3(a[2], b[2], C[2], y[2], G[2], P[2]);
full_adder_1bit a4(a[3], b[3], C[3], y[3], G[3], P[3]);CLA_4 CLA_4_inst(P,G,Cin0,C,Gm,Pm);assign Cout = C[4];
endmodulemodule full_adder_1bit
(input wire a, b,input wire Cin,output wire y, //Cout = a*b + a*Cin + b*Cin = a*b + (a+b)*Cin = g + p*Cinoutput wire g, //生成信号output wire p //传播信号
);assign y = a ^ b ^ Cin;
assign g = a & b;
assign p = a | b;
endmodulemodule CLA_4
(input wire [3:0] P ,input wire [3:0] G ,input wire C_in ,output wire [4:1] Ci ,output wire Gm ,output wire Pm
);assign Ci[1]=G[0]|P[0]&C_in;
assign Ci[2]=G[1]|P[1]&G[0]|P[1]&P[0]&C_in;
assign Ci[3]=G[2]|P[2]&G[1]|P[2]&P[1]&G[0]|P[2]&P[1]&P[0]&C_in;
assign Ci[4]=G[3]|P[3]&G[2]|P[3]&P[2]&G[1]|P[3]&P[2]&P[1]&G[0]|P[3]&P[2]&P[1]&P[0]&C_in;//Cout = a*b + a*Cin + b*Cin = a*b + (a+b)*Cin = g + p*Cin
assign Gm=G[3]|P[3]&G[2]|P[3]&P[2]&G[1]|P[3]&P[2]&P[1]&G[0];
assign Pm=P[3]&P[2]&P[1]&P[0];
endmodule
module tb_adder4_CLA();
reg [3:0] a,b;
reg Cin0;wire [3:0] y;
wire Gm, Pm, Cout;initial begina = 4'd5;Cin0 = 1'b1;b = 4'd8;#50 a = 4'd1;#50 a = 4'd3;#50 b = 4'd7;#50 a = 4'd10;
endadder4_CLA adder4_CLA_inst
(.a ( a ), .b ( b ),.Cin0 ( Cin0 ),.Gm ( Gm ),.Pm ( Pm ),.y ( y ),.Cout ( Cout )
);
endmodule
仿真结果:
Verilog实现4-bit行波进位加法器和超前进位加法器相关推荐
- 32位进位选择加法器_超前进位加法器amp;行波进位加法器
超前进位加法器&行波进位加法器 八位超前进位加法器 原理 设计文件 综合电路 测试文件 仿真波形 八位行波进位加法器 原理 设计文件 测试文件 仿真波形 总结 八位超前进位加法器 原理 有学弟 ...
- 四位行波进位加法器_超前进位加法器amp;行波进位加法器
超前进位加法器&行波进位加法器 八位超前进位加法器 原理 设计文件 综合电路 测试文件 仿真波形 八位行波进位加法器 原理 设计文件 测试文件 仿真波形 总结 八位超前进位加法器 原理 有学弟 ...
- verilog 实现32位加法器(超前进位)
一.功能概述: 先行进位加法器是对普通的全加器进行改良而设计成的并行加法器,主要是针对普通全加器串联时互相进位产生的延迟进行了改良.超前进位加法器是通过增加了一个不是十分复杂的逻辑电路来做到这点的. ...
- 串行进位加法器与超前进位加法器 verilog
文章目录 串行进位加法器 半加器 全加器 任意位数串行进位加法器 tb 4bit超前进位加法器 Reference 串行进位加法器 半加器 module half_adder (input in1,i ...
- 半加器、全加器、行波进位加法器、超前进位加法器
半加器 两个1bit数据相加,不包含进位. 全加器 包含低位来的进位,相当于三个1bit数据相加. 至于为啥或和异或一样的解释:因为AB为00,01,10时异或和或结果一样,但是11时或为1,异或为0 ...
- 加法器的实现(半加器,全加器,行波进位加法器,超前进位加法器,流水线加法器)
一.半加器和全加器 二.行波进位加法器 三.超前进位加法器(Carry-Lookahead Adder,CLA) https://www.jianshu.com/p/6ce9cad8b467 四.流水 ...
- 串行进位加法器和超前进位加法器代码实现及性能对比
写在前面:要了解超前进位加法器的实现机制,参考超前进位加法器-郭天祥 代码实现 串行进位加法器 代码 adder_4bits.v module adder_4bits(a,b,cin,cout,sum ...
- Verilog快速入门(8)—— 4bit超前进位加法器电路
Verilog快速入门 (1) 四选一多路器 (2)异步复位的串联T触发器 (3)奇偶校验 (4)移位运算与乘法 (5)位拆分与运算 (6)使用子模块实现三输入数的大小比较 (7)4位数值比较器电路 ...
- Verilog实现超前进位加法器
在CPU等对性能要求较高的电路中,一般都会采用超前进位加法器,因为超前进位加法器的延时相对来说比较小.下面讲述超前进位加法器的原理: 我们知道,一个三输入,二输出的全加器,其逻辑关系为 S=A⊕B⊕C ...
最新文章
- 关于owner group others的测试
- SD卡格式化怎么恢复?只需要五个步骤
- Windows系统IntelliJ IDEA安装配置
- mvcpager之学习
- matlab模糊推理,模糊推理系统的matlab代码
- Pandas Period
- 解决博易博客后台文章管理页面无法显示分页的问题
- Java基础复习(1) 为什么在java中我们要将main定义为一个static方法?
- transform 二维转变
- Jquery—JQuery对checkbox的操作(01)
- Activiti 工作流表单设计及开发
- 爬虫python 英文,python爬虫—爬取英文名以及正则表达式的介绍
- 超级弱口令检查工具使用简介
- WISP Client+AP WDS 的区别
- STM32 USB DFU功能
- 京东充值系统现漏洞 被恶意盗刷
- php活体检测,活体检测
- Auto-encoder(自编码器)的原理及最新的技术应用(李宏毅视频课整理和总结)
- html如何设置多级列表,如何在Word文档中设置多级列表
- Android gif 动画
热门文章
- 【软件问题】解决WPS中的VBA支持库安装问题(亲测可用)
- android studio 排除,Android Studio从构建中排除类?
- strcmp,stricmp,strcmpi,strncmp,strnicmp,strncmpi,strcat,strncat比较
- 电影TS、TC、SCR、R5、BD、HD等版本是什么意思
- kubernetes pod-name生成过程 源码分析
- objc_msgSend流程分析之缓存查找
- RequireJS 教程详解
- 三步走做好艾默生质量流量计使用工作
- 形函数的构造原理-有限元形函数的几个种类
- 读秀数据库的用法+全国图书馆参考咨询联盟